From a87563c3553cce23f4fd5c926eb000523619fa0b Mon Sep 17 00:00:00 2001 From: Dana Dahlstrom Date: Tue, 27 Feb 2024 18:00:00 -0800 Subject: [PATCH] protobuf --- .../.github/ISSUE_TEMPLATE/bug_report.md | 28 + .../.github/ISSUE_TEMPLATE/feature_request.md | 18 + .../.github/ISSUE_TEMPLATE/question.md | 7 + third_party/protobuf/.github/mergeable.yml | 18 + third_party/protobuf/.gitignore | 112 +- third_party/protobuf/.gitmodules | 7 + third_party/protobuf/.travis.yml | 84 - third_party/protobuf/BUILD | 715 +- third_party/protobuf/BUILD.gn | 446 +- third_party/protobuf/CHANGES.txt | 943 +- third_party/protobuf/CONTRIBUTING.md | 98 + third_party/protobuf/DEPS | 3 + third_party/protobuf/LICENSE | 12 +- third_party/protobuf/METADATA | 4 +- third_party/protobuf/Makefile.am | 735 +- third_party/protobuf/OWNERS | 4 +- third_party/protobuf/Protobuf.podspec | 26 +- third_party/protobuf/README.chromium | 84 +- third_party/protobuf/README.md | 46 +- third_party/protobuf/WORKSPACE | 52 +- third_party/protobuf/appveyor.bat | 29 +- third_party/protobuf/appveyor.yml | 41 +- third_party/protobuf/autogen.sh | 16 +- third_party/protobuf/benchmarks/Makefile.am | 687 +- .../protobuf/benchmarks/ProtoBench.java | 203 - third_party/protobuf/benchmarks/README.md | 237 +- third_party/protobuf/benchmarks/__init__.py | 0 .../benchmark_messages_proto2.proto | 141 - .../protobuf/benchmarks/cpp/cpp_benchmark.cc | 254 + .../proto2/benchmark_message1_proto2.proto | 78 + .../proto2/dataset.google_message1_proto2.pb} | Bin 228 -> 289 bytes .../proto3/benchmark_message1_proto3.proto} | 2 + .../proto3/dataset.google_message1_proto3.pb | Bin 0 -> 289 bytes .../google_message2/benchmark_message2.proto | 76 + .../dataset.google_message2.pb} | Bin 84570 -> 84625 bytes .../google_message3/benchmark_message3.proto | 534 + .../benchmark_message3_1.proto | 1280 + .../benchmark_message3_2.proto | 499 + .../benchmark_message3_3.proto | 466 + .../benchmark_message3_4.proto | 491 + .../benchmark_message3_5.proto | 473 + .../benchmark_message3_6.proto | 454 + .../benchmark_message3_7.proto | 56 + .../benchmark_message3_8.proto | 1900 ++ .../google_message4/benchmark_message4.proto | 454 + .../benchmark_message4_1.proto | 474 + .../benchmark_message4_2.proto | 292 + .../benchmark_message4_3.proto | 751 + .../protobuf/benchmarks/download_data.sh | 5 + .../protobuf/benchmarks/generate_datasets.cc | 117 - .../benchmarks/go/go_benchmark_test.go | 124 + third_party/protobuf/benchmarks/java/pom.xml | 98 + .../protobuf/ProtoCaliperBenchmark.java | 214 + .../protobuf/benchmarks/js/benchmark_suite.js | 33 + .../protobuf/benchmarks/js/js_benchmark.js | 82 + .../protobuf/benchmarks/php/PhpBenchmark.php | 170 + .../protobuf/benchmarks/php/autoload.php | 25 + .../protobuf.js/generate_pbjs_files.js | 25 + .../protobuf.js/protobufjs_benchmark.js | 66 + .../protobuf/benchmarks/python/__init__.py | 0 .../benchmarks/python/py_benchmark.py | 161 + .../python/python_benchmark_messages.cc | 29 + third_party/protobuf/benchmarks/readme.txt | 50 - .../protobuf/benchmarks/util/__init__.py | 0 .../benchmarks/util/big_query_utils.py | 189 + .../util/data_proto2_to_proto3_util.h | 64 + .../benchmarks/util/gogo_data_scrubber.cc | 74 + .../benchmarks/util/proto3_data_stripper.cc | 74 + .../benchmarks/util/protoc-gen-gogoproto.cc | 103 + .../util/protoc-gen-proto2_to_proto3.cc | 115 + .../protobuf/benchmarks/util/result_parser.py | 300 + .../benchmarks/util/result_uploader.py | 107 + .../util/schema_proto2_to_proto3_util.h | 194 + third_party/protobuf/cmake/CMakeLists.txt | 114 +- third_party/protobuf/cmake/README.md | 57 +- third_party/protobuf/cmake/conformance.cmake | 50 + third_party/protobuf/cmake/examples.cmake | 57 + .../protobuf/cmake/extract_includes.bat.in | 226 +- third_party/protobuf/cmake/install.cmake | 141 +- .../protobuf/cmake/libprotobuf-lite.cmake | 49 +- third_party/protobuf/cmake/libprotobuf.cmake | 73 +- third_party/protobuf/cmake/libprotoc.cmake | 104 +- .../cmake/protobuf-config-version.cmake.in | 61 +- .../protobuf/cmake/protobuf-config.cmake.in | 140 +- .../protobuf/cmake/protobuf-lite.pc.cmake | 11 + .../protobuf/cmake/protobuf-module.cmake.in | 204 +- .../protobuf/cmake/protobuf-options.cmake | 7 + third_party/protobuf/cmake/protobuf.pc.cmake | 11 + third_party/protobuf/cmake/protoc.cmake | 14 +- third_party/protobuf/cmake/tests.cmake | 59 +- third_party/protobuf/cmake/version.rc.in | 45 + .../protobuf/compiler_config_setting.bzl | 21 + third_party/protobuf/composer.json | 23 + third_party/protobuf/configure.ac | 86 +- .../protobuf/conformance/ConformanceJava.java | 238 +- .../conformance/ConformanceJavaLite.java | 4 +- third_party/protobuf/conformance/Makefile.am | 235 +- third_party/protobuf/conformance/README.md | 38 +- third_party/protobuf/conformance/autoload.php | 21 + .../binary_json_conformance_suite.cc | 2460 ++ .../binary_json_conformance_suite.h | 121 + .../protobuf/conformance/conformance.proto | 225 +- .../protobuf/conformance/conformance_cpp.cc | 100 +- .../conformance/conformance_nodejs.js | 186 + .../protobuf/conformance/conformance_objc.m | 37 +- .../protobuf/conformance/conformance_php.php | 120 + .../conformance/conformance_python.py | 98 +- .../protobuf/conformance/conformance_ruby.rb | 31 +- .../protobuf/conformance/conformance_test.cc | 2021 +- .../protobuf/conformance/conformance_test.h | 231 +- .../conformance/conformance_test_main.cc | 40 + .../conformance/conformance_test_runner.cc | 411 +- .../protobuf/conformance/failure_list_cpp.txt | 124 +- .../conformance/failure_list_csharp.txt | 18 +- .../conformance/failure_list_java.txt | 84 +- .../protobuf/conformance/failure_list_js.txt | 13 + .../conformance/failure_list_objc.txt | 6 +- .../protobuf/conformance/failure_list_php.txt | 20 + .../conformance/failure_list_php_c.txt | 44 + .../conformance/failure_list_php_zts_c.txt | 225 + .../conformance/failure_list_python.txt | 106 +- .../conformance/failure_list_python_cpp.txt | 114 +- .../conformance/failure_list_ruby.txt | 265 +- .../conformance/failure_list_ruby_mac.txt | 66 + .../text_format_conformance_suite.cc | 317 + .../text_format_conformance_suite.h | 69 + .../text_format_failure_list_csharp.txt | 8 + .../text_format_failure_list_java.txt | 6 + .../text_format_failure_list_php.txt | 8 + .../text_format_failure_list_python.txt | 5 + .../text_format_failure_list_ruby.txt | 8 + .../conformance/third_party/jsoncpp/json.h | 20 +- .../third_party/jsoncpp/jsoncpp.cpp | 20 +- .../conformance/update_failure_list.py | 73 + third_party/protobuf/csharp/.gitignore | 24 +- third_party/protobuf/csharp/CHANGES.txt | 18 +- .../csharp/Google.Protobuf.Tools.nuspec | 44 +- third_party/protobuf/csharp/README.md | 54 +- .../protobuf/csharp/build_packages.bat | 7 +- third_party/protobuf/csharp/build_tools.sh | 52 + third_party/protobuf/csharp/buildall.bat | 13 + third_party/protobuf/csharp/buildall.sh | 16 +- .../csharp/protos/unittest_issues.proto | 126 + .../google/protobuf/map_unittest_proto3.proto | 0 .../protobuf/unittest_import_proto3.proto | 0 .../unittest_import_public_proto3.proto | 0 .../src/google/protobuf/unittest_proto3.proto | 388 + .../protobuf/unittest_well_known_types.proto | 114 + .../Google.Protobuf.Test/ByteStringTest.cs | 171 + .../CodedInputStreamExtensions.cs | 53 + .../CodedInputStreamTest.cs | 598 + .../CodedOutputStreamTest.cs | 419 + .../Collections/MapFieldTest.cs | 532 + .../Collections/RepeatedFieldTest.cs | 746 + .../PropertyInfoExtensionsTest.cs | 98 + .../Compatibility/TypeExtensionsTest.cs | 117 + .../DeprecatedMemberTest.cs} | 103 +- .../Google.Protobuf.Test/EqualityTester.cs | 64 + .../Google.Protobuf.Test/FieldCodecTest.cs | 196 + .../GeneratedMessageTest.cs | 725 + .../Google.Protobuf.Test.csproj | 30 + .../src/Google.Protobuf.Test/IssuesTest.cs | 82 + .../Google.Protobuf.Test/JsonParserTest.cs | 939 + .../Google.Protobuf.Test/JsonTokenizerTest.cs | 408 + .../src/Google.Protobuf.Test/Program.cs | 47 + .../Reflection/DescriptorsTest.cs | 259 + .../Reflection/FieldAccessTest.cs | 218 + .../Reflection/TypeRegistryTest.cs | 94 + .../src/Google.Protobuf.Test/SampleEnum.cs | 42 + .../Google.Protobuf.Test/SampleMessages.cs | 99 + .../Google.Protobuf.Test/TestCornerCases.cs | 62 + .../TestProtos/ForeignMessagePartial.cs | 45 + .../WellKnownTypes/AnyTest.cs | 116 + .../WellKnownTypes/DurationTest.cs | 132 + .../WellKnownTypes/FieldMaskTest.cs | 62 + .../WellKnownTypes/TimestampTest.cs | 115 + .../WellKnownTypes/WrappersTest.cs | 421 + .../csharp/compatibility_tests/v3.0.0/test.sh | 96 + .../protobuf/csharp/generate_protos.sh | 37 +- .../protobuf/csharp/install_dotnet_sdk.ps1 | 21 + third_party/protobuf/csharp/protos/README.md | 3 + .../csharp/protos/map_unittest_proto3.proto | 116 + .../unittest_custom_options_proto3.proto | 336 + .../protos/unittest_import_proto3.proto} | 34 +- .../unittest_import_public_proto3.proto} | 14 +- .../csharp/protos/unittest_issues.proto | 30 +- .../csharp/protos/unittest_proto3.proto | 410 + .../csharp/src/AddressBook/AddPerson.cs | 262 +- .../csharp/src/AddressBook/AddressBook.csproj | 77 +- .../csharp/src/AddressBook/Addressbook.cs | 189 +- .../csharp/src/AddressBook/ListPeople.cs | 196 +- .../csharp/src/AddressBook/Program.cs | 188 +- .../AddressBook/Properties/AssemblyInfo.cs | 18 - .../csharp/src/AddressBook/SampleUsage.cs | 144 +- .../csharp/src/AddressBook/app.config | 3 - .../BenchmarkMessage1Proto3.cs | 1980 ++ .../Google.Protobuf.Benchmarks/Benchmarks.cs | 250 + .../Google.Protobuf.Benchmarks.csproj | 18 + .../src/Google.Protobuf.Benchmarks/Program.cs | 46 + .../SerializationBenchmark.cs | 120 + .../SerializationConfig.cs | 89 + .../Google.Protobuf.Conformance/App.config | 6 - .../Conformance.cs | 3755 +-- .../Google.Protobuf.Conformance.csproj | 65 +- .../Google.Protobuf.Conformance/Program.cs | 28 +- .../Google.Protobuf.JsonDump.csproj | 71 +- .../src/Google.Protobuf.JsonDump/Program.cs | 143 +- .../Properties/AssemblyInfo.cs | 19 - .../src/Google.Protobuf.JsonDump/app.config | 3 - .../Google.Protobuf.Test/ByteStringTest.cs | 406 +- .../CodedInputStreamTest.cs | 1334 +- .../CodedOutputStreamTest.cs | 843 +- .../Collections/MapFieldTest.cs | 79 +- .../ProtobufEqualityComparersTest.cs | 124 + .../Collections/RepeatedFieldTest.cs | 104 +- .../Compatibility/StreamExtensionsTest.cs | 67 + .../Compatibility/TypeExtensionsTest.cs | 22 +- .../DeprecatedMemberTest.cs | 110 +- .../Google.Protobuf.Test/EqualityTester.cs | 5 +- .../Google.Protobuf.Test/FieldCodecTest.cs | 14 +- .../Google.Protobuf.Test/FieldMaskTreeTest.cs | 436 + .../GeneratedMessageTest.cs | 1457 +- .../Google.Protobuf.Test.csproj | 161 +- .../src/Google.Protobuf.Test/IssuesTest.cs | 176 +- .../Google.Protobuf.Test/JsonFormatterTest.cs | 134 +- .../Google.Protobuf.Test/JsonParserTest.cs | 44 +- .../Google.Protobuf.Test/JsonTokenizerTest.cs | 26 +- .../Properties/AppManifest.xml | 6 - .../Properties/AssemblyInfo.cs | 20 - .../Reflection/CustomOptionsTest.cs | 212 + .../Reflection/DescriptorDeclarationTest.cs | 175 + .../Reflection/DescriptorsTest.cs | 188 +- .../Reflection/FieldAccessTest.cs | 2 +- .../src/Google.Protobuf.Test/SampleEnum.cs | 2 +- .../src/Google.Protobuf.Test/SampleNaNs.cs | 53 + .../Google.Protobuf.Test/TestCornerCases.cs | 124 +- .../TestProtos/MapUnittestProto3.cs | 624 +- .../TestProtos/TestMessagesProto3.cs | 3804 +++ .../TestProtos/UnittestCustomOptionsProto3.cs | 2962 ++ .../TestProtos/UnittestImportProto3.cs | 61 +- .../TestProtos/UnittestImportPublicProto3.cs | 55 +- .../TestProtos/UnittestIssues.cs | 850 +- .../TestProtos/UnittestProto3.cs | 2399 +- .../TestProtos/UnittestWellKnownTypes.cs | 420 +- .../UnknownFieldSetTest.cs | 194 + .../WellKnownTypes/AnyTest.cs | 49 +- .../WellKnownTypes/FieldMaskTest.cs | 189 +- .../WellKnownTypes/TimestampTest.cs | 103 +- .../WellKnownTypes/WrappersTest.cs | 15 +- .../src/Google.Protobuf.Test/packages.config | 5 - .../src/Google.Protobuf.Test/testprotos.pb | Bin 0 -> 205207 bytes .../csharp/src/Google.Protobuf/ByteArray.cs | 156 +- .../csharp/src/Google.Protobuf/ByteString.cs | 755 +- .../src/Google.Protobuf/CodedInputStream.cs | 2581 +- .../CodedOutputStream.ComputeSize.cs | 610 +- .../src/Google.Protobuf/CodedOutputStream.cs | 1531 +- .../src/Google.Protobuf/Collections/Lists.cs | 89 + .../Google.Protobuf/Collections/MapField.cs | 1531 +- .../Collections/ProtobufEqualityComparers.cs | 130 + .../Collections/ReadOnlyDictionary.cs | 292 +- .../Collections/RepeatedField.cs | 1167 +- .../Compatibility/MethodInfoExtensions.cs | 47 + .../Compatibility/PropertyInfoExtensions.cs | 8 + .../Compatibility/StreamExtensions.cs} | 65 +- .../Compatibility/TypeExtensions.cs | 11 +- .../csharp/src/Google.Protobuf/Extension.cs | 111 + .../src/Google.Protobuf/ExtensionRegistry.cs | 175 + .../src/Google.Protobuf/ExtensionSet.cs | 341 + .../src/Google.Protobuf/ExtensionValue.cs | 207 + .../csharp/src/Google.Protobuf/FieldCodec.cs | 191 +- .../src/Google.Protobuf/FieldMaskTree.cs | 365 + .../Google.Protobuf/FrameworkPortability.cs | 96 +- .../Google.Protobuf/Google.Protobuf.csproj | 198 +- .../Google.Protobuf/Google.Protobuf.nuspec | 54 - .../src/Google.Protobuf/IExtendableMessage.cs | 78 + .../csharp/src/Google.Protobuf/IMessage.cs | 174 +- .../InvalidProtocolBufferException.cs | 267 +- .../src/Google.Protobuf/JsonFormatter.cs | 200 +- .../csharp/src/Google.Protobuf/JsonParser.cs | 66 +- .../src/Google.Protobuf/JsonTokenizer.cs | 34 +- .../src/Google.Protobuf/LimitedInputStream.cs | 2 +- .../src/Google.Protobuf/MessageExtensions.cs | 156 +- .../src/Google.Protobuf/MessageParser.cs | 129 +- .../src/Google.Protobuf/ObjectIntPair.cs | 40 + .../Properties/AssemblyInfo.cs | 116 +- .../src/Google.Protobuf/ProtoPreconditions.cs | 156 +- .../Reflection/CustomOptions.cs | 310 + .../Google.Protobuf/Reflection/Descriptor.cs | 5268 +++- .../Reflection/DescriptorBase.cs | 47 +- .../Reflection/DescriptorDeclaration.cs | 112 + .../Reflection/DescriptorPool.cs | 60 +- .../Reflection/EnumDescriptor.cs | 37 + .../Reflection/EnumValueDescriptor.cs | 33 +- ...PartialClasses.cs => ExtensionAccessor.cs} | 48 +- .../Reflection/ExtensionCollection.cs | 105 + .../Reflection/FieldAccessorBase.cs | 1 + .../Reflection/FieldDescriptor.cs | 111 +- .../Google.Protobuf/Reflection/FieldType.cs | 2 +- .../Reflection/FileDescriptor.cs | 248 +- .../Reflection/GeneratedClrTypeInfo.cs | 27 +- .../Google.Protobuf/Reflection/IDescriptor.cs | 2 +- .../Reflection/IFieldAccessor.cs | 5 + .../Reflection/MapFieldAccessor.cs | 5 + .../Reflection/MessageDescriptor.cs | 67 +- .../Reflection/MethodDescriptor.cs | 31 +- .../Reflection/OneofAccessor.cs | 4 +- .../Reflection/OneofDescriptor.cs | 43 + .../Reflection/OriginalNameAttribute.cs | 9 +- .../Reflection/ReflectionUtil.cs | 304 +- .../Reflection/RepeatedFieldAccessor.cs | 5 + .../Reflection/ServiceDescriptor.cs | 41 +- .../Reflection/SingleFieldAccessor.cs | 42 +- .../src/Google.Protobuf/UnknownField.cs | 290 + .../src/Google.Protobuf/UnknownFieldSet.cs | 339 + .../src/Google.Protobuf/WellKnownTypes/Any.cs | 204 +- .../WellKnownTypes/AnyPartial.cs | 54 +- .../src/Google.Protobuf/WellKnownTypes/Api.cs | 369 +- .../WellKnownTypes/Duration.cs | 145 +- .../WellKnownTypes/DurationPartial.cs | 2 +- .../Google.Protobuf/WellKnownTypes/Empty.cs | 64 +- .../WellKnownTypes/FieldMask.cs | 399 +- .../WellKnownTypes/FieldMaskPartial.cs | 285 +- .../WellKnownTypes/SourceContext.cs | 58 +- .../Google.Protobuf/WellKnownTypes/Struct.cs | 190 +- .../WellKnownTypes/TimeExtensions.cs | 4 - .../WellKnownTypes/Timestamp.cs | 173 +- .../WellKnownTypes/TimestampPartial.cs | 105 +- .../Google.Protobuf/WellKnownTypes/Type.cs | 411 +- .../WellKnownTypes/Wrappers.cs | 383 +- .../csharp/src/Google.Protobuf/WireFormat.cs | 206 +- .../src/Google.Protobuf/packages.config | 4 - .../csharp/src/packages/repositories.config | 4 - third_party/protobuf/docs/options.md | 207 + third_party/protobuf/docs/performance.md | 304 + third_party/protobuf/docs/swift/DesignDoc.md | 674 - third_party/protobuf/docs/third_party.md | 55 +- third_party/protobuf/editors/protobuf-mode.el | 5 +- third_party/protobuf/examples/BUILD | 101 + third_party/protobuf/examples/CMakeLists.txt | 48 + third_party/protobuf/examples/ListPeople.java | 3 + third_party/protobuf/examples/README.md | 144 + third_party/protobuf/examples/README.txt | 54 - third_party/protobuf/examples/WORKSPACE | 50 + third_party/protobuf/examples/add_person.cc | 9 +- third_party/protobuf/examples/add_person.dart | 70 + third_party/protobuf/examples/add_person.go | 2 +- third_party/protobuf/examples/add_person.py | 13 +- .../protobuf/examples/add_person_test.go | 6 +- .../protobuf/examples/addressbook.proto | 4 + third_party/protobuf/examples/list_people.cc | 13 +- .../protobuf/examples/list_people.dart | 47 + third_party/protobuf/examples/list_people.go | 2 +- third_party/protobuf/examples/list_people.py | 19 +- .../protobuf/examples/list_people_test.go | 4 +- third_party/protobuf/examples/pubspec.yaml | 5 + .../protobuf/examples/third_party/zlib.BUILD | 1 + third_party/protobuf/gen_extra_chromium_files | 22 + third_party/protobuf/generate_changelog.py | 65 + .../protobuf/generate_descriptor_proto.sh | 63 +- third_party/protobuf/global.json | 5 + third_party/protobuf/gmock.BUILD | 28 - third_party/protobuf/java/README.md | 160 +- third_party/protobuf/java/bom/pom.xml | 110 + .../java/compatibility_tests/README.md | 50 + .../compatibility_tests/v2.5.0/deps/pom.xml | 43 + .../v2.5.0/more_protos/pom.xml | 69 + .../google/protobuf/multiple_files_test.proto | 71 + .../protobuf/nested_builders_test.proto | 53 + .../google/protobuf/nested_extension.proto | 45 + .../protobuf/nested_extension_lite.proto | 48 + .../protobuf/non_nested_extension.proto | 48 + .../protobuf/non_nested_extension_lite.proto | 50 + .../protobuf/test_bad_identifiers.proto | 108 + .../proto/google/protobuf/descriptor.proto | 620 + .../src/proto/google/protobuf/unittest.proto | 719 + .../protobuf/unittest_custom_options.proto | 387 + .../unittest_embed_optimize_for.proto | 50 + .../google/protobuf/unittest_empty.proto | 37 + .../unittest_enormous_descriptor.proto | 1046 + .../google/protobuf/unittest_import.proto | 64 + .../protobuf/unittest_import_lite.proto} | 21 +- .../protobuf/unittest_import_public.proto | 40 + .../unittest_import_public_lite.proto | 42 + .../proto/google/protobuf/unittest_lite.proto | 360 + .../unittest_lite_imports_nonlite.proto | 43 + .../proto/google/protobuf/unittest_mset.proto | 72 + .../unittest_no_generic_services.proto | 52 + .../protobuf/unittest_optimize_for.proto | 61 + .../java/compatibility_tests/v2.5.0/pom.xml | 30 + .../compatibility_tests/v2.5.0/protos/pom.xml | 71 + .../google/protobuf/multiple_files_test.proto | 71 + .../protobuf/nested_builders_test.proto | 53 + .../google/protobuf/nested_extension.proto | 45 + .../protobuf/nested_extension_lite.proto | 48 + .../protobuf/non_nested_extension.proto | 48 + .../protobuf/non_nested_extension_lite.proto | 50 + .../protobuf/test_bad_identifiers.proto | 108 + .../proto/google/protobuf/descriptor.proto | 620 + .../src/proto/google/protobuf/unittest.proto | 719 + .../protobuf/unittest_custom_options.proto | 387 + .../unittest_embed_optimize_for.proto | 50 + .../google/protobuf/unittest_empty.proto | 37 + .../unittest_enormous_descriptor.proto | 1046 + .../google/protobuf/unittest_import.proto | 64 + .../protobuf/unittest_import_lite.proto | 51 + .../protobuf/unittest_import_public.proto | 40 + .../unittest_import_public_lite.proto | 42 + .../proto/google/protobuf/unittest_lite.proto | 360 + .../unittest_lite_imports_nonlite.proto | 43 + .../proto/google/protobuf/unittest_mset.proto | 72 + .../unittest_no_generic_services.proto | 52 + .../protobuf/unittest_optimize_for.proto | 61 + .../java/compatibility_tests/v2.5.0/test.sh | 143 + .../compatibility_tests/v2.5.0/tests/pom.xml | 73 + .../protobuf/test/AbstractMessageTest.java | 510 + .../protobuf/test/BoundedByteStringTest.java | 56 + .../google/protobuf/test/ByteStringTest.java | 590 + .../protobuf/test/CodedInputStreamTest.java | 469 + .../protobuf/test/CodedOutputStreamTest.java | 318 + .../protobuf/test/DeprecatedFieldTest.java | 81 + .../google/protobuf/test/DescriptorsTest.java | 649 + .../protobuf/test/DynamicMessageTest.java | 265 + .../test/ForceFieldBuildersPreRun.java | 49 + .../protobuf/test/GeneratedMessageTest.java | 961 + .../test/LazyStringArrayListTest.java | 163 + .../protobuf/test/LazyStringEndToEndTest.java | 108 + .../protobuf/test/LiteralByteStringTest.java | 344 + .../com/google/protobuf/test/MessageTest.java | 354 + .../protobuf/test/NestedBuildersTest.java | 186 + .../com/google/protobuf/test/ParserTest.java | 278 + .../test/RopeByteStringSubstringTest.java | 62 + .../protobuf/test/RopeByteStringTest.java | 84 + .../com/google/protobuf/test/ServiceTest.java | 321 + .../protobuf/test/TestBadIdentifiers.java | 64 + .../com/google/protobuf/test/TestUtil.java | 3068 +++ .../google/protobuf/test/TextFormatTest.java | 536 + .../protobuf/test/UnknownFieldSetTest.java | 438 + .../test/UnmodifiableLazyStringListTest.java | 153 + .../google/protobuf/test/WireFormatTest.java | 465 + .../java/core/generate-test-sources-build.xml | 49 +- third_party/protobuf/java/core/pom.xml | 57 +- .../com/google/protobuf/AbstractMessage.java | 288 +- .../google/protobuf/AbstractMessageLite.java | 232 +- .../com/google/protobuf/AbstractParser.java | 62 +- .../google/protobuf/AbstractProtobufList.java | 35 +- .../com/google/protobuf/AllocatedBuffer.java | 263 + .../java/com/google/protobuf/Android.java | 57 + .../com/google/protobuf/ArrayDecoders.java | 1076 + .../com/google/protobuf/BinaryReader.java | 1729 ++ .../com/google/protobuf/BinaryWriter.java | 3071 +++ .../google/protobuf/BlockingRpcChannel.java | 12 +- .../com/google/protobuf/BlockingService.java | 25 +- .../com/google/protobuf/BooleanArrayList.java | 91 +- .../com/google/protobuf/BufferAllocator.java | 64 + .../com/google/protobuf/ByteBufferWriter.java | 74 +- .../java/com/google/protobuf/ByteOutput.java | 24 +- .../java/com/google/protobuf/ByteString.java | 814 +- .../com/google/protobuf/CodedInputStream.java | 4572 +++- .../protobuf/CodedInputStreamReader.java | 1333 + .../google/protobuf/CodedOutputStream.java | 1204 +- .../protobuf/CodedOutputStreamWriter.java | 691 + .../DescriptorMessageInfoFactory.java | 690 + .../java/com/google/protobuf/Descriptors.java | 1354 +- .../protobuf/DiscardUnknownFieldsParser.java} | 86 +- .../com/google/protobuf/DoubleArrayList.java | 94 +- .../com/google/protobuf/DynamicMessage.java | 191 +- .../com/google/protobuf/ExperimentalApi.java | 27 +- .../java/com/google/protobuf/Extension.java | 28 +- .../com/google/protobuf/ExtensionLite.java | 13 +- .../google/protobuf/ExtensionRegistry.java | 196 +- .../protobuf/ExtensionRegistryFactory.java | 95 + .../protobuf/ExtensionRegistryLite.java | 155 +- .../com/google/protobuf/ExtensionSchema.java | 98 + .../google/protobuf/ExtensionSchemaFull.java | 547 + .../google/protobuf/ExtensionSchemaLite.java | 541 + .../com/google/protobuf/ExtensionSchemas.java | 56 + .../java/com/google/protobuf/FieldInfo.java | 577 + .../java/com/google/protobuf/FieldSet.java | 527 +- .../java/com/google/protobuf/FieldType.java | 346 + .../com/google/protobuf/FloatArrayList.java | 93 +- .../com/google/protobuf/GeneratedMessage.java | 214 +- .../protobuf/GeneratedMessageInfoFactory.java | 65 + .../google/protobuf/GeneratedMessageLite.java | 1846 +- .../google/protobuf/GeneratedMessageV3.java | 2986 ++ .../com/google/protobuf/IntArrayList.java | 91 +- .../java/com/google/protobuf/Internal.java | 392 +- .../InvalidProtocolBufferException.java | 65 +- .../IterableByteBufferInputStream.java | 150 + .../java/com/google/protobuf/JavaType.java} | 70 +- .../java/com/google/protobuf/LazyField.java | 20 +- .../com/google/protobuf/LazyFieldLite.java | 161 +- .../google/protobuf/LazyStringArrayList.java | 80 +- .../com/google/protobuf/LazyStringList.java | 102 +- .../com/google/protobuf/ListFieldSchema.java | 190 + .../com/google/protobuf/LongArrayList.java | 93 +- .../protobuf/ManifestSchemaFactory.java | 172 + .../java/com/google/protobuf/MapEntry.java | 338 +- .../com/google/protobuf/MapEntryLite.java | 350 +- .../java/com/google/protobuf/MapField.java | 497 +- .../com/google/protobuf/MapFieldLite.java | 500 +- .../com/google/protobuf/MapFieldSchema.java | 63 + .../google/protobuf/MapFieldSchemaFull.java | 112 + .../google/protobuf/MapFieldSchemaLite.java | 107 + .../com/google/protobuf/MapFieldSchemas.java} | 30 +- .../java/com/google/protobuf/Message.java | 172 +- .../java/com/google/protobuf/MessageInfo.java | 43 + .../google/protobuf/MessageInfoFactory.java | 41 + .../java/com/google/protobuf/MessageLite.java | 285 +- .../google/protobuf/MessageLiteOrBuilder.java | 23 +- .../google/protobuf/MessageLiteToString.java | 100 +- .../com/google/protobuf/MessageOrBuilder.java | 102 +- .../google/protobuf/MessageReflection.java | 404 +- .../com/google/protobuf/MessageSchema.java | 5884 ++++ .../com/google/protobuf/MessageSetSchema.java | 392 + .../com/google/protobuf/MutabilityOracle.java | 21 +- .../google/protobuf/NewInstanceSchema.java | 36 + .../protobuf/NewInstanceSchemaFull.java | 39 + .../protobuf/NewInstanceSchemaLite.java | 39 + .../google/protobuf/NewInstanceSchemas.java | 53 + .../com/google/protobuf/NioByteString.java | 28 +- .../java/com/google/protobuf/OneofInfo.java | 66 + .../main/java/com/google/protobuf/Parser.java | 216 +- .../PrimitiveNonBoxingCollection.java | 34 + .../java/com/google/protobuf/ProtoSyntax.java | 38 + .../java/com/google/protobuf/Protobuf.java | 152 + .../google/protobuf/ProtobufArrayList.java | 21 +- .../com/google/protobuf/ProtobufLists.java | 94 + .../google/protobuf/ProtocolMessageEnum.java | 15 +- .../google/protobuf/ProtocolStringList.java | 12 +- .../com/google/protobuf/RawMessageInfo.java | 220 + .../main/java/com/google/protobuf/Reader.java | 379 + .../google/protobuf/RepeatedFieldBuilder.java | 221 +- .../protobuf/RepeatedFieldBuilderV3.java | 667 + .../com/google/protobuf/RopeByteString.java | 376 +- .../java/com/google/protobuf/RpcCallback.java | 13 +- .../java/com/google/protobuf/RpcChannel.java | 43 +- .../com/google/protobuf/RpcController.java | 76 +- .../java/com/google/protobuf/RpcUtil.java | 50 +- .../main/java/com/google/protobuf/Schema.java | 85 + .../com/google/protobuf/SchemaFactory.java | 38 + .../java/com/google/protobuf/SchemaUtil.java | 991 + .../java/com/google/protobuf/Service.java | 86 +- .../google/protobuf/SingleFieldBuilder.java | 92 +- .../google/protobuf/SingleFieldBuilderV3.java | 227 + .../com/google/protobuf/SmallSortedMap.java | 270 +- .../protobuf/StructuralMessageInfo.java | 167 + .../java/com/google/protobuf/TextFormat.java | 1666 +- .../google/protobuf/TextFormatEscaper.java | 125 +- .../protobuf/TextFormatParseInfoTree.java | 42 +- .../protobuf/TextFormatParseLocation.java | 7 +- .../UninitializedMessageException.java | 37 +- .../google/protobuf/UnknownFieldSchema.java | 133 + .../com/google/protobuf/UnknownFieldSet.java | 419 +- .../google/protobuf/UnknownFieldSetLite.java | 282 +- .../protobuf/UnknownFieldSetLiteSchema.java | 140 + .../protobuf/UnknownFieldSetSchema.java | 132 + .../protobuf/UnmodifiableLazyStringList.java | 8 +- .../google/protobuf/UnsafeByteOperations.java | 67 +- .../java/com/google/protobuf/UnsafeUtil.java | 659 + .../main/java/com/google/protobuf/Utf8.java | 1043 +- .../java/com/google/protobuf/WireFormat.java | 193 +- .../main/java/com/google/protobuf/Writer.java | 219 + .../google/protobuf/AbstractMessageTest.java | 211 +- .../AbstractProto2LiteSchemaTest.java | 199 + .../protobuf/AbstractProto2SchemaTest.java | 224 + .../AbstractProto3LiteSchemaTest.java | 143 + .../protobuf/AbstractProto3SchemaTest.java | 151 + .../google/protobuf/AbstractSchemaTest.java | 157 + .../java/com/google/protobuf/AnyTest.java | 39 +- .../google/protobuf/ArrayDecodersTest.java | 236 + .../google/protobuf/BinaryProtocolTest.java | 90 + .../google/protobuf/BooleanArrayListTest.java | 222 +- .../protobuf/BoundedByteStringTest.java | 30 +- .../google/protobuf/ByteBufferWriterTest.java | 7 +- .../com/google/protobuf/ByteStringTest.java | 309 +- .../google/protobuf/CachedFieldSizeTest.java | 65 + .../com/google/protobuf/CheckUtf8Test.java | 56 +- .../com/google/protobuf/CodedAdapterTest.java | 110 + .../google/protobuf/CodedInputStreamTest.java | 1147 +- .../protobuf/CodedOutputStreamTest.java | 148 +- .../com/google/protobuf/DecodeUtf8Test.java | 325 + .../google/protobuf/DeprecatedFieldTest.java | 42 +- .../com/google/protobuf/DescriptorsTest.java | 645 +- .../protobuf/DiscardUnknownFieldsTest.java | 120 + .../google/protobuf/DoubleArrayListTest.java | 217 +- .../google/protobuf/DynamicMessageTest.java | 135 +- .../java/com/google/protobuf/EnumTest.java | 28 +- .../protobuf/ExperimentalMessageFactory.java | 40 + .../ExperimentalSerializationUtil.java | 113 + .../ExperimentalTestDataProvider.java | 189 + .../ExtensionRegistryFactoryTest.java | 285 + .../google/protobuf/FieldPresenceTest.java | 229 +- .../google/protobuf/FloatArrayListTest.java | 217 +- .../protobuf/ForceFieldBuildersPreRun.java | 9 +- .../google/protobuf/GeneratedMessageTest.java | 757 +- .../com/google/protobuf/IntArrayListTest.java | 175 +- .../com/google/protobuf/IsValidUtf8Test.java | 53 +- .../google/protobuf/IsValidUtf8TestUtil.java | 173 +- .../google/protobuf/LazyFieldLiteTest.java | 51 +- .../com/google/protobuf/LazyFieldTest.java | 14 +- .../google/protobuf/LazyMessageLiteTest.java | 192 +- .../protobuf/LazyStringArrayListTest.java | 69 +- .../protobuf/LazyStringEndToEndTest.java | 65 +- .../protobuf/LiteEqualsAndHashTest.java | 2 +- .../protobuf/LiteralByteStringTest.java | 284 +- .../google/protobuf/LongArrayListTest.java | 215 +- .../google/protobuf/MapForProto2LiteTest.java | 734 +- .../com/google/protobuf/MapForProto2Test.java | 811 +- .../java/com/google/protobuf/MapLiteTest.java | 894 + .../java/com/google/protobuf/MapTest.java | 1011 +- .../java/com/google/protobuf/MessageTest.java | 238 +- .../google/protobuf/NestedBuildersTest.java | 81 +- .../google/protobuf/NioByteStringTest.java | 326 +- .../com/google/protobuf/PackedFieldTest.java | 232 + .../google/protobuf/ParseExceptionsTest.java | 78 +- .../com/google/protobuf/ParserLiteTest.java | 191 + .../java/com/google/protobuf/ParserTest.java | 270 +- .../Proto2ExtensionLookupSchemaTest.java | 171 + .../google/protobuf/Proto2LiteSchemaTest.java | 49 + .../google/protobuf/Proto2MessageFactory.java | 555 + .../protobuf/Proto2MessageInfoFactory.java | 892 + .../protobuf/Proto2MessageLiteFactory.java | 558 + .../com/google/protobuf/Proto2SchemaTest.java | 49 + .../protobuf/Proto2UnknownEnumValueTest.java | 111 + .../google/protobuf/Proto3LiteSchemaTest.java | 49 + .../google/protobuf/Proto3MessageFactory.java | 450 + .../protobuf/Proto3MessageInfoFactory.java | 506 + .../protobuf/Proto3MessageLiteFactory.java | 452 + .../Proto3MessageLiteInfoFactory.java | 816 + .../com/google/protobuf/Proto3SchemaTest.java | 48 + .../protobuf/ProtobufArrayListTest.java | 211 +- ...t.java => RepeatedFieldBuilderV3Test.java} | 45 +- .../protobuf/RopeByteStringSubstringTest.java | 38 +- .../google/protobuf/RopeByteStringTest.java | 90 +- .../java/com/google/protobuf/ServiceTest.java | 167 +- ...est.java => SingleFieldBuilderV3Test.java} | 68 +- .../google/protobuf/SmallSortedMapTest.java | 78 +- .../google/protobuf/TestBadIdentifiers.java | 62 +- .../protobuf/TestBadIdentifiersLite.java | 89 + .../java/com/google/protobuf/TestSchemas.java | 94 + .../com/google/protobuf/TestSchemasLite.java | 103 + .../java/com/google/protobuf/TestUtil.java | 4585 ++-- .../com/google/protobuf/TestUtilLite.java | 496 +- .../protobuf/TextFormatParseInfoTreeTest.java | 7 +- .../protobuf/TextFormatParseLocationTest.java | 4 +- .../com/google/protobuf/TextFormatTest.java | 1231 +- .../google/protobuf/UnknownEnumValueTest.java | 181 +- .../protobuf/UnknownFieldSetLiteTest.java | 328 - .../google/protobuf/UnknownFieldSetTest.java | 470 +- .../UnmodifiableLazyStringListTest.java | 15 +- .../java/com/google/protobuf/Utf8Test.java | 232 + .../java/com/google/protobuf/Utf8Utils.java | 193 + .../google/protobuf/WireFormatLiteTest.java | 1023 + .../com/google/protobuf/WireFormatTest.java | 387 +- .../protobuf/WrappersLiteOfMethodTest.java | 61 + .../google/protobuf/WrappersOfMethodTest.java | 61 + .../proto/com/google/protobuf/any_test.proto | 4 +- .../protobuf/cached_field_size_test.proto} | 21 +- .../com/google/protobuf/deprecated_file.proto | 38 + .../google/protobuf/field_presence_test.proto | 3 +- .../google/protobuf/lazy_fields_lite.proto | 2 - .../protobuf/lite_equals_and_hash.proto | 12 +- .../protobuf/map_for_proto2_lite_test.proto | 69 +- .../google/protobuf/map_for_proto2_test.proto | 69 +- .../map_initialization_order_test.proto | 3 +- .../com/google/protobuf/map_lite_test.proto | 121 + .../proto/com/google/protobuf/map_test.proto | 71 +- .../message_lite_extension_util_test.proto} | 22 +- .../google/protobuf/multiple_files_test.proto | 12 +- .../protobuf/nested_builders_test.proto | 1 - .../google/protobuf/nested_extension.proto | 5 +- .../protobuf/nested_extension_lite.proto | 5 +- .../protobuf/non_nested_extension.proto | 5 +- .../protobuf/non_nested_extension_lite.proto | 5 +- .../protobuf/outer_class_name_test.proto | 3 +- .../protobuf/outer_class_name_test2.proto | 3 +- .../protobuf/outer_class_name_test3.proto | 4 +- .../google/protobuf/packed_field_test.proto | 76 + .../com/google/protobuf/proto2_message.proto | 430 + .../google/protobuf/proto2_message_lite.proto | 423 + .../protobuf/proto2_unknown_enum_values.proto | 60 + .../com/google/protobuf/proto3_message.proto | 327 + .../google/protobuf/proto3_message_lite.proto | 320 + .../protobuf/test_bad_identifiers.proto | 46 +- .../google/protobuf/test_custom_options.proto | 2 +- .../protobuf/test_extra_interfaces.proto | 3 - .../com/google/protobuf/wrappers_test.proto} | 52 +- third_party/protobuf/java/lite.md | 39 + .../java/lite/generate-sources-build.xml | 7 +- .../java/lite/generate-test-sources-build.xml | 69 +- third_party/protobuf/java/lite/lite.awk | 25 + third_party/protobuf/java/lite/pom.xml | 328 +- .../java/lite/process-lite-sources-build.xml | 7 + .../java/com/google/protobuf/LiteTest.java | 1876 +- .../Proto2MessageLiteInfoFactory.java | 1327 + third_party/protobuf/java/pom.xml | 88 +- third_party/protobuf/java/util/pom.xml | 54 +- .../com/google/protobuf/util/Durations.java | 455 + .../google/protobuf/util/FieldMaskTree.java | 100 +- .../google/protobuf/util/FieldMaskUtil.java | 138 +- .../com/google/protobuf/util/JsonFormat.java | 1250 +- .../com/google/protobuf/util/Structs.java | 65 + .../com/google/protobuf/util/TimeUtil.java | 382 +- .../com/google/protobuf/util/Timestamps.java | 437 + .../java/com/google/protobuf/util/Values.java | 85 + .../protobuf/util/FieldMaskTreeTest.java | 150 +- .../protobuf/util/FieldMaskUtilTest.java | 113 +- .../google/protobuf/util/JsonFormatTest.java | 1338 +- .../com/google/protobuf/util/StructsTest.java | 59 + .../google/protobuf/util/TimeUtilTest.java | 84 +- .../com/google/protobuf/util/ValuesTest.java | 102 + .../com/google/protobuf/util/json_test.proto | 59 +- third_party/protobuf/javanano/README.md | 398 - third_party/protobuf/javanano/pom.xml | 244 - .../nano/CodedInputByteBufferNano.java | 683 - .../nano/CodedOutputByteBufferNano.java | 1214 - .../protobuf/nano/ExtendableMessageNano.java | 169 - .../com/google/protobuf/nano/Extension.java | 706 - .../com/google/protobuf/nano/FieldArray.java | 291 - .../com/google/protobuf/nano/FieldData.java | 240 - .../google/protobuf/nano/InternalNano.java | 547 - .../InvalidProtocolBufferNanoException.java | 93 - .../com/google/protobuf/nano/MessageNano.java | 198 - .../protobuf/nano/MessageNanoPrinter.java | 275 - .../google/protobuf/nano/WireFormatNano.java | 124 - .../com/google/protobuf/nano/NanoTest.java | 4468 --- .../nano/unittest_accessors_nano.proto | 118 - .../nano/unittest_enum_validity_nano.proto | 28 - .../nano/unittest_extension_nano.proto | 37 - .../nano/unittest_extension_packed_nano.proto | 29 - .../unittest_extension_repeated_nano.proto | 34 - .../unittest_extension_singular_nano.proto | 34 - .../google/protobuf/nano/unittest_nano.proto | 195 - .../nano/unittest_reference_types_nano.proto | 116 - .../unittest_repeated_packables_nano.proto | 95 - third_party/protobuf/jenkins/README.md | 6 - .../protobuf/jenkins/buildcmds/README.md | 6 - .../jenkins/buildcmds/pull_request.sh | 15 - .../protobuf/jenkins/docker/Dockerfile | 130 - .../jenkins/pull_request_in_docker.sh | 72 - third_party/protobuf/js/README.md | 24 +- third_party/protobuf/js/binary/arith.js | 2 +- third_party/protobuf/js/binary/arith_test.js | 109 +- third_party/protobuf/js/binary/constants.js | 32 +- third_party/protobuf/js/binary/decoder.js | 136 +- .../protobuf/js/binary/decoder_test.js | 65 +- third_party/protobuf/js/binary/encoder.js | 86 +- .../protobuf/js/binary/message_test.js | 60 + third_party/protobuf/js/binary/proto_test.js | 51 +- third_party/protobuf/js/binary/reader.js | 159 +- third_party/protobuf/js/binary/reader_test.js | 88 +- third_party/protobuf/js/binary/utils.js | 26 +- third_party/protobuf/js/binary/utils_test.js | 27 +- third_party/protobuf/js/binary/writer.js | 581 +- third_party/protobuf/js/binary/writer_test.js | 16 +- third_party/protobuf/js/commonjs/export.js | 9 + .../protobuf/js/commonjs/export_asserts.js | 4 + .../protobuf/js/commonjs/export_testdeps.js | 6 + .../protobuf/js/commonjs/strict_test.js | 67 + .../v3.0.0/binary/arith_test.js | 355 + .../v3.0.0/binary/decoder_test.js | 317 + .../v3.0.0/binary/proto_test.js | 628 + .../v3.0.0/binary/reader_test.js | 922 + .../v3.0.0/binary/utils_test.js | 668 + .../v3.0.0/binary/writer_test.js | 122 + .../v3.0.0/commonjs/export_asserts.js | 37 + .../v3.0.0/commonjs/export_testdeps.js | 18 + .../v3.0.0/commonjs/import_test.js | 52 + .../v3.0.0/commonjs/jasmine.json | 9 + .../commonjs/rewrite_tests_for_commonjs.js | 97 + .../v3.0.0/commonjs/test6/test6.proto | 40 + .../v3.0.0/commonjs/test7/test7.proto | 42 + .../js/compatibility_tests/v3.0.0/data.proto | 51 + .../compatibility_tests/v3.0.0/debug_test.js | 105 + .../compatibility_tests/v3.0.0/jasmine1.json | 17 + .../compatibility_tests/v3.0.0/jasmine2.json | 17 + .../compatibility_tests/v3.0.0/jasmine3.json | 17 + .../v3.0.0/message_test.js | 1080 + .../compatibility_tests/v3.0.0/proto3_test.js | 329 + .../v3.0.0/proto3_test.proto | 89 + .../js/compatibility_tests/v3.0.0/test.proto | 236 + .../js/compatibility_tests/v3.0.0/test.sh | 92 + .../js/compatibility_tests/v3.0.0/test2.proto | 54 + .../js/compatibility_tests/v3.0.0/test3.proto | 53 + .../compatibility_tests/v3.0.0/test4.proto} | 15 +- .../compatibility_tests/v3.0.0/test5.proto} | 19 +- .../v3.0.0/testbinary.proto | 212 + .../v3.0.0/testempty.proto | 34 + .../v3.1.0/binary/arith_test.js | 355 + .../v3.1.0/binary/decoder_test.js | 317 + .../v3.1.0/binary/proto_test.js | 628 + .../v3.1.0/binary/reader_test.js | 922 + .../v3.1.0/binary/utils_test.js | 668 + .../v3.1.0/binary/writer_test.js | 122 + .../v3.1.0/commonjs/test6/test6.proto | 40 + .../v3.1.0/commonjs/test7/test7.proto | 42 + .../js/compatibility_tests/v3.1.0/data.proto | 51 + .../compatibility_tests/v3.1.0/debug_test.js | 105 + .../compatibility_tests/v3.1.0/maps_test.js | 301 + .../v3.1.0/message_test.js | 1032 + .../compatibility_tests/v3.1.0/proto3_test.js | 329 + .../v3.1.0/proto3_test.proto | 89 + .../js/compatibility_tests/v3.1.0/test.proto | 262 + .../js/compatibility_tests/v3.1.0/test2.proto | 54 + .../js/compatibility_tests/v3.1.0/test3.proto | 53 + .../js/compatibility_tests/v3.1.0/test4.proto | 42 + .../js/compatibility_tests/v3.1.0/test5.proto | 44 + .../v3.1.0/testbinary.proto | 212 + .../v3.1.0/testempty.proto | 34 + third_party/protobuf/js/data.proto | 5 +- third_party/protobuf/js/debug.js | 27 +- third_party/protobuf/js/debug_test.js | 85 +- third_party/protobuf/js/gulpfile.js | 221 +- third_party/protobuf/js/jasmine.json | 7 +- third_party/protobuf/js/map.js | 542 + third_party/protobuf/js/maps_test.js | 406 + third_party/protobuf/js/message.js | 821 +- third_party/protobuf/js/message_test.js | 1058 +- third_party/protobuf/js/package.json | 24 +- third_party/protobuf/js/proto3_test.js | 131 +- third_party/protobuf/js/proto3_test.proto | 59 +- third_party/protobuf/js/test.proto | 101 +- .../test10.proto} | 9 +- third_party/protobuf/js/test11.proto | 52 + third_party/protobuf/js/test12.proto | 119 + third_party/protobuf/js/test13.proto | 70 + third_party/protobuf/js/test14.proto | 43 + third_party/protobuf/js/test15.proto | 39 + third_party/protobuf/js/test2.proto | 10 +- third_party/protobuf/js/test3.proto | 4 +- third_party/protobuf/js/test4.proto | 6 +- third_party/protobuf/js/test5.proto | 4 +- .../test8.proto} | 25 +- third_party/protobuf/js/test9.proto | 39 + third_party/protobuf/js/testbinary.proto | 239 +- third_party/protobuf/js/testempty.proto | 1 - third_party/protobuf/kokoro/README.md | 6 + .../protobuf/kokoro/linux/32-bit/Dockerfile | 143 + .../protobuf/kokoro/linux/32-bit/build.sh | 18 + .../kokoro/linux/32-bit/continuous.cfg | 11 + .../kokoro/linux/32-bit/presubmit.cfg | 11 + .../protobuf/kokoro/linux/64-bit/Dockerfile | 244 + .../protobuf/kokoro/linux/bazel/build.sh | 13 + .../kokoro/linux/bazel/continuous.cfg | 5 + .../protobuf/kokoro/linux/bazel/presubmit.cfg | 5 + .../protobuf/kokoro/linux/benchmark/build.sh | 26 + .../kokoro/linux/benchmark/continuous.cfg | 11 + .../protobuf/kokoro/linux/benchmark/run.sh | 105 + .../linux}/build_and_run_docker.sh | 45 +- .../kokoro/linux/cpp_distcheck/build.sh | 21 + .../kokoro/linux/cpp_distcheck/continuous.cfg | 5 + .../kokoro/linux/cpp_distcheck/presubmit.cfg | 5 + .../kokoro/linux/cpp_tcmalloc/build.sh | 13 + .../kokoro/linux/cpp_tcmalloc/continuous.cfg | 5 + .../kokoro/linux/cpp_tcmalloc/presubmit.cfg | 5 + .../protobuf/kokoro/linux/csharp/build.sh | 18 + .../kokoro/linux/csharp/continuous.cfg | 5 + .../kokoro/linux/csharp/presubmit.cfg | 5 + .../kokoro/linux/dist_install/build.sh | 15 + .../kokoro/linux/dist_install/continuous.cfg | 5 + .../kokoro/linux/dist_install/presubmit.cfg | 5 + .../linux/dockerfile/push_testing_images.sh | 29 + .../release/ruby_rake_compiler/Dockerfile | 3 + .../dockerfile/test/cpp_tcmalloc/Dockerfile | 29 + .../linux/dockerfile/test/csharp/Dockerfile | 36 + .../dockerfile/test/javascript/Dockerfile | 33 + .../linux/dockerfile/test/php/Dockerfile | 238 + .../dockerfile/test/php_32bit/Dockerfile | 224 + .../dockerfile/test/python_jessie/Dockerfile | 39 + .../dockerfile/test/python_stretch/Dockerfile | 47 + .../linux/dockerfile/test/ruby/Dockerfile | 37 + .../protobuf/kokoro/linux/golang/build.sh | 17 + .../kokoro/linux/golang/continuous.cfg | 11 + .../kokoro/linux/golang/presubmit.cfg | 11 + .../kokoro/linux/java_compatibility/build.sh | 17 + .../linux/java_compatibility/continuous.cfg | 5 + .../linux/java_compatibility/presubmit.cfg | 5 + .../protobuf/kokoro/linux/java_jdk7/build.sh | 17 + .../kokoro/linux/java_jdk7/continuous.cfg | 11 + .../kokoro/linux/java_jdk7/presubmit.cfg | 11 + .../kokoro/linux/java_oracle7/build.sh | 17 + .../kokoro/linux/java_oracle7/continuous.cfg | 11 + .../kokoro/linux/java_oracle7/presubmit.cfg | 11 + .../protobuf/kokoro/linux/javascript/build.sh | 18 + .../kokoro/linux/javascript/continuous.cfg | 11 + .../kokoro/linux/javascript/presubmit.cfg | 11 + .../linux}/make_test_output.py | 11 +- .../protobuf/kokoro/linux/php_all/build.sh | 18 + .../kokoro/linux/php_all/continuous.cfg | 11 + .../kokoro/linux/php_all/presubmit.cfg | 11 + .../kokoro/linux/pull_request_in_docker.sh | 25 + .../protobuf/kokoro/linux/python/build.sh | 17 + .../kokoro/linux/python/continuous.cfg | 11 + .../kokoro/linux/python/presubmit.cfg | 11 + .../protobuf/kokoro/linux/python27/build.sh | 18 + .../kokoro/linux/python27/continuous.cfg | 11 + .../kokoro/linux/python27/presubmit.cfg | 11 + .../kokoro/linux/python27_cpp/build.sh | 18 + .../kokoro/linux/python27_cpp/continuous.cfg | 11 + .../kokoro/linux/python27_cpp/presubmit.cfg | 11 + .../protobuf/kokoro/linux/python33/build.sh | 18 + .../kokoro/linux/python33/continuous.cfg | 11 + .../kokoro/linux/python33/presubmit.cfg | 11 + .../kokoro/linux/python33_cpp/build.sh | 18 + .../kokoro/linux/python33_cpp/continuous.cfg | 11 + .../kokoro/linux/python33_cpp/presubmit.cfg | 11 + .../protobuf/kokoro/linux/python34/build.sh | 18 + .../kokoro/linux/python34/continuous.cfg | 11 + .../kokoro/linux/python34/presubmit.cfg | 11 + .../kokoro/linux/python34_cpp/build.sh | 18 + .../kokoro/linux/python34_cpp/continuous.cfg | 11 + .../kokoro/linux/python34_cpp/presubmit.cfg | 11 + .../protobuf/kokoro/linux/python35/build.sh | 18 + .../kokoro/linux/python35/continuous.cfg | 11 + .../kokoro/linux/python35/presubmit.cfg | 11 + .../kokoro/linux/python35_cpp/build.sh | 18 + .../kokoro/linux/python35_cpp/continuous.cfg | 11 + .../kokoro/linux/python35_cpp/presubmit.cfg | 11 + .../protobuf/kokoro/linux/python36/build.sh | 18 + .../kokoro/linux/python36/continuous.cfg | 11 + .../kokoro/linux/python36/presubmit.cfg | 11 + .../kokoro/linux/python36_cpp/build.sh | 18 + .../kokoro/linux/python36_cpp/continuous.cfg | 11 + .../kokoro/linux/python36_cpp/presubmit.cfg | 11 + .../protobuf/kokoro/linux/python37/build.sh | 18 + .../kokoro/linux/python37/continuous.cfg | 11 + .../kokoro/linux/python37/presubmit.cfg | 11 + .../kokoro/linux/python37_cpp/build.sh | 18 + .../kokoro/linux/python37_cpp/continuous.cfg | 11 + .../kokoro/linux/python37_cpp/presubmit.cfg | 11 + .../linux/python_compatibility/build.sh | 17 + .../linux/python_compatibility/continuous.cfg | 5 + .../linux/python_compatibility/presubmit.cfg | 5 + .../protobuf/kokoro/linux/python_cpp/build.sh | 17 + .../kokoro/linux/python_cpp/continuous.cfg | 11 + .../kokoro/linux/python_cpp/presubmit.cfg | 11 + .../protobuf/kokoro/linux/ruby23/build.sh | 18 + .../kokoro/linux/ruby23/continuous.cfg | 11 + .../kokoro/linux/ruby23/presubmit.cfg | 11 + .../protobuf/kokoro/linux/ruby24/build.sh | 18 + .../kokoro/linux/ruby24/continuous.cfg | 11 + .../kokoro/linux/ruby24/presubmit.cfg | 11 + .../protobuf/kokoro/linux/ruby25/build.sh | 18 + .../kokoro/linux/ruby25/continuous.cfg | 11 + .../kokoro/linux/ruby25/presubmit.cfg | 11 + .../protobuf/kokoro/linux/ruby26/build.sh | 18 + .../kokoro/linux/ruby26/continuous.cfg | 11 + .../kokoro/linux/ruby26/presubmit.cfg | 11 + .../protobuf/kokoro/macos/cpp/build.sh | 11 + .../protobuf/kokoro/macos/cpp/continuous.cfg | 5 + .../protobuf/kokoro/macos/cpp/presubmit.cfg | 5 + .../kokoro/macos/cpp_distcheck/build.sh | 11 + .../kokoro/macos/cpp_distcheck/continuous.cfg | 5 + .../kokoro/macos/cpp_distcheck/presubmit.cfg | 5 + .../protobuf/kokoro/macos/javascript/build.sh | 11 + .../kokoro/macos/javascript/continuous.cfg | 5 + .../kokoro/macos/javascript/presubmit.cfg | 5 + .../objectivec_cocoapods_integration/build.sh | 11 + .../continuous.cfg | 5 + .../presubmit.cfg | 5 + .../macos/objectivec_ios_debug/build.sh | 11 + .../macos/objectivec_ios_debug/continuous.cfg | 5 + .../macos/objectivec_ios_debug/presubmit.cfg | 5 + .../macos/objectivec_ios_release/build.sh | 11 + .../objectivec_ios_release/continuous.cfg | 5 + .../objectivec_ios_release/presubmit.cfg | 5 + .../kokoro/macos/objectivec_osx/build.sh | 11 + .../macos/objectivec_osx/continuous.cfg | 5 + .../kokoro/macos/objectivec_osx/presubmit.cfg | 5 + .../protobuf/kokoro/macos/php5.6_mac/build.sh | 11 + .../kokoro/macos/php5.6_mac/continuous.cfg | 5 + .../kokoro/macos/php5.6_mac/presubmit.cfg | 5 + .../protobuf/kokoro/macos/php7.0_mac/build.sh | 11 + .../kokoro/macos/php7.0_mac/continuous.cfg | 5 + .../kokoro/macos/php7.0_mac/presubmit.cfg | 5 + .../kokoro/macos/prepare_build_macos_rc | 40 + .../protobuf/kokoro/macos/python/build.sh | 11 + .../kokoro/macos/python/continuous.cfg | 5 + .../kokoro/macos/python/presubmit.cfg | 5 + .../protobuf/kokoro/macos/python_cpp/build.sh | 12 + .../kokoro/macos/python_cpp/continuous.cfg | 5 + .../kokoro/macos/python_cpp/presubmit.cfg | 5 + .../protobuf/kokoro/macos/ruby23/build.sh | 11 + .../kokoro/macos/ruby23/continuous.cfg | 5 + .../kokoro/macos/ruby23/presubmit.cfg | 5 + .../protobuf/kokoro/macos/ruby24/build.sh | 11 + .../kokoro/macos/ruby24/continuous.cfg | 5 + .../kokoro/macos/ruby24/presubmit.cfg | 5 + .../protobuf/kokoro/macos/ruby25/build.sh | 11 + .../kokoro/macos/ruby25/continuous.cfg | 5 + .../kokoro/macos/ruby25/presubmit.cfg | 5 + .../protobuf/kokoro/macos/ruby26/build.sh | 11 + .../kokoro/macos/ruby26/continuous.cfg | 5 + .../kokoro/macos/ruby26/presubmit.cfg | 5 + .../kokoro/release/collect_all_artifacts.cfg | 7 + .../kokoro/release/collect_all_artifacts.sh | 62 + .../release/csharp/windows/build_nuget.bat | 14 + .../release/csharp/windows/continuous.cfg | 11 + .../release/csharp/windows/presubmit.cfg | 11 + .../kokoro/release/csharp/windows/release.cfg | 11 + .../kokoro/release/protoc/linux/build.sh | 40 + .../kokoro/release/protoc/linux/release.cfg | 7 + .../kokoro/release/protoc/macos/build.sh | 23 + .../kokoro/release/protoc/macos/release.cfg | 8 + .../kokoro/release/protoc/windows/build.bat | 27 + .../kokoro/release/protoc/windows/release.cfg | 8 + .../release/python/linux/build_artifacts.sh | 56 + .../kokoro/release/python/linux/config.sh | 50 + .../release/python/linux/continuous.cfg | 8 + .../kokoro/release/python/linux/presubmit.cfg | 8 + .../kokoro/release/python/linux/release.cfg | 8 + .../release/python/macos/build_artifacts.sh | 57 + .../kokoro/release/python/macos/config.sh | 48 + .../release/python/macos/continuous.cfg | 8 + .../kokoro/release/python/macos/presubmit.cfg | 8 + .../kokoro/release/python/macos/release.cfg | 8 + .../python/windows/build_artifacts.bat | 68 + .../python/windows/build_single_artifact.bat | 72 + .../release/python/windows/continuous.cfg | 8 + .../release/python/windows/presubmit.cfg | 8 + .../kokoro/release/python/windows/release.cfg | 8 + .../release/ruby/linux/build_artifacts.sh | 14 + .../kokoro/release/ruby/linux/continuous.cfg | 8 + .../release/ruby/linux/prepare_build.sh | 18 + .../kokoro/release/ruby/linux/presubmit.cfg | 8 + .../kokoro/release/ruby/linux/release.cfg | 8 + .../release/ruby/linux/ruby/ruby_build.sh | 17 + .../ruby/linux/ruby/ruby_build_environment.sh | 8 + .../release/ruby/macos/build_artifacts.sh | 19 + .../kokoro/release/ruby/macos/continuous.cfg | 8 + .../kokoro/release/ruby/macos/presubmit.cfg | 8 + .../kokoro/release/ruby/macos/release.cfg | 8 + .../release/ruby/macos/ruby/ruby_build.sh | 17 + .../ruby/macos/ruby/ruby_build_environment.sh | 57 + .../protobuf/kokoro/windows/csharp/build.bat | 14 + .../kokoro/windows/csharp/continuous.cfg | 5 + .../kokoro/windows/csharp/presubmit.cfg | 5 + third_party/protobuf/m4/acx_check_suncc.m4 | 5 +- third_party/protobuf/m4/acx_pthread.m4 | 397 - .../protobuf/m4/ax_cxx_compile_stdcxx.m4 | 1001 + .../protobuf/m4/ax_prog_cc_for_build.m4 | 125 + .../protobuf/m4/ax_prog_cxx_for_build.m4 | 110 + third_party/protobuf/m4/ax_pthread.m4 | 485 + third_party/protobuf/mirclient.cc | 469 + third_party/protobuf/mirclient.map | 30 + third_party/protobuf/objectivec/.gitignore | 23 + .../DevTools/check_version_stamps.sh | 67 +- .../DevTools/compile_testing_protos.sh | 96 +- .../objectivec/DevTools/full_mac_build.sh | 199 +- .../protobuf/objectivec/DevTools/pddm.py | 24 +- .../objectivec/DevTools/pddm_tests.py | 6 +- third_party/protobuf/objectivec/GPBArray.h | 1534 +- third_party/protobuf/objectivec/GPBArray.m | 139 +- .../protobuf/objectivec/GPBBootstrap.h | 86 +- .../protobuf/objectivec/GPBCodedInputStream.h | 227 +- .../protobuf/objectivec/GPBCodedInputStream.m | 150 +- .../GPBCodedInputStream_PackagePrivate.h | 2 - .../objectivec/GPBCodedOutputStream.h | 608 +- .../objectivec/GPBCodedOutputStream.m | 63 +- .../protobuf/objectivec/GPBDescriptor.h | 203 +- .../protobuf/objectivec/GPBDescriptor.m | 200 +- .../objectivec/GPBDescriptor_PackagePrivate.h | 42 +- .../protobuf/objectivec/GPBDictionary.h | 5817 +++- .../protobuf/objectivec/GPBDictionary.m | 6105 ++--- .../objectivec/GPBExtensionInternals.m | 11 + .../objectivec/GPBExtensionRegistry.h | 71 +- .../objectivec/GPBExtensionRegistry.m | 80 +- third_party/protobuf/objectivec/GPBMessage.h | 580 +- third_party/protobuf/objectivec/GPBMessage.m | 316 +- .../objectivec/GPBMessage_PackagePrivate.h | 29 +- .../protobuf/objectivec/GPBProtocolBuffers.h | 39 +- .../protobuf/objectivec/GPBProtocolBuffers.m | 14 +- .../GPBProtocolBuffers_RuntimeSupport.h | 2 +- .../protobuf/objectivec/GPBRootObject.h | 13 +- .../protobuf/objectivec/GPBRootObject.m | 29 +- .../protobuf/objectivec/GPBRuntimeTypes.h | 72 +- .../protobuf/objectivec/GPBUnknownField.h | 66 +- .../protobuf/objectivec/GPBUnknownField.m | 17 +- .../protobuf/objectivec/GPBUnknownFieldSet.h | 47 +- .../protobuf/objectivec/GPBUnknownFieldSet.m | 54 +- .../GPBUnknownField_PackagePrivate.h | 2 - .../protobuf/objectivec/GPBUtilities.h | 498 +- .../protobuf/objectivec/GPBUtilities.m | 725 +- .../objectivec/GPBUtilities_PackagePrivate.h | 32 +- .../protobuf/objectivec/GPBWellKnownTypes.h | 205 +- .../protobuf/objectivec/GPBWellKnownTypes.m | 189 +- .../protobuf/objectivec/GPBWireFormat.h | 1 + .../protobuf/objectivec/GPBWireFormat.m | 7 + third_party/protobuf/objectivec/README.md | 61 +- .../OSXCocoaPodsTester/AppDelegate.h | 37 + .../OSXCocoaPodsTester/AppDelegate.m | 48 + .../AppIcon.appiconset/Contents.json | 58 + .../Base.lproj/MainMenu.xib | 680 + .../OSXCocoaPodsTester/Info.plist | 34 + .../OSXCocoaPodsTester/main.m | 35 + .../OSXCocoaPodsTester/Podfile-framework | 10 + .../OSXCocoaPodsTester/Podfile-static | 8 + .../objectivec/Tests/CocoaPods/README.md | 9 + .../iOSCocoaPodsTester/Podfile-framework | 10 + .../iOSCocoaPodsTester/Podfile-static | 8 + .../iOSCocoaPodsTester/AppDelegate.h | 39 + .../iOSCocoaPodsTester/AppDelegate.m | 67 + .../AppIcon.appiconset/Contents.json | 54 +- .../Base.lproj/LaunchScreen.storyboard | 27 + .../Base.lproj/Main.storyboard | 26 + .../iOSCocoaPodsTester}/Info.plist | 16 +- .../iOSCocoaPodsTester/ViewController.h | 37 + .../iOSCocoaPodsTester/ViewController.m | 49 + .../iOSCocoaPodsTester/main.m | 39 + .../objectivec/Tests/CocoaPods/run_tests.sh | 150 + .../objectivec/Tests/GPBARCUnittestProtos.m | 2 + .../protobuf/objectivec/Tests/GPBArrayTests.m | 331 +- .../Tests/GPBCodedInputStreamTests.m | 187 +- .../Tests/GPBCodedOuputStreamTests.m | 98 +- .../objectivec/Tests/GPBCompileTest01.m | 40 + .../objectivec/Tests/GPBCompileTest02.m | 40 + .../objectivec/Tests/GPBCompileTest03.m | 40 + .../objectivec/Tests/GPBCompileTest04.m | 40 + .../objectivec/Tests/GPBCompileTest05.m | 40 + .../objectivec/Tests/GPBCompileTest06.m | 40 + .../objectivec/Tests/GPBCompileTest07.m | 40 + .../objectivec/Tests/GPBCompileTest08.m | 40 + .../objectivec/Tests/GPBCompileTest09.m | 40 + .../objectivec/Tests/GPBCompileTest10.m | 40 + .../objectivec/Tests/GPBCompileTest11.m | 40 + .../objectivec/Tests/GPBCompileTest12.m | 40 + .../objectivec/Tests/GPBCompileTest13.m | 40 + .../objectivec/Tests/GPBCompileTest14.m | 40 + .../objectivec/Tests/GPBCompileTest15.m | 40 + .../objectivec/Tests/GPBCompileTest16.m | 40 + .../objectivec/Tests/GPBCompileTest17.m | 40 + .../objectivec/Tests/GPBCompileTest18.m | 40 + .../objectivec/Tests/GPBCompileTest19.m | 40 + .../objectivec/Tests/GPBCompileTest20.m | 40 + .../objectivec/Tests/GPBCompileTest21.m | 40 + .../objectivec/Tests/GPBCompileTest22.m | 40 + .../objectivec/Tests/GPBCompileTest23.m | 40 + .../objectivec/Tests/GPBCompileTest24.m | 42 + .../objectivec/Tests/GPBCompileTest25.m | 42 + .../objectivec/Tests/GPBDescriptorTests.m | 248 +- .../Tests/GPBDictionaryTests+Bool.m | 1086 +- .../Tests/GPBDictionaryTests+Int32.m | 2129 +- .../Tests/GPBDictionaryTests+Int64.m | 2129 +- .../Tests/GPBDictionaryTests+String.m | 2111 +- .../Tests/GPBDictionaryTests+UInt32.m | 2129 +- .../Tests/GPBDictionaryTests+UInt64.m | 2129 +- .../objectivec/Tests/GPBDictionaryTests.m | 186 + .../objectivec/Tests/GPBDictionaryTests.pddm | 455 +- .../Tests/GPBExtensionRegistryTest.m | 138 + .../Tests/GPBMessageTests+Runtime.m | 509 +- .../Tests/GPBMessageTests+Serialization.m | 288 +- .../objectivec/Tests/GPBMessageTests.m | 174 +- .../protobuf/objectivec/Tests/GPBPerfTests.m | 106 + .../objectivec/Tests/GPBSwiftTests.swift | 314 +- .../objectivec/Tests/GPBTestUtilities.h | 3 + .../objectivec/Tests/GPBTestUtilities.m | 32 +- .../objectivec/Tests/GPBUnittestProtos.m | 11 + .../objectivec/Tests/GPBUnittestProtos2.m | 34 + .../objectivec/Tests/GPBUnknownFieldSetTest.m | 271 +- .../objectivec/Tests/GPBUtilitiesTests.m | 257 +- .../objectivec/Tests/GPBWellKnownTypesTest.m | 216 +- .../objectivec/Tests/GPBWireFormatTests.m | 8 +- .../Tests/iOSTestHarness/AppDelegate.m | 35 - .../AppIcon.appiconset/iPad6.png | Bin 8583 -> 0 bytes .../AppIcon.appiconset/iPad6_2x.png | Bin 17744 -> 0 bytes .../AppIcon.appiconset/iPad7.png | Bin 8969 -> 0 bytes .../AppIcon.appiconset/iPad7_2x.png | Bin 18788 -> 0 bytes .../AppIcon.appiconset/iPhone6.png | Bin 7021 -> 0 bytes .../AppIcon.appiconset/iPhone6_2x.png | Bin 13348 -> 0 bytes .../AppIcon.appiconset/iPhone7_2x.png | Bin 11128 -> 0 bytes .../AppIcon.appiconset/iPhone7_3x.png | Bin 21792 -> 0 bytes .../LaunchImage.launchimage/Contents.json | 49 - .../Tests/iOSTestHarness/LaunchScreen.xib | 33 - .../iOSTestHarness/en.lproj/InfoPlist.strings | 2 - .../text_format_extensions_unittest_data.txt | 140 + .../objectivec/Tests/unittest_cycle.proto | 6 +- .../Tests/unittest_deprecated.proto | 95 + .../Tests/unittest_deprecated_file.proto | 76 + .../Tests/unittest_extension_chain_a.proto | 51 + .../Tests/unittest_extension_chain_b.proto | 47 + .../Tests/unittest_extension_chain_c.proto | 45 + .../Tests/unittest_extension_chain_d.proto | 49 + .../Tests/unittest_extension_chain_e.proto | 40 + .../Tests/unittest_extension_chain_f.proto | 44 + .../Tests/unittest_extension_chain_g.proto | 41 + .../objectivec/Tests/unittest_objc.proto | 505 +- .../Tests/unittest_objc_options.proto | 61 + .../objectivec/google/protobuf/Any.pbobjc.h | 233 +- .../objectivec/google/protobuf/Any.pbobjc.m | 33 +- .../objectivec/google/protobuf/Api.pbobjc.h | 335 +- .../objectivec/google/protobuf/Api.pbobjc.m | 68 +- .../google/protobuf/Duration.pbobjc.h | 162 +- .../google/protobuf/Duration.pbobjc.m | 31 +- .../objectivec/google/protobuf/Empty.pbobjc.h | 61 +- .../objectivec/google/protobuf/Empty.pbobjc.m | 31 +- .../google/protobuf/FieldMask.pbobjc.h | 395 +- .../google/protobuf/FieldMask.pbobjc.m | 31 +- .../google/protobuf/SourceContext.pbobjc.h | 53 +- .../google/protobuf/SourceContext.pbobjc.m | 31 +- .../google/protobuf/Struct.pbobjc.h | 147 +- .../google/protobuf/Struct.pbobjc.m | 55 +- .../google/protobuf/Timestamp.pbobjc.h | 196 +- .../google/protobuf/Timestamp.pbobjc.m | 31 +- .../objectivec/google/protobuf/Type.pbobjc.h | 307 +- .../objectivec/google/protobuf/Type.pbobjc.m | 99 +- .../google/protobuf/Wrappers.pbobjc.h | 131 +- .../google/protobuf/Wrappers.pbobjc.m | 79 +- .../0003-remove-static-initializers.patch | 2 +- ...ger-types-and-shared-library-exports.patch | 74 +- .../0005-fix-include-js-generator.patch | 11 - .../patches/0007-uninline_googleonce.patch | 36 - .../0008-uninline_get_empty_string.patch | 39 +- .../patches/0009-uninline-arenastring.patch | 73 +- .../0010-uninline-generated-code.patch | 37 +- .../patches/0011-libprotobuf_export.patch | 11 - ...ix-protobuf-s-library-.gitinore-file.patch | 12 + .../protobuf/patches/0023-php_generator.patch | 87 + .../0026-json_objectwriter_override.patch | 49 + .../patches/0027-explicit-namespace.patch | 11 + .../0028-fix-repeated-field-export.patch | 270 + .../0029-Fix-order-for-mutex-macros.patch | 11 + ...ix-use_unaligned-not-defined-warning.patch | 11 + third_party/protobuf/php/README.md | 97 + third_party/protobuf/php/composer.json | 28 + .../protobuf/php/ext/google/protobuf/array.c | 545 + .../google/protobuf/builtin_descriptors.inc | 635 + .../php/ext/google/protobuf/config.m4 | 8 +- .../protobuf/php/ext/google/protobuf/def.c | 1275 +- .../php/ext/google/protobuf/encode_decode.c | 1879 ++ .../protobuf/php/ext/google/protobuf/map.c | 592 + .../php/ext/google/protobuf/message.c | 2650 +- .../php/ext/google/protobuf/package.xml | 379 + .../php/ext/google/protobuf/protobuf.c | 386 +- .../php/ext/google/protobuf/protobuf.h | 1605 +- .../php/ext/google/protobuf/storage.c | 1225 +- .../protobuf/php/ext/google/protobuf/test.php | 15 - .../php/ext/google/protobuf/type_check.c | 606 + .../protobuf/php/ext/google/protobuf/upb.c | 21286 ++++++++------- .../protobuf/php/ext/google/protobuf/upb.h | 11968 ++++---- .../protobuf/php/ext/google/protobuf/utf8.c | 68 + .../protobuf/php/ext/google/protobuf/utf8.h | 36 + .../php/generate_descriptor_protos.sh | 16 + third_party/protobuf/php/phpunit.xml | 18 + third_party/protobuf/php/release.sh | 37 + .../src/GPBMetadata/Google/Protobuf/Any.php | 30 + .../src/GPBMetadata/Google/Protobuf/Api.php | 49 + .../GPBMetadata/Google/Protobuf/Duration.php | 31 + .../GPBMetadata/Google/Protobuf/FieldMask.php | 31 + .../GPBMetadata/Google/Protobuf/GPBEmpty.php | 30 + .../Google/Protobuf/Internal/Descriptor.php | 277 + .../Google/Protobuf/SourceContext.php | 32 + .../GPBMetadata/Google/Protobuf/Struct.php | 45 + .../GPBMetadata/Google/Protobuf/Timestamp.php | 31 + .../src/GPBMetadata/Google/Protobuf/Type.php | 78 + .../GPBMetadata/Google/Protobuf/Wrappers.php | 38 + .../protobuf/php/src/Google/Protobuf/Any.php | 325 + .../protobuf/php/src/Google/Protobuf/Api.php | 350 + .../php/src/Google/Protobuf/BoolValue.php | 68 + .../php/src/Google/Protobuf/BytesValue.php | 68 + .../src/Google/Protobuf/Descriptor.php} | 96 +- .../src/Google/Protobuf/DescriptorPool.php | 76 + .../php/src/Google/Protobuf/DoubleValue.php | 68 + .../php/src/Google/Protobuf/Duration.php | 173 + .../protobuf/php/src/Google/Protobuf/Enum.php | 203 + .../src/Google/Protobuf/EnumDescriptor.php | 79 + .../php/src/Google/Protobuf/EnumValue.php | 135 + .../Google/Protobuf/EnumValueDescriptor.php | 64 + .../php/src/Google/Protobuf/Field.php | 381 + .../src/Google/Protobuf/Field/Cardinality.php | 70 + .../php/src/Google/Protobuf/Field/Kind.php | 175 + .../src/Google/Protobuf/FieldDescriptor.php | 117 + .../php/src/Google/Protobuf/FieldMask.php | 223 + .../src/Google/Protobuf/Field_Cardinality.php | 16 + .../php/src/Google/Protobuf/Field_Kind.php | 16 + .../php/src/Google/Protobuf/FloatValue.php | 68 + .../php/src/Google/Protobuf/GPBEmpty.php | 39 + .../php/src/Google/Protobuf/Int32Value.php | 68 + .../php/src/Google/Protobuf/Int64Value.php | 68 + .../Protobuf/Internal/CodedInputStream.php | 378 + .../Protobuf/Internal/CodedOutputStream.php | 159 + .../Google/Protobuf/Internal/Descriptor.php | 222 + .../Protobuf/Internal/DescriptorPool.php | 179 + .../Protobuf/Internal/DescriptorProto.php | 386 + .../DescriptorProto/ExtensionRange.php | 152 + .../DescriptorProto/ReservedRange.php | 122 + .../DescriptorProto_ExtensionRange.php | 16 + .../DescriptorProto_ReservedRange.php | 16 + .../Protobuf/Internal/EnumBuilderContext.php | 63 + .../Protobuf/Internal/EnumDescriptor.php | 115 + .../Protobuf/Internal/EnumDescriptorProto.php | 231 + .../EnumDescriptorProto/EnumReservedRange.php | 124 + .../EnumDescriptorProto_EnumReservedRange.php | 16 + .../Google/Protobuf/Internal/EnumOptions.php | 172 + .../Internal/EnumValueDescriptorProto.php | 137 + .../Protobuf/Internal/EnumValueOptions.php | 127 + .../Internal/ExtensionRangeOptions.php | 74 + .../Protobuf/Internal/FieldDescriptor.php | 284 + .../Internal/FieldDescriptorProto.php | 473 + .../Internal/FieldDescriptorProto/Label.php | 58 + .../Internal/FieldDescriptorProto/Type.php | 153 + .../Internal/FieldDescriptorProto_Label.php | 16 + .../Internal/FieldDescriptorProto_Type.php | 16 + .../Google/Protobuf/Internal/FieldOptions.php | 488 + .../Protobuf/Internal/FieldOptions/CType.php | 58 + .../Protobuf/Internal/FieldOptions/JSType.php | 62 + .../Protobuf/Internal/FieldOptions_CType.php | 16 + .../Protobuf/Internal/FieldOptions_JSType.php | 16 + .../Protobuf/Internal/FileDescriptor.php | 89 + .../Protobuf/Internal/FileDescriptorProto.php | 519 + .../Protobuf/Internal/FileDescriptorSet.php | 70 + .../Google/Protobuf/Internal/FileOptions.php | 1046 + .../Internal/FileOptions/OptimizeMode.php | 64 + .../Internal/FileOptions_OptimizeMode.php | 16 + .../Protobuf/Internal/GPBDecodeException.php | 47 + .../Google/Protobuf/Internal/GPBJsonWire.php | 304 + .../src/Google/Protobuf/Internal/GPBLabel.php | 40 + .../src/Google/Protobuf/Internal/GPBType.php | 55 + .../src/Google/Protobuf/Internal/GPBUtil.php | 615 + .../src/Google/Protobuf/Internal/GPBWire.php | 622 + .../Google/Protobuf/Internal/GPBWireType.php | 43 + .../Protobuf/Internal/GeneratedCodeInfo.php | 82 + .../Internal/GeneratedCodeInfo/Annotation.php | 216 + .../Internal/GeneratedCodeInfo_Annotation.php | 16 + .../Internal/GetPublicDescriptorTrait.php | 41 + .../Internal/HasPublicDescriptorTrait.php | 43 + .../src/Google/Protobuf/Internal/MapEntry.php | 57 + .../src/Google/Protobuf/Internal/MapField.php | 290 + .../Google/Protobuf/Internal/MapFieldIter.php | 124 + .../src/Google/Protobuf/Internal/Message.php | 1947 ++ .../Internal/MessageBuilderContext.php | 120 + .../Protobuf/Internal/MessageOptions.php | 382 + .../Internal/MethodDescriptorProto.php | 264 + .../Protobuf/Internal/MethodOptions.php | 161 + .../MethodOptions/IdempotencyLevel.php | 64 + .../MethodOptions_IdempotencyLevel.php | 16 + .../Protobuf/Internal/OneofDescriptor.php | 78 + .../Internal/OneofDescriptorProto.php | 103 + .../Google/Protobuf/Internal/OneofField.php | 77 + .../Google/Protobuf/Internal/OneofOptions.php | 74 + .../Protobuf/Internal/RawInputStream.php | 50 + .../Protobuf/Internal/RepeatedField.php | 258 + .../Protobuf/Internal/RepeatedFieldIter.php | 118 + .../Internal/ServiceDescriptorProto.php | 137 + .../Protobuf/Internal/ServiceOptions.php | 127 + .../Protobuf/Internal/SourceCodeInfo.php | 237 + .../Internal/SourceCodeInfo/Location.php | 463 + .../Internal/SourceCodeInfo_Location.php | 16 + .../Protobuf/Internal/UninterpretedOption.php | 289 + .../Internal/UninterpretedOption/NamePart.php | 110 + .../Internal/UninterpretedOption_NamePart.php | 16 + .../php/src/Google/Protobuf/ListValue.php | 68 + .../php/src/Google/Protobuf/Method.php | 271 + .../php/src/Google/Protobuf/Mixin.php | 166 + .../php/src/Google/Protobuf/NullValue.php | 48 + .../src/Google/Protobuf/OneofDescriptor.php | 75 + .../php/src/Google/Protobuf/Option.php | 126 + .../php/src/Google/Protobuf/SourceContext.php | 72 + .../php/src/Google/Protobuf/StringValue.php | 68 + .../php/src/Google/Protobuf/Struct.php | 73 + .../php/src/Google/Protobuf/Syntax.php | 53 + .../php/src/Google/Protobuf/Timestamp.php | 200 + .../protobuf/php/src/Google/Protobuf/Type.php | 237 + .../php/src/Google/Protobuf/UInt32Value.php | 68 + .../php/src/Google/Protobuf/UInt64Value.php | 68 + .../php/src/Google/Protobuf/Value.php | 214 + third_party/protobuf/php/src/phpdoc.dist.xml | 15 + third_party/protobuf/php/tests/array_test.php | 593 + third_party/protobuf/php/tests/autoload.php | 27 +- .../protobuf/php/tests/bootstrap_phpunit.php | 5 + .../protobuf/php/tests/compatibility_test.sh | 164 + .../protobuf/php/tests/compile_extension.sh | 10 + .../protobuf/php/tests/descriptors_test.php | 246 + .../protobuf/php/tests/encode_decode_test.php | 1178 + third_party/protobuf/php/tests/gdb_test.sh | 19 + .../php/tests/generated_class_test.php | 1509 + .../php/tests/generated_phpdoc_test.php | 345 + .../php/tests/generated_service_test.php | 110 + .../protobuf/php/tests/map_field_test.php | 505 + .../protobuf/php/tests/memory_leak_test.php | 208 + .../php/tests/php_implementation_test.php | 598 + .../protobuf/php/tests/proto/empty/echo.proto | 17 + .../protobuf/php/tests/proto/test.proto | 209 + .../php/tests/proto/test_descriptors.proto | 35 + .../proto/test_empty_php_namespace.proto | 19 + .../proto/test_import_descriptor_proto.proto | 14 + .../php/tests/proto/test_include.proto | 18 + .../php/tests/proto/test_no_namespace.proto | 22 + .../php/tests/proto/test_php_namespace.proto | 31 + .../php/tests/proto/test_prefix.proto | 20 + .../proto/test_reserved_enum_lower.proto | 77 + .../proto/test_reserved_enum_upper.proto | 77 + .../test_reserved_enum_value_lower.proto | 79 + .../test_reserved_enum_value_upper.proto | 79 + .../proto/test_reserved_message_lower.proto | 77 + .../proto/test_reserved_message_upper.proto | 77 + .../php/tests/proto/test_service.proto | 18 + .../tests/proto/test_service_namespace.proto | 13 + .../proto/test_wrapper_type_setters.proto | 26 + third_party/protobuf/php/tests/test.sh | 40 + third_party/protobuf/php/tests/test_base.php | 343 + third_party/protobuf/php/tests/test_util.php | 547 + .../protobuf/php/tests/undefined_test.php | 920 + .../protobuf/php/tests/well_known_test.php | 419 + .../php/tests/wrapper_type_setters_test.php | 312 + third_party/protobuf/post_process_dist.sh | 2 +- third_party/protobuf/proto_library.gni | 203 +- third_party/protobuf/protobuf-lite.pc.in | 2 +- third_party/protobuf/protobuf.bzl | 698 +- third_party/protobuf/protobuf.pc.in | 3 +- third_party/protobuf/protobuf_deps.bzl | 15 + .../protobuf/protoc-artifacts/Dockerfile | 47 +- .../protobuf/protoc-artifacts/README.md | 218 +- .../protobuf/protoc-artifacts/build-protoc.sh | 97 +- .../protobuf/protoc-artifacts/build-zip.sh | 118 + third_party/protobuf/protoc-artifacts/pom.xml | 83 +- .../protoc-artifacts/scl-enable-devtoolset.sh | 13 + third_party/protobuf/python/MANIFEST.in | 3 + third_party/protobuf/python/README.md | 89 +- .../protobuf/internal/factory_test1.proto | 55 + .../protobuf/internal/factory_test2.proto | 77 + .../protobuf/internal/more_extensions.proto | 58 + .../internal/more_extensions_dynamic.proto | 49 + .../protobuf/internal/more_messages.proto | 51 + .../internal/test_bad_identifiers.proto | 52 + .../proto/google/protobuf/descriptor.proto | 620 + .../src/proto/google/protobuf/unittest.proto | 719 + .../protobuf/unittest_custom_options.proto | 387 + .../google/protobuf/unittest_import.proto | 64 + .../protobuf/unittest_import_public.proto | 40 + .../proto/google/protobuf/unittest_mset.proto | 72 + .../unittest_no_generic_services.proto | 52 + .../compatibility_tests/v2.5.0/setup.py | 87 + .../python/compatibility_tests/v2.5.0/test.sh | 104 + .../v2.5.0/tests/__init__.py | 4 + .../v2.5.0/tests/google/__init__.py | 4 + .../v2.5.0/tests/google/protobuf/__init__.py | 4 + .../google/protobuf/internal/__init__.py} | 36 +- .../protobuf/internal/descriptor_test.py | 613 + .../protobuf/internal/generator_test.py | 269 + .../google/protobuf/internal/golden_message | Bin 0 -> 509 bytes .../internal/golden_packed_fields_message | Bin 0 -> 142 bytes .../google/protobuf/internal/message_test.py | 499 + .../internal/service_reflection_test.py | 136 + .../google/protobuf/internal/test_util.py | 651 + .../protobuf/internal/text_format_test.py | 622 + .../internal/text_format_unittest_data.txt | 128 + .../text_format_unittest_extensions_data.txt | 128 + .../protobuf/internal/wire_format_test.py | 253 + .../python/google/protobuf/__init__.py | 2 +- .../google/protobuf/compiler/__init__.py | 0 .../python/google/protobuf/descriptor.py | 206 +- .../google/protobuf/descriptor_database.py | 64 +- .../python/google/protobuf/descriptor_pb2.py | 889 +- .../python/google/protobuf/descriptor_pool.py | 633 +- .../google/protobuf/internal/__init__.py | 30 + .../protobuf/internal/_parameterized.py | 70 +- .../google/protobuf/internal/any_test.proto | 15 +- .../protobuf/internal/api_implementation.cc | 68 +- .../protobuf/internal/api_implementation.py | 48 +- .../google/protobuf/internal/containers.py | 202 +- .../google/protobuf/internal/decoder.py | 218 +- .../internal/descriptor_database_test.py | 63 + .../protobuf/internal/descriptor_pool_test.py | 508 +- .../protobuf/internal/descriptor_test.py | 395 +- .../google/protobuf/internal/encoder.py | 117 +- .../protobuf/internal/enum_type_wrapper.py | 10 +- .../protobuf/internal/extension_dict.py | 206 + .../protobuf/internal/factory_test1.proto | 14 + .../protobuf/internal/factory_test2.proto | 5 + .../protobuf/internal/file_options_test.proto | 43 + .../protobuf/internal/generator_test.py | 13 +- .../protobuf/internal/json_format_test.py | 415 +- .../google/protobuf/internal/keywords_test.py | 105 + .../protobuf/internal/message_factory_test.py | 59 +- .../google/protobuf/internal/message_test.py | 803 +- .../internal/missing_enum_values.proto | 1 + .../protobuf/internal/more_extensions.proto | 4 +- .../internal/more_extensions_dynamic.proto | 1 + .../protobuf/internal/more_messages.proto | 308 + .../google/protobuf/internal/no_package.proto | 40 + .../protobuf/internal/python_message.py | 483 +- .../protobuf/internal/python_protobuf.cc} | 55 +- .../protobuf/internal/reflection_test.py | 307 +- .../internal/service_reflection_test.py | 4 + .../protobuf/internal/symbol_database_test.py | 35 +- .../internal/test_bad_identifiers.proto | 8 +- .../google/protobuf/internal/test_util.py | 212 +- .../protobuf/internal/testing_refleaks.py | 133 + .../protobuf/internal/text_format_test.py | 1532 +- .../google/protobuf/internal/type_checkers.py | 66 +- .../protobuf/internal/unknown_fields_test.py | 288 +- .../protobuf/internal/well_known_types.py | 235 +- .../internal/well_known_types_test.py | 434 +- .../python/google/protobuf/json_format.py | 946 +- .../python/google/protobuf/message.py | 44 +- .../python/google/protobuf/message_factory.py | 53 +- .../python/google/protobuf/proto_api.h | 97 + .../google/protobuf/pyext/cpp_message.py | 6 +- .../google/protobuf/pyext/descriptor.cc | 629 +- .../python/google/protobuf/pyext/descriptor.h | 9 +- .../protobuf/pyext/descriptor_containers.cc | 628 +- .../protobuf/pyext/descriptor_containers.h | 10 +- .../protobuf/pyext/descriptor_database.cc | 39 +- .../protobuf/pyext/descriptor_database.h | 9 +- .../google/protobuf/pyext/descriptor_pool.cc | 519 +- .../google/protobuf/pyext/descriptor_pool.h | 57 +- .../google/protobuf/pyext/extension_dict.cc | 473 +- .../google/protobuf/pyext/extension_dict.h | 76 +- .../python/google/protobuf/pyext/field.cc | 142 + .../google/protobuf/pyext/field.h} | 35 +- .../google/protobuf/pyext/map_container.cc | 471 +- .../google/protobuf/pyext/map_container.h | 69 +- .../python/google/protobuf/pyext/message.cc | 2162 +- .../python/google/protobuf/pyext/message.h | 238 +- .../google/protobuf/pyext/message_factory.cc | 303 + .../google/protobuf/pyext/message_factory.h | 103 + .../google/protobuf/pyext/message_module.cc | 121 + .../protobuf/pyext/proto2_api_test.proto | 4 +- .../python/google/protobuf/pyext/python.proto | 8 +- .../pyext/repeated_composite_container.cc | 564 +- .../pyext/repeated_composite_container.h | 81 +- .../pyext/repeated_scalar_container.cc | 264 +- .../pyext/repeated_scalar_container.h | 53 +- .../google/protobuf/pyext/safe_numerics.h | 164 + .../protobuf/pyext/scoped_pyobject_ptr.h | 62 +- .../google/protobuf/pyext/unknown_fields.cc | 357 + .../google/protobuf/pyext/unknown_fields.h} | 101 +- .../protobuf/{pyext => }/python_protobuf.h | 2 +- .../python/google/protobuf/reflection.py | 57 +- .../python/google/protobuf/symbol_database.py | 104 +- .../python/google/protobuf/text_encoding.py | 84 +- .../python/google/protobuf/text_format.py | 1035 +- .../python/google/protobuf/util/__init__.py | 0 third_party/protobuf/python/mox.py | 2 +- third_party/protobuf/python/release.sh | 116 + .../protobuf/python/release/wheel/Dockerfile | 6 + .../protobuf/python/release/wheel/README.md | 17 + .../release/wheel/build_wheel_manylinux.sh | 27 + .../release/wheel/protobuf_optimized_pip.sh | 66 + third_party/protobuf/python/setup.cfg | 2 + third_party/protobuf/python/setup.py | 87 +- third_party/protobuf/python/stubout.py | 3 + third_party/protobuf/python/tox.ini | 8 +- third_party/protobuf/ruby/.gitignore | 1 + third_party/protobuf/ruby/Gemfile.lock | 30 - third_party/protobuf/ruby/README.md | 11 +- third_party/protobuf/ruby/Rakefile | 64 +- .../ruby/compatibility_tests/v3.0.0/README.md | 5 + .../ruby/compatibility_tests/v3.0.0/Rakefile | 25 + .../ruby/compatibility_tests/v3.0.0/test.sh | 17 + .../compatibility_tests/v3.0.0/tests/basic.rb | 1279 + .../v3.0.0/tests/generated_code.proto | 67 + .../v3.0.0/tests/generated_code_test.rb | 19 + .../v3.0.0/tests/repeated_field_test.rb | 641 + .../v3.0.0/tests/stress.rb | 38 + .../v3.0.0/tests/test_import.proto | 5 + .../ruby/ext/google/protobuf_c/defs.c | 660 +- .../ext/google/protobuf_c/encode_decode.c | 660 +- .../ruby/ext/google/protobuf_c/extconf.rb | 17 +- .../protobuf/ruby/ext/google/protobuf_c/map.c | 70 +- .../ruby/ext/google/protobuf_c/message.c | 384 +- .../ruby/ext/google/protobuf_c/protobuf.c | 8 +- .../ruby/ext/google/protobuf_c/protobuf.h | 99 +- .../ext/google/protobuf_c/repeated_field.c | 31 +- .../ruby/ext/google/protobuf_c/storage.c | 411 +- .../protobuf/ruby/ext/google/protobuf_c/upb.c | 22757 ++++++++++------ .../protobuf/ruby/ext/google/protobuf_c/upb.h | 3788 ++- .../ruby/ext/google/protobuf_c/wrap_memcpy.c | 51 + .../protobuf/ruby/google-protobuf.gemspec | 14 +- .../protobuf/ruby/lib/google/protobuf.rb | 11 +- .../ruby/lib/google/protobuf/message_exts.rb | 4 +- .../lib/google/protobuf/repeated_field.rb | 10 +- .../lib/google/protobuf/well_known_types.rb | 224 + third_party/protobuf/ruby/pom.xml | 10 +- .../com/google/protobuf/jruby/RubyMap.java | 6 +- .../google/protobuf/jruby/RubyMessage.java | 96 +- .../protobuf/jruby/RubyRepeatedField.java | 4 +- .../protobuf/jruby/SentinelOuterClass.java | 44 +- .../java/com/google/protobuf/jruby/Utils.java | 37 +- third_party/protobuf/ruby/tests/basic.rb | 1213 +- .../protobuf/ruby/tests/basic_proto2.rb | 265 + .../protobuf/ruby/tests/basic_test.proto | 155 + .../ruby/tests/basic_test_proto2.proto | 162 + .../protobuf/ruby/tests/common_tests.rb | 1551 ++ .../protobuf/ruby/tests/encode_decode_test.rb | 97 + third_party/protobuf/ruby/tests/gc_test.rb | 102 + .../protobuf/ruby/tests/generated_code.proto | 20 +- .../ruby/tests/generated_code_proto2.proto | 80 + .../ruby/tests/generated_code_proto2_test.rb | 21 + .../ruby/tests/generated_code_test.rb | 10 +- .../ruby/tests/repeated_field_test.rb | 35 +- .../protobuf/ruby/tests/test_import.proto | 5 + .../ruby/tests/test_import_proto2.proto | 5 + .../ruby/tests/test_ruby_package.proto | 7 + .../ruby/tests/test_ruby_package_proto2.proto | 7 + .../protobuf/ruby/tests/type_errors.rb | 176 + .../ruby/tests/well_known_types_test.rb | 142 + third_party/protobuf/ruby/travis-test.sh | 39 +- third_party/protobuf/src/Makefile.am | 468 +- third_party/protobuf/src/README.md | 150 +- .../protobuf/src/google/protobuf/any.cc | 81 +- .../protobuf/src/google/protobuf/any.h | 74 +- .../protobuf/src/google/protobuf/any.pb.cc | 563 +- .../protobuf/src/google/protobuf/any.pb.h | 318 +- .../protobuf/src/google/protobuf/any.proto | 47 +- .../protobuf/src/google/protobuf/any_lite.cc | 123 + .../protobuf/src/google/protobuf/any_test.cc | 85 +- .../protobuf/src/google/protobuf/api.pb.cc | 2329 +- .../protobuf/src/google/protobuf/api.pb.h | 1100 +- .../protobuf/src/google/protobuf/api.proto | 52 +- .../protobuf/src/google/protobuf/arena.cc | 492 +- .../protobuf/src/google/protobuf/arena.h | 967 +- .../protobuf/src/google/protobuf/arena_impl.h | 326 + .../src/google/protobuf/arena_test_util.cc | 2 +- .../src/google/protobuf/arena_test_util.h | 47 +- .../src/google/protobuf/arena_unittest.cc | 482 +- .../src/google/protobuf/arenastring.cc | 20 +- .../src/google/protobuf/arenastring.h | 186 +- .../google/protobuf/arenastring_unittest.cc | 92 +- .../protobuf/compiler/annotation_test_util.cc | 167 + .../protobuf/compiler/annotation_test_util.h | 115 + .../protobuf/compiler/code_generator.cc | 57 +- .../google/protobuf/compiler/code_generator.h | 88 +- .../compiler/command_line_interface.cc | 1396 +- .../compiler/command_line_interface.h | 232 +- .../command_line_interface_unittest.cc | 1600 +- .../compiler/cpp/cpp_bootstrap_unittest.cc | 148 +- .../google/protobuf/compiler/cpp/cpp_enum.cc | 457 +- .../google/protobuf/compiler/cpp/cpp_enum.h | 40 +- .../protobuf/compiler/cpp/cpp_enum_field.cc | 668 +- .../protobuf/compiler/cpp/cpp_enum_field.h | 20 +- .../protobuf/compiler/cpp/cpp_extension.cc | 162 +- .../protobuf/compiler/cpp/cpp_extension.h | 23 +- .../google/protobuf/compiler/cpp/cpp_field.cc | 139 +- .../google/protobuf/compiler/cpp/cpp_field.h | 136 +- .../google/protobuf/compiler/cpp/cpp_file.cc | 1899 +- .../google/protobuf/compiler/cpp/cpp_file.h | 149 +- .../protobuf/compiler/cpp/cpp_generator.cc | 119 +- .../protobuf/compiler/cpp/cpp_generator.h | 39 +- .../protobuf/compiler/cpp/cpp_helpers.cc | 1787 +- .../protobuf/compiler/cpp/cpp_helpers.h | 743 +- .../protobuf/compiler/cpp/cpp_map_field.cc | 470 +- .../protobuf/compiler/cpp/cpp_map_field.h | 14 +- .../protobuf/compiler/cpp/cpp_message.cc | 6210 +++-- .../protobuf/compiler/cpp/cpp_message.h | 163 +- .../compiler/cpp/cpp_message_field.cc | 1453 +- .../protobuf/compiler/cpp/cpp_message_field.h | 62 +- .../cpp_message_layout_helper.h} | 43 +- .../compiler/cpp/cpp_move_unittest.cc | 169 + .../protobuf/compiler/cpp/cpp_options.h | 41 +- .../compiler/cpp/cpp_padding_optimizer.cc | 227 + .../compiler/cpp/cpp_padding_optimizer.h | 64 + .../compiler/cpp/cpp_plugin_unittest.cc | 37 +- .../compiler/cpp/cpp_primitive_field.cc | 624 +- .../compiler/cpp/cpp_primitive_field.h | 20 +- .../protobuf/compiler/cpp/cpp_service.cc | 383 +- .../protobuf/compiler/cpp/cpp_service.h | 24 +- .../protobuf/compiler/cpp/cpp_string_field.cc | 1641 +- .../protobuf/compiler/cpp/cpp_string_field.h | 32 +- .../cpp/cpp_test_bad_identifiers.proto | 64 +- .../protobuf/compiler/cpp/cpp_unittest.cc | 2073 +- .../protobuf/compiler/cpp/cpp_unittest.h | 2 +- .../protobuf/compiler/cpp/cpp_unittest.inc | 2275 ++ .../protobuf/compiler/cpp/metadata_test.cc | 138 +- .../csharp/csharp_bootstrap_unittest.cc | 194 + .../compiler/csharp/csharp_doc_comment.cc | 5 +- .../protobuf/compiler/csharp/csharp_enum.cc | 25 +- .../protobuf/compiler/csharp/csharp_enum.h | 7 +- .../compiler/csharp/csharp_enum_field.cc | 33 +- .../compiler/csharp/csharp_enum_field.h | 18 +- .../compiler/csharp/csharp_field_base.cc | 190 +- .../compiler/csharp/csharp_field_base.h | 23 +- .../compiler/csharp/csharp_generator.cc | 15 +- .../compiler/csharp/csharp_generator.h | 15 +- .../compiler/csharp/csharp_helpers.cc | 108 +- .../protobuf/compiler/csharp/csharp_helpers.h | 39 +- .../compiler/csharp/csharp_map_field.cc | 13 +- .../compiler/csharp/csharp_map_field.h | 8 +- .../compiler/csharp/csharp_message.cc | 330 +- .../protobuf/compiler/csharp/csharp_message.h | 17 +- .../compiler/csharp/csharp_message_field.cc | 159 +- .../compiler/csharp/csharp_message_field.h | 19 +- .../protobuf/compiler/csharp/csharp_names.h | 21 +- .../protobuf/compiler/csharp/csharp_options.h | 19 +- .../compiler/csharp/csharp_primitive_field.cc | 164 +- .../compiler/csharp/csharp_primitive_field.h | 19 +- .../csharp/csharp_reflection_class.cc | 66 +- .../compiler/csharp/csharp_reflection_class.h | 8 +- .../csharp/csharp_repeated_enum_field.cc | 19 +- .../csharp/csharp_repeated_enum_field.h | 14 +- .../csharp/csharp_repeated_message_field.cc | 34 +- .../csharp/csharp_repeated_message_field.h | 10 +- .../csharp/csharp_repeated_primitive_field.cc | 16 +- .../csharp/csharp_repeated_primitive_field.h | 10 +- .../csharp/csharp_source_generator_base.cc | 3 +- .../csharp/csharp_source_generator_base.h | 8 +- .../compiler/csharp/csharp_wrapper_field.cc | 94 +- .../compiler/csharp/csharp_wrapper_field.h | 16 +- .../src/google/protobuf/compiler/importer.cc | 204 +- .../src/google/protobuf/compiler/importer.h | 125 +- .../protobuf/compiler/importer_unittest.cc | 210 +- .../protobuf/compiler/java/java_context.cc | 46 +- .../protobuf/compiler/java/java_context.h | 55 +- .../compiler/java/java_doc_comment.cc | 64 +- .../protobuf/compiler/java/java_doc_comment.h | 16 +- .../protobuf/compiler/java/java_enum.cc | 319 +- .../google/protobuf/compiler/java/java_enum.h | 37 +- .../protobuf/compiler/java/java_enum_field.cc | 1142 +- .../protobuf/compiler/java/java_enum_field.h | 47 +- .../compiler/java/java_enum_field_lite.cc | 1123 +- .../compiler/java/java_enum_field_lite.h | 83 +- .../protobuf/compiler/java/java_enum_lite.cc | 193 +- .../protobuf/compiler/java/java_enum_lite.h | 39 +- .../protobuf/compiler/java/java_extension.cc | 63 +- .../protobuf/compiler/java/java_extension.h | 42 +- .../compiler/java/java_extension_lite.cc | 19 +- .../compiler/java/java_extension_lite.h | 5 +- .../protobuf/compiler/java/java_field.cc | 173 +- .../protobuf/compiler/java/java_field.h | 101 +- .../protobuf/compiler/java/java_file.cc | 457 +- .../google/protobuf/compiler/java/java_file.h | 66 +- .../protobuf/compiler/java/java_generator.cc | 118 +- .../protobuf/compiler/java/java_generator.h | 14 +- .../compiler/java/java_generator_factory.cc | 5 +- .../compiler/java/java_generator_factory.h | 28 +- .../protobuf/compiler/java/java_helpers.cc | 760 +- .../protobuf/compiler/java/java_helpers.h | 221 +- .../compiler/java/java_lazy_message_field.cc | 814 - .../compiler/java/java_lazy_message_field.h | 121 - .../java/java_lazy_message_field_lite.cc | 706 - .../java/java_lazy_message_field_lite.h | 118 - .../protobuf/compiler/java/java_map_field.cc | 689 +- .../protobuf/compiler/java/java_map_field.h | 13 +- .../compiler/java/java_map_field_lite.cc | 765 +- .../compiler/java/java_map_field_lite.h | 25 +- .../protobuf/compiler/java/java_message.cc | 1319 +- .../protobuf/compiler/java/java_message.h | 39 +- .../compiler/java/java_message_builder.cc | 663 +- .../compiler/java/java_message_builder.h | 24 +- .../java/java_message_builder_lite.cc | 122 +- .../compiler/java/java_message_builder_lite.h | 26 +- .../compiler/java/java_message_field.cc | 1533 +- .../compiler/java/java_message_field.h | 68 +- .../compiler/java/java_message_field_lite.cc | 1048 +- .../compiler/java/java_message_field_lite.h | 83 +- .../compiler/java/java_message_lite.cc | 1187 +- .../compiler/java/java_message_lite.h | 23 +- .../compiler/java/java_name_resolver.cc | 147 +- .../compiler/java/java_name_resolver.h | 56 +- .../protobuf/compiler/java/java_names.h | 35 +- .../java_options.h} | 59 +- .../compiler/java/java_plugin_unittest.cc | 34 +- .../compiler/java/java_primitive_field.cc | 922 +- .../compiler/java/java_primitive_field.h | 48 +- .../java/java_primitive_field_lite.cc | 895 +- .../compiler/java/java_primitive_field_lite.h | 86 +- .../protobuf/compiler/java/java_service.cc | 383 +- .../protobuf/compiler/java/java_service.h | 30 +- .../java/java_shared_code_generator.cc | 159 +- .../java/java_shared_code_generator.h | 47 +- .../compiler/java/java_string_field.cc | 1109 +- .../compiler/java/java_string_field.h | 47 +- .../compiler/java/java_string_field_lite.cc | 943 +- .../compiler/java/java_string_field_lite.h | 82 +- .../compiler/javanano/javanano_enum.cc | 143 - .../compiler/javanano/javanano_enum_field.cc | 544 - .../compiler/javanano/javanano_enum_field.h | 126 - .../compiler/javanano/javanano_extension.cc | 150 - .../compiler/javanano/javanano_field.cc | 209 - .../compiler/javanano/javanano_field.h | 130 - .../compiler/javanano/javanano_file.cc | 263 - .../compiler/javanano/javanano_generator.cc | 230 - .../compiler/javanano/javanano_helpers.cc | 591 - .../compiler/javanano/javanano_helpers.h | 199 - .../compiler/javanano/javanano_map_field.cc | 186 - .../compiler/javanano/javanano_message.cc | 676 - .../compiler/javanano/javanano_message.h | 97 - .../javanano/javanano_message_field.cc | 363 - .../javanano/javanano_message_field.h | 121 - .../compiler/javanano/javanano_params.h | 258 - .../javanano/javanano_primitive_field.cc | 968 - .../javanano/javanano_primitive_field.h | 150 - .../protobuf/compiler/js/js_generator.cc | 3172 ++- .../protobuf/compiler/js/js_generator.h | 249 +- .../compiler/js/well_known_types_embed.cc | 270 + .../compiler/js/well_known_types_embed.h | 43 + .../src/google/protobuf/compiler/main.cc | 58 +- .../protobuf/compiler/mock_code_generator.cc | 215 +- .../protobuf/compiler/mock_code_generator.h | 62 +- .../compiler/objectivec/method_dump.sh | 179 + .../compiler/objectivec/objectivec_enum.cc | 64 +- .../compiler/objectivec/objectivec_enum.h | 18 +- .../objectivec/objectivec_enum_field.cc | 20 +- .../objectivec/objectivec_enum_field.h | 11 +- .../objectivec/objectivec_extension.cc | 26 +- .../objectivec/objectivec_extension.h | 17 +- .../compiler/objectivec/objectivec_field.cc | 29 +- .../compiler/objectivec/objectivec_field.h | 46 +- .../compiler/objectivec/objectivec_file.cc | 536 +- .../compiler/objectivec/objectivec_file.h | 38 +- .../objectivec/objectivec_generator.cc | 111 +- .../objectivec/objectivec_generator.h | 29 +- .../compiler/objectivec/objectivec_helpers.cc | 1011 +- .../compiler/objectivec/objectivec_helpers.h | 203 +- .../objectivec/objectivec_map_field.cc | 7 +- .../objectivec/objectivec_map_field.h | 9 +- .../compiler/objectivec/objectivec_message.cc | 207 +- .../compiler/objectivec/objectivec_message.h | 29 +- .../objectivec/objectivec_message_field.cc | 7 +- .../objectivec/objectivec_message_field.h | 17 +- .../objectivec/objectivec_nsobject_methods.h | 197 + .../compiler/objectivec/objectivec_oneof.cc | 14 +- .../compiler/objectivec/objectivec_oneof.h | 15 +- .../objectivec/objectivec_primitive_field.cc | 12 +- .../objectivec/objectivec_primitive_field.h | 17 +- .../google/protobuf/compiler/package_info.h | 1 - .../src/google/protobuf/compiler/parser.cc | 804 +- .../src/google/protobuf/compiler/parser.h | 120 +- .../protobuf/compiler/parser_unittest.cc | 3045 ++- .../protobuf/compiler/php/php_generator.cc | 1684 ++ .../php_generator.h} | 59 +- .../src/google/protobuf/compiler/plugin.cc | 98 +- .../src/google/protobuf/compiler/plugin.h | 16 +- .../src/google/protobuf/compiler/plugin.pb.cc | 2369 +- .../src/google/protobuf/compiler/plugin.pb.h | 1336 +- .../src/google/protobuf/compiler/plugin.proto | 20 +- .../compiler/python/python_generator.cc | 754 +- .../compiler/python/python_generator.h | 72 +- .../compiler/python/python_plugin_unittest.cc | 82 +- .../compiler/ruby/ruby_generated_code.rb | 74 - .../compiler/ruby/ruby_generated_code_pb.rb | 76 + .../ruby/ruby_generated_code_proto2.proto | 68 + .../ruby/ruby_generated_code_proto2_pb.rb | 77 + .../ruby/ruby_generated_pkg_explicit.proto | 9 + .../ruby_generated_pkg_explicit_legacy.proto | 9 + .../ruby_generated_pkg_explicit_legacy_pb.rb | 20 + .../ruby/ruby_generated_pkg_explicit_pb.rb | 20 + .../ruby/ruby_generated_pkg_implicit.proto | 7 + .../ruby/ruby_generated_pkg_implicit_pb.rb | 20 + .../protobuf/compiler/ruby/ruby_generator.cc | 289 +- .../protobuf/compiler/ruby/ruby_generator.h | 13 +- .../compiler/ruby/ruby_generator_unittest.cc | 58 +- .../src/google/protobuf/compiler/scc.h | 164 + .../google/protobuf/compiler/subprocess.cc | 105 +- .../src/google/protobuf/compiler/subprocess.h | 19 +- .../google/protobuf/compiler/test_plugin.cc | 22 +- .../protobuf/compiler/zip_output_unittest.sh | 17 +- .../google/protobuf/compiler/zip_writer.cc | 170 +- .../src/google/protobuf/compiler/zip_writer.h | 6 +- .../src/google/protobuf/descriptor.cc | 4363 +-- .../protobuf/src/google/protobuf/descriptor.h | 1026 +- .../src/google/protobuf/descriptor.pb.cc | 20329 +++++++------- .../src/google/protobuf/descriptor.pb.h | 11706 +++++--- .../src/google/protobuf/descriptor.proto | 254 +- .../google/protobuf/descriptor_database.cc | 278 +- .../src/google/protobuf/descriptor_database.h | 196 +- .../protobuf/descriptor_database_unittest.cc | 363 +- .../google/protobuf/descriptor_unittest.cc | 5883 ++-- .../protobuf/drop_unknown_fields_test.cc | 25 +- .../src/google/protobuf/duration.pb.cc | 488 +- .../src/google/protobuf/duration.pb.h | 246 +- .../src/google/protobuf/duration.proto | 24 +- .../src/google/protobuf/dynamic_message.cc | 568 +- .../src/google/protobuf/dynamic_message.h | 119 +- .../protobuf/dynamic_message_unittest.cc | 146 +- .../protobuf/src/google/protobuf/empty.pb.cc | 360 +- .../protobuf/src/google/protobuf/empty.pb.h | 207 +- .../protobuf/src/google/protobuf/empty.proto | 1 - .../src/google/protobuf/extension_set.cc | 1715 +- .../src/google/protobuf/extension_set.h | 1017 +- .../google/protobuf/extension_set_heavy.cc | 662 +- .../src/google/protobuf/extension_set_inl.h | 283 + .../google/protobuf/extension_set_unittest.cc | 705 +- .../src/google/protobuf/field_mask.pb.cc | 472 +- .../src/google/protobuf/field_mask.pb.h | 256 +- .../src/google/protobuf/field_mask.proto | 55 +- .../protobuf/generated_enum_reflection.h | 35 +- .../google/protobuf/generated_enum_util.cc | 95 + .../src/google/protobuf/generated_enum_util.h | 43 +- .../protobuf/generated_message_reflection.cc | 2212 +- .../protobuf/generated_message_reflection.h | 840 +- .../generated_message_reflection_unittest.cc | 470 +- .../generated_message_table_driven.cc | 105 + .../protobuf/generated_message_table_driven.h | 339 + .../generated_message_table_driven_lite.cc | 107 + .../generated_message_table_driven_lite.h | 905 + .../google/protobuf/generated_message_util.cc | 788 +- .../google/protobuf/generated_message_util.h | 211 +- .../javanano/javanano_file.h => has_bits.h} | 116 +- .../google/protobuf/implicit_weak_message.cc | 74 + .../google/protobuf/implicit_weak_message.h | 145 + .../google/protobuf/inlined_string_field.h | 259 + .../src/google/protobuf/io/coded_stream.cc | 437 +- .../src/google/protobuf/io/coded_stream.h | 581 +- .../src/google/protobuf/io/coded_stream_inl.h | 4 +- .../protobuf/io/coded_stream_unittest.cc | 468 +- .../src/google/protobuf/io/gzip_stream.cc | 49 +- .../src/google/protobuf/io/gzip_stream.h | 40 +- .../src/google/protobuf/io/io_win32.cc | 416 + .../src/google/protobuf/io/io_win32.h | 120 + .../google/protobuf/io/io_win32_unittest.cc | 454 + .../src/google/protobuf/io/package_info.h | 1 - .../src/google/protobuf/io/printer.cc | 331 +- .../protobuf/src/google/protobuf/io/printer.h | 173 +- .../google/protobuf/io/printer_unittest.cc | 328 +- .../protobuf/src/google/protobuf/io/strtod.cc | 32 +- .../protobuf/src/google/protobuf/io/strtod.h | 2 +- .../src/google/protobuf/io/tokenizer.cc | 272 +- .../src/google/protobuf/io/tokenizer.h | 83 +- .../google/protobuf/io/tokenizer_unittest.cc | 865 +- .../google/protobuf/io/zero_copy_stream.cc | 3 - .../src/google/protobuf/io/zero_copy_stream.h | 20 +- .../protobuf/io/zero_copy_stream_impl.cc | 211 +- .../protobuf/io/zero_copy_stream_impl.h | 136 +- .../protobuf/io/zero_copy_stream_impl_lite.cc | 194 +- .../protobuf/io/zero_copy_stream_impl_lite.h | 161 +- .../protobuf/io/zero_copy_stream_unittest.cc | 190 +- .../google/protobuf/lite_arena_unittest.cc | 45 +- .../src/google/protobuf/lite_unittest.cc | 875 +- .../protobuf/src/google/protobuf/map.h | 881 +- .../protobuf/src/google/protobuf/map_entry.h | 278 +- .../src/google/protobuf/map_entry_lite.h | 711 +- .../protobuf/src/google/protobuf/map_field.cc | 415 +- .../protobuf/src/google/protobuf/map_field.h | 670 +- .../src/google/protobuf/map_field_inl.h | 398 +- .../src/google/protobuf/map_field_lite.h | 299 +- .../src/google/protobuf/map_field_test.cc | 138 +- .../src/google/protobuf/map_lite_test_util.h | 2 +- .../google/protobuf/map_lite_unittest.proto | 2 +- .../google/protobuf/map_proto2_unittest.proto | 27 +- .../protobuf/src/google/protobuf/map_test.cc | 1275 +- .../src/google/protobuf/map_test_util.cc | 1108 +- .../src/google/protobuf/map_test_util.h | 15 +- .../src/google/protobuf/map_test_util_impl.h | 93 +- .../src/google/protobuf/map_type_handler.h | 646 +- .../src/google/protobuf/map_unittest.proto | 3 +- .../protobuf/src/google/protobuf/message.cc | 746 +- .../protobuf/src/google/protobuf/message.h | 1079 +- .../src/google/protobuf/message_lite.cc | 473 +- .../src/google/protobuf/message_lite.h | 384 +- .../src/google/protobuf/message_unittest.cc | 442 +- .../src/google/protobuf/message_unittest.inc | 633 + .../protobuf/src/google/protobuf/metadata.h | 121 +- .../src/google/protobuf/metadata_lite.h | 235 + .../google/protobuf/no_field_presence_test.cc | 109 +- .../src/google/protobuf/package_info.h | 8 +- .../src/google/protobuf/parse_context.cc | 559 + .../src/google/protobuf/parse_context.h | 760 + .../protobuf/src/google/protobuf/port.h | 6 + .../protobuf/src/google/protobuf/port_def.inc | 536 + .../src/google/protobuf/port_undef.inc | 95 + .../protobuf/preserve_unknown_enum_test.cc | 141 +- .../protobuf/proto3_arena_lite_unittest.cc | 39 +- .../google/protobuf/proto3_arena_unittest.cc | 35 +- .../google/protobuf/proto3_lite_unittest.cc | 116 +- .../google/protobuf/proto3_lite_unittest.inc | 139 + .../protobuf/src/google/protobuf/reflection.h | 296 +- .../src/google/protobuf/reflection_internal.h | 177 +- .../src/google/protobuf/reflection_ops.cc | 191 +- .../src/google/protobuf/reflection_ops.h | 16 +- .../protobuf/reflection_ops_unittest.cc | 139 +- .../src/google/protobuf/repeated_field.cc | 59 +- .../src/google/protobuf/repeated_field.h | 1295 +- .../protobuf/repeated_field_reflection.h | 337 - .../repeated_field_reflection_unittest.cc | 220 +- .../protobuf/repeated_field_unittest.cc | 758 +- .../protobuf/src/google/protobuf/service.cc | 1 - .../protobuf/src/google/protobuf/service.h | 51 +- .../src/google/protobuf/source_context.pb.cc | 452 +- .../src/google/protobuf/source_context.pb.h | 245 +- .../src/google/protobuf/source_context.proto | 4 +- .../protobuf/src/google/protobuf/struct.pb.cc | 1779 +- .../protobuf/src/google/protobuf/struct.pb.h | 955 +- .../protobuf/src/google/protobuf/struct.proto | 3 +- .../src/google/protobuf/stubs/atomicops.h | 271 - .../stubs/atomicops_internals_arm64_gcc.h | 325 - .../stubs/atomicops_internals_arm_gcc.h | 151 - .../stubs/atomicops_internals_arm_qnx.h | 146 - .../atomicops_internals_atomicword_compat.h | 122 - .../stubs/atomicops_internals_generic_gcc.h | 137 - .../stubs/atomicops_internals_macosx.h | 225 - .../stubs/atomicops_internals_mips_gcc.h | 313 - .../stubs/atomicops_internals_pnacl.h | 231 - .../stubs/atomicops_internals_power.h | 440 - .../stubs/atomicops_internals_ppc_gcc.h | 155 - .../stubs/atomicops_internals_solaris.h | 188 - .../stubs/atomicops_internals_starboard.h | 153 - .../protobuf/stubs/atomicops_internals_tsan.h | 219 - .../stubs/atomicops_internals_x86_gcc.cc | 137 - .../stubs/atomicops_internals_x86_gcc.h | 293 - .../stubs/atomicops_internals_x86_msvc.cc | 112 - .../stubs/atomicops_internals_x86_msvc.h | 150 - .../src/google/protobuf/stubs/bytestream.cc | 4 +- .../src/google/protobuf/stubs/bytestream.h | 51 +- .../src/google/protobuf/stubs/callback.h | 123 +- .../src/google/protobuf/stubs/casts.h | 9 +- .../src/google/protobuf/stubs/common.cc | 234 +- .../src/google/protobuf/stubs/common.h | 76 +- .../google/protobuf/stubs/common_unittest.cc | 20 +- .../src/google/protobuf/stubs/fastmem.h | 13 +- .../protobuf/src/google/protobuf/stubs/hash.h | 352 +- .../src/google/protobuf/stubs/int128.cc | 71 +- .../src/google/protobuf/stubs/int128.h | 16 +- .../google/protobuf/stubs/int128_unittest.cc | 144 +- .../src/google/protobuf/stubs/logging.h | 32 +- .../src/google/protobuf/stubs/macros.h | 48 - .../src/google/protobuf/stubs/map_util.h | 50 +- .../src/google/protobuf/stubs/mathlimits.cc | 55 - .../src/google/protobuf/stubs/mathlimits.h | 169 +- .../src/google/protobuf/stubs/mathutil.h | 28 +- .../src/google/protobuf/stubs/mutex.h | 104 +- .../src/google/protobuf/stubs/once.cc | 106 - .../protobuf/src/google/protobuf/stubs/once.h | 132 +- .../google/protobuf/stubs/once_unittest.cc | 255 - .../google/protobuf/stubs/platform_macros.h | 18 +- .../protobuf/src/google/protobuf/stubs/port.h | 319 +- .../src/google/protobuf/stubs/scoped_ptr.h | 236 - .../src/google/protobuf/stubs/shared_ptr.h | 474 - .../google/protobuf/stubs/starboard_poem.h | 13 - .../src/google/protobuf/stubs/status.cc | 5 +- .../src/google/protobuf/stubs/status.h | 15 +- .../src/google/protobuf/stubs/status_macros.h | 10 +- .../src/google/protobuf/stubs/status_test.cc | 7 + .../src/google/protobuf/stubs/statusor.cc | 2 + .../src/google/protobuf/stubs/statusor.h | 20 +- .../src/google/protobuf/stubs/stl_util.h | 6 +- .../src/google/protobuf/stubs/stringpiece.cc | 4 +- .../src/google/protobuf/stubs/stringpiece.h | 92 +- .../protobuf/stubs/stringpiece_unittest.cc | 24 +- .../src/google/protobuf/stubs/stringprintf.cc | 6 +- .../src/google/protobuf/stubs/stringprintf.h | 19 +- .../protobuf/stubs/stringprintf_unittest.cc | 4 +- .../protobuf/stubs/structurally_valid.cc | 33 +- .../stubs/structurally_valid_unittest.cc | 30 + .../src/google/protobuf/stubs/strutil.cc | 239 +- .../src/google/protobuf/stubs/strutil.h | 322 +- .../google/protobuf/stubs/strutil_unittest.cc | 43 +- .../src/google/protobuf/stubs/substitute.cc | 10 +- .../src/google/protobuf/stubs/substitute.h | 56 +- .../src/google/protobuf/stubs/time.cc | 42 +- .../protobuf/src/google/protobuf/stubs/time.h | 15 +- .../src/google/protobuf/stubs/time_test.cc | 53 + .../src/google/protobuf/stubs/type_traits.h | 364 - .../protobuf/stubs/type_traits_unittest.cc | 631 - .../protobuf/test_messages_proto2.proto | 233 + .../protobuf/test_messages_proto3.proto | 244 + .../protobuf/src/google/protobuf/test_util.cc | 3299 --- .../protobuf/src/google/protobuf/test_util.h | 1374 +- .../src/google/protobuf/test_util.inc | 2406 ++ .../protobuf/src/google/protobuf/test_util2.h | 83 + .../src/google/protobuf/test_util_lite.cc | 2745 +- .../src/google/protobuf/test_util_lite.h | 2 +- .../google/protobuf/testdata/bad_utf8_string | 1 + .../protobuf/testdata/golden_message_maps | Bin 0 -> 13619 bytes .../src/google/protobuf/testing/file.cc | 42 +- .../src/google/protobuf/testing/file.h | 7 +- .../src/google/protobuf/testing/googletest.cc | 53 +- .../src/google/protobuf/testing/googletest.h | 10 +- .../src/google/protobuf/testing/zcgunzip.cc | 5 +- .../src/google/protobuf/text_format.cc | 1781 +- .../src/google/protobuf/text_format.h | 362 +- .../google/protobuf/text_format_unittest.cc | 1321 +- .../src/google/protobuf/timestamp.pb.cc | 496 +- .../src/google/protobuf/timestamp.pb.h | 243 +- .../src/google/protobuf/timestamp.proto | 63 +- .../protobuf/src/google/protobuf/type.pb.cc | 3990 ++- .../protobuf/src/google/protobuf/type.pb.h | 2352 +- .../protobuf/src/google/protobuf/type.proto | 53 +- .../src/google/protobuf/unittest.proto | 230 +- .../protobuf/unittest_custom_options.proto | 9 + .../unittest_enormous_descriptor.proto | 2 +- .../protobuf/unittest_lazy_dependencies.proto | 75 + ...test_lazy_dependencies_custom_option.proto | 67 + .../unittest_lazy_dependencies_enum.proto | 61 + .../src/google/protobuf/unittest_lite.proto | 83 +- .../unittest_lite_imports_nonlite.proto | 3 + .../src/google/protobuf/unittest_mset.proto | 2 + .../google/protobuf/unittest_no_arena.proto | 4 + .../unittest_no_generic_services.proto | 2 +- .../src/google/protobuf/unittest_proto3.proto | 372 +- .../protobuf/unittest_proto3_arena.proto | 4 +- .../src/google/protobuf/unknown_field_set.cc | 286 +- .../src/google/protobuf/unknown_field_set.h | 196 +- .../protobuf/unknown_field_set_unittest.cc | 95 +- .../protobuf/util/delimited_message_util.cc | 121 + .../protobuf/util/delimited_message_util.h | 107 + .../util/delimited_message_util_test.cc | 87 + .../google/protobuf/util/field_comparator.cc | 69 +- .../google/protobuf/util/field_comparator.h | 115 +- .../protobuf/util/field_comparator_test.cc | 296 +- .../google/protobuf/util/field_mask_util.cc | 320 +- .../google/protobuf/util/field_mask_util.h | 96 +- .../protobuf/util/field_mask_util_test.cc | 357 +- .../google/protobuf/util/internal/constants.h | 16 +- .../protobuf/util/internal/datapiece.cc | 183 +- .../google/protobuf/util/internal/datapiece.h | 82 +- .../internal/default_value_objectwriter.cc | 247 +- .../internal/default_value_objectwriter.h | 152 +- .../default_value_objectwriter_test.cc | 48 +- .../protobuf/util/internal/error_listener.h | 35 +- .../util/internal/expecting_objectwriter.h | 54 +- .../util/internal/field_mask_utility.cc | 68 +- .../util/internal/field_mask_utility.h | 11 +- .../protobuf/util/internal/json_escaping.cc | 127 +- .../protobuf/util/internal/json_escaping.h | 8 +- .../util/internal/json_objectwriter.cc | 45 +- .../util/internal/json_objectwriter.h | 94 +- .../util/internal/json_objectwriter_test.cc | 68 +- .../util/internal/json_stream_parser.cc | 210 +- .../util/internal/json_stream_parser.h | 57 +- .../util/internal/json_stream_parser_test.cc | 130 +- .../protobuf/util/internal/location_tracker.h | 10 +- .../util/internal/mock_error_listener.h | 15 +- .../util/internal/object_location_tracker.h | 6 +- .../protobuf/util/internal/object_source.h | 8 +- .../protobuf/util/internal/object_writer.cc | 4 +- .../protobuf/util/internal/object_writer.h | 13 +- .../protobuf/util/internal/proto_writer.cc | 269 +- .../protobuf/util/internal/proto_writer.h | 145 +- .../util/internal/protostream_objectsource.cc | 342 +- .../util/internal/protostream_objectsource.h | 124 +- .../internal/protostream_objectsource_test.cc | 320 +- .../util/internal/protostream_objectwriter.cc | 396 +- .../util/internal/protostream_objectwriter.h | 173 +- .../internal/protostream_objectwriter_test.cc | 1142 +- .../util/internal/structured_objectwriter.h | 19 +- .../util/internal/testdata/anys.proto | 75 +- .../util/internal/testdata/books.proto | 63 +- .../internal/testdata/default_value.proto | 2 +- .../testdata/default_value_test.proto | 2 +- .../util/internal/testdata/field_mask.proto | 2 +- .../util/internal/testdata/maps.proto | 78 +- .../util/internal/testdata/oneofs.proto | 35 +- .../util/internal/testdata/proto3.proto | 42 + .../util/internal/testdata/struct.proto | 86 +- .../testdata/timestamp_duration.proto | 49 +- .../util/internal/testdata/wrappers.proto | 2 +- .../protobuf/util/internal/type_info.cc | 74 +- .../google/protobuf/util/internal/type_info.h | 8 +- .../util/internal/type_info_test_helper.cc | 17 +- .../util/internal/type_info_test_helper.h | 17 +- .../google/protobuf/util/internal/utility.cc | 165 +- .../google/protobuf/util/internal/utility.h | 119 +- .../google/protobuf/util/json_format.proto | 130 + .../protobuf/util/json_format_proto3.proto | 21 +- .../src/google/protobuf/util/json_util.cc | 198 +- .../src/google/protobuf/util/json_util.h | 147 +- .../google/protobuf/util/json_util_test.cc | 432 +- .../protobuf/util/message_differencer.cc | 1042 +- .../protobuf/util/message_differencer.h | 381 +- .../util/message_differencer_unittest.cc | 1247 +- .../util/message_differencer_unittest.proto | 32 +- .../src/google/protobuf/util/package_info.h | 46 + .../src/google/protobuf/util/time_util.cc | 82 +- .../src/google/protobuf/util/time_util.h | 69 +- .../google/protobuf/util/time_util_test.cc | 4 +- .../src/google/protobuf/util/type_resolver.h | 20 +- .../protobuf/util/type_resolver_util.cc | 240 +- .../google/protobuf/util/type_resolver_util.h | 13 +- .../protobuf/util/type_resolver_util_test.cc | 423 +- .../src/google/protobuf/wire_format.cc | 921 +- .../src/google/protobuf/wire_format.h | 156 +- .../src/google/protobuf/wire_format_lite.cc | 538 +- .../src/google/protobuf/wire_format_lite.h | 1772 +- .../google/protobuf/wire_format_lite_inl.h | 878 - .../google/protobuf/wire_format_unittest.cc | 566 +- .../src/google/protobuf/wrappers.pb.cc | 2987 +- .../src/google/protobuf/wrappers.pb.h | 1539 +- .../src/google/protobuf/wrappers.proto | 6 +- third_party/protobuf/src/libprotobuf-lite.map | 9 + third_party/protobuf/src/libprotobuf.map | 9 + third_party/protobuf/src/libprotoc.map | 9 + third_party/protobuf/tests.sh | 754 +- third_party/protobuf/third_party/six/six.py | 116 +- third_party/protobuf/third_party/zlib.BUILD | 60 + third_party/protobuf/update_file_lists.sh | 24 +- third_party/protobuf/update_version.py | 344 + tools/protoc | Bin 3453240 -> 0 bytes tools/protoc.exe | Bin 3987968 -> 0 bytes tools/protoc_mac | Bin 3547296 -> 0 bytes 2180 files changed, 427160 insertions(+), 195777 deletions(-) create mode 100644 third_party/protobuf/.github/ISSUE_TEMPLATE/bug_report.md create mode 100644 third_party/protobuf/.github/ISSUE_TEMPLATE/feature_request.md create mode 100644 third_party/protobuf/.github/ISSUE_TEMPLATE/question.md create mode 100644 third_party/protobuf/.github/mergeable.yml create mode 100644 third_party/protobuf/.gitmodules delete mode 100644 third_party/protobuf/.travis.yml create mode 100644 third_party/protobuf/CONTRIBUTING.md delete mode 100644 third_party/protobuf/benchmarks/ProtoBench.java create mode 100644 third_party/protobuf/benchmarks/__init__.py delete mode 100644 third_party/protobuf/benchmarks/benchmark_messages_proto2.proto create mode 100644 third_party/protobuf/benchmarks/cpp/cpp_benchmark.cc create mode 100644 third_party/protobuf/benchmarks/datasets/google_message1/proto2/benchmark_message1_proto2.proto rename third_party/protobuf/benchmarks/{google_message1.dat => datasets/google_message1/proto2/dataset.google_message1_proto2.pb} (78%) rename third_party/protobuf/benchmarks/{benchmark_messages_proto3.proto => datasets/google_message1/proto3/benchmark_message1_proto3.proto} (98%) create mode 100644 third_party/protobuf/benchmarks/datasets/google_message1/proto3/dataset.google_message1_proto3.pb create mode 100644 third_party/protobuf/benchmarks/datasets/google_message2/benchmark_message2.proto rename third_party/protobuf/benchmarks/{google_message2.dat => datasets/google_message2/dataset.google_message2.pb} (99%) create mode 100644 third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3.proto create mode 100644 third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_1.proto create mode 100644 third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_2.proto create mode 100644 third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_3.proto create mode 100644 third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_4.proto create mode 100644 third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_5.proto create mode 100644 third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_6.proto create mode 100644 third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_7.proto create mode 100644 third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_8.proto create mode 100644 third_party/protobuf/benchmarks/datasets/google_message4/benchmark_message4.proto create mode 100644 third_party/protobuf/benchmarks/datasets/google_message4/benchmark_message4_1.proto create mode 100644 third_party/protobuf/benchmarks/datasets/google_message4/benchmark_message4_2.proto create mode 100644 third_party/protobuf/benchmarks/datasets/google_message4/benchmark_message4_3.proto create mode 100755 third_party/protobuf/benchmarks/download_data.sh delete mode 100644 third_party/protobuf/benchmarks/generate_datasets.cc create mode 100644 third_party/protobuf/benchmarks/go/go_benchmark_test.go create mode 100644 third_party/protobuf/benchmarks/java/pom.xml create mode 100644 third_party/protobuf/benchmarks/java/src/main/java/com/google/protobuf/ProtoCaliperBenchmark.java create mode 100644 third_party/protobuf/benchmarks/js/benchmark_suite.js create mode 100644 third_party/protobuf/benchmarks/js/js_benchmark.js create mode 100644 third_party/protobuf/benchmarks/php/PhpBenchmark.php create mode 100644 third_party/protobuf/benchmarks/php/autoload.php create mode 100644 third_party/protobuf/benchmarks/protobuf.js/generate_pbjs_files.js create mode 100644 third_party/protobuf/benchmarks/protobuf.js/protobufjs_benchmark.js create mode 100644 third_party/protobuf/benchmarks/python/__init__.py create mode 100755 third_party/protobuf/benchmarks/python/py_benchmark.py create mode 100644 third_party/protobuf/benchmarks/python/python_benchmark_messages.cc delete mode 100644 third_party/protobuf/benchmarks/readme.txt create mode 100644 third_party/protobuf/benchmarks/util/__init__.py create mode 100755 third_party/protobuf/benchmarks/util/big_query_utils.py create mode 100644 third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h create mode 100644 third_party/protobuf/benchmarks/util/gogo_data_scrubber.cc create mode 100644 third_party/protobuf/benchmarks/util/proto3_data_stripper.cc create mode 100644 third_party/protobuf/benchmarks/util/protoc-gen-gogoproto.cc create mode 100644 third_party/protobuf/benchmarks/util/protoc-gen-proto2_to_proto3.cc create mode 100755 third_party/protobuf/benchmarks/util/result_parser.py create mode 100755 third_party/protobuf/benchmarks/util/result_uploader.py create mode 100644 third_party/protobuf/benchmarks/util/schema_proto2_to_proto3_util.h create mode 100644 third_party/protobuf/cmake/conformance.cmake create mode 100644 third_party/protobuf/cmake/examples.cmake create mode 100644 third_party/protobuf/cmake/protobuf-lite.pc.cmake create mode 100644 third_party/protobuf/cmake/protobuf-options.cmake create mode 100644 third_party/protobuf/cmake/protobuf.pc.cmake create mode 100644 third_party/protobuf/cmake/version.rc.in create mode 100644 third_party/protobuf/compiler_config_setting.bzl create mode 100644 third_party/protobuf/composer.json create mode 100644 third_party/protobuf/conformance/autoload.php create mode 100644 third_party/protobuf/conformance/binary_json_conformance_suite.cc create mode 100644 third_party/protobuf/conformance/binary_json_conformance_suite.h create mode 100755 third_party/protobuf/conformance/conformance_nodejs.js create mode 100755 third_party/protobuf/conformance/conformance_php.php create mode 100644 third_party/protobuf/conformance/conformance_test_main.cc create mode 100644 third_party/protobuf/conformance/failure_list_js.txt create mode 100644 third_party/protobuf/conformance/failure_list_php.txt create mode 100644 third_party/protobuf/conformance/failure_list_php_c.txt create mode 100644 third_party/protobuf/conformance/failure_list_php_zts_c.txt create mode 100644 third_party/protobuf/conformance/failure_list_ruby_mac.txt create mode 100644 third_party/protobuf/conformance/text_format_conformance_suite.cc create mode 100644 third_party/protobuf/conformance/text_format_conformance_suite.h create mode 100644 third_party/protobuf/conformance/text_format_failure_list_csharp.txt create mode 100755 third_party/protobuf/conformance/text_format_failure_list_java.txt create mode 100644 third_party/protobuf/conformance/text_format_failure_list_php.txt create mode 100644 third_party/protobuf/conformance/text_format_failure_list_python.txt create mode 100644 third_party/protobuf/conformance/text_format_failure_list_ruby.txt create mode 100755 third_party/protobuf/conformance/update_failure_list.py create mode 100755 third_party/protobuf/csharp/build_tools.sh create mode 100644 third_party/protobuf/csharp/buildall.bat create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/protos/csharp/protos/unittest_issues.proto rename third_party/protobuf/{ => csharp/compatibility_tests/v3.0.0/protos}/src/google/protobuf/map_unittest_proto3.proto (100%) rename third_party/protobuf/{ => csharp/compatibility_tests/v3.0.0/protos}/src/google/protobuf/unittest_import_proto3.proto (100%) rename third_party/protobuf/{ => csharp/compatibility_tests/v3.0.0/protos}/src/google/protobuf/unittest_import_public_proto3.proto (100%) create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_proto3.proto create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_well_known_types.proto create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/ByteStringTest.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamTest.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedOutputStreamTest.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Collections/MapFieldTest.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Compatibility/PropertyInfoExtensionsTest.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs rename third_party/protobuf/csharp/{src/Google.Protobuf.Conformance/Properties/AssemblyInfo.cs => compatibility_tests/v3.0.0/src/Google.Protobuf.Test/DeprecatedMemberTest.cs} (73%) create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/EqualityTester.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/FieldCodecTest.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/GeneratedMessageTest.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/IssuesTest.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/JsonParserTest.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/JsonTokenizerTest.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Program.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/TypeRegistryTest.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/SampleEnum.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/SampleMessages.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/TestCornerCases.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/TestProtos/ForeignMessagePartial.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs create mode 100644 third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs create mode 100755 third_party/protobuf/csharp/compatibility_tests/v3.0.0/test.sh create mode 100644 third_party/protobuf/csharp/install_dotnet_sdk.ps1 create mode 100644 third_party/protobuf/csharp/protos/README.md create mode 100644 third_party/protobuf/csharp/protos/map_unittest_proto3.proto create mode 100644 third_party/protobuf/csharp/protos/unittest_custom_options_proto3.proto rename third_party/protobuf/{javanano/src/test/java/com/google/protobuf/nano/unittest_simple_nano.proto => csharp/protos/unittest_import_proto3.proto} (76%) rename third_party/protobuf/{javanano/src/test/java/com/google/protobuf/nano/unittest_stringutf8_nano.proto => csharp/protos/unittest_import_public_proto3.proto} (86%) create mode 100644 third_party/protobuf/csharp/protos/unittest_proto3.proto delete mode 100644 third_party/protobuf/csharp/src/AddressBook/Properties/AssemblyInfo.cs delete mode 100644 third_party/protobuf/csharp/src/AddressBook/app.config create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/Benchmarks.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/Google.Protobuf.Benchmarks.csproj create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/Program.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/SerializationBenchmark.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/SerializationConfig.cs delete mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Conformance/App.config delete mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Properties/AssemblyInfo.cs delete mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/app.config create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Test/Collections/ProtobufEqualityComparersTest.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Test/Compatibility/StreamExtensionsTest.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Test/FieldMaskTreeTest.cs delete mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Test/Properties/AppManifest.xml delete mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Test/Properties/AssemblyInfo.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Test/Reflection/CustomOptionsTest.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Test/Reflection/DescriptorDeclarationTest.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Test/SampleNaNs.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Test/UnknownFieldSetTest.cs delete mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Test/packages.config create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf.Test/testprotos.pb create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf/Collections/Lists.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf/Collections/ProtobufEqualityComparers.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf/Compatibility/MethodInfoExtensions.cs rename third_party/protobuf/{javanano/src/main/java/com/google/protobuf/nano/MapFactories.java => csharp/src/Google.Protobuf/Compatibility/StreamExtensions.cs} (59%) create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf/Extension.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf/ExtensionRegistry.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf/ExtensionSet.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf/ExtensionValue.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf/FieldMaskTree.cs delete mode 100644 third_party/protobuf/csharp/src/Google.Protobuf/Google.Protobuf.nuspec create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf/IExtendableMessage.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf/ObjectIntPair.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf/Reflection/CustomOptions.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf/Reflection/DescriptorDeclaration.cs rename third_party/protobuf/csharp/src/Google.Protobuf/Reflection/{PartialClasses.cs => ExtensionAccessor.cs} (63%) create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf/Reflection/ExtensionCollection.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf/UnknownField.cs create mode 100644 third_party/protobuf/csharp/src/Google.Protobuf/UnknownFieldSet.cs delete mode 100644 third_party/protobuf/csharp/src/Google.Protobuf/packages.config delete mode 100644 third_party/protobuf/csharp/src/packages/repositories.config create mode 100644 third_party/protobuf/docs/options.md create mode 100644 third_party/protobuf/docs/performance.md delete mode 100644 third_party/protobuf/docs/swift/DesignDoc.md create mode 100644 third_party/protobuf/examples/BUILD create mode 100644 third_party/protobuf/examples/CMakeLists.txt create mode 100755 third_party/protobuf/examples/README.md delete mode 100644 third_party/protobuf/examples/README.txt create mode 100644 third_party/protobuf/examples/WORKSPACE create mode 100644 third_party/protobuf/examples/add_person.dart create mode 100644 third_party/protobuf/examples/list_people.dart create mode 100644 third_party/protobuf/examples/pubspec.yaml create mode 120000 third_party/protobuf/examples/third_party/zlib.BUILD create mode 100755 third_party/protobuf/gen_extra_chromium_files create mode 100755 third_party/protobuf/generate_changelog.py create mode 100644 third_party/protobuf/global.json delete mode 100644 third_party/protobuf/gmock.BUILD create mode 100644 third_party/protobuf/java/bom/pom.xml create mode 100644 third_party/protobuf/java/compatibility_tests/README.md create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/deps/pom.xml create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/pom.xml create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/com/google/protobuf/multiple_files_test.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/com/google/protobuf/nested_builders_test.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/com/google/protobuf/nested_extension.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/com/google/protobuf/nested_extension_lite.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/com/google/protobuf/non_nested_extension.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/com/google/protobuf/non_nested_extension_lite.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/com/google/protobuf/test_bad_identifiers.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/google/protobuf/descriptor.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/google/protobuf/unittest.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/google/protobuf/unittest_custom_options.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/google/protobuf/unittest_embed_optimize_for.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/google/protobuf/unittest_empty.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/google/protobuf/unittest_enormous_descriptor.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/google/protobuf/unittest_import.proto rename third_party/protobuf/{javanano/src/test/java/com/google/protobuf/nano/unittest_import_nano.proto => java/compatibility_tests/v2.5.0/more_protos/src/proto/google/protobuf/unittest_import_lite.proto} (81%) create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/google/protobuf/unittest_import_public.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/google/protobuf/unittest_import_public_lite.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/google/protobuf/unittest_lite.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/google/protobuf/unittest_lite_imports_nonlite.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/google/protobuf/unittest_mset.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/google/protobuf/unittest_no_generic_services.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/more_protos/src/proto/google/protobuf/unittest_optimize_for.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/pom.xml create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/pom.xml create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/com/google/protobuf/multiple_files_test.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/com/google/protobuf/nested_builders_test.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/com/google/protobuf/nested_extension.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/com/google/protobuf/nested_extension_lite.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/com/google/protobuf/non_nested_extension.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/com/google/protobuf/non_nested_extension_lite.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/com/google/protobuf/test_bad_identifiers.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/descriptor.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_custom_options.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_embed_optimize_for.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_empty.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_enormous_descriptor.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_import.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_import_lite.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_import_public.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_import_public_lite.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_lite.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_lite_imports_nonlite.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_mset.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_no_generic_services.proto create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_optimize_for.proto create mode 100755 third_party/protobuf/java/compatibility_tests/v2.5.0/test.sh create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/pom.xml create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/AbstractMessageTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/BoundedByteStringTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/ByteStringTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/CodedInputStreamTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/CodedOutputStreamTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/DeprecatedFieldTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/DescriptorsTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/DynamicMessageTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/ForceFieldBuildersPreRun.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/GeneratedMessageTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/LazyStringArrayListTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/LazyStringEndToEndTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/LiteralByteStringTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/MessageTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/NestedBuildersTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/ParserTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/RopeByteStringSubstringTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/RopeByteStringTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/ServiceTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/TestBadIdentifiers.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/TestUtil.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/TextFormatTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/UnknownFieldSetTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/UnmodifiableLazyStringListTest.java create mode 100644 third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/WireFormatTest.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/AllocatedBuffer.java create mode 100644 third_party/protobuf/java/core/src/main/java/com/google/protobuf/Android.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/ArrayDecoders.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/BinaryReader.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/BinaryWriter.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/BufferAllocator.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/CodedInputStreamReader.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/CodedOutputStreamWriter.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/DescriptorMessageInfoFactory.java rename third_party/protobuf/{javanano/src/test/java/com/google/protobuf/nano/unittest_has_nano.proto => java/core/src/main/java/com/google/protobuf/DiscardUnknownFieldsParser.java} (55%) create mode 100644 third_party/protobuf/java/core/src/main/java/com/google/protobuf/ExtensionRegistryFactory.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/ExtensionSchema.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/ExtensionSchemaFull.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/ExtensionSchemaLite.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/ExtensionSchemas.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/FieldInfo.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/FieldType.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/GeneratedMessageInfoFactory.java create mode 100644 third_party/protobuf/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java create mode 100644 third_party/protobuf/java/core/src/main/java/com/google/protobuf/IterableByteBufferInputStream.java rename third_party/protobuf/{javanano/src/test/java/com/google/protobuf/nano/map_test.proto => java/core/src/main/java/com/google/protobuf/JavaType.java} (54%) mode change 100644 => 100755 create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/ListFieldSchema.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/ManifestSchemaFactory.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/MapFieldSchema.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/MapFieldSchemaFull.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/MapFieldSchemaLite.java rename third_party/protobuf/{javanano/src/test/java/com/google/protobuf/nano/unittest_recursive_nano.proto => java/core/src/main/java/com/google/protobuf/MapFieldSchemas.java} (72%) mode change 100644 => 100755 create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/MessageInfo.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/MessageInfoFactory.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/MessageSchema.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/MessageSetSchema.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/NewInstanceSchema.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/NewInstanceSchemaFull.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/NewInstanceSchemaLite.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/NewInstanceSchemas.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/OneofInfo.java create mode 100644 third_party/protobuf/java/core/src/main/java/com/google/protobuf/PrimitiveNonBoxingCollection.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/ProtoSyntax.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/Protobuf.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/ProtobufLists.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/RawMessageInfo.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/Reader.java create mode 100644 third_party/protobuf/java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/Schema.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/SchemaFactory.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/SchemaUtil.java create mode 100644 third_party/protobuf/java/core/src/main/java/com/google/protobuf/SingleFieldBuilderV3.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/StructuralMessageInfo.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/UnknownFieldSchema.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/UnknownFieldSetLiteSchema.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/UnknownFieldSetSchema.java create mode 100644 third_party/protobuf/java/core/src/main/java/com/google/protobuf/UnsafeUtil.java create mode 100755 third_party/protobuf/java/core/src/main/java/com/google/protobuf/Writer.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/AbstractProto2LiteSchemaTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/AbstractProto2SchemaTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/AbstractProto3LiteSchemaTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/AbstractProto3SchemaTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/AbstractSchemaTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/ArrayDecodersTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/BinaryProtocolTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/CachedFieldSizeTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/CodedAdapterTest.java create mode 100644 third_party/protobuf/java/core/src/test/java/com/google/protobuf/DecodeUtf8Test.java create mode 100644 third_party/protobuf/java/core/src/test/java/com/google/protobuf/DiscardUnknownFieldsTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/ExperimentalMessageFactory.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/ExperimentalSerializationUtil.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/ExperimentalTestDataProvider.java create mode 100644 third_party/protobuf/java/core/src/test/java/com/google/protobuf/ExtensionRegistryFactoryTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/MapLiteTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/PackedFieldTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/ParserLiteTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/Proto2ExtensionLookupSchemaTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/Proto2LiteSchemaTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/Proto2MessageFactory.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/Proto2MessageInfoFactory.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/Proto2MessageLiteFactory.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/Proto2SchemaTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/Proto2UnknownEnumValueTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/Proto3LiteSchemaTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/Proto3MessageFactory.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/Proto3MessageInfoFactory.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/Proto3MessageLiteFactory.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/Proto3MessageLiteInfoFactory.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/Proto3SchemaTest.java rename third_party/protobuf/java/core/src/test/java/com/google/protobuf/{RepeatedFieldBuilderTest.java => RepeatedFieldBuilderV3Test.java} (83%) rename third_party/protobuf/java/core/src/test/java/com/google/protobuf/{SingleFieldBuilderTest.java => SingleFieldBuilderV3Test.java} (70%) create mode 100644 third_party/protobuf/java/core/src/test/java/com/google/protobuf/TestBadIdentifiersLite.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/TestSchemas.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/TestSchemasLite.java delete mode 100644 third_party/protobuf/java/core/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/Utf8Test.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/Utf8Utils.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/WireFormatLiteTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/WrappersLiteOfMethodTest.java create mode 100755 third_party/protobuf/java/core/src/test/java/com/google/protobuf/WrappersOfMethodTest.java rename third_party/protobuf/{javanano/src/test/java/com/google/protobuf/nano/unittest_enum_class_multiple_nano.proto => java/core/src/test/proto/com/google/protobuf/cached_field_size_test.proto} (83%) mode change 100644 => 100755 create mode 100644 third_party/protobuf/java/core/src/test/proto/com/google/protobuf/deprecated_file.proto create mode 100644 third_party/protobuf/java/core/src/test/proto/com/google/protobuf/map_lite_test.proto rename third_party/protobuf/{javanano/src/test/java/com/google/protobuf/nano/unittest_enum_class_nano.proto => java/core/src/test/proto/com/google/protobuf/message_lite_extension_util_test.proto} (82%) mode change 100644 => 100755 create mode 100755 third_party/protobuf/java/core/src/test/proto/com/google/protobuf/packed_field_test.proto create mode 100755 third_party/protobuf/java/core/src/test/proto/com/google/protobuf/proto2_message.proto create mode 100755 third_party/protobuf/java/core/src/test/proto/com/google/protobuf/proto2_message_lite.proto create mode 100644 third_party/protobuf/java/core/src/test/proto/com/google/protobuf/proto2_unknown_enum_values.proto create mode 100755 third_party/protobuf/java/core/src/test/proto/com/google/protobuf/proto3_message.proto create mode 100755 third_party/protobuf/java/core/src/test/proto/com/google/protobuf/proto3_message_lite.proto rename third_party/protobuf/{javanano/src/test/java/com/google/protobuf/nano/unittest_multiple_nano.proto => java/core/src/test/proto/com/google/protobuf/wrappers_test.proto} (71%) mode change 100644 => 100755 create mode 100644 third_party/protobuf/java/lite.md create mode 100644 third_party/protobuf/java/lite/lite.awk create mode 100644 third_party/protobuf/java/lite/process-lite-sources-build.xml rename third_party/protobuf/java/{core => lite}/src/test/java/com/google/protobuf/LiteTest.java (59%) mode change 100644 => 100755 create mode 100755 third_party/protobuf/java/lite/src/test/java/com/google/protobuf/Proto2MessageLiteInfoFactory.java create mode 100644 third_party/protobuf/java/util/src/main/java/com/google/protobuf/util/Durations.java create mode 100755 third_party/protobuf/java/util/src/main/java/com/google/protobuf/util/Structs.java create mode 100644 third_party/protobuf/java/util/src/main/java/com/google/protobuf/util/Timestamps.java create mode 100755 third_party/protobuf/java/util/src/main/java/com/google/protobuf/util/Values.java create mode 100755 third_party/protobuf/java/util/src/test/java/com/google/protobuf/util/StructsTest.java create mode 100755 third_party/protobuf/java/util/src/test/java/com/google/protobuf/util/ValuesTest.java delete mode 100644 third_party/protobuf/javanano/README.md delete mode 100644 third_party/protobuf/javanano/pom.xml delete mode 100644 third_party/protobuf/javanano/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java delete mode 100644 third_party/protobuf/javanano/src/main/java/com/google/protobuf/nano/CodedOutputByteBufferNano.java delete mode 100644 third_party/protobuf/javanano/src/main/java/com/google/protobuf/nano/ExtendableMessageNano.java delete mode 100644 third_party/protobuf/javanano/src/main/java/com/google/protobuf/nano/Extension.java delete mode 100644 third_party/protobuf/javanano/src/main/java/com/google/protobuf/nano/FieldArray.java delete mode 100644 third_party/protobuf/javanano/src/main/java/com/google/protobuf/nano/FieldData.java delete mode 100644 third_party/protobuf/javanano/src/main/java/com/google/protobuf/nano/InternalNano.java delete mode 100644 third_party/protobuf/javanano/src/main/java/com/google/protobuf/nano/InvalidProtocolBufferNanoException.java delete mode 100644 third_party/protobuf/javanano/src/main/java/com/google/protobuf/nano/MessageNano.java delete mode 100644 third_party/protobuf/javanano/src/main/java/com/google/protobuf/nano/MessageNanoPrinter.java delete mode 100644 third_party/protobuf/javanano/src/main/java/com/google/protobuf/nano/WireFormatNano.java delete mode 100644 third_party/protobuf/javanano/src/test/java/com/google/protobuf/nano/NanoTest.java delete mode 100644 third_party/protobuf/javanano/src/test/java/com/google/protobuf/nano/unittest_accessors_nano.proto delete mode 100644 third_party/protobuf/javanano/src/test/java/com/google/protobuf/nano/unittest_enum_validity_nano.proto delete mode 100644 third_party/protobuf/javanano/src/test/java/com/google/protobuf/nano/unittest_extension_nano.proto delete mode 100644 third_party/protobuf/javanano/src/test/java/com/google/protobuf/nano/unittest_extension_packed_nano.proto delete mode 100644 third_party/protobuf/javanano/src/test/java/com/google/protobuf/nano/unittest_extension_repeated_nano.proto delete mode 100644 third_party/protobuf/javanano/src/test/java/com/google/protobuf/nano/unittest_extension_singular_nano.proto delete mode 100644 third_party/protobuf/javanano/src/test/java/com/google/protobuf/nano/unittest_nano.proto delete mode 100644 third_party/protobuf/javanano/src/test/java/com/google/protobuf/nano/unittest_reference_types_nano.proto delete mode 100644 third_party/protobuf/javanano/src/test/java/com/google/protobuf/nano/unittest_repeated_packables_nano.proto delete mode 100644 third_party/protobuf/jenkins/README.md delete mode 100644 third_party/protobuf/jenkins/buildcmds/README.md delete mode 100755 third_party/protobuf/jenkins/buildcmds/pull_request.sh delete mode 100644 third_party/protobuf/jenkins/docker/Dockerfile delete mode 100755 third_party/protobuf/jenkins/pull_request_in_docker.sh create mode 100644 third_party/protobuf/js/binary/message_test.js create mode 100644 third_party/protobuf/js/commonjs/strict_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/binary/arith_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/binary/decoder_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/binary/proto_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/binary/reader_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/binary/utils_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/binary/writer_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/commonjs/export_asserts.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/commonjs/export_testdeps.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/commonjs/import_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/commonjs/jasmine.json create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/commonjs/rewrite_tests_for_commonjs.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/commonjs/test6/test6.proto create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/commonjs/test7/test7.proto create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/data.proto create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/debug_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/jasmine1.json create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/jasmine2.json create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/jasmine3.json create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/message_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/proto3_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/proto3_test.proto create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/test.proto create mode 100755 third_party/protobuf/js/compatibility_tests/v3.0.0/test.sh create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/test2.proto create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/test3.proto rename third_party/protobuf/{javanano/src/test/java/com/google/protobuf/nano/unittest_multiple_nameclash_nano.proto => js/compatibility_tests/v3.0.0/test4.proto} (87%) rename third_party/protobuf/{src/google/protobuf/arena_nc.cc => js/compatibility_tests/v3.0.0/test5.proto} (83%) create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/testbinary.proto create mode 100644 third_party/protobuf/js/compatibility_tests/v3.0.0/testempty.proto create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/binary/arith_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/binary/decoder_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/binary/proto_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/binary/reader_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/binary/utils_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/binary/writer_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/commonjs/test6/test6.proto create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/commonjs/test7/test7.proto create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/data.proto create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/debug_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/maps_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/message_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/proto3_test.js create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/proto3_test.proto create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/test.proto create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/test2.proto create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/test3.proto create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/test4.proto create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/test5.proto create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/testbinary.proto create mode 100644 third_party/protobuf/js/compatibility_tests/v3.1.0/testempty.proto create mode 100644 third_party/protobuf/js/map.js create mode 100755 third_party/protobuf/js/maps_test.js rename third_party/protobuf/{javanano/src/test/java/com/google/protobuf/nano/unittest_single_nano.proto => js/test10.proto} (91%) create mode 100644 third_party/protobuf/js/test11.proto create mode 100644 third_party/protobuf/js/test12.proto create mode 100644 third_party/protobuf/js/test13.proto create mode 100644 third_party/protobuf/js/test14.proto create mode 100644 third_party/protobuf/js/test15.proto rename third_party/protobuf/{javanano/src/test/java/com/google/protobuf/nano/unittest_repeated_merge_nano.proto => js/test8.proto} (80%) create mode 100644 third_party/protobuf/js/test9.proto create mode 100644 third_party/protobuf/kokoro/README.md create mode 100644 third_party/protobuf/kokoro/linux/32-bit/Dockerfile create mode 100755 third_party/protobuf/kokoro/linux/32-bit/build.sh create mode 100644 third_party/protobuf/kokoro/linux/32-bit/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/32-bit/presubmit.cfg create mode 100644 third_party/protobuf/kokoro/linux/64-bit/Dockerfile create mode 100755 third_party/protobuf/kokoro/linux/bazel/build.sh create mode 100644 third_party/protobuf/kokoro/linux/bazel/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/bazel/presubmit.cfg create mode 100644 third_party/protobuf/kokoro/linux/benchmark/build.sh create mode 100755 third_party/protobuf/kokoro/linux/benchmark/continuous.cfg create mode 100755 third_party/protobuf/kokoro/linux/benchmark/run.sh rename third_party/protobuf/{jenkins => kokoro/linux}/build_and_run_docker.sh (50%) create mode 100755 third_party/protobuf/kokoro/linux/cpp_distcheck/build.sh create mode 100644 third_party/protobuf/kokoro/linux/cpp_distcheck/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/cpp_distcheck/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/cpp_tcmalloc/build.sh create mode 100644 third_party/protobuf/kokoro/linux/cpp_tcmalloc/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/cpp_tcmalloc/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/csharp/build.sh create mode 100644 third_party/protobuf/kokoro/linux/csharp/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/csharp/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/dist_install/build.sh create mode 100644 third_party/protobuf/kokoro/linux/dist_install/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/dist_install/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/dockerfile/push_testing_images.sh create mode 100644 third_party/protobuf/kokoro/linux/dockerfile/release/ruby_rake_compiler/Dockerfile create mode 100644 third_party/protobuf/kokoro/linux/dockerfile/test/cpp_tcmalloc/Dockerfile create mode 100644 third_party/protobuf/kokoro/linux/dockerfile/test/csharp/Dockerfile create mode 100644 third_party/protobuf/kokoro/linux/dockerfile/test/javascript/Dockerfile create mode 100644 third_party/protobuf/kokoro/linux/dockerfile/test/php/Dockerfile create mode 100644 third_party/protobuf/kokoro/linux/dockerfile/test/php_32bit/Dockerfile create mode 100644 third_party/protobuf/kokoro/linux/dockerfile/test/python_jessie/Dockerfile create mode 100644 third_party/protobuf/kokoro/linux/dockerfile/test/python_stretch/Dockerfile create mode 100644 third_party/protobuf/kokoro/linux/dockerfile/test/ruby/Dockerfile create mode 100755 third_party/protobuf/kokoro/linux/golang/build.sh create mode 100644 third_party/protobuf/kokoro/linux/golang/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/golang/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/java_compatibility/build.sh create mode 100644 third_party/protobuf/kokoro/linux/java_compatibility/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/java_compatibility/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/java_jdk7/build.sh create mode 100644 third_party/protobuf/kokoro/linux/java_jdk7/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/java_jdk7/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/java_oracle7/build.sh create mode 100644 third_party/protobuf/kokoro/linux/java_oracle7/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/java_oracle7/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/javascript/build.sh create mode 100644 third_party/protobuf/kokoro/linux/javascript/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/javascript/presubmit.cfg rename third_party/protobuf/{jenkins => kokoro/linux}/make_test_output.py (96%) create mode 100755 third_party/protobuf/kokoro/linux/php_all/build.sh create mode 100644 third_party/protobuf/kokoro/linux/php_all/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/php_all/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/pull_request_in_docker.sh create mode 100755 third_party/protobuf/kokoro/linux/python/build.sh create mode 100644 third_party/protobuf/kokoro/linux/python/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/python/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/python27/build.sh create mode 100644 third_party/protobuf/kokoro/linux/python27/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/python27/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/python27_cpp/build.sh create mode 100644 third_party/protobuf/kokoro/linux/python27_cpp/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/python27_cpp/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/python33/build.sh create mode 100644 third_party/protobuf/kokoro/linux/python33/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/python33/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/python33_cpp/build.sh create mode 100644 third_party/protobuf/kokoro/linux/python33_cpp/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/python33_cpp/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/python34/build.sh create mode 100644 third_party/protobuf/kokoro/linux/python34/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/python34/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/python34_cpp/build.sh create mode 100644 third_party/protobuf/kokoro/linux/python34_cpp/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/python34_cpp/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/python35/build.sh create mode 100644 third_party/protobuf/kokoro/linux/python35/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/python35/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/python35_cpp/build.sh create mode 100644 third_party/protobuf/kokoro/linux/python35_cpp/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/python35_cpp/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/python36/build.sh create mode 100644 third_party/protobuf/kokoro/linux/python36/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/python36/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/python36_cpp/build.sh create mode 100644 third_party/protobuf/kokoro/linux/python36_cpp/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/python36_cpp/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/python37/build.sh create mode 100644 third_party/protobuf/kokoro/linux/python37/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/python37/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/python37_cpp/build.sh create mode 100644 third_party/protobuf/kokoro/linux/python37_cpp/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/python37_cpp/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/python_compatibility/build.sh create mode 100644 third_party/protobuf/kokoro/linux/python_compatibility/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/python_compatibility/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/python_cpp/build.sh create mode 100644 third_party/protobuf/kokoro/linux/python_cpp/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/python_cpp/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/ruby23/build.sh create mode 100644 third_party/protobuf/kokoro/linux/ruby23/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/ruby23/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/ruby24/build.sh create mode 100644 third_party/protobuf/kokoro/linux/ruby24/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/ruby24/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/ruby25/build.sh create mode 100644 third_party/protobuf/kokoro/linux/ruby25/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/ruby25/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/linux/ruby26/build.sh create mode 100644 third_party/protobuf/kokoro/linux/ruby26/continuous.cfg create mode 100644 third_party/protobuf/kokoro/linux/ruby26/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/macos/cpp/build.sh create mode 100644 third_party/protobuf/kokoro/macos/cpp/continuous.cfg create mode 100644 third_party/protobuf/kokoro/macos/cpp/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/macos/cpp_distcheck/build.sh create mode 100644 third_party/protobuf/kokoro/macos/cpp_distcheck/continuous.cfg create mode 100644 third_party/protobuf/kokoro/macos/cpp_distcheck/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/macos/javascript/build.sh create mode 100644 third_party/protobuf/kokoro/macos/javascript/continuous.cfg create mode 100644 third_party/protobuf/kokoro/macos/javascript/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/macos/objectivec_cocoapods_integration/build.sh create mode 100644 third_party/protobuf/kokoro/macos/objectivec_cocoapods_integration/continuous.cfg create mode 100644 third_party/protobuf/kokoro/macos/objectivec_cocoapods_integration/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/macos/objectivec_ios_debug/build.sh create mode 100644 third_party/protobuf/kokoro/macos/objectivec_ios_debug/continuous.cfg create mode 100644 third_party/protobuf/kokoro/macos/objectivec_ios_debug/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/macos/objectivec_ios_release/build.sh create mode 100644 third_party/protobuf/kokoro/macos/objectivec_ios_release/continuous.cfg create mode 100644 third_party/protobuf/kokoro/macos/objectivec_ios_release/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/macos/objectivec_osx/build.sh create mode 100644 third_party/protobuf/kokoro/macos/objectivec_osx/continuous.cfg create mode 100644 third_party/protobuf/kokoro/macos/objectivec_osx/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/macos/php5.6_mac/build.sh create mode 100644 third_party/protobuf/kokoro/macos/php5.6_mac/continuous.cfg create mode 100644 third_party/protobuf/kokoro/macos/php5.6_mac/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/macos/php7.0_mac/build.sh create mode 100644 third_party/protobuf/kokoro/macos/php7.0_mac/continuous.cfg create mode 100644 third_party/protobuf/kokoro/macos/php7.0_mac/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/macos/prepare_build_macos_rc create mode 100755 third_party/protobuf/kokoro/macos/python/build.sh create mode 100644 third_party/protobuf/kokoro/macos/python/continuous.cfg create mode 100644 third_party/protobuf/kokoro/macos/python/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/macos/python_cpp/build.sh create mode 100644 third_party/protobuf/kokoro/macos/python_cpp/continuous.cfg create mode 100644 third_party/protobuf/kokoro/macos/python_cpp/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/macos/ruby23/build.sh create mode 100644 third_party/protobuf/kokoro/macos/ruby23/continuous.cfg create mode 100644 third_party/protobuf/kokoro/macos/ruby23/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/macos/ruby24/build.sh create mode 100644 third_party/protobuf/kokoro/macos/ruby24/continuous.cfg create mode 100644 third_party/protobuf/kokoro/macos/ruby24/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/macos/ruby25/build.sh create mode 100644 third_party/protobuf/kokoro/macos/ruby25/continuous.cfg create mode 100644 third_party/protobuf/kokoro/macos/ruby25/presubmit.cfg create mode 100755 third_party/protobuf/kokoro/macos/ruby26/build.sh create mode 100644 third_party/protobuf/kokoro/macos/ruby26/continuous.cfg create mode 100644 third_party/protobuf/kokoro/macos/ruby26/presubmit.cfg create mode 100644 third_party/protobuf/kokoro/release/collect_all_artifacts.cfg create mode 100755 third_party/protobuf/kokoro/release/collect_all_artifacts.sh create mode 100644 third_party/protobuf/kokoro/release/csharp/windows/build_nuget.bat create mode 100644 third_party/protobuf/kokoro/release/csharp/windows/continuous.cfg create mode 100644 third_party/protobuf/kokoro/release/csharp/windows/presubmit.cfg create mode 100644 third_party/protobuf/kokoro/release/csharp/windows/release.cfg create mode 100755 third_party/protobuf/kokoro/release/protoc/linux/build.sh create mode 100644 third_party/protobuf/kokoro/release/protoc/linux/release.cfg create mode 100644 third_party/protobuf/kokoro/release/protoc/macos/build.sh create mode 100644 third_party/protobuf/kokoro/release/protoc/macos/release.cfg create mode 100644 third_party/protobuf/kokoro/release/protoc/windows/build.bat create mode 100644 third_party/protobuf/kokoro/release/protoc/windows/release.cfg create mode 100755 third_party/protobuf/kokoro/release/python/linux/build_artifacts.sh create mode 100644 third_party/protobuf/kokoro/release/python/linux/config.sh create mode 100644 third_party/protobuf/kokoro/release/python/linux/continuous.cfg create mode 100644 third_party/protobuf/kokoro/release/python/linux/presubmit.cfg create mode 100644 third_party/protobuf/kokoro/release/python/linux/release.cfg create mode 100755 third_party/protobuf/kokoro/release/python/macos/build_artifacts.sh create mode 100644 third_party/protobuf/kokoro/release/python/macos/config.sh create mode 100644 third_party/protobuf/kokoro/release/python/macos/continuous.cfg create mode 100644 third_party/protobuf/kokoro/release/python/macos/presubmit.cfg create mode 100644 third_party/protobuf/kokoro/release/python/macos/release.cfg create mode 100644 third_party/protobuf/kokoro/release/python/windows/build_artifacts.bat create mode 100644 third_party/protobuf/kokoro/release/python/windows/build_single_artifact.bat create mode 100644 third_party/protobuf/kokoro/release/python/windows/continuous.cfg create mode 100644 third_party/protobuf/kokoro/release/python/windows/presubmit.cfg create mode 100644 third_party/protobuf/kokoro/release/python/windows/release.cfg create mode 100755 third_party/protobuf/kokoro/release/ruby/linux/build_artifacts.sh create mode 100644 third_party/protobuf/kokoro/release/ruby/linux/continuous.cfg create mode 100755 third_party/protobuf/kokoro/release/ruby/linux/prepare_build.sh create mode 100644 third_party/protobuf/kokoro/release/ruby/linux/presubmit.cfg create mode 100644 third_party/protobuf/kokoro/release/ruby/linux/release.cfg create mode 100755 third_party/protobuf/kokoro/release/ruby/linux/ruby/ruby_build.sh create mode 100755 third_party/protobuf/kokoro/release/ruby/linux/ruby/ruby_build_environment.sh create mode 100755 third_party/protobuf/kokoro/release/ruby/macos/build_artifacts.sh create mode 100644 third_party/protobuf/kokoro/release/ruby/macos/continuous.cfg create mode 100644 third_party/protobuf/kokoro/release/ruby/macos/presubmit.cfg create mode 100644 third_party/protobuf/kokoro/release/ruby/macos/release.cfg create mode 100755 third_party/protobuf/kokoro/release/ruby/macos/ruby/ruby_build.sh create mode 100755 third_party/protobuf/kokoro/release/ruby/macos/ruby/ruby_build_environment.sh create mode 100644 third_party/protobuf/kokoro/windows/csharp/build.bat create mode 100644 third_party/protobuf/kokoro/windows/csharp/continuous.cfg create mode 100644 third_party/protobuf/kokoro/windows/csharp/presubmit.cfg delete mode 100644 third_party/protobuf/m4/acx_pthread.m4 create mode 100644 third_party/protobuf/m4/ax_cxx_compile_stdcxx.m4 create mode 100644 third_party/protobuf/m4/ax_prog_cc_for_build.m4 create mode 100644 third_party/protobuf/m4/ax_prog_cxx_for_build.m4 create mode 100644 third_party/protobuf/m4/ax_pthread.m4 create mode 100644 third_party/protobuf/mirclient.cc create mode 100644 third_party/protobuf/mirclient.map create mode 100644 third_party/protobuf/objectivec/.gitignore create mode 100644 third_party/protobuf/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.h create mode 100644 third_party/protobuf/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.m create mode 100644 third_party/protobuf/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 third_party/protobuf/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Base.lproj/MainMenu.xib create mode 100644 third_party/protobuf/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Info.plist create mode 100644 third_party/protobuf/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/main.m create mode 100644 third_party/protobuf/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-framework create mode 100644 third_party/protobuf/objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-static create mode 100644 third_party/protobuf/objectivec/Tests/CocoaPods/README.md create mode 100644 third_party/protobuf/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-framework create mode 100644 third_party/protobuf/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-static create mode 100644 third_party/protobuf/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.h create mode 100644 third_party/protobuf/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.m rename third_party/protobuf/objectivec/Tests/{iOSTestHarness/Images.xcassets => CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Assets.xcassets}/AppIcon.appiconset/Contents.json (53%) create mode 100644 third_party/protobuf/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/LaunchScreen.storyboard create mode 100644 third_party/protobuf/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/Main.storyboard rename third_party/protobuf/objectivec/Tests/{iOSTestHarness => CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester}/Info.plist (84%) create mode 100644 third_party/protobuf/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.h create mode 100644 third_party/protobuf/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.m create mode 100644 third_party/protobuf/objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/main.m create mode 100755 third_party/protobuf/objectivec/Tests/CocoaPods/run_tests.sh create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest01.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest02.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest03.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest04.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest05.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest06.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest07.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest08.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest09.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest10.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest11.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest12.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest13.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest14.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest15.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest16.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest17.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest18.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest19.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest20.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest21.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest22.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest23.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest24.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBCompileTest25.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBDictionaryTests.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBExtensionRegistryTest.m create mode 100644 third_party/protobuf/objectivec/Tests/GPBUnittestProtos2.m delete mode 100644 third_party/protobuf/objectivec/Tests/iOSTestHarness/AppDelegate.m delete mode 100644 third_party/protobuf/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6.png delete mode 100644 third_party/protobuf/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6_2x.png delete mode 100644 third_party/protobuf/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7.png delete mode 100644 third_party/protobuf/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7_2x.png delete mode 100644 third_party/protobuf/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6.png delete mode 100644 third_party/protobuf/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6_2x.png delete mode 100644 third_party/protobuf/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_2x.png delete mode 100644 third_party/protobuf/objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_3x.png delete mode 100644 third_party/protobuf/objectivec/Tests/iOSTestHarness/Images.xcassets/LaunchImage.launchimage/Contents.json delete mode 100644 third_party/protobuf/objectivec/Tests/iOSTestHarness/LaunchScreen.xib delete mode 100644 third_party/protobuf/objectivec/Tests/iOSTestHarness/en.lproj/InfoPlist.strings create mode 100644 third_party/protobuf/objectivec/Tests/text_format_extensions_unittest_data.txt create mode 100644 third_party/protobuf/objectivec/Tests/unittest_deprecated.proto create mode 100644 third_party/protobuf/objectivec/Tests/unittest_deprecated_file.proto create mode 100644 third_party/protobuf/objectivec/Tests/unittest_extension_chain_a.proto create mode 100644 third_party/protobuf/objectivec/Tests/unittest_extension_chain_b.proto create mode 100644 third_party/protobuf/objectivec/Tests/unittest_extension_chain_c.proto create mode 100644 third_party/protobuf/objectivec/Tests/unittest_extension_chain_d.proto create mode 100644 third_party/protobuf/objectivec/Tests/unittest_extension_chain_e.proto create mode 100644 third_party/protobuf/objectivec/Tests/unittest_extension_chain_f.proto create mode 100644 third_party/protobuf/objectivec/Tests/unittest_extension_chain_g.proto create mode 100644 third_party/protobuf/objectivec/Tests/unittest_objc_options.proto delete mode 100644 third_party/protobuf/patches/0005-fix-include-js-generator.patch delete mode 100644 third_party/protobuf/patches/0007-uninline_googleonce.patch delete mode 100644 third_party/protobuf/patches/0011-libprotobuf_export.patch create mode 100644 third_party/protobuf/patches/0021-Fix-protobuf-s-library-.gitinore-file.patch create mode 100644 third_party/protobuf/patches/0023-php_generator.patch create mode 100644 third_party/protobuf/patches/0026-json_objectwriter_override.patch create mode 100644 third_party/protobuf/patches/0027-explicit-namespace.patch create mode 100644 third_party/protobuf/patches/0028-fix-repeated-field-export.patch create mode 100644 third_party/protobuf/patches/0029-Fix-order-for-mutex-macros.patch create mode 100644 third_party/protobuf/patches/0030-fix-use_unaligned-not-defined-warning.patch create mode 100644 third_party/protobuf/php/README.md create mode 100644 third_party/protobuf/php/composer.json create mode 100644 third_party/protobuf/php/ext/google/protobuf/array.c create mode 100644 third_party/protobuf/php/ext/google/protobuf/builtin_descriptors.inc create mode 100644 third_party/protobuf/php/ext/google/protobuf/encode_decode.c create mode 100644 third_party/protobuf/php/ext/google/protobuf/map.c create mode 100644 third_party/protobuf/php/ext/google/protobuf/package.xml delete mode 100644 third_party/protobuf/php/ext/google/protobuf/test.php create mode 100644 third_party/protobuf/php/ext/google/protobuf/type_check.c create mode 100644 third_party/protobuf/php/ext/google/protobuf/utf8.c create mode 100644 third_party/protobuf/php/ext/google/protobuf/utf8.h create mode 100755 third_party/protobuf/php/generate_descriptor_protos.sh create mode 100644 third_party/protobuf/php/phpunit.xml create mode 100755 third_party/protobuf/php/release.sh create mode 100644 third_party/protobuf/php/src/GPBMetadata/Google/Protobuf/Any.php create mode 100644 third_party/protobuf/php/src/GPBMetadata/Google/Protobuf/Api.php create mode 100644 third_party/protobuf/php/src/GPBMetadata/Google/Protobuf/Duration.php create mode 100644 third_party/protobuf/php/src/GPBMetadata/Google/Protobuf/FieldMask.php create mode 100644 third_party/protobuf/php/src/GPBMetadata/Google/Protobuf/GPBEmpty.php create mode 100644 third_party/protobuf/php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php create mode 100644 third_party/protobuf/php/src/GPBMetadata/Google/Protobuf/SourceContext.php create mode 100644 third_party/protobuf/php/src/GPBMetadata/Google/Protobuf/Struct.php create mode 100644 third_party/protobuf/php/src/GPBMetadata/Google/Protobuf/Timestamp.php create mode 100644 third_party/protobuf/php/src/GPBMetadata/Google/Protobuf/Type.php create mode 100644 third_party/protobuf/php/src/GPBMetadata/Google/Protobuf/Wrappers.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Any.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Api.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/BoolValue.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/BytesValue.php rename third_party/protobuf/{javanano/src/main/java/com/google/protobuf/nano/UnknownFieldData.java => php/src/Google/Protobuf/Descriptor.php} (52%) create mode 100644 third_party/protobuf/php/src/Google/Protobuf/DescriptorPool.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/DoubleValue.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Duration.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Enum.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/EnumDescriptor.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/EnumValue.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/EnumValueDescriptor.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Field.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Field/Cardinality.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Field/Kind.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/FieldDescriptor.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/FieldMask.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Field_Cardinality.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Field_Kind.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/FloatValue.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/GPBEmpty.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Int32Value.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Int64Value.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/CodedInputStream.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/CodedOutputStream.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/Descriptor.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/DescriptorPool.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/DescriptorProto.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/EnumBuilderContext.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/EnumDescriptor.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/EnumDescriptorProto_EnumReservedRange.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/EnumOptions.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/EnumValueOptions.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/FieldDescriptor.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/FieldDescriptorProto/Label.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/FieldDescriptorProto/Type.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/FieldOptions.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/FieldOptions/CType.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/FieldOptions/JSType.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/FieldOptions_CType.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/FieldOptions_JSType.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/FileDescriptor.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/FileDescriptorProto.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/FileDescriptorSet.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/FileOptions.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/FileOptions/OptimizeMode.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/GPBDecodeException.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/GPBJsonWire.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/GPBLabel.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/GPBType.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/GPBUtil.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/GPBWire.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/GPBWireType.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/GetPublicDescriptorTrait.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/HasPublicDescriptorTrait.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/MapEntry.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/MapField.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/MapFieldIter.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/Message.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/MessageBuilderContext.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/MessageOptions.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/MethodOptions.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/MethodOptions/IdempotencyLevel.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/OneofDescriptor.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/OneofField.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/OneofOptions.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/RawInputStream.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/RepeatedField.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/RepeatedFieldIter.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/ServiceOptions.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/SourceCodeInfo.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/UninterpretedOption.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/ListValue.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Method.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Mixin.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/NullValue.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/OneofDescriptor.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Option.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/SourceContext.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/StringValue.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Struct.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Syntax.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Timestamp.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Type.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/UInt32Value.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/UInt64Value.php create mode 100644 third_party/protobuf/php/src/Google/Protobuf/Value.php create mode 100644 third_party/protobuf/php/src/phpdoc.dist.xml create mode 100644 third_party/protobuf/php/tests/array_test.php mode change 100644 => 100755 third_party/protobuf/php/tests/autoload.php create mode 100644 third_party/protobuf/php/tests/bootstrap_phpunit.php create mode 100755 third_party/protobuf/php/tests/compatibility_test.sh create mode 100755 third_party/protobuf/php/tests/compile_extension.sh create mode 100644 third_party/protobuf/php/tests/descriptors_test.php create mode 100644 third_party/protobuf/php/tests/encode_decode_test.php create mode 100755 third_party/protobuf/php/tests/gdb_test.sh create mode 100644 third_party/protobuf/php/tests/generated_class_test.php create mode 100644 third_party/protobuf/php/tests/generated_phpdoc_test.php create mode 100644 third_party/protobuf/php/tests/generated_service_test.php create mode 100644 third_party/protobuf/php/tests/map_field_test.php create mode 100644 third_party/protobuf/php/tests/memory_leak_test.php create mode 100644 third_party/protobuf/php/tests/php_implementation_test.php create mode 100644 third_party/protobuf/php/tests/proto/empty/echo.proto create mode 100644 third_party/protobuf/php/tests/proto/test.proto create mode 100644 third_party/protobuf/php/tests/proto/test_descriptors.proto create mode 100644 third_party/protobuf/php/tests/proto/test_empty_php_namespace.proto create mode 100644 third_party/protobuf/php/tests/proto/test_import_descriptor_proto.proto create mode 100644 third_party/protobuf/php/tests/proto/test_include.proto create mode 100644 third_party/protobuf/php/tests/proto/test_no_namespace.proto create mode 100644 third_party/protobuf/php/tests/proto/test_php_namespace.proto create mode 100644 third_party/protobuf/php/tests/proto/test_prefix.proto create mode 100644 third_party/protobuf/php/tests/proto/test_reserved_enum_lower.proto create mode 100644 third_party/protobuf/php/tests/proto/test_reserved_enum_upper.proto create mode 100644 third_party/protobuf/php/tests/proto/test_reserved_enum_value_lower.proto create mode 100644 third_party/protobuf/php/tests/proto/test_reserved_enum_value_upper.proto create mode 100644 third_party/protobuf/php/tests/proto/test_reserved_message_lower.proto create mode 100644 third_party/protobuf/php/tests/proto/test_reserved_message_upper.proto create mode 100644 third_party/protobuf/php/tests/proto/test_service.proto create mode 100644 third_party/protobuf/php/tests/proto/test_service_namespace.proto create mode 100644 third_party/protobuf/php/tests/proto/test_wrapper_type_setters.proto create mode 100755 third_party/protobuf/php/tests/test.sh create mode 100644 third_party/protobuf/php/tests/test_base.php create mode 100644 third_party/protobuf/php/tests/test_util.php create mode 100644 third_party/protobuf/php/tests/undefined_test.php create mode 100644 third_party/protobuf/php/tests/well_known_test.php create mode 100644 third_party/protobuf/php/tests/wrapper_type_setters_test.php create mode 100644 third_party/protobuf/protobuf_deps.bzl create mode 100755 third_party/protobuf/protoc-artifacts/build-zip.sh create mode 100755 third_party/protobuf/protoc-artifacts/scl-enable-devtoolset.sh create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/factory_test1.proto create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/factory_test2.proto create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/more_extensions.proto create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/more_extensions_dynamic.proto create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/more_messages.proto create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/test_bad_identifiers.proto create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/descriptor.proto create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest.proto create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_custom_options.proto create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_import.proto create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_import_public.proto create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_mset.proto create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_no_generic_services.proto create mode 100755 third_party/protobuf/python/compatibility_tests/v2.5.0/setup.py create mode 100755 third_party/protobuf/python/compatibility_tests/v2.5.0/test.sh create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/tests/__init__.py create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/tests/google/__init__.py create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/tests/google/protobuf/__init__.py rename third_party/protobuf/{src/google/protobuf/arena_nc_test.py => python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/__init__.py} (62%) create mode 100755 third_party/protobuf/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/descriptor_test.py create mode 100755 third_party/protobuf/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/generator_test.py create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/golden_message create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/golden_packed_fields_message create mode 100755 third_party/protobuf/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/message_test.py create mode 100755 third_party/protobuf/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/service_reflection_test.py create mode 100755 third_party/protobuf/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/test_util.py create mode 100755 third_party/protobuf/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/text_format_test.py create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/text_format_unittest_data.txt create mode 100644 third_party/protobuf/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/text_format_unittest_extensions_data.txt create mode 100755 third_party/protobuf/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/wire_format_test.py create mode 100644 third_party/protobuf/python/google/protobuf/compiler/__init__.py create mode 100644 third_party/protobuf/python/google/protobuf/internal/extension_dict.py create mode 100644 third_party/protobuf/python/google/protobuf/internal/file_options_test.proto create mode 100755 third_party/protobuf/python/google/protobuf/internal/keywords_test.py create mode 100644 third_party/protobuf/python/google/protobuf/internal/no_package.proto rename third_party/protobuf/{src/google/protobuf/stubs/singleton.h => python/google/protobuf/internal/python_protobuf.cc} (65%) create mode 100644 third_party/protobuf/python/google/protobuf/internal/testing_refleaks.py create mode 100644 third_party/protobuf/python/google/protobuf/proto_api.h create mode 100755 third_party/protobuf/python/google/protobuf/pyext/field.cc rename third_party/protobuf/{src/google/protobuf/stubs/atomic_sequence_num.h => python/google/protobuf/pyext/field.h} (73%) mode change 100644 => 100755 create mode 100644 third_party/protobuf/python/google/protobuf/pyext/message_factory.cc create mode 100644 third_party/protobuf/python/google/protobuf/pyext/message_factory.h create mode 100644 third_party/protobuf/python/google/protobuf/pyext/message_module.cc create mode 100644 third_party/protobuf/python/google/protobuf/pyext/safe_numerics.h create mode 100755 third_party/protobuf/python/google/protobuf/pyext/unknown_fields.cc rename third_party/protobuf/{src/google/protobuf/compiler/javanano/javanano_enum.h => python/google/protobuf/pyext/unknown_fields.h} (53%) mode change 100644 => 100755 rename third_party/protobuf/python/google/protobuf/{pyext => }/python_protobuf.h (100%) create mode 100644 third_party/protobuf/python/google/protobuf/util/__init__.py create mode 100755 third_party/protobuf/python/release.sh create mode 100644 third_party/protobuf/python/release/wheel/Dockerfile create mode 100644 third_party/protobuf/python/release/wheel/README.md create mode 100755 third_party/protobuf/python/release/wheel/build_wheel_manylinux.sh create mode 100755 third_party/protobuf/python/release/wheel/protobuf_optimized_pip.sh create mode 100644 third_party/protobuf/python/setup.cfg delete mode 100644 third_party/protobuf/ruby/Gemfile.lock create mode 100644 third_party/protobuf/ruby/compatibility_tests/v3.0.0/README.md create mode 100644 third_party/protobuf/ruby/compatibility_tests/v3.0.0/Rakefile create mode 100755 third_party/protobuf/ruby/compatibility_tests/v3.0.0/test.sh create mode 100644 third_party/protobuf/ruby/compatibility_tests/v3.0.0/tests/basic.rb create mode 100644 third_party/protobuf/ruby/compatibility_tests/v3.0.0/tests/generated_code.proto create mode 100644 third_party/protobuf/ruby/compatibility_tests/v3.0.0/tests/generated_code_test.rb create mode 100644 third_party/protobuf/ruby/compatibility_tests/v3.0.0/tests/repeated_field_test.rb create mode 100644 third_party/protobuf/ruby/compatibility_tests/v3.0.0/tests/stress.rb create mode 100644 third_party/protobuf/ruby/compatibility_tests/v3.0.0/tests/test_import.proto create mode 100644 third_party/protobuf/ruby/ext/google/protobuf_c/wrap_memcpy.c create mode 100644 third_party/protobuf/ruby/lib/google/protobuf/well_known_types.rb create mode 100644 third_party/protobuf/ruby/tests/basic_proto2.rb create mode 100644 third_party/protobuf/ruby/tests/basic_test.proto create mode 100644 third_party/protobuf/ruby/tests/basic_test_proto2.proto create mode 100644 third_party/protobuf/ruby/tests/common_tests.rb create mode 100644 third_party/protobuf/ruby/tests/encode_decode_test.rb create mode 100644 third_party/protobuf/ruby/tests/gc_test.rb create mode 100644 third_party/protobuf/ruby/tests/generated_code_proto2.proto create mode 100644 third_party/protobuf/ruby/tests/generated_code_proto2_test.rb create mode 100644 third_party/protobuf/ruby/tests/test_import.proto create mode 100644 third_party/protobuf/ruby/tests/test_import_proto2.proto create mode 100644 third_party/protobuf/ruby/tests/test_ruby_package.proto create mode 100644 third_party/protobuf/ruby/tests/test_ruby_package_proto2.proto create mode 100644 third_party/protobuf/ruby/tests/type_errors.rb create mode 100644 third_party/protobuf/ruby/tests/well_known_types_test.rb create mode 100644 third_party/protobuf/src/google/protobuf/any_lite.cc mode change 100755 => 100644 third_party/protobuf/src/google/protobuf/arena.cc create mode 100644 third_party/protobuf/src/google/protobuf/arena_impl.h mode change 100755 => 100644 third_party/protobuf/src/google/protobuf/arenastring.h create mode 100644 third_party/protobuf/src/google/protobuf/compiler/annotation_test_util.cc create mode 100644 third_party/protobuf/src/google/protobuf/compiler/annotation_test_util.h rename third_party/protobuf/src/google/protobuf/compiler/{javanano/javanano_extension.h => cpp/cpp_message_layout_helper.h} (67%) create mode 100644 third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_move_unittest.cc create mode 100644 third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc create mode 100644 third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.h create mode 100644 third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_unittest.inc create mode 100644 third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/java/java_lazy_message_field.cc delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/java/java_lazy_message_field.h delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/java/java_lazy_message_field_lite.h rename third_party/protobuf/src/google/protobuf/compiler/{javanano/javanano_map_field.h => java/java_options.h} (60%) delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_enum.cc delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_enum_field.cc delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_enum_field.h delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_extension.cc delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_field.cc delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_field.h delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_file.cc delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_generator.cc delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_helpers.cc delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_helpers.h delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_map_field.cc delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_message.cc delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_message.h delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_message_field.cc delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_message_field.h delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_params.h delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_primitive_field.h mode change 100755 => 100644 third_party/protobuf/src/google/protobuf/compiler/js/js_generator.cc mode change 100755 => 100644 third_party/protobuf/src/google/protobuf/compiler/js/js_generator.h create mode 100644 third_party/protobuf/src/google/protobuf/compiler/js/well_known_types_embed.cc create mode 100644 third_party/protobuf/src/google/protobuf/compiler/js/well_known_types_embed.h create mode 100755 third_party/protobuf/src/google/protobuf/compiler/objectivec/method_dump.sh create mode 100644 third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_nsobject_methods.h create mode 100644 third_party/protobuf/src/google/protobuf/compiler/php/php_generator.cc rename third_party/protobuf/src/google/protobuf/compiler/{javanano/javanano_generator.h => php/php_generator.h} (60%) delete mode 100644 third_party/protobuf/src/google/protobuf/compiler/ruby/ruby_generated_code.rb create mode 100644 third_party/protobuf/src/google/protobuf/compiler/ruby/ruby_generated_code_pb.rb create mode 100644 third_party/protobuf/src/google/protobuf/compiler/ruby/ruby_generated_code_proto2.proto create mode 100644 third_party/protobuf/src/google/protobuf/compiler/ruby/ruby_generated_code_proto2_pb.rb create mode 100644 third_party/protobuf/src/google/protobuf/compiler/ruby/ruby_generated_pkg_explicit.proto create mode 100644 third_party/protobuf/src/google/protobuf/compiler/ruby/ruby_generated_pkg_explicit_legacy.proto create mode 100644 third_party/protobuf/src/google/protobuf/compiler/ruby/ruby_generated_pkg_explicit_legacy_pb.rb create mode 100644 third_party/protobuf/src/google/protobuf/compiler/ruby/ruby_generated_pkg_explicit_pb.rb create mode 100644 third_party/protobuf/src/google/protobuf/compiler/ruby/ruby_generated_pkg_implicit.proto create mode 100644 third_party/protobuf/src/google/protobuf/compiler/ruby/ruby_generated_pkg_implicit_pb.rb create mode 100644 third_party/protobuf/src/google/protobuf/compiler/scc.h create mode 100644 third_party/protobuf/src/google/protobuf/extension_set_inl.h create mode 100755 third_party/protobuf/src/google/protobuf/generated_enum_util.cc create mode 100644 third_party/protobuf/src/google/protobuf/generated_message_table_driven.cc create mode 100644 third_party/protobuf/src/google/protobuf/generated_message_table_driven.h create mode 100644 third_party/protobuf/src/google/protobuf/generated_message_table_driven_lite.cc create mode 100644 third_party/protobuf/src/google/protobuf/generated_message_table_driven_lite.h rename third_party/protobuf/src/google/protobuf/{compiler/javanano/javanano_file.h => has_bits.h} (50%) create mode 100644 third_party/protobuf/src/google/protobuf/implicit_weak_message.cc create mode 100644 third_party/protobuf/src/google/protobuf/implicit_weak_message.h create mode 100644 third_party/protobuf/src/google/protobuf/inlined_string_field.h mode change 100644 => 100755 third_party/protobuf/src/google/protobuf/io/coded_stream.h create mode 100755 third_party/protobuf/src/google/protobuf/io/io_win32.cc create mode 100755 third_party/protobuf/src/google/protobuf/io/io_win32.h create mode 100755 third_party/protobuf/src/google/protobuf/io/io_win32_unittest.cc create mode 100644 third_party/protobuf/src/google/protobuf/message_unittest.inc create mode 100644 third_party/protobuf/src/google/protobuf/metadata_lite.h create mode 100644 third_party/protobuf/src/google/protobuf/parse_context.cc create mode 100644 third_party/protobuf/src/google/protobuf/parse_context.h create mode 100644 third_party/protobuf/src/google/protobuf/port.h create mode 100644 third_party/protobuf/src/google/protobuf/port_def.inc create mode 100644 third_party/protobuf/src/google/protobuf/port_undef.inc create mode 100644 third_party/protobuf/src/google/protobuf/proto3_lite_unittest.inc mode change 100755 => 100644 third_party/protobuf/src/google/protobuf/reflection.h delete mode 100644 third_party/protobuf/src/google/protobuf/repeated_field_reflection.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/atomicops.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/atomicops_internals_macosx.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/atomicops_internals_pnacl.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/atomicops_internals_power.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/atomicops_internals_solaris.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/atomicops_internals_starboard.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/atomicops_internals_tsan.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/once.cc delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/once_unittest.cc delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/scoped_ptr.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/shared_ptr.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/starboard_poem.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/type_traits.h delete mode 100644 third_party/protobuf/src/google/protobuf/stubs/type_traits_unittest.cc create mode 100644 third_party/protobuf/src/google/protobuf/test_messages_proto2.proto create mode 100644 third_party/protobuf/src/google/protobuf/test_messages_proto3.proto create mode 100644 third_party/protobuf/src/google/protobuf/test_util.inc create mode 100644 third_party/protobuf/src/google/protobuf/test_util2.h create mode 100644 third_party/protobuf/src/google/protobuf/testdata/bad_utf8_string create mode 100644 third_party/protobuf/src/google/protobuf/testdata/golden_message_maps create mode 100644 third_party/protobuf/src/google/protobuf/unittest_lazy_dependencies.proto create mode 100644 third_party/protobuf/src/google/protobuf/unittest_lazy_dependencies_custom_option.proto create mode 100644 third_party/protobuf/src/google/protobuf/unittest_lazy_dependencies_enum.proto create mode 100644 third_party/protobuf/src/google/protobuf/util/delimited_message_util.cc create mode 100644 third_party/protobuf/src/google/protobuf/util/delimited_message_util.h create mode 100644 third_party/protobuf/src/google/protobuf/util/delimited_message_util_test.cc create mode 100644 third_party/protobuf/src/google/protobuf/util/internal/testdata/proto3.proto create mode 100644 third_party/protobuf/src/google/protobuf/util/json_format.proto mode change 100755 => 100644 third_party/protobuf/src/google/protobuf/util/message_differencer_unittest.cc create mode 100644 third_party/protobuf/src/google/protobuf/util/package_info.h delete mode 100644 third_party/protobuf/src/google/protobuf/wire_format_lite_inl.h create mode 100644 third_party/protobuf/src/libprotobuf-lite.map create mode 100644 third_party/protobuf/src/libprotobuf.map create mode 100644 third_party/protobuf/src/libprotoc.map create mode 100644 third_party/protobuf/third_party/zlib.BUILD create mode 100755 third_party/protobuf/update_version.py delete mode 100755 tools/protoc delete mode 100755 tools/protoc.exe delete mode 100755 tools/protoc_mac diff --git a/third_party/protobuf/.github/ISSUE_TEMPLATE/bug_report.md b/third_party/protobuf/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000000..2f6d026378c2 --- /dev/null +++ b/third_party/protobuf/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,28 @@ +--- +name: Bug report +about: Create a report to help us improve + +--- + +**What version of protobuf and what language are you using?** +Version: master/v3.6.0/v3.5.0 etc. +Language: C++/Java/Python/C#/Ruby/PHP/Objective-C/Javascript + +**What operating system (Linux, Windows, ...) and version?** + +**What runtime / compiler are you using (e.g., python version or gcc version)** + +**What did you do?** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**What did you expect to see** + +**What did you see instead?** + +Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs). + +**Anything else we should know about your project / environment** diff --git a/third_party/protobuf/.github/ISSUE_TEMPLATE/feature_request.md b/third_party/protobuf/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000000..722db4ce5904 --- /dev/null +++ b/third_party/protobuf/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,18 @@ +--- +name: Feature request +about: Suggest an idea for this project + +--- + +**What language does this apply to?** +If it's a proto syntax change, is it for proto2 or proto3? +If it's about generated code change, what programming language? + +**Describe the problem you are trying to solve.** + +**Describe the solution you'd like** + +**Describe alternatives you've considered** + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/third_party/protobuf/.github/ISSUE_TEMPLATE/question.md b/third_party/protobuf/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 000000000000..bfa6ddea8801 --- /dev/null +++ b/third_party/protobuf/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,7 @@ +--- +name: Question +about: Questions and troubleshooting + +--- + + diff --git a/third_party/protobuf/.github/mergeable.yml b/third_party/protobuf/.github/mergeable.yml new file mode 100644 index 000000000000..c4170019c141 --- /dev/null +++ b/third_party/protobuf/.github/mergeable.yml @@ -0,0 +1,18 @@ +mergeable: + pull_requests: + label: + and: + - must_exclude: + regex: '^disposition/DO NOT MERGE' + message: 'Pull request marked not mergeable' + - or: + - and: + - must_include: + regex: 'release notes: yes' + message: 'Please include release note: yes' + - must_include: + regex: '^(c#|c\+\+|cleanup|conformance tests|integration|java|javascript|go|objective-c|php|python|ruby)' + message: 'Please include at least a language label (e.g., c++, java, python). Or apply one of the following labels: cleanup, conformance tests, integration.' + - must_include: + regex: 'release notes: no' + message: 'Please include release note: no' diff --git a/third_party/protobuf/.gitignore b/third_party/protobuf/.gitignore index 27eeb9c224af..942af14f9b66 100644 --- a/third_party/protobuf/.gitignore +++ b/third_party/protobuf/.gitignore @@ -19,7 +19,7 @@ m4/lt~obsolete.m4 autom4te.cache # downloaded files -gmock +/gmock # in-tree configure-generated files Makefile @@ -53,17 +53,22 @@ src/google/protobuf/util/**/*.pb.h *.pyc *.egg-info *_pb2.py -python/*.egg +!python/google/protobuf/descriptor_pb2.py +python/**/*.egg python/.eggs/ python/.tox python/build/ -python/google/protobuf/compiler/ -python/google/protobuf/util/ +src/js_embed src/protoc src/unittest_proto_middleman +# vim generated +*.swp + # Generated test scaffolding +src/no_warning_test.cc +src/no-warning-test src/protobuf*-test src/test_plugin src/testzip.* @@ -77,8 +82,11 @@ src/**/*.log src/**/*.trs # JavaBuild output. -java/target +java/core/target +java/util/target javanano/target +java/.idea +java/**/*.iml # Windows native output. cmake/build @@ -88,16 +96,14 @@ build_msvc # packages themselves. /csharp/src/packages/*/ -# Directories created by opening the Objective C Xcode projects. -objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/xcuserdata/ -objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/xcshareddata/ProtocolBuffers_OSX.xccheckout -objectivec/ProtocolBuffers_OSX.xcodeproj/xcuserdata/ -objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcuserdata/ -objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcshareddata/ProtocolBuffers_iOS.xccheckout -objectivec/ProtocolBuffers_iOS.xcodeproj/xcuserdata/ # OS X's Finder creates these for state about opened windows/etc. **/.DS_Store +# Cocoapods artifacts +# Podfile.lock and the workspace file are tracked, to ease deleting them. That's +# needed to trigger "pod install" to rerun the preinstall commands. +Pods/ + # Comformance test output conformance/.libs/ conformance/com/ @@ -110,8 +116,88 @@ conformance/conformance.pb.cc conformance/conformance.pb.h conformance/Conformance.pbobjc.h conformance/Conformance.pbobjc.m -conformance/conformance.rb +conformance/conformance_pb.js +conformance/conformance_pb.rb +conformance/failing_tests.txt conformance/google/ +conformance/google-protobuf/ conformance/javac_middleman conformance/lite/ +conformance/nonexistent_tests.txt conformance/protoc_middleman +conformance/succeeding_tests.txt +conformance/Conformance/ +conformance/GPBMetadata/ +conformance/Google/ +conformance/Protobuf_test_messages/ +conformance/conformance-php +conformance/conformance-php-c +conformance/*.class + +# php test output +composer.lock +php/tests/generated/ +php/tests/old_protoc +php/tests/protobuf/ +php/ext/google/protobuf/.libs/ +php/ext/google/protobuf/Makefile.fragments +php/ext/google/protobuf/Makefile.global +php/ext/google/protobuf/Makefile.objects +php/ext/google/protobuf/acinclude.m4 +php/ext/google/protobuf/build/ +php/ext/google/protobuf/config.h +php/ext/google/protobuf/config.h.in~ +php/ext/google/protobuf/config.nice +php/ext/google/protobuf/configure.ac +php/ext/google/protobuf/configure.in +php/ext/google/protobuf/mkinstalldirs +php/ext/google/protobuf/run-tests.php +vendor/ + +# JavaScript artifacts +js/commonjs_out/ +js/compatibility_tests/v3.0.0/commonjs_out* +js/compatibility_tests/v3.0.0/protoc +js/compatibility_tests/v3.0.0/testproto_libs1.js +js/compatibility_tests/v3.0.0/testproto_libs1_new.js +js/compatibility_tests/v3.0.0/testproto_libs2.js +js/compatibility_tests/v3.0.0/testproto_libs2_new.js +js/deps.js +js/google-protobuf.js +js/google/ +js/node_modules/ +js/testproto_libs1.js +js/testproto_libs2.js + +# Ignore the bazel symlinks +/bazel-* + +# ruby test output +ruby/lib/ +ruby/tests/basic_test_pb.rb +ruby/tests/basic_test_proto2_pb.rb +ruby/tests/generated_code_pb.rb +ruby/tests/test_import_pb.rb +ruby/tests/test_ruby_package_pb.rb +ruby/tests/generated_code_proto2_pb.rb +ruby/tests/test_import_proto2_pb.rb +ruby/tests/test_ruby_package_proto2_pb.rb +ruby/Gemfile.lock +ruby/compatibility_tests/v3.0.0/protoc +ruby/compatibility_tests/v3.0.0/tests/generated_code_pb.rb +ruby/compatibility_tests/v3.0.0/tests/test_import_pb.rb + +# IntelliJ CLion Config files and build output +cmake/.idea +cmake/cmake-build-debug/ + +# Common build subdirectories. +./.build/ +./_build/ + +# Visual Studio 2017 +.vs + +# IntelliJ +.idea +*.iml diff --git a/third_party/protobuf/.gitmodules b/third_party/protobuf/.gitmodules new file mode 100644 index 000000000000..bcd125a49582 --- /dev/null +++ b/third_party/protobuf/.gitmodules @@ -0,0 +1,7 @@ +[submodule "third_party/benchmark"] + path = third_party/benchmark + url = https://github.com/google/benchmark.git +[submodule "third_party/googletest"] + path = third_party/googletest + url = https://github.com/google/googletest.git + ignore = dirty diff --git a/third_party/protobuf/.travis.yml b/third_party/protobuf/.travis.yml deleted file mode 100644 index bcf3851bc216..000000000000 --- a/third_party/protobuf/.travis.yml +++ /dev/null @@ -1,84 +0,0 @@ -sudo: required -# Note: travis currently does not support listing more than one language so -# this cheats and claims to only be cpp. If they add multiple language -# support, this should probably get updated to install steps and/or -# rvm/gemfile/jdk/etc. entries rather than manually doing the work. -language: cpp -os: - - linux - - osx -# The Objective C build needs Xcode 7.0 or later. -osx_image: xcode7.2 -script: - - ./tests.sh $CONFIG -env: - - CONFIG=cpp - - CONFIG=cpp_distcheck - - CONFIG=csharp - - CONFIG=golang - - CONFIG=java_jdk6 - - CONFIG=java_jdk7 - - CONFIG=java_oracle7 - - CONFIG=javanano_jdk6 - - CONFIG=javanano_jdk7 - - CONFIG=javanano_oracle7 - - CONFIG=javascript - - CONFIG=python - - CONFIG=python_cpp - - CONFIG=ruby19 - - CONFIG=ruby20 - - CONFIG=ruby21 - - CONFIG=ruby22 - - CONFIG=jruby -matrix: - exclude: - # It's nontrivial to programmatically install a new JDK from the command - # line on OS X, so we rely on testing on Linux for Java code. - - os: osx - env: CONFIG=java_jdk6 - - os: osx - env: CONFIG=java_jdk7 - - os: osx - env: CONFIG=java_oracle7 - - os: osx - env: CONFIG=javanano_jdk6 - - os: osx - env: CONFIG=javanano_jdk7 - - os: osx - env: CONFIG=javanano_oracle7 - # Requires installing mono, currently travis.sh is doing that with apt-get - # which doesn't work on OS X. - - os: osx - env: CONFIG=csharp - # Requires installing golang, currently travis.sh is doing that with apt-get - # which doesn't work on OS X. - - os: osx - env: CONFIG=golang - # Add into the matrix OS X tests of Objective C (needs Xcode, so it won't - # work on other platforms). These are split so it doesn't take as long to run. - include: - - os: osx - env: CONFIG=objectivec_ios - - os: osx - env: CONFIG=objectivec_osx - allow_failures: - # These currently do not work on OS X but are being worked on by @haberman. - - os: osx - env: CONFIG=ruby22 - - os: osx - env: CONFIG=jruby - # https://github.com/google/protobuf/issues/1253 - Started failing when - # we moved to an OS X image that is 10.11. - - os: osx - env: CONFIG=python_cpp - # xctool 0.2.8 seems to have a bug where it randomly kills tests saying - # they failed. - # https://github.com/facebook/xctool/issues/619 - # https://github.com/google/protobuf/issues/1232 - # travis updated their images to include 0.2.8: - # https://blog.travis-ci.com/2016-03-23-xcode-image-updates - # Mark the iOS test as flakey so these failures don't turn things red. - - os: osx - env: CONFIG=objectivec_ios -notifications: - email: false diff --git a/third_party/protobuf/BUILD b/third_party/protobuf/BUILD index 8b1046b90d5c..44beeb298186 100644 --- a/third_party/protobuf/BUILD +++ b/third_party/protobuf/BUILD @@ -1,91 +1,131 @@ -# Bazel (http://bazel.io/) BUILD file for Protobuf. +# Bazel (https://bazel.build/) BUILD file for Protobuf. licenses(["notice"]) +exports_files(["LICENSE"]) + ################################################################################ -# Protobuf Runtime Library +# Java 9 configuration ################################################################################ -COPTS = [ - "-DHAVE_PTHREAD", - "-Wall", - "-Wwrite-strings", - "-Woverloaded-virtual", - "-Wno-sign-compare", - "-Wno-error=unused-function", -] - config_setting( - name = "android", + name = "jdk9", values = { - "crosstool_top": "//external:android/crosstool", + "java_toolchain": "@bazel_tools//tools/jdk:toolchain_jdk9", }, ) -# Android builds do not need to link in a separate pthread library. -LINK_OPTS = select({ - ":android": [], - "//conditions:default": ["-lpthread"], +################################################################################ +# ZLIB configuration +################################################################################ + +ZLIB_DEPS = ["@zlib//:zlib"] + +################################################################################ +# Protobuf Runtime Library +################################################################################ + +MSVC_COPTS = [ + "/DHAVE_PTHREAD", + "/wd4018", # -Wno-sign-compare + "/wd4065", # switch statement contains 'default' but no 'case' labels + "/wd4146", # unary minus operator applied to unsigned type, result still unsigned + "/wd4244", # 'conversion' conversion from 'type1' to 'type2', possible loss of data + "/wd4251", # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' + "/wd4267", # 'var' : conversion from 'size_t' to 'type', possible loss of data + "/wd4305", # 'identifier' : truncation from 'type1' to 'type2' + "/wd4307", # 'operator' : integral constant overflow + "/wd4309", # 'conversion' : truncation of constant value + "/wd4334", # 'operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) + "/wd4355", # 'this' : used in base member initializer list + "/wd4506", # no definition for inline function 'function' + "/wd4514", # -Wno-unused-function + "/wd4800", # 'type' : forcing value to bool 'true' or 'false' (performance warning) + "/wd4996", # The compiler encountered a deprecated declaration. +] + +COPTS = select({ + ":msvc" : MSVC_COPTS, + "//conditions:default": [ + "-DHAVE_PTHREAD", + "-DHAVE_ZLIB", + "-Woverloaded-virtual", + "-Wno-sign-compare", + "-Wno-unused-function", + # Prevents ISO C++ const string assignment warnings for pyext sources. + "-Wno-write-strings", + ], }) -load( - "protobuf", - "cc_proto_library", - "py_proto_library", - "internal_gen_well_known_protos_java", - "internal_protobuf_py_tests", -) +load(":compiler_config_setting.bzl", "create_compiler_config_setting") + +create_compiler_config_setting(name = "msvc", value = "msvc-cl") config_setting( - name = "ios_armv7", + name = "android", values = { - "ios_cpu": "armv7", + "crosstool_top": "//external:android/crosstool", }, ) config_setting( - name = "ios_armv7s", + name = "android-libcpp", values = { - "ios_cpu": "armv7s", + "crosstool_top": "@androidndk//:toolchain-libcpp", }, ) config_setting( - name = "ios_arm64", + name = "android-gnu-libstdcpp", values = { - "ios_cpu": "arm64", + "crosstool_top": "@androidndk//:toolchain-gnu-libstdcpp", }, ) -IOS_ARM_COPTS = COPTS + [ - "-DOS_IOS", - "-miphoneos-version-min=7.0", - "-arch armv7", - "-arch armv7s", - "-arch arm64", - "-D__thread=", - "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/", -] +# Android and MSVC builds do not need to link in a separate pthread library. +LINK_OPTS = select({ + ":android": [], + ":android-libcpp": [], + ":android-gnu-libstdcpp": [], + ":msvc": [ + # Suppress linker warnings about files with no symbols defined. + "-ignore:4221", + ], + "//conditions:default": ["-lpthread", "-lm"], +}) + +load( + ":protobuf.bzl", + "cc_proto_library", + "py_proto_library", + "internal_copied_filegroup", + "internal_gen_well_known_protos_java", + "internal_protobuf_py_tests", +) cc_library( name = "protobuf_lite", srcs = [ # AUTOGEN(protobuf_lite_srcs) + "src/google/protobuf/any_lite.cc", "src/google/protobuf/arena.cc", - "src/google/protobuf/arenastring.cc", "src/google/protobuf/extension_set.cc", + "src/google/protobuf/generated_enum_util.cc", + "src/google/protobuf/generated_message_table_driven_lite.cc", "src/google/protobuf/generated_message_util.cc", + "src/google/protobuf/implicit_weak_message.cc", "src/google/protobuf/io/coded_stream.cc", + "src/google/protobuf/io/io_win32.cc", + "src/google/protobuf/io/strtod.cc", "src/google/protobuf/io/zero_copy_stream.cc", + "src/google/protobuf/io/zero_copy_stream_impl.cc", "src/google/protobuf/io/zero_copy_stream_impl_lite.cc", "src/google/protobuf/message_lite.cc", + "src/google/protobuf/parse_context.cc", "src/google/protobuf/repeated_field.cc", - "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc", - "src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc", "src/google/protobuf/stubs/bytestream.cc", "src/google/protobuf/stubs/common.cc", "src/google/protobuf/stubs/int128.cc", - "src/google/protobuf/stubs/once.cc", "src/google/protobuf/stubs/status.cc", "src/google/protobuf/stubs/statusor.cc", "src/google/protobuf/stubs/stringpiece.cc", @@ -95,18 +135,18 @@ cc_library( "src/google/protobuf/stubs/time.cc", "src/google/protobuf/wire_format_lite.cc", ], - hdrs = glob(["src/google/protobuf/**/*.h"]), - copts = select({ - ":ios_armv7": IOS_ARM_COPTS, - ":ios_armv7s": IOS_ARM_COPTS, - ":ios_arm64": IOS_ARM_COPTS, - "//conditions:default": COPTS, - }), + hdrs = glob(["src/google/protobuf/**/*.h", "src/google/protobuf/**/*.inc"]), + copts = COPTS, includes = ["src/"], linkopts = LINK_OPTS, visibility = ["//visibility:public"], ) +PROTOBUF_DEPS = select({ + ":msvc": [], + "//conditions:default": ZLIB_DEPS, +}) + cc_library( name = "protobuf", srcs = [ @@ -125,11 +165,10 @@ cc_library( "src/google/protobuf/extension_set_heavy.cc", "src/google/protobuf/field_mask.pb.cc", "src/google/protobuf/generated_message_reflection.cc", + "src/google/protobuf/generated_message_table_driven.cc", "src/google/protobuf/io/gzip_stream.cc", "src/google/protobuf/io/printer.cc", - "src/google/protobuf/io/strtod.cc", "src/google/protobuf/io/tokenizer.cc", - "src/google/protobuf/io/zero_copy_stream_impl.cc", "src/google/protobuf/map_field.cc", "src/google/protobuf/message.cc", "src/google/protobuf/reflection_ops.cc", @@ -142,6 +181,7 @@ cc_library( "src/google/protobuf/timestamp.pb.cc", "src/google/protobuf/type.pb.cc", "src/google/protobuf/unknown_field_set.cc", + "src/google/protobuf/util/delimited_message_util.cc", "src/google/protobuf/util/field_comparator.cc", "src/google/protobuf/util/field_mask_util.cc", "src/google/protobuf/util/internal/datapiece.cc", @@ -165,42 +205,43 @@ cc_library( "src/google/protobuf/wire_format.cc", "src/google/protobuf/wrappers.pb.cc", ], - hdrs = glob(["src/**/*.h"]), - copts = select({ - ":ios_armv7": IOS_ARM_COPTS, - ":ios_armv7s": IOS_ARM_COPTS, - ":ios_arm64": IOS_ARM_COPTS, - "//conditions:default": COPTS, - }), + hdrs = glob(["src/**/*.h", "src/**/*.inc"]), + copts = COPTS, includes = ["src/"], linkopts = LINK_OPTS, visibility = ["//visibility:public"], - deps = [":protobuf_lite"], + deps = [":protobuf_lite"] + PROTOBUF_DEPS, ) -objc_library( - name = "protobuf_objc", - hdrs = ["objectivec/GPBProtocolBuffers.h"], - includes = ["objectivec"], - non_arc_srcs = ["objectivec/GPBProtocolBuffers.m"], +# This provides just the header files for use in projects that need to build +# shared libraries for dynamic loading. This target is available until Bazel +# adds native support for such use cases. +# TODO(keveman): Remove this target once the support gets added to Bazel. +cc_library( + name = "protobuf_headers", + hdrs = glob(["src/**/*.h", "src/**/*.inc"]), + includes = ["src/"], visibility = ["//visibility:public"], ) -RELATIVE_WELL_KNOWN_PROTOS = [ - # AUTOGEN(well_known_protos) - "google/protobuf/any.proto", - "google/protobuf/api.proto", - "google/protobuf/compiler/plugin.proto", - "google/protobuf/descriptor.proto", - "google/protobuf/duration.proto", - "google/protobuf/empty.proto", - "google/protobuf/field_mask.proto", - "google/protobuf/source_context.proto", - "google/protobuf/struct.proto", - "google/protobuf/timestamp.proto", - "google/protobuf/type.proto", - "google/protobuf/wrappers.proto", -] +# Map of all well known protos. +# name => (include path, imports) +WELL_KNOWN_PROTO_MAP = { + "any" : ("google/protobuf/any.proto", []), + "api" : ("google/protobuf/api.proto", ["source_context", "type"]), + "compiler_plugin" : ("google/protobuf/compiler/plugin.proto", ["descriptor"]), + "descriptor" : ("google/protobuf/descriptor.proto", []), + "duration" : ("google/protobuf/duration.proto", []), + "empty" : ("google/protobuf/empty.proto", []), + "field_mask" : ("google/protobuf/field_mask.proto", []), + "source_context" : ("google/protobuf/source_context.proto", []), + "struct" : ("google/protobuf/struct.proto", []), + "timestamp" : ("google/protobuf/timestamp.proto", []), + "type" : ("google/protobuf/type.proto", ["any", "source_context"]), + "wrappers" : ("google/protobuf/wrappers.proto", []), +} + +RELATIVE_WELL_KNOWN_PROTOS = [proto[1][0] for proto in WELL_KNOWN_PROTO_MAP.items()] WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS] @@ -220,6 +261,33 @@ cc_proto_library( visibility = ["//visibility:public"], ) +################################################################################ +# Well Known Types Proto Library Rules +# +# These proto_library rules can be used with one of the language specific proto +# library rules i.e. java_proto_library: +# +# java_proto_library( +# name = "any_java_proto", +# deps = ["@com_google_protobuf//:any_proto], +# ) +################################################################################ + +internal_copied_filegroup( + name = "_internal_wkt_protos", + srcs = WELL_KNOWN_PROTOS, + dest = "", + strip_prefix = "src", + visibility = ["//visibility:private"], +) + +[proto_library( + name = proto[0] + "_proto", + srcs = [proto[1][0]], + deps = [dep + "_proto" for dep in proto[1][1]], + visibility = ["//visibility:public"], + ) for proto in WELL_KNOWN_PROTO_MAP.items()] + ################################################################################ # Protocol Buffers Compiler ################################################################################ @@ -240,6 +308,7 @@ cc_library( "src/google/protobuf/compiler/cpp/cpp_map_field.cc", "src/google/protobuf/compiler/cpp/cpp_message.cc", "src/google/protobuf/compiler/cpp/cpp_message_field.cc", + "src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc", "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc", "src/google/protobuf/compiler/cpp/cpp_service.cc", "src/google/protobuf/compiler/cpp/cpp_string_field.cc", @@ -272,8 +341,6 @@ cc_library( "src/google/protobuf/compiler/java/java_generator.cc", "src/google/protobuf/compiler/java/java_generator_factory.cc", "src/google/protobuf/compiler/java/java_helpers.cc", - "src/google/protobuf/compiler/java/java_lazy_message_field.cc", - "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc", "src/google/protobuf/compiler/java/java_map_field.cc", "src/google/protobuf/compiler/java/java_map_field_lite.cc", "src/google/protobuf/compiler/java/java_message.cc", @@ -289,18 +356,8 @@ cc_library( "src/google/protobuf/compiler/java/java_shared_code_generator.cc", "src/google/protobuf/compiler/java/java_string_field.cc", "src/google/protobuf/compiler/java/java_string_field_lite.cc", - "src/google/protobuf/compiler/javanano/javanano_enum.cc", - "src/google/protobuf/compiler/javanano/javanano_enum_field.cc", - "src/google/protobuf/compiler/javanano/javanano_extension.cc", - "src/google/protobuf/compiler/javanano/javanano_field.cc", - "src/google/protobuf/compiler/javanano/javanano_file.cc", - "src/google/protobuf/compiler/javanano/javanano_generator.cc", - "src/google/protobuf/compiler/javanano/javanano_helpers.cc", - "src/google/protobuf/compiler/javanano/javanano_map_field.cc", - "src/google/protobuf/compiler/javanano/javanano_message.cc", - "src/google/protobuf/compiler/javanano/javanano_message_field.cc", - "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc", "src/google/protobuf/compiler/js/js_generator.cc", + "src/google/protobuf/compiler/js/well_known_types_embed.cc", "src/google/protobuf/compiler/objectivec/objectivec_enum.cc", "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc", "src/google/protobuf/compiler/objectivec/objectivec_extension.cc", @@ -313,6 +370,7 @@ cc_library( "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc", "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc", "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc", + "src/google/protobuf/compiler/php/php_generator.cc", "src/google/protobuf/compiler/plugin.cc", "src/google/protobuf/compiler/plugin.pb.cc", "src/google/protobuf/compiler/python/python_generator.cc", @@ -322,7 +380,25 @@ cc_library( ], copts = COPTS, includes = ["src/"], - linkopts = LINK_OPTS, + linkopts = LINK_OPTS + select({ + ":msvc": [ + # Linking to setargv.obj makes the default command line argument + # parser expand wildcards, so the main method's argv will contain the + # expanded list instead of the wildcards. + # + # Adding dummy "-DEFAULTLIB:kernel32.lib", because: + # - Microsoft ships this object file next to default libraries + # - but this file is not a library, just a precompiled object + # - "-WHOLEARCHIVE" and "-DEFAULTLIB" only accept library, + # not precompiled object. + # - Bazel would assume linkopt that does not start with "-" or "$" + # as a label to a target, so we add a harmless "-DEFAULTLIB:kernel32.lib" + # before "setargv.obj". + # See https://msdn.microsoft.com/en-us/library/8bch7bkk.aspx + "-DEFAULTLIB:kernel32.lib setargv.obj", + ], + "//conditions:default": [], + }), visibility = ["//visibility:public"], deps = [":protobuf"], ) @@ -366,6 +442,9 @@ RELATIVE_TEST_PROTOS = [ "google/protobuf/unittest_enormous_descriptor.proto", "google/protobuf/unittest_import.proto", "google/protobuf/unittest_import_public.proto", + "google/protobuf/unittest_lazy_dependencies.proto", + "google/protobuf/unittest_lazy_dependencies_custom_option.proto", + "google/protobuf/unittest_lazy_dependencies_enum.proto", "google/protobuf/unittest_lite_imports_nonlite.proto", "google/protobuf/unittest_mset.proto", "google/protobuf/unittest_mset_wire_format.proto", @@ -376,6 +455,7 @@ RELATIVE_TEST_PROTOS = [ "google/protobuf/unittest_optimize_for.proto", "google/protobuf/unittest_preserve_unknown_enum.proto", "google/protobuf/unittest_preserve_unknown_enum2.proto", + "google/protobuf/unittest_proto3.proto", "google/protobuf/unittest_proto3_arena.proto", "google/protobuf/unittest_proto3_arena_lite.proto", "google/protobuf/unittest_proto3_lite.proto", @@ -387,8 +467,11 @@ RELATIVE_TEST_PROTOS = [ "google/protobuf/util/internal/testdata/field_mask.proto", "google/protobuf/util/internal/testdata/maps.proto", "google/protobuf/util/internal/testdata/oneofs.proto", + "google/protobuf/util/internal/testdata/proto3.proto", "google/protobuf/util/internal/testdata/struct.proto", "google/protobuf/util/internal/testdata/timestamp_duration.proto", + "google/protobuf/util/internal/testdata/wrappers.proto", + "google/protobuf/util/json_format.proto", "google/protobuf/util/json_format_proto3.proto", "google/protobuf/util/message_differencer_unittest.proto", ] @@ -409,6 +492,7 @@ COMMON_TEST_SRCS = [ "src/google/protobuf/arena_test_util.cc", "src/google/protobuf/map_test_util.cc", "src/google/protobuf/test_util.cc", + "src/google/protobuf/test_util.inc", "src/google/protobuf/testing/file.cc", "src/google/protobuf/testing/googletest.cc", ] @@ -428,6 +512,16 @@ cc_binary( ], ) +cc_test( + name = "win32_test", + srcs = ["src/google/protobuf/io/io_win32_unittest.cc"], + deps = [ + ":protobuf_lite", + "//external:gtest_main", + ], + tags = ["manual", "windows"], +) + cc_test( name = "protobuf_test", srcs = COMMON_TEST_SRCS + [ @@ -435,11 +529,14 @@ cc_test( "src/google/protobuf/any_test.cc", "src/google/protobuf/arena_unittest.cc", "src/google/protobuf/arenastring_unittest.cc", - "src/google/protobuf/compiler/command_line_interface_unittest.cc", + "src/google/protobuf/compiler/annotation_test_util.cc", "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc", + "src/google/protobuf/compiler/cpp/cpp_move_unittest.cc", "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc", "src/google/protobuf/compiler/cpp/cpp_unittest.cc", + "src/google/protobuf/compiler/cpp/cpp_unittest.inc", "src/google/protobuf/compiler/cpp/metadata_test.cc", + "src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc", "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc", "src/google/protobuf/compiler/importer_unittest.cc", "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc", @@ -456,24 +553,26 @@ cc_test( "src/google/protobuf/extension_set_unittest.cc", "src/google/protobuf/generated_message_reflection_unittest.cc", "src/google/protobuf/io/coded_stream_unittest.cc", + "src/google/protobuf/io/io_win32_unittest.cc", "src/google/protobuf/io/printer_unittest.cc", "src/google/protobuf/io/tokenizer_unittest.cc", "src/google/protobuf/io/zero_copy_stream_unittest.cc", "src/google/protobuf/map_field_test.cc", "src/google/protobuf/map_test.cc", "src/google/protobuf/message_unittest.cc", + "src/google/protobuf/message_unittest.inc", "src/google/protobuf/no_field_presence_test.cc", "src/google/protobuf/preserve_unknown_enum_test.cc", "src/google/protobuf/proto3_arena_lite_unittest.cc", "src/google/protobuf/proto3_arena_unittest.cc", "src/google/protobuf/proto3_lite_unittest.cc", + "src/google/protobuf/proto3_lite_unittest.inc", "src/google/protobuf/reflection_ops_unittest.cc", "src/google/protobuf/repeated_field_reflection_unittest.cc", "src/google/protobuf/repeated_field_unittest.cc", "src/google/protobuf/stubs/bytestream_unittest.cc", "src/google/protobuf/stubs/common_unittest.cc", "src/google/protobuf/stubs/int128_unittest.cc", - "src/google/protobuf/stubs/once_unittest.cc", "src/google/protobuf/stubs/status_test.cc", "src/google/protobuf/stubs/statusor_test.cc", "src/google/protobuf/stubs/stringpiece_unittest.cc", @@ -482,9 +581,9 @@ cc_test( "src/google/protobuf/stubs/strutil_unittest.cc", "src/google/protobuf/stubs/template_util_unittest.cc", "src/google/protobuf/stubs/time_test.cc", - "src/google/protobuf/stubs/type_traits_unittest.cc", "src/google/protobuf/text_format_unittest.cc", "src/google/protobuf/unknown_field_set_unittest.cc", + "src/google/protobuf/util/delimited_message_util_test.cc", "src/google/protobuf/util/field_comparator_test.cc", "src/google/protobuf/util/field_mask_util_test.cc", "src/google/protobuf/util/internal/default_value_objectwriter_test.cc", @@ -499,12 +598,21 @@ cc_test( "src/google/protobuf/util/type_resolver_util_test.cc", "src/google/protobuf/well_known_types_unittest.cc", "src/google/protobuf/wire_format_unittest.cc", - ], + ] + select({ + "//conditions:default" : [ + # Doesn't pass on Windows with MSVC + "src/google/protobuf/compiler/command_line_interface_unittest.cc", + ], + ":msvc": [] + }), copts = COPTS, data = [ ":test_plugin", ] + glob([ "src/google/protobuf/**/*", + # Files for csharp_bootstrap_unittest.cc. + "conformance/**/*", + "csharp/src/**/*", ]), includes = [ "src/", @@ -515,7 +623,7 @@ cc_test( ":protobuf", ":protoc_lib", "//external:gtest_main", - ], + ] + PROTOBUF_DEPS, ) ################################################################################ @@ -532,6 +640,111 @@ java_library( ]) + [ ":gen_well_known_protos_java", ], + javacopts = select({ + "//:jdk9": ["--add-modules=jdk.unsupported"], + "//conditions:default": ["-source 7", "-target 7"], + }), + visibility = ["//visibility:public"], +) + +java_library( + name = "protobuf_javalite", + srcs = [ + # Keep in sync with java/lite/pom.xml + "java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java", + "java/core/src/main/java/com/google/protobuf/AbstractParser.java", + "java/core/src/main/java/com/google/protobuf/AbstractProtobufList.java", + "java/core/src/main/java/com/google/protobuf/AllocatedBuffer.java", + "java/core/src/main/java/com/google/protobuf/Android.java", + "java/core/src/main/java/com/google/protobuf/ArrayDecoders.java", + "java/core/src/main/java/com/google/protobuf/BinaryReader.java", + "java/core/src/main/java/com/google/protobuf/BinaryWriter.java", + "java/core/src/main/java/com/google/protobuf/BooleanArrayList.java", + "java/core/src/main/java/com/google/protobuf/BufferAllocator.java", + "java/core/src/main/java/com/google/protobuf/ByteBufferWriter.java", + "java/core/src/main/java/com/google/protobuf/ByteOutput.java", + "java/core/src/main/java/com/google/protobuf/ByteString.java", + "java/core/src/main/java/com/google/protobuf/CodedInputStream.java", + "java/core/src/main/java/com/google/protobuf/CodedInputStreamReader.java", + "java/core/src/main/java/com/google/protobuf/CodedOutputStream.java", + "java/core/src/main/java/com/google/protobuf/CodedOutputStreamWriter.java", + "java/core/src/main/java/com/google/protobuf/DoubleArrayList.java", + "java/core/src/main/java/com/google/protobuf/ExperimentalApi.java", + "java/core/src/main/java/com/google/protobuf/ExtensionLite.java", + "java/core/src/main/java/com/google/protobuf/ExtensionRegistryFactory.java", + "java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java", + "java/core/src/main/java/com/google/protobuf/ExtensionSchema.java", + "java/core/src/main/java/com/google/protobuf/ExtensionSchemaLite.java", + "java/core/src/main/java/com/google/protobuf/ExtensionSchemas.java", + "java/core/src/main/java/com/google/protobuf/FieldInfo.java", + "java/core/src/main/java/com/google/protobuf/FieldSet.java", + "java/core/src/main/java/com/google/protobuf/FieldType.java", + "java/core/src/main/java/com/google/protobuf/FloatArrayList.java", + "java/core/src/main/java/com/google/protobuf/GeneratedMessageInfoFactory.java", + "java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java", + "java/core/src/main/java/com/google/protobuf/IntArrayList.java", + "java/core/src/main/java/com/google/protobuf/Internal.java", + "java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java", + "java/core/src/main/java/com/google/protobuf/IterableByteBufferInputStream.java", + "java/core/src/main/java/com/google/protobuf/JavaType.java", + "java/core/src/main/java/com/google/protobuf/LazyField.java", + "java/core/src/main/java/com/google/protobuf/LazyFieldLite.java", + "java/core/src/main/java/com/google/protobuf/LazyStringArrayList.java", + "java/core/src/main/java/com/google/protobuf/LazyStringList.java", + "java/core/src/main/java/com/google/protobuf/ListFieldSchema.java", + "java/core/src/main/java/com/google/protobuf/LongArrayList.java", + "java/core/src/main/java/com/google/protobuf/ManifestSchemaFactory.java", + "java/core/src/main/java/com/google/protobuf/MapEntryLite.java", + "java/core/src/main/java/com/google/protobuf/MapFieldLite.java", + "java/core/src/main/java/com/google/protobuf/MapFieldSchema.java", + "java/core/src/main/java/com/google/protobuf/MapFieldSchemaLite.java", + "java/core/src/main/java/com/google/protobuf/MapFieldSchemas.java", + "java/core/src/main/java/com/google/protobuf/MessageInfo.java", + "java/core/src/main/java/com/google/protobuf/MessageInfoFactory.java", + "java/core/src/main/java/com/google/protobuf/MessageLite.java", + "java/core/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java", + "java/core/src/main/java/com/google/protobuf/MessageLiteToString.java", + "java/core/src/main/java/com/google/protobuf/MessageSchema.java", + "java/core/src/main/java/com/google/protobuf/MessageSetSchema.java", + "java/core/src/main/java/com/google/protobuf/MutabilityOracle.java", + "java/core/src/main/java/com/google/protobuf/NewInstanceSchema.java", + "java/core/src/main/java/com/google/protobuf/NewInstanceSchemaLite.java", + "java/core/src/main/java/com/google/protobuf/NewInstanceSchemas.java", + "java/core/src/main/java/com/google/protobuf/NioByteString.java", + "java/core/src/main/java/com/google/protobuf/OneofInfo.java", + "java/core/src/main/java/com/google/protobuf/Parser.java", + "java/core/src/main/java/com/google/protobuf/PrimitiveNonBoxingCollection.java", + "java/core/src/main/java/com/google/protobuf/ProtoSyntax.java", + "java/core/src/main/java/com/google/protobuf/Protobuf.java", + "java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java", + "java/core/src/main/java/com/google/protobuf/ProtobufLists.java", + "java/core/src/main/java/com/google/protobuf/ProtocolStringList.java", + "java/core/src/main/java/com/google/protobuf/RawMessageInfo.java", + "java/core/src/main/java/com/google/protobuf/Reader.java", + "java/core/src/main/java/com/google/protobuf/RopeByteString.java", + "java/core/src/main/java/com/google/protobuf/Schema.java", + "java/core/src/main/java/com/google/protobuf/SchemaFactory.java", + "java/core/src/main/java/com/google/protobuf/SchemaUtil.java", + "java/core/src/main/java/com/google/protobuf/SmallSortedMap.java", + "java/core/src/main/java/com/google/protobuf/StructuralMessageInfo.java", + "java/core/src/main/java/com/google/protobuf/TextFormatEscaper.java", + "java/core/src/main/java/com/google/protobuf/UninitializedMessageException.java", + "java/core/src/main/java/com/google/protobuf/UnknownFieldSchema.java", + "java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java", + "java/core/src/main/java/com/google/protobuf/UnknownFieldSetLiteSchema.java", + "java/core/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java", + "java/core/src/main/java/com/google/protobuf/UnsafeUtil.java", + "java/core/src/main/java/com/google/protobuf/Utf8.java", + "java/core/src/main/java/com/google/protobuf/WireFormat.java", + "java/core/src/main/java/com/google/protobuf/Writer.java", + ], + javacopts = select({ + "//:jdk9": ["--add-modules=jdk.unsupported"], + "//conditions:default": [ + "-source 7", + "-target 7", + ], + }), visibility = ["//visibility:public"], ) @@ -540,12 +753,14 @@ java_library( srcs = glob([ "java/util/src/main/java/com/google/protobuf/util/*.java", ]), + javacopts = ["-source 7", "-target 7"], + visibility = ["//visibility:public"], deps = [ "protobuf_java", + "//external:error_prone_annotations", "//external:gson", "//external:guava", ], - visibility = ["//visibility:public"], ) ################################################################################ @@ -556,20 +771,23 @@ py_library( name = "python_srcs", srcs = glob( [ + "python/google/__init__.py", "python/google/protobuf/*.py", "python/google/protobuf/**/*.py", ], exclude = [ + "python/google/protobuf/__init__.py", + "python/google/protobuf/**/__init__.py", "python/google/protobuf/internal/*_test.py", "python/google/protobuf/internal/test_util.py", ], ), - srcs_version = "PY2AND3", imports = ["python"], + srcs_version = "PY2AND3", ) cc_binary( - name = "internal/_api_implementation.so", + name = "python/google/protobuf/internal/_api_implementation.so", srcs = ["python/google/protobuf/internal/api_implementation.cc"], copts = COPTS + [ "-DPYTHON_PROTO2_CPP_IMPL_V2", @@ -583,7 +801,7 @@ cc_binary( ) cc_binary( - name = "pyext/_message.so", + name = "python/google/protobuf/pyext/_message.so", srcs = glob([ "python/google/protobuf/pyext/*.cc", "python/google/protobuf/pyext/*.h", @@ -602,6 +820,7 @@ cc_binary( linkstatic = 1, deps = [ ":protobuf", + ":proto_api", ] + select({ "//conditions:default": [], ":use_fast_cpp_protos": ["//external:python_headers"], @@ -622,31 +841,66 @@ config_setting( }, ) +# Copy the builtin proto files from src/google/protobuf to +# python/google/protobuf. This way, the generated Python sources will be in the +# same directory as the Python runtime sources. This is necessary for the +# modules to be imported correctly since they are all part of the same Python +# package. +internal_copied_filegroup( + name = "protos_python", + srcs = WELL_KNOWN_PROTOS, + dest = "python", + strip_prefix = "src", +) + +# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in +# which case we can simply add :protos_python in srcs. +COPIED_WELL_KNOWN_PROTOS = ["python/" + s for s in RELATIVE_WELL_KNOWN_PROTOS] + py_proto_library( name = "protobuf_python", - srcs = WELL_KNOWN_PROTOS, - include = "src", + srcs = COPIED_WELL_KNOWN_PROTOS, + include = "python", data = select({ "//conditions:default": [], ":use_fast_cpp_protos": [ - ":internal/_api_implementation.so", - ":pyext/_message.so", + ":python/google/protobuf/internal/_api_implementation.so", + ":python/google/protobuf/pyext/_message.so", ], }), default_runtime = "", protoc = ":protoc", py_libs = [ ":python_srcs", - "//external:six" + "//external:six", ], + py_extra_srcs = glob(["python/**/__init__.py"]), srcs_version = "PY2AND3", visibility = ["//visibility:public"], ) +# Copy the test proto files from src/google/protobuf to +# python/google/protobuf. This way, the generated Python sources will be in the +# same directory as the Python runtime sources. This is necessary for the +# modules to be imported correctly by the tests since they are all part of the +# same Python package. +internal_copied_filegroup( + name = "protos_python_test", + srcs = LITE_TEST_PROTOS + TEST_PROTOS, + dest = "python", + strip_prefix = "src", +) + +# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in +# which case we can simply add :protos_python_test in srcs. +COPIED_LITE_TEST_PROTOS = ["python/" + s for s in RELATIVE_LITE_TEST_PROTOS] + +COPIED_TEST_PROTOS = ["python/" + s for s in RELATIVE_TEST_PROTOS] + py_proto_library( name = "python_common_test_protos", - srcs = LITE_TEST_PROTOS + TEST_PROTOS, - include = "src", + srcs = COPIED_LITE_TEST_PROTOS + COPIED_TEST_PROTOS, + include = "python", default_runtime = "", protoc = ":protoc", srcs_version = "PY2AND3", @@ -672,6 +926,7 @@ py_library( [ "python/google/protobuf/internal/*_test.py", "python/google/protobuf/internal/test_util.py", + "python/google/protobuf/internal/import_test_package/__init__.py", ], ), imports = ["python"], @@ -707,3 +962,243 @@ internal_protobuf_py_tests( ], deps = [":python_tests"], ) + +cc_library( + name = "proto_api", + hdrs = ["python/google/protobuf/proto_api.h"], + deps = [ + "//external:python_headers", + ], + visibility = ["//visibility:public"], +) + +proto_lang_toolchain( + name = "cc_toolchain", + command_line = "--cpp_out=$(OUT)", + runtime = ":protobuf", + visibility = ["//visibility:public"], + blacklisted_protos = [":_internal_wkt_protos_genrule"], +) + +proto_lang_toolchain( + name = "java_toolchain", + command_line = "--java_out=$(OUT)", + runtime = ":protobuf_java", + visibility = ["//visibility:public"], +) + +alias( + name = "objectivec", + actual = ":protobuf_objc", + visibility = ["//visibility:public"], +) + +objc_library( + name = "protobuf_objc", + hdrs = [ + "objectivec/GPBArray.h", + "objectivec/GPBBootstrap.h", + "objectivec/GPBCodedInputStream.h", + "objectivec/GPBCodedOutputStream.h", + "objectivec/GPBDescriptor.h", + "objectivec/GPBDictionary.h", + "objectivec/GPBExtensionInternals.h", + "objectivec/GPBExtensionRegistry.h", + "objectivec/GPBMessage.h", + "objectivec/GPBProtocolBuffers.h", + "objectivec/GPBProtocolBuffers_RuntimeSupport.h", + "objectivec/GPBRootObject.h", + "objectivec/GPBRuntimeTypes.h", + "objectivec/GPBUnknownField.h", + "objectivec/GPBUnknownFieldSet.h", + "objectivec/GPBUtilities.h", + "objectivec/GPBWellKnownTypes.h", + "objectivec/GPBWireFormat.h", + "objectivec/google/protobuf/Any.pbobjc.h", + "objectivec/google/protobuf/Api.pbobjc.h", + "objectivec/google/protobuf/Duration.pbobjc.h", + "objectivec/google/protobuf/Empty.pbobjc.h", + "objectivec/google/protobuf/FieldMask.pbobjc.h", + "objectivec/google/protobuf/SourceContext.pbobjc.h", + "objectivec/google/protobuf/Struct.pbobjc.h", + "objectivec/google/protobuf/Timestamp.pbobjc.h", + "objectivec/google/protobuf/Type.pbobjc.h", + "objectivec/google/protobuf/Wrappers.pbobjc.h", + # Package private headers, but exposed because the generated sources + # need to use them. + "objectivec/GPBArray_PackagePrivate.h", + "objectivec/GPBCodedInputStream_PackagePrivate.h", + "objectivec/GPBCodedOutputStream_PackagePrivate.h", + "objectivec/GPBDescriptor_PackagePrivate.h", + "objectivec/GPBDictionary_PackagePrivate.h", + "objectivec/GPBMessage_PackagePrivate.h", + "objectivec/GPBRootObject_PackagePrivate.h", + "objectivec/GPBUnknownFieldSet_PackagePrivate.h", + "objectivec/GPBUnknownField_PackagePrivate.h", + "objectivec/GPBUtilities_PackagePrivate.h", + ], + copts = [ + "-Wno-vla", + ], + includes = [ + "objectivec", + ], + non_arc_srcs = [ + "objectivec/GPBArray.m", + "objectivec/GPBCodedInputStream.m", + "objectivec/GPBCodedOutputStream.m", + "objectivec/GPBDescriptor.m", + "objectivec/GPBDictionary.m", + "objectivec/GPBExtensionInternals.m", + "objectivec/GPBExtensionRegistry.m", + "objectivec/GPBMessage.m", + "objectivec/GPBRootObject.m", + "objectivec/GPBUnknownField.m", + "objectivec/GPBUnknownFieldSet.m", + "objectivec/GPBUtilities.m", + "objectivec/GPBWellKnownTypes.m", + "objectivec/GPBWireFormat.m", + "objectivec/google/protobuf/Any.pbobjc.m", + "objectivec/google/protobuf/Api.pbobjc.m", + "objectivec/google/protobuf/Duration.pbobjc.m", + "objectivec/google/protobuf/Empty.pbobjc.m", + "objectivec/google/protobuf/FieldMask.pbobjc.m", + "objectivec/google/protobuf/SourceContext.pbobjc.m", + "objectivec/google/protobuf/Struct.pbobjc.m", + "objectivec/google/protobuf/Timestamp.pbobjc.m", + "objectivec/google/protobuf/Type.pbobjc.m", + "objectivec/google/protobuf/Wrappers.pbobjc.m", + ], + visibility = ["//visibility:public"], +) + +################################################################################ +# Test generated proto support +################################################################################ + +genrule( + name = "generated_protos", + srcs = ["src/google/protobuf/unittest_import.proto"], + outs = ["unittest_gen.proto"], + cmd = "cat $(SRCS) | sed 's|google/|src/google/|' > $(OUTS)" +) + +proto_library( + name = "generated_protos_proto", + srcs = [ + "unittest_gen.proto", + "src/google/protobuf/unittest_import_public.proto", + ], +) + +py_proto_library( + name = "generated_protos_py", + srcs = [ + "unittest_gen.proto", + "src/google/protobuf/unittest_import_public.proto", + ], + default_runtime = "", + protoc = ":protoc", +) + +################################################################################ +# Conformance tests +################################################################################ + +proto_library( + name = "test_messages_proto2_proto", + srcs = ["src/google/protobuf/test_messages_proto2.proto"], + visibility = ["//visibility:public"], +) + +proto_library( + name = "test_messages_proto3_proto", + srcs = ["src/google/protobuf/test_messages_proto3.proto"], + deps = [ + ":any_proto", + ":duration_proto", + ":field_mask_proto", + ":struct_proto", + ":timestamp_proto", + ":wrappers_proto", + ], + visibility = ["//visibility:public"], +) + +cc_proto_library( + name = "test_messages_proto2_proto_cc", + srcs = ["src/google/protobuf/test_messages_proto2.proto"], +) + +cc_proto_library( + name = "test_messages_proto3_proto_cc", + srcs = ["src/google/protobuf/test_messages_proto3.proto"], + deps = [ + ":cc_wkt_protos", + ], +) + +proto_library( + name = "conformance_proto", + srcs = ["conformance/conformance.proto"], + visibility = ["//visibility:public"], +) + +cc_proto_library( + name = "conformance_proto_cc", + srcs = ["conformance/conformance.proto"], +) + +cc_library( + name = "jsoncpp", + hdrs = ["conformance/third_party/jsoncpp/json.h"], + srcs = ["conformance/third_party/jsoncpp/jsoncpp.cpp"], + includes = ["conformance"], +) + +cc_library( + name = "conformance_test", + srcs = [ + "conformance/conformance_test.cc", + "conformance/conformance_test_runner.cc", + ], + hdrs = [ + "conformance/conformance_test.h", + ], + deps = [":conformance_proto_cc"], + includes = ["conformance", "src"], +) + +cc_library( + name = "binary_json_conformance_suite", + srcs = ["conformance/binary_json_conformance_suite.cc"], + hdrs = ["conformance/binary_json_conformance_suite.h"], + deps = [ + ":conformance_test", + ":jsoncpp", + ":test_messages_proto2_proto_cc", + ":test_messages_proto3_proto_cc", + ], +) + +cc_library( + name = "text_format_conformance_suite", + srcs = ["conformance/text_format_conformance_suite.cc"], + hdrs = ["conformance/text_format_conformance_suite.h"], + deps = [ + ":conformance_test", + ":test_messages_proto2_proto_cc", + ":test_messages_proto3_proto_cc", + ], +) + +cc_binary( + name = "conformance_test_runner", + srcs = ["conformance/conformance_test_main.cc"], + deps = [ + ":binary_json_conformance_suite", + ":conformance_test", + ":text_format_conformance_suite", + ], + visibility = ["//visibility:public"], +) diff --git a/third_party/protobuf/BUILD.gn b/third_party/protobuf/BUILD.gn index ee3076e9ffad..a9750425b12c 100644 --- a/third_party/protobuf/BUILD.gn +++ b/third_party/protobuf/BUILD.gn @@ -1,6 +1,7 @@ # Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/config/sanitizers/sanitizers.gni") config("protobuf_config") { include_dirs = [ "src" ] @@ -11,21 +12,6 @@ config("protobuf_config") { if (!is_win) { defines += [ "HAVE_PTHREAD" ] } - - if (is_starboard) { - if (is_clang) { - cflags = [ - # protobuf-3 contains a few functions that are unused. - "-Wno-unused-function", - # protobuf-3 mixes generated enum types. - "-Wno-enum-compare-switch", - # Used by older version of clang. - "-Wno-enum-compare", - # Older version of clang don't have -Wno-enum-compare-switch - "-Wno-unknown-warning-option", - ] - } - } } config("protobuf_warnings") { @@ -52,19 +38,35 @@ config("using_proto") { } protobuf_lite_sources = [ + "src/google/protobuf/any_lite.cc", "src/google/protobuf/arena.cc", "src/google/protobuf/arena.h", + "src/google/protobuf/arena_impl.h", "src/google/protobuf/arenastring.cc", "src/google/protobuf/arenastring.h", "src/google/protobuf/extension_set.cc", "src/google/protobuf/extension_set.h", + "src/google/protobuf/generated_enum_util.cc", + "src/google/protobuf/generated_enum_util.h", + "src/google/protobuf/generated_message_table_driven_lite.cc", + "src/google/protobuf/generated_message_table_driven_lite.h", "src/google/protobuf/generated_message_util.cc", "src/google/protobuf/generated_message_util.h", + "src/google/protobuf/has_bits.h", + "src/google/protobuf/implicit_weak_message.cc", + "src/google/protobuf/implicit_weak_message.h", + "src/google/protobuf/inlined_string_field.h", "src/google/protobuf/io/coded_stream.cc", "src/google/protobuf/io/coded_stream.h", "src/google/protobuf/io/coded_stream_inl.h", + "src/google/protobuf/io/io_win32.cc", + "src/google/protobuf/io/io_win32.h", + "src/google/protobuf/io/strtod.cc", + "src/google/protobuf/io/strtod.h", "src/google/protobuf/io/zero_copy_stream.cc", "src/google/protobuf/io/zero_copy_stream.h", + "src/google/protobuf/io/zero_copy_stream_impl.cc", + "src/google/protobuf/io/zero_copy_stream_impl.h", "src/google/protobuf/io/zero_copy_stream_impl_lite.cc", "src/google/protobuf/io/zero_copy_stream_impl_lite.h", "src/google/protobuf/map.h", @@ -75,24 +77,6 @@ protobuf_lite_sources = [ "src/google/protobuf/message_lite.h", "src/google/protobuf/repeated_field.cc", "src/google/protobuf/repeated_field.h", - "src/google/protobuf/stubs/atomicops.h", - "src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h", - "src/google/protobuf/stubs/atomicops_internals_arm_gcc.h", - "src/google/protobuf/stubs/atomicops_internals_arm_qnx.h", - "src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h", - "src/google/protobuf/stubs/atomicops_internals_generic_gcc.h", - "src/google/protobuf/stubs/atomicops_internals_macosx.h", - "src/google/protobuf/stubs/atomicops_internals_mips_gcc.h", - "src/google/protobuf/stubs/atomicops_internals_pnacl.h", - "src/google/protobuf/stubs/atomicops_internals_power.h", - "src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h", - "src/google/protobuf/stubs/atomicops_internals_solaris.h", - "src/google/protobuf/stubs/atomicops_internals_tsan.h", - "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc", - "src/google/protobuf/stubs/atomicops_internals_x86_gcc.h", - "src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc", - "src/google/protobuf/stubs/atomicops_internals_x86_msvc.h", - "src/google/protobuf/stubs/atomic_sequence_num.h", "src/google/protobuf/stubs/bytestream.cc", "src/google/protobuf/stubs/bytestream.h", "src/google/protobuf/stubs/callback.h", @@ -107,12 +91,9 @@ protobuf_lite_sources = [ "src/google/protobuf/stubs/macros.h", "src/google/protobuf/stubs/map_util.h", "src/google/protobuf/stubs/mutex.h", - "src/google/protobuf/stubs/once.cc", "src/google/protobuf/stubs/once.h", "src/google/protobuf/stubs/platform_macros.h", "src/google/protobuf/stubs/port.h", - "src/google/protobuf/stubs/scoped_ptr.h", - "src/google/protobuf/stubs/shared_ptr.h", "src/google/protobuf/stubs/status.cc", "src/google/protobuf/stubs/status.h", "src/google/protobuf/stubs/status_macros.h", @@ -127,12 +108,10 @@ protobuf_lite_sources = [ "src/google/protobuf/stubs/strutil.cc", "src/google/protobuf/stubs/strutil.h", "src/google/protobuf/stubs/template_util.h", - "src/google/protobuf/stubs/type_traits.h", "src/google/protobuf/stubs/time.cc", "src/google/protobuf/stubs/time.h", "src/google/protobuf/wire_format_lite.cc", "src/google/protobuf/wire_format_lite.h", - "src/google/protobuf/wire_format_lite_inl.h", ] protobuf_lite_cflags = [] @@ -151,14 +130,31 @@ if (is_win) { ] } +# Do not allow libprotobuf_lite to be dynamically linked on Linux. Later +# versions of Ubuntu like Xenial and Yakkety link in the system +# libprotobuf_lite by the following dependency chain: chrome -> gtk -> +# libmirclient -> libmirprotobuf -> libprotobuf-lite. Trying to load +# the system libprotobuf-lite after already having loaded the libprotobuf_lite +# component will result in an immediate crash. (crbug.com/700120) +if (is_component_build && is_desktop_linux) { + shared_library("mirclient") { + inputs = [ + "mirclient.map", + ] + sources = [ + "mirclient.cc", + ] + ldflags = + [ "-Wl,--version-script=" + + rebase_path("//third_party/protobuf/mirclient.map", root_build_dir) ] + output_extension = "so.9" + } +} + component("protobuf_lite") { sources = protobuf_lite_sources - if (is_starboard) { - deps = [ "//starboard/common" ] - } else if (!is_native_target_build) { configs -= [ "//build/config/compiler:chromium_code" ] - } configs += [ "//build/config/compiler:no_chromium_code", @@ -167,6 +163,12 @@ component("protobuf_lite") { ":protobuf_warnings", ] + # Remove Sanitizers and coverage for a performance boost when fuzzing. This is + # OK because the only fuzzers that use protobuf are libprotobuf-mutator based + # fuzzers, and they don't actually target the protobuf code, they just use it. + configs -= not_fuzzed_remove_configs + configs += [ "//build/config/sanitizers:not_fuzzed" ] + if (is_win) { configs -= [ "//build/config/win:lean_and_mean" ] } @@ -175,20 +177,21 @@ component("protobuf_lite") { ":protobuf_config", # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - # "//build/config/compiler:no_size_t_to_int_warning", + "//build/config/compiler:no_size_t_to_int_warning", ] - if (use_cobalt_customizations) { - public_configs -= [ ":protobuf_config" ] - all_dependent_configs = [ ":protobuf_config" ] - } else { - deps = [ - "//build/config/sanitizers:deps", - ] + if (is_android) { + libs = [ "log" ] # Used by src/google/protobuf/stubs/common.cc } cflags = protobuf_lite_cflags + if (is_component_build && is_desktop_linux) { + deps = [ + ":mirclient", + ] + } + # Required for component builds. See http://crbug.com/172800. if (is_component_build) { public_configs += [ ":protobuf_use_dlls" ] @@ -196,151 +199,168 @@ component("protobuf_lite") { } } -# Only compile the compiler for the host architecture. -if (current_toolchain == host_toolchain) { # This is the full, heavy protobuf lib that's needed for c++ .protos that don't # specify the LITE_RUNTIME option. The protocol compiler itself (protoc) falls # into that category. Do not use in Chrome code. static_library("protobuf_full") { # Prevent people from depending on this outside our file. - visibility = [ ":*" ] + visibility = [ + ":*", - sources = protobuf_lite_sources - sources += [ - "src/google/protobuf/any.cc", - "src/google/protobuf/any.h", - "src/google/protobuf/any.pb.cc", - "src/google/protobuf/any.pb.h", - "src/google/protobuf/api.pb.cc", - "src/google/protobuf/api.pb.h", - "src/google/protobuf/compiler/importer.cc", - "src/google/protobuf/compiler/importer.h", - "src/google/protobuf/compiler/parser.cc", - "src/google/protobuf/compiler/parser.h", - "src/google/protobuf/descriptor.cc", - "src/google/protobuf/descriptor.h", - "src/google/protobuf/descriptor.pb.cc", - "src/google/protobuf/descriptor.pb.h", - "src/google/protobuf/descriptor_database.cc", - "src/google/protobuf/descriptor_database.h", - "src/google/protobuf/duration.pb.cc", - "src/google/protobuf/duration.pb.h", - "src/google/protobuf/dynamic_message.cc", - "src/google/protobuf/dynamic_message.h", - "src/google/protobuf/empty.pb.cc", - "src/google/protobuf/empty.pb.h", - "src/google/protobuf/extension_set_heavy.cc", - "src/google/protobuf/field_mask.pb.cc", - "src/google/protobuf/field_mask.pb.h", - "src/google/protobuf/generated_enum_reflection.h", - "src/google/protobuf/generated_enum_util.h", - "src/google/protobuf/generated_message_reflection.cc", - "src/google/protobuf/generated_message_reflection.h", - - # gzip_stream.cc pulls in zlib, but it's not actually used by protoc, just - # by test code, so instead of compiling zlib for the host, let's just - # exclude this. - # "src/google/protobuf/io/gzip_stream.cc", - # "src/google/protobuf/io/gzip_stream.h", - - "src/google/protobuf/io/printer.cc", - "src/google/protobuf/io/printer.h", - "src/google/protobuf/io/strtod.cc", - "src/google/protobuf/io/strtod.h", - "src/google/protobuf/io/tokenizer.cc", - "src/google/protobuf/io/tokenizer.h", - "src/google/protobuf/io/zero_copy_stream_impl.cc", - "src/google/protobuf/io/zero_copy_stream_impl.h", - "src/google/protobuf/map_entry.h", - "src/google/protobuf/map_field.cc", - "src/google/protobuf/map_field.h", - "src/google/protobuf/map_field_inl.h", - "src/google/protobuf/message.cc", - "src/google/protobuf/message.h", - "src/google/protobuf/metadata.h", - "src/google/protobuf/reflection.h", - "src/google/protobuf/reflection_internal.h", - "src/google/protobuf/reflection_ops.cc", - "src/google/protobuf/reflection_ops.h", - "src/google/protobuf/service.cc", - "src/google/protobuf/service.h", - "src/google/protobuf/source_context.pb.cc", - "src/google/protobuf/source_context.pb.h", - "src/google/protobuf/struct.pb.cc", - "src/google/protobuf/struct.pb.h", - "src/google/protobuf/stubs/mathlimits.cc", - "src/google/protobuf/stubs/mathlimits.h", - "src/google/protobuf/stubs/mathutil.h", - "src/google/protobuf/stubs/singleton.h", - "src/google/protobuf/stubs/substitute.cc", - "src/google/protobuf/stubs/substitute.h", - "src/google/protobuf/text_format.cc", - "src/google/protobuf/text_format.h", - "src/google/protobuf/timestamp.pb.cc", - "src/google/protobuf/timestamp.pb.h", - "src/google/protobuf/type.pb.cc", - "src/google/protobuf/type.pb.h", - "src/google/protobuf/unknown_field_set.cc", - "src/google/protobuf/unknown_field_set.h", - "src/google/protobuf/util/field_comparator.cc", - "src/google/protobuf/util/field_comparator.h", - "src/google/protobuf/util/field_mask_util.cc", - "src/google/protobuf/util/field_mask_util.h", - "src/google/protobuf/util/internal/constants.h", - "src/google/protobuf/util/internal/datapiece.cc", - "src/google/protobuf/util/internal/datapiece.h", - "src/google/protobuf/util/internal/default_value_objectwriter.cc", - "src/google/protobuf/util/internal/default_value_objectwriter.h", - "src/google/protobuf/util/internal/error_listener.cc", - "src/google/protobuf/util/internal/error_listener.h", - "src/google/protobuf/util/internal/field_mask_utility.cc", - "src/google/protobuf/util/internal/field_mask_utility.h", - "src/google/protobuf/util/internal/json_escaping.cc", - "src/google/protobuf/util/internal/json_escaping.h", - "src/google/protobuf/util/internal/json_objectwriter.cc", - "src/google/protobuf/util/internal/json_objectwriter.h", - "src/google/protobuf/util/internal/json_stream_parser.cc", - "src/google/protobuf/util/internal/json_stream_parser.h", - "src/google/protobuf/util/internal/location_tracker.h", - "src/google/protobuf/util/internal/object_location_tracker.h", - "src/google/protobuf/util/internal/object_source.h", - "src/google/protobuf/util/internal/object_writer.cc", - "src/google/protobuf/util/internal/object_writer.h", - "src/google/protobuf/util/internal/proto_writer.cc", - "src/google/protobuf/util/internal/proto_writer.h", - "src/google/protobuf/util/internal/protostream_objectsource.cc", - "src/google/protobuf/util/internal/protostream_objectsource.h", - "src/google/protobuf/util/internal/protostream_objectwriter.cc", - "src/google/protobuf/util/internal/protostream_objectwriter.h", - "src/google/protobuf/util/internal/structured_objectwriter.h", - "src/google/protobuf/util/internal/type_info.cc", - "src/google/protobuf/util/internal/type_info.h", - "src/google/protobuf/util/internal/type_info_test_helper.cc", - "src/google/protobuf/util/internal/type_info_test_helper.h", - "src/google/protobuf/util/internal/utility.cc", - "src/google/protobuf/util/internal/utility.h", - "src/google/protobuf/util/json_util.cc", - "src/google/protobuf/util/json_util.h", - "src/google/protobuf/util/message_differencer.cc", - "src/google/protobuf/util/message_differencer.h", - "src/google/protobuf/util/time_util.cc", - "src/google/protobuf/util/time_util.h", - "src/google/protobuf/util/type_resolver.h", - "src/google/protobuf/util/type_resolver_util.cc", - "src/google/protobuf/util/type_resolver_util.h", - "src/google/protobuf/wire_format.cc", - "src/google/protobuf/wire_format.h", - "src/google/protobuf/wrappers.pb.cc", - "src/google/protobuf/wrappers.pb.h", + # requires descriptors & reflection; testonly. + "//third_party/libprotobuf-mutator:*", + + # The traffic_annotation tool is not part of Chrome itself, and needs to + # parse human-readable protobufs. + "//tools/traffic_annotation/*", + + # Chromecast requires descriptors and reflection. + "//chromecast/*", + + # libassistant requires descriptors and reflection for testing. + "//libassistant/*", + + # Perfetto uses the full library for testing. + "//third_party/perfetto/gn:protobuf_full", + + # Some tests inside ChromeOS need reflection to parse golden files. + # Not included in production code. + "//chrome/test:usage_time_limit_unittests", + + # The protobuf-based SQLite and GPU fuzzers need protobuf_full and are not + # included in Chrome. + "//third_party/sqlite:sqlite3_lpm_corpus_gen", + "//gpu:gl_lpm_fuzzer_proto", + "//gpu:gl_lpm_fuzzer_proto_gen", + "//gpu:gl_lpm_shader_to_string_unittest", ] - if (!is_starboard) { + sources = protobuf_lite_sources + [ + "src/google/protobuf/any.cc", + "src/google/protobuf/any.h", + "src/google/protobuf/any.pb.cc", + "src/google/protobuf/any.pb.h", + "src/google/protobuf/api.pb.cc", + "src/google/protobuf/api.pb.h", + "src/google/protobuf/compiler/importer.cc", + "src/google/protobuf/compiler/importer.h", + "src/google/protobuf/compiler/parser.cc", + "src/google/protobuf/compiler/parser.h", + "src/google/protobuf/descriptor.cc", + "src/google/protobuf/descriptor.h", + "src/google/protobuf/descriptor.pb.cc", + "src/google/protobuf/descriptor.pb.h", + "src/google/protobuf/descriptor_database.cc", + "src/google/protobuf/descriptor_database.h", + "src/google/protobuf/duration.pb.cc", + "src/google/protobuf/duration.pb.h", + "src/google/protobuf/dynamic_message.cc", + "src/google/protobuf/dynamic_message.h", + "src/google/protobuf/empty.pb.cc", + "src/google/protobuf/empty.pb.h", + "src/google/protobuf/extension_set_heavy.cc", + "src/google/protobuf/field_mask.pb.cc", + "src/google/protobuf/field_mask.pb.h", + "src/google/protobuf/generated_enum_reflection.h", + "src/google/protobuf/generated_message_reflection.cc", + "src/google/protobuf/generated_message_reflection.h", + "src/google/protobuf/io/gzip_stream.cc", + "src/google/protobuf/io/gzip_stream.h", + "src/google/protobuf/io/printer.cc", + "src/google/protobuf/io/printer.h", + "src/google/protobuf/io/tokenizer.cc", + "src/google/protobuf/io/tokenizer.h", + "src/google/protobuf/map_entry.h", + "src/google/protobuf/map_field.cc", + "src/google/protobuf/map_field.h", + "src/google/protobuf/map_field_inl.h", + "src/google/protobuf/message.cc", + "src/google/protobuf/message.h", + "src/google/protobuf/metadata.h", + "src/google/protobuf/reflection.h", + "src/google/protobuf/reflection_internal.h", + "src/google/protobuf/reflection_ops.cc", + "src/google/protobuf/reflection_ops.h", + "src/google/protobuf/service.cc", + "src/google/protobuf/service.h", + "src/google/protobuf/source_context.pb.cc", + "src/google/protobuf/source_context.pb.h", + "src/google/protobuf/struct.pb.cc", + "src/google/protobuf/struct.pb.h", + "src/google/protobuf/stubs/mathlimits.cc", + "src/google/protobuf/stubs/mathlimits.h", + "src/google/protobuf/stubs/mathutil.h", + "src/google/protobuf/stubs/substitute.cc", + "src/google/protobuf/stubs/substitute.h", + "src/google/protobuf/text_format.cc", + "src/google/protobuf/text_format.h", + "src/google/protobuf/timestamp.pb.cc", + "src/google/protobuf/timestamp.pb.h", + "src/google/protobuf/type.pb.cc", + "src/google/protobuf/type.pb.h", + "src/google/protobuf/unknown_field_set.cc", + "src/google/protobuf/unknown_field_set.h", + "src/google/protobuf/util/field_comparator.cc", + "src/google/protobuf/util/field_comparator.h", + "src/google/protobuf/util/field_mask_util.cc", + "src/google/protobuf/util/field_mask_util.h", + "src/google/protobuf/util/internal/constants.h", + "src/google/protobuf/util/internal/datapiece.cc", + "src/google/protobuf/util/internal/datapiece.h", + "src/google/protobuf/util/internal/default_value_objectwriter.cc", + "src/google/protobuf/util/internal/default_value_objectwriter.h", + "src/google/protobuf/util/internal/error_listener.cc", + "src/google/protobuf/util/internal/error_listener.h", + "src/google/protobuf/util/internal/field_mask_utility.cc", + "src/google/protobuf/util/internal/field_mask_utility.h", + "src/google/protobuf/util/internal/json_escaping.cc", + "src/google/protobuf/util/internal/json_escaping.h", + "src/google/protobuf/util/internal/json_objectwriter.cc", + "src/google/protobuf/util/internal/json_objectwriter.h", + "src/google/protobuf/util/internal/json_stream_parser.cc", + "src/google/protobuf/util/internal/json_stream_parser.h", + "src/google/protobuf/util/internal/location_tracker.h", + "src/google/protobuf/util/internal/object_location_tracker.h", + "src/google/protobuf/util/internal/object_source.h", + "src/google/protobuf/util/internal/object_writer.cc", + "src/google/protobuf/util/internal/object_writer.h", + "src/google/protobuf/util/internal/proto_writer.cc", + "src/google/protobuf/util/internal/proto_writer.h", + "src/google/protobuf/util/internal/protostream_objectsource.cc", + "src/google/protobuf/util/internal/protostream_objectsource.h", + "src/google/protobuf/util/internal/protostream_objectwriter.cc", + "src/google/protobuf/util/internal/protostream_objectwriter.h", + "src/google/protobuf/util/internal/structured_objectwriter.h", + "src/google/protobuf/util/internal/type_info.cc", + "src/google/protobuf/util/internal/type_info.h", + "src/google/protobuf/util/internal/type_info_test_helper.cc", + "src/google/protobuf/util/internal/type_info_test_helper.h", + "src/google/protobuf/util/internal/utility.cc", + "src/google/protobuf/util/internal/utility.h", + "src/google/protobuf/util/json_util.cc", + "src/google/protobuf/util/json_util.h", + "src/google/protobuf/util/message_differencer.cc", + "src/google/protobuf/util/message_differencer.h", + "src/google/protobuf/util/time_util.cc", + "src/google/protobuf/util/time_util.h", + "src/google/protobuf/util/type_resolver.h", + "src/google/protobuf/util/type_resolver_util.cc", + "src/google/protobuf/util/type_resolver_util.h", + "src/google/protobuf/wire_format.cc", + "src/google/protobuf/wire_format.h", + "src/google/protobuf/wrappers.pb.cc", + "src/google/protobuf/wrappers.pb.h", + ] + deps = [ - "//build/config/sanitizers:deps", + "//third_party/zlib", ] - configs -= [ "//build/config/compiler:chromium_code" ] + if (is_android) { + libs = [ "log" ] # Used by src/google/protobuf/stubs/common.cc } + + configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code", @@ -348,6 +368,13 @@ static_library("protobuf_full") { # correctly. ":protobuf_warnings", ] + + # Remove coverage and Sanitizers other than ASan for a performance boost when + # fuzzing. ASan can't be removed here because of a bug preventing unsanitized + # code from using libc++, which protobuf_full uses. + configs -= not_fuzzed_remove_nonasan_configs + configs += [ "//build/config/sanitizers:not_fuzzed" ] + if (is_win) { configs -= [ "//build/config/win:lean_and_mean" ] } @@ -359,8 +386,12 @@ static_library("protobuf_full") { ] cflags = protobuf_lite_cflags + + defines = [ "HAVE_ZLIB" ] } +# Only compile the compiler for the host architecture. +if (current_toolchain == host_toolchain) { # protoc compiler is separated into protoc library and executable targets to # support protoc plugins that need to link libprotoc, but not the main() # itself. See src/google/protobuf/compiler/plugin.h @@ -390,7 +421,10 @@ static_library("protobuf_full") { "src/google/protobuf/compiler/cpp/cpp_message.h", "src/google/protobuf/compiler/cpp/cpp_message_field.cc", "src/google/protobuf/compiler/cpp/cpp_message_field.h", + "src/google/protobuf/compiler/cpp/cpp_message_layout_helper.h", "src/google/protobuf/compiler/cpp/cpp_options.h", + "src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc", + "src/google/protobuf/compiler/cpp/cpp_padding_optimizer.h", "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc", "src/google/protobuf/compiler/cpp/cpp_primitive_field.h", "src/google/protobuf/compiler/cpp/cpp_service.cc", @@ -456,10 +490,6 @@ static_library("protobuf_full") { "src/google/protobuf/compiler/java/java_generator_factory.h", "src/google/protobuf/compiler/java/java_helpers.cc", "src/google/protobuf/compiler/java/java_helpers.h", - "src/google/protobuf/compiler/java/java_lazy_message_field.cc", - "src/google/protobuf/compiler/java/java_lazy_message_field.h", - "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc", - "src/google/protobuf/compiler/java/java_lazy_message_field_lite.h", "src/google/protobuf/compiler/java/java_map_field.cc", "src/google/protobuf/compiler/java/java_map_field.h", "src/google/protobuf/compiler/java/java_map_field_lite.cc", @@ -478,6 +508,7 @@ static_library("protobuf_full") { "src/google/protobuf/compiler/java/java_message_lite.h", "src/google/protobuf/compiler/java/java_name_resolver.cc", "src/google/protobuf/compiler/java/java_name_resolver.h", + "src/google/protobuf/compiler/java/java_options.h", "src/google/protobuf/compiler/java/java_primitive_field.cc", "src/google/protobuf/compiler/java/java_primitive_field.h", "src/google/protobuf/compiler/java/java_primitive_field_lite.cc", @@ -490,30 +521,10 @@ static_library("protobuf_full") { "src/google/protobuf/compiler/java/java_string_field.h", "src/google/protobuf/compiler/java/java_string_field_lite.cc", "src/google/protobuf/compiler/java/java_string_field_lite.h", - "src/google/protobuf/compiler/javanano/javanano_enum.cc", - "src/google/protobuf/compiler/javanano/javanano_enum.h", - "src/google/protobuf/compiler/javanano/javanano_enum_field.cc", - "src/google/protobuf/compiler/javanano/javanano_enum_field.h", - "src/google/protobuf/compiler/javanano/javanano_extension.cc", - "src/google/protobuf/compiler/javanano/javanano_extension.h", - "src/google/protobuf/compiler/javanano/javanano_field.cc", - "src/google/protobuf/compiler/javanano/javanano_field.h", - "src/google/protobuf/compiler/javanano/javanano_file.cc", - "src/google/protobuf/compiler/javanano/javanano_file.h", - "src/google/protobuf/compiler/javanano/javanano_generator.cc", - "src/google/protobuf/compiler/javanano/javanano_generator.h", - "src/google/protobuf/compiler/javanano/javanano_helpers.cc", - "src/google/protobuf/compiler/javanano/javanano_helpers.h", - "src/google/protobuf/compiler/javanano/javanano_map_field.cc", - "src/google/protobuf/compiler/javanano/javanano_map_field.h", - "src/google/protobuf/compiler/javanano/javanano_message.cc", - "src/google/protobuf/compiler/javanano/javanano_message.h", - "src/google/protobuf/compiler/javanano/javanano_message_field.cc", - "src/google/protobuf/compiler/javanano/javanano_message_field.h", - "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc", - "src/google/protobuf/compiler/javanano/javanano_primitive_field.h", "src/google/protobuf/compiler/js/js_generator.cc", "src/google/protobuf/compiler/js/js_generator.h", + "src/google/protobuf/compiler/js/well_known_types_embed.cc", + "src/google/protobuf/compiler/js/well_known_types_embed.h", "src/google/protobuf/compiler/objectivec/objectivec_enum.cc", "src/google/protobuf/compiler/objectivec/objectivec_enum.h", "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc", @@ -538,6 +549,8 @@ static_library("protobuf_full") { "src/google/protobuf/compiler/objectivec/objectivec_oneof.h", "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc", "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h", + "src/google/protobuf/compiler/php/php_generator.cc", + "src/google/protobuf/compiler/php/php_generator.h", "src/google/protobuf/compiler/plugin.cc", "src/google/protobuf/compiler/plugin.h", "src/google/protobuf/compiler/plugin.pb.cc", @@ -552,9 +565,7 @@ static_library("protobuf_full") { "src/google/protobuf/compiler/zip_writer.h", ] - if (!is_starboard) { configs -= [ "//build/config/compiler:chromium_code" ] - } configs += [ "//build/config/compiler:no_chromium_code", @@ -581,9 +592,7 @@ static_library("protobuf_full") { "src/google/protobuf/compiler/main.cc", ] - if (!is_starboard) { configs -= [ "//build/config/compiler:chromium_code" ] - } configs += [ "//build/config/compiler:no_chromium_code" ] cflags = protobuf_lite_cflags @@ -597,7 +606,6 @@ static_library("protobuf_full") { } } -if (!is_starboard) { google_python_dir = "$root_out_dir/pyproto/google" copy("copy_google") { @@ -656,6 +664,7 @@ copy("copy_google_protobuf_internal") { "python/google/protobuf/internal/decoder.py", "python/google/protobuf/internal/encoder.py", "python/google/protobuf/internal/enum_type_wrapper.py", + "python/google/protobuf/internal/extension_dict.py", "python/google/protobuf/internal/message_listener.py", "python/google/protobuf/internal/python_message.py", "python/google/protobuf/internal/type_checkers.py", @@ -667,6 +676,7 @@ copy("copy_google_protobuf_internal") { ] } +# Build time dependency for action rules. group("py_proto") { public_deps = [ ":copy_google", @@ -674,6 +684,13 @@ group("py_proto") { ":copy_google_protobuf_internal", ":copy_six", ] +} + +# Runtime dependency if the target needs the python scripts. +group("py_proto_runtime") { + deps = [ + ":py_proto", + ] # Targets that depend on this should depend on the copied data files. data = get_target_outputs(":copy_google") @@ -681,4 +698,3 @@ group("py_proto") { data += get_target_outputs(":copy_google_protobuf") data += get_target_outputs(":copy_google_protobuf_internal") } -} diff --git a/third_party/protobuf/CHANGES.txt b/third_party/protobuf/CHANGES.txt index 3459cccfa9cf..d3cc7b861577 100644 --- a/third_party/protobuf/CHANGES.txt +++ b/third_party/protobuf/CHANGES.txt @@ -1,3 +1,944 @@ +2019-06-28 version 3.9.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + + C++ + * Optimize and simplify implementation of RepeatedPtrFieldBase + * Don't create unnecessary unknown field sets. + * Remove branch from accessors to repeated field element array. + * Added delimited parse and serialize util. + * Reduce size by not emitting constants for fieldnumbers + * Fix a bug when comparing finite and infinite field values with explicit tolerances. + * TextFormat::Parser should use a custom Finder to look up extensions by number if one is provided. + * Add MessageLite::Utf8DebugString() to make MessageLite more compatible with Message. + * Fail fast for better performance in DescriptorPool::FindExtensionByNumber() if descriptor has no defined extensions. + * Adding the file name to help debug colliding extensions + * Added FieldDescriptor::PrintableNameForExtension() and DescriptorPool::FindExtensionByPrintableName(). + The latter will replace Reflection::FindKnownExtensionByName(). + * Replace NULL with nullptr + * Created a new Add method in repeated field that allows adding a range of elements all at once. + * Enabled enum name-to-value mapping functions for C++ lite + * Avoid dynamic initialization in descriptor.proto generated code + * Move stream functions to MessageLite from Message. + * Move all zero_copy_stream functionality to io_lite. + * Do not create array of matched fields for simple repeated fields + * Enabling silent mode by default to reduce make compilation noise. (#6237) + + Java + * Expose TextFormat.Printer and make it configurable. Deprecate the static methods. + * Library for constructing google.protobuf.Struct and google.protobuf.Value + * Make OneofDescriptor extend GenericDescriptor. + * Expose streamingness of service methods from MethodDescriptor. + * Fix a bug where TextFormat fails to parse Any filed with > 1 embedded message sub-fields. + * Establish consistent JsonFormat behavior for nulls in oneofs, regardless of order. + * Update GSON version to 3.8.5. (#6268) + * Add `protobuf_java_lite` Bazel target. (#6177) + + Python + * Change implementation of Name() for enums that allow aliases in proto2 in Python + to be in line with claims in C++ implementation (to return first value). + * Explicitly say what field cannot be set when the new value fails a type check. + * Duplicate register in descriptor pool will raise errors + * Add __slots__ to all well_known_types classes, custom attributes are not allowed anymore. + * text_format only present 8 valid digits for float fields by default + + JavaScript + * Add Oneof enum to the list of goog.provide + + PHP + * Make php message class final to avoid mocking. (#6277) + * Rename get/setXXXValue to get/setXXXWrapper. (#6295) + + Ruby + * Remove to_hash methods. (#6166) + + +2019-04-29 version 3.8.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + + C++ + * Use std::atomic in case of myriad2 platform + * Always declare enums to be int-sized + * Added DebugString() and ShortDebugString() methods on MessageLite + * Specialized different parse loop control flows + * Make hasbits potentially in register. The or's start forming an obstacle because it's a read modify store on the same mem address on each iteration. + * Move to an internal MACRO for parser validity checks. + * Improve map parsing performance. + * Make MergePartialFromCodedStream non virtual. This allows direct calls, potential inlining and is also a code health improvement + * Add an overall limit to parse_context to prevent reading past it. This allows to remove a annoying level of indirection. + * Fix a mistake, we shouldn't verify map key/value strings for utf8 in opt mode for proto2. + * Further improvements to cut binary size. + * Prepare to make MergePartialFromCodedStream non-virtual. + * A report on some interesting behavior change in python (caused by b/27494216) made me realize there is a check that needs to be done in case the parse ended on a end group tag. + * Add a note of caution to the comments around skip in CodedOutputStream. + * Simplify end check. + * Add overload for ParseMessage for MessageLite/Message types. If the explicit type is not known inlining won't help de-virtualizing the virtual call. + * Reduce linker input. It turns out that ParseMessage is not inlined, producing template instantiations that are used only once and save nothing but cost more. + * Improve the parser. + * [c++17] Changed proto2::RepeatedPtrField iterators to no longer derive from the deprecated std::iterator class. + * Change the default value of case_insensitive_enum_parsing to false for JsonStringToMessage. + * Add a warning if a field name doesn't match the style guide. + * Fix TextFormat not round-trip correctly when float value is max float. + * Added locationed info for some errors at compiler + * Python reserved keywords are now working with getattr()/setattr() for most descriptors. + * Added AllowUnknownField() in text_format + * Append '_' to C++ reserved keywords for message, enum, extension + * Fix MSVC warning C4244 in protobuf's parse_context.h. + * Updating Iterators to be compatible with C++17 in MSVC. + * Use capability annotation in mutex.h + * Fix "UndefinedBehaviorSanitizer: cfi-bad-type" + * CriticalSectionLock class as a lightweight replacement for std::mutex on Windows platforms. + * Removed vestigial wire_format_lite_inl.h + + C# + * Added System.Memory dependency. + + Java + * Make Java protoc code generator ignore optimize_for LITE_RUNTIME. Users should instead use the Java lite protoc plugin. + * Change Extension getMessageDefaultInstance() to return Message instead of MessageLite. + * Prevent malicious input streams from leaking buffers for ByteString or ByteBuffer parsing. + * Release new Javalite runtime. + * Show warning in case potential file name conflict. + * Allow Java reserved keywords to be used in extensions. + * Added setAllowUnknownFields() in text format + * Add memoization to ExtensionRegistryLite.getEmptyRegistry() + * Improve performance of CodedOutputStream.writeUInt32NoTag + * Add an optimized mismatch-finding algorithm to UnsafeUtil. + * When serializing uint32 varints, check that we have MAX_VARINT32_SIZE bytes left, not just MAX_VARINT_SIZE. + * Minor optimization to RopeByteString.PieceIterator + + JavaScript + * Simplify generated toObject code when the default value is used. + + Python + * Changes implementation of Name() for enums that allow aliases in proto2 in Python to be in line with claims in C++ implementation (to return first value). + * Added double_format option in text format printer. + * Added iter and __contains__ to extension dict + * Added allow_unknown_field option in python text format parser + * Fixed Timestamp.ToDatetime() loses precision issue + * Support unknown field in text format printer. + * Float field will be convert to inf if bigger than struct.unpack('f', b'\xff\xff\x7f\x7f')[0] which is about 3.4028234664e+38, + convert to -inf if smaller than -3.4028234664e+38 + * Allowed casting str->bytes in Message.__setstate__ + + Ruby + * Helper methods to get enum name for Ruby. + + +2019-01-24 version 3.7.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + + C++ + * Introduced new MOMI (maybe-outside-memory-interval) parser. + * Add an option to json_util to parse enum as case-insensitive. In the future, enum parsing in json_util will become case-sensitive. + * Added conformance test for enum aliases + * Added support for --cpp_out=speed:... + * Added use of C++ override keyword where appropriate + * Many other cleanups and fixes. + + Java + * Fix illegal reflective access warning in JDK 9+ + * Add BOM + + Python + * Added Python 3.7 compatibility. + * Modified ParseFromString to return bytes parsed . + * Introduce Proto C API. + * FindFileContainingSymbol in descriptor pool is now able to find field and enum values. + * reflection.MakeClass() and reflection.ParseMessage() are deprecated. + * Added DescriptorPool.FindMethodByName() method in pure python (c extension alreay has it) + * Flipped proto3 to preserve unknown fields by default. + * Added support for memoryview in python3 proto message parsing. + * Added MergeFrom for repeated scalar fields in c extension (pure python already has it) + * Surrogates are now rejected at setters in python3. + * Added public unknown field API. + * RecursionLimit is also set to max if allow_oversize_protos is enabled. + * Disallow duplicate scalars in proto3 text_format parse. + * Fix some segment faults for c extension map field. + + PHP + * Most issues for json encoding/decoding in the c extension have been fixed. There are still some edge cases not fixed. For more details, check conformance/failure_list_php_c.txt. + * Supports php 7.3 + * Added helper methods to convert between enum values and names. + * Allow setting/getting wrapper message fields using primitive values. + * Various bug fixes. + + Ruby + * Ruby 2.6 support. + * Drops support for ruby < 2.3. + * Most issues for json encoding/decoding in the c extension have been fixed. There are still some edge cases not fixed. For more details, check conformance/failure_list_ruby.txt. + * Json parsing can specify an option to ignore unknown fields: msg.decode_json(data, {ignore_unknown_fields: true}). + * Added support for proto2 syntax (partially). + * Various bug fixes. + + Csharp + * More support for FieldMask include merge, intersect and more. + * Increasing the default recursion limit to 100. + * Support loading FileDescriptors dynamically. + * Provide access to comments from descriptors. + * Added Any.Is method. + * Compatible with C# 6 + * Added IComparable and comparison operators on Timestamp. + + Objective C + * Add ability to introspect list of enum values (#4678) + * Copy the value when setting message/data fields (#5215) + * Support suppressing the objc package prefix checks on a list of files (#5309) + * More complete keyword and NSObject method (via categories) checks for field names, can result in more fields being rename, but avoids the collisions at runtime (#5289) + * Small fixes to TextFormat generation for extensions (#5362) + * Provide more details/context in deprecation messages (#5412) + * Array/Dictionary enumeration blocks NS_NOESCAPE annotation for Swift (#5421) + * Properly annotate extensions for ARC when their names imply behaviors (#5427) + * Enum alias name collision improvements (#5480) + + +2018-07-27 version 3.6.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + + C++ + * Introduced workaround for Windows issue with std::atomic and std::once_flag + initialization (#4777, #4773). + + PHP + * Added compatibility with PHP 7.3 (#4898). + + Ruby + * Fixed Ruby crash involving Any encoding (#4718). + +2018-06-01 version 3.6.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + + C++ + * Starting from this release, we now require C++11. For those we cannot yet + upgrade to C++11, we will try to keep the 3.5.x branch updated with + critical bug fixes only. If you have any concerns about this, please + comment on issue #2780. + * Moved to C++11 types like std::atomic and std::unique_ptr and away from our + old custom-built equivalents. + * Added support for repeated message fields in lite protos using implicit + weak fields. This is an experimental feature that allows the linker to + strip out more unused messages than previously was possible. + * Fixed SourceCodeInfo for interpreted options and extension range options. + * Fixed always_print_enums_as_ints option for JSON serialization. + * Added support for ignoring unknown enum values when parsing JSON. + * Create std::string in Arena memory. + * Fixed ValidateDateTime to correctly check the day. + * Fixed bug in ZeroCopyStreamByteSink. + * Various other cleanups and fixes. + + Java + * Dropped support for Java 6. + * Added a UTF-8 decoder that uses Unsafe to directly decode a byte buffer. + * Added deprecation annotations to generated code for deprecated oneof + fields. + * Fixed map field serialization in DynamicMessage. + * Cleanup and documentation for Java Lite runtime. + * Various other fixes and cleanups + * Fixed unboxed arraylists to handle an edge case + * Improved performance for copying between unboxed arraylists + * Fixed lite protobuf to avoid Java compiler warnings + * Improved test coverage for lite runtime + * Performance improvements for lite runtime + + Python + * Fixed bytes/string map key incompatibility between C++ and pure-Python + implementations (issue #4029) + * Added __init__.py files to compiler and util subpackages + * Use /MT for all Windows versions + * Fixed an issue affecting the Python-C++ implementation when used with + Cython (issue #2896) + * Various text format fixes + * Various fixes to resolve behavior differences between the pure-Python and + Python-C++ implementations + + PHP + * Added php_metadata_namespace to control the file path of generated metadata + file. + * Changed generated classes of nested message/enum. E.g., Foo.Bar, which + previously generates Foo_Bar, now generates Foo/Bar + * Added array constructor. When creating a message, users can pass a php + array whose content is field name to value pairs into constructor. The + created message will be initialized according to the array. Note that + message field should use a message value instead of a sub-array. + * Various bug fixes. + + Objective-C + * We removed some helper class methods from GPBDictionary to shrink the size + of the library, the functionary is still there, but you may need to do some + specific +alloc / -init… methods instead. + * Minor improvements in the performance of object field getters/setters by + avoiding some memory management overhead. + * Fix a memory leak during the raising of some errors. + * Make header importing completely order independent. + * Small code improvements for things the undefined behaviors compiler option + was flagging. + + Ruby + * Added ruby_package file option to control the module of generated class. + * Various bug fixes. + + Javascript + * Allow setting string to int64 field. + + Csharp + * Unknown fields are now parsed and then sent back on the wire. They can be + discarded at parse time via a CodedInputStream option. + * Movement towards working with .NET 3.5 and Unity + * Expression trees are no longer used + * AOT generics issues in Unity/il2cpp have a workaround (see this commit for + details) + * Floating point values are now compared bitwise (affects NaN value + comparisons) + * The default size limit when parsing is now 2GB rather than 64MB + * MessageParser now supports parsing from a slice of a byte array + * JSON list parsing now accepts null values where the underlying proto + representation does + +2017-12-20 version 3.5.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + Planned Future Changes + * Make C++ implementation C++11 only: we plan to require C++11 to build + protobuf code starting from 3.6.0 release. Please join this github issue: + https://github.com/protocolbuffers/protobuf/issues/2780 to provide your feedback. + + protoc + * Fixed a bug introduced in 3.5.0 and protoc in Windows now accepts non-ascii + characters in paths again. + + C++ + * Removed several usages of C++11 features in the code base. + * Fixed some compiler warnings. + + PHP + * Fixed memory leak in C-extension implementation. + * Added discardUnknokwnFields API. + * Removed duplicatd typedef in C-extension headers. + * Avoided calling private php methods (timelib_update_ts). + * Fixed Any.php to use fully-qualified name for DescriptorPool. + + Ruby + * Added Google_Protobuf_discard_unknown for discarding unknown fields in + messages. + + C# + * Unknown fields are now preserved by default. + * Floating point values are now bitwise compared, affecting message equality + check and Contains() API in map and repeated fields. + + +2017-11-13 version 3.5.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + Planned Future Changes + * Make C++ implementation C++11 only: we plan to require C++11 to build + protobuf code starting from 3.6.0 release. Please join this github issue: + https://github.com/protocolbuffers/protobuf/issues/2780 to provide your feedback. + + General + * Unknown fields are now preserved in proto3 for most of the language + implementations for proto3 by default. See the per-language section for + details. + * reserve keyword are now supported in enums + + C++ + * Proto3 messages are now preserving unknown fields by default. If you rely on + unknowns fields being dropped. Please use DiscardUnknownFields() explicitly. + * Deprecated the unsafe_arena_release_* and unsafe_arena_add_allocated_* + methods for string fields. + * Added move constructor and move assignment to RepeatedField, + RepeatedPtrField and google::protobuf::Any. + * Added perfect forwarding in Arena::CreateMessage + * In-progress experimental support for implicit weak fields with lite protos. + This feature allows the linker to strip out more unused messages and reduce + binary size. + * Various performance optimizations. + + Java + * Proto3 messages are now preserving unknown fields by default. If you’d like + to drop unknown fields, please use the DiscardUnknownFieldsParser API. For + example: + Parser parser = DiscardUnknownFieldsParser.wrap(Foo.parser()); + Foo foo = parser.parseFrom(input); + * Added a new CodedInputStream decoder for Iterable with direct + ByteBuffers. + * TextFormat now prints unknown length-delimited fields as messages if + possible. + * FieldMaskUtil.merge() no longer creates unnecessary empty messages when a + message field is unset in both source message and destination message. + * Various performance optimizations. + + Python + * Proto3 messages are now preserving unknown fields by default. Use + message.DiscardUnknownFields() to drop unknown fields. + * Add FieldDescriptor.file in generated code. + * Add descriptor pool FindOneofByName in pure python. + * Change unknown enum values into unknown field set . + * Add more Python dict/list compatibility for Struct/ListValue. + * Add utf-8 support for text_format.Merge()/Parse(). + * Support numeric unknown enum values for proto3 JSON format. + * Add warning for Unexpected end-group tag in cpp extension. + + PHP + * Proto3 messages are now preserving unknown fields. + * Provide well known type messages in runtime. + * Add prefix ‘PB’ to generated class of reserved names. + * Fixed all conformance tests for encode/decode json in php runtime. C + extension needs more work. + + Objective-C + * Fixed some issues around copying of messages with unknown fields and then + mutating the unknown fields in the copy. + + C# + * Added unknown field support in JsonParser. + * Fixed oneof message field merge. + * Simplify parsing messages from array slices. + + Ruby + * Unknown fields are now preserved by default. + * Fixed several bugs for segment fault. + + Javascript + * Decoder can handle both paced and unpacked data no matter how the proto is + defined. + * Decoder now accept long varint for 32 bit integers. + + +2017-08-14 version 3.4.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + Planned Future Changes + * There are some changes that are not included in this release but are planned + for the near future + - Preserve unknown fields in proto3: We are going to bring unknown fields + back into proto3. In this release, some languages start to support + preserving unknown fields in proto3, controlled by flags/options. Some + languages also introduce explicit APIs to drop unknown fields for + migration. Please read the change log sections by languages for details. + For general timeline and plan: + + https://docs.google.com/document/d/1KMRX-G91Aa-Y2FkEaHeeviLRRNblgIahbsk4wA14gRk/view + + For issues and discussions: + + https://github.com/protocolbuffers/protobuf/issues/272 + + - Make C++ implementation C++11 only: we plan to require C++11 to build + protobuf code starting from 3.5.0 or 3.6.0 release, after unknown fields + semantic changes are finished. Please join this + github issue: + + https://github.com/protocolbuffers/protobuf/issues/2780 + + to provide your feedback. + + General + * Extension ranges now accept options and are customizable. + * "reserve" keyword now supports “max†in field number ranges, + e.g. reserve 1000 to max; + + C++ + * Proto3 messages are now able to preserve unknown fields. The default + behavior is still to drop unknowns, which will be flipped in a future + release. If you rely on unknowns fields being dropped. Please use + Message::DiscardUnknownFields() explicitly. + * Packable proto3 fields are now packed by default in serialization. + * Following C++11 features are introduced when C++11 is available: + - move-constructor and move-assignment are introduced to messages + - Repeated fields constructor now takes std::initializer_list + - rvalue setters are introduced for string fields + * Experimental Table-Driven parsing and serialization available to test. To + enable it, pass in table_driven_parsing table_driven_serialization protoc + generator flags for C++ + + $ protoc --cpp_out=table_driven_parsing,table_driven_serialization:./ \ + test.proto + + * lite generator parameter supported by the generator. Once set, all generated + files, use lite runtime regardless of the optimizer_for setting in the + .proto file. + * Various optimizations to make C++ code more performant on PowerPC platform + * Fixed maps data corruption when the maps are modified by both reflection API + and generated API. + * Deterministic serialization on maps reflection now uses stable sort. + * file() accessors are introduced to various *Descriptor classes to make + writing template function easier. + * ByteSize() and SpaceUsed() are deprecated.Use ByteSizeLong() and + SpaceUsedLong() instead + * Consistent hash function is used for maps in DEBUG and NDEBUG build. + * "using namespace std" is removed from stubs/common.h + * Various performance optimizations and bug fixes + + Java + * Introduced new parser API DiscardUnknownFieldsParser in preparation of + proto3 unknown fields preservation change. Users who want to drop unknown + fields should migrate to use this new parser API. For example: + + Parser parser = DiscardUnknownFieldsParser.wrap(Foo.parser()); + Foo foo = parser.parseFrom(input); + + * Introduced new TextFormat API printUnicodeFieldValue() that prints field + value without escaping unicode characters. + * Added Durations.compare(Duration, Duration) and + Timestamps.compare(Timestamp, Timestamp). + * JsonFormat now accepts base64url encoded bytes fields. + * Optimized CodedInputStream to do less copies when parsing large bytes + fields. + * Optimized TextFormat to allocate less memory when printing. + + Python + * SerializeToString API is changed to SerializeToString(self, **kwargs), + deterministic parameter is accepted for deterministic serialization. + * Added sort_keys parameter in json format to make the output deterministic. + * Added indent parameter in json format. + * Added extension support in json format. + * Added __repr__ support for repeated field in cpp implementation. + * Added file in FieldDescriptor. + * Added pretty-print filter to text format. + * Services and method descriptors are always printed even if generic_service + option is turned off. + * Note: AppEngine 2.5 is deprecated on June 2017 that AppEngine 2.5 will + never update protobuf runtime. Users who depend on AppEngine 2.5 should use + old protoc. + + PHP + * Support PHP generic services. Specify file option php_generic_service=true + to enable generating service interface. + * Message, repeated and map fields setters take value instead of reference. + * Added map iterator in c extension. + * Support json  encode/decode. + * Added more type info in getter/setter phpdoc + * Fixed the problem that c extension and php implementation cannot be used + together. + * Added file option php_namespace to use custom php namespace instead of + package. + * Added fluent setter. + * Added descriptor API in runtime for custom encode/decode. + * Various bug fixes. + + Objective-C + * Fix for GPBExtensionRegistry copying and add tests. + * Optimize GPBDictionary.m codegen to reduce size of overall library by 46K + per architecture. + * Fix some cases of reading of 64bit map values. + * Properly error on a tag with field number zero. + * Preserve unknown fields in proto3 syntax files. + * Document the exceptions on some of the writing apis. + + C# + * Implemented IReadOnlyDictionary in MapField + * Added TryUnpack method for Any message in addition to Unpack. + * Converted C# projects to MSBuild (csproj) format. + + Ruby + * Several bug fixes. + + Javascript + * Added support of field option js_type. Now one can specify the JS type of a + 64-bit integer field to be string in the generated code by adding option + [jstype = JS_STRING] on the field. + +2017-04-05 version 3.3.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + Planned Future Changes + * There are some changes that are not included in this release but are + planned for the near future: + - Preserve unknown fields in proto3: please read this doc: + + https://docs.google.com/document/d/1KMRX-G91Aa-Y2FkEaHeeviLRRNblgIahbsk4wA14gRk/view + + for the timeline and follow up this github issue: + + https://github.com/protocolbuffers/protobuf/issues/272 + + for discussion. + - Make C++ implementation C++11 only: we plan to require C++11 to build + protobuf code starting from 3.4.0 or 3.5.0 release. Please join this + github issue: + + https://github.com/protocolbuffers/protobuf/issues/2780 + + to provide your feedback. + + C++ + * Fixed map fields serialization of DynamicMessage to correctly serialize + both key and value regardless of their presence. + * Parser now rejects field number 0 correctly. + * New API Message::SpaceUsedLong() that’s equivalent to + Message::SpaceUsed() but returns the value in size_t. + * JSON support + - New flag always_print_enums_as_ints in JsonPrintOptions. + - New flag preserve_proto_field_names in JsonPrintOptions. It will instruct + the JSON printer to use the original field name declared in the .proto + file instead of converting them to lowerCamelCase when printing JSON. + - JsonPrintOptions.always_print_primtive_fields now works for oneof message + fields. + - Fixed a bug that doesn’t allow different fields to set the same json_name + value. + - Fixed a performance bug that causes excessive memory copy when printing + large messages. + * Various performance optimizations. + + Java + * Map field setters eagerly validate inputs and throw NullPointerExceptions + as appropriate. + * Added ByteBuffer overloads to the generated parsing methods and the Parser + interface. + * proto3 enum's getNumber() method now throws on UNRECOGNIZED values. + * Output of JsonFormat is now locale independent. + + Python + * Added FindServiceByName() in the pure-Python DescriptorPool. This works only + for descriptors added with DescriptorPool.Add(). Generated descriptor_pool + does not support this yet. + * Added a descriptor_pool parameter for parsing Any in text_format.Parse(). + * descriptor_pool.FindFileContainingSymbol() now is able to find nested + extensions. + * Extending empty [] to repeated field now sets parent message presence. + + PHP + * Added file option php_class_prefix. The prefix will be prepended to all + generated classes defined in the file. + * When encoding, negative int32 values are sign-extended to int64. + * Repeated/Map field setter accepts a regular PHP array. Type checking is + done on the array elements. + * encode/decode are renamed to serializeToString/mergeFromString. + * Added mergeFrom, clear method on Message. + * Fixed a bug that oneof accessor didn’t return the field name that is + actually set. + * C extension now works with php7. + * This is the first GA release of PHP. We guarantee that old generated code + can always work with new runtime and new generated code. + + Objective-C + * Fixed help for GPBTimestamp for dates before the epoch that contain + fractional seconds. + * Added GPBMessageDropUnknownFieldsRecursively() to remove unknowns from a + message and any sub messages. + * Addressed a threading race in extension registration/lookup. + * Increased the max message parsing depth to 100 to match the other languages. + * Removed some use of dispatch_once in favor of atomic compare/set since it + needs to be heap based. + * Fixes for new Xcode 8.3 warnings. + + C# + * Fixed MapField.Values.CopyTo, which would throw an exception unnecessarily + if provided exactly the right size of array to copy to. + * Fixed enum JSON formatting when multiple names mapped to the same numeric + value. + * Added JSON formatting option to format enums as integers. + * Modified RepeatedField to implement IReadOnlyList. + * Introduced the start of custom option handling; it's not as pleasant as it + might be, but the information is at least present. We expect to extend code + generation to improve this in the future. + * Introduced ByteString.FromStream and ByteString.FromStreamAsync to + efficiently create a ByteString from a stream. + * Added whole-message deprecation, which decorates the class with [Obsolete]. + + Ruby + * Fixed Message#to_h for messages with map fields. + * Fixed memcpy() in binary gems to work for old glibc, without breaking the + build for non-glibc libc’s like musl. + + Javascript + * Added compatibility tests for version 3.0.0. + * Added conformance tests. + * Fixed serialization of extensions: we need to emit a value even if it is + falsy (like the number 0). + * Use closurebuilder.py in favor of calcdeps.py for compiling JavaScript. + +2017-01-23 version 3.2.0 (C++/Java/Python/PHP/Ruby/Objective-C/C#/JavaScript/Lite) + General + * Added protoc version number to protoc plugin protocol. It can be used by + protoc plugin to detect which version of protoc is used with the plugin and + mitigate known problems in certain version of protoc. + + C++ + * The default parsing byte size limit has been raised from 64MB to 2GB. + * Added rvalue setters for non-arena string fields. + * Enabled debug logging for Android. + * Fixed a double-free problem when using Reflection::SetAllocatedMessage() + with extension fields. + * Fixed several deterministic serialization bugs: + * MessageLite::SerializeAsString() now respects the global deterministic + serialization flag. + * Extension fields are serialized deterministically as well. Fixed protocol + compiler to correctly report importing-self as an error. + * Fixed FileDescriptor::DebugString() to print custom options correctly. + * Various performance/codesize optimizations and cleanups. + + Java + * The default parsing byte size limit has been raised from 64MB to 2GB. + * Added recursion limit when parsing JSON. + * Fixed a bug that enumType.getDescriptor().getOptions() doesn't have custom + options. + * Fixed generated code to support field numbers up to 2^29-1. + + Python + * You can now assign NumPy scalars/arrays (np.int32, np.int64) to protobuf + fields, and assigning other numeric types has been optimized for + performance. + * Pure-Python: message types are now garbage-collectable. + * Python/C++: a lot of internal cleanup/refactoring. + + PHP (Alpha) + * For 64-bit integers type (int64/uint64/sfixed64/fixed64/sint64), use PHP + integer on 64-bit environment and PHP string on 32-bit environment. + * PHP generated code also conforms to PSR-4 now. + * Fixed ZTS build for c extension. + * Fixed c extension build on Mac. + * Fixed c extension build on 32-bit linux. + * Fixed the bug that message without namespace is not found in the descriptor + pool. (#2240) + * Fixed the bug that repeated field is not iterable in c extension. + * Message names Empty will be converted to GPBEmpty in generated code. + * Added phpdoc in generated files. + * The released API is almost stable. Unless there is large problem, we won't + change it. See + https://developers.google.com/protocol-buffers/docs/reference/php-generated + for more details. + + Objective-C + * Added support for push/pop of the stream limit on CodedInputStream for + anyone doing manual parsing. + + C# + * No changes. + + Ruby + * Message objects now support #respond_to? for field getters/setters. + * You can now compare “message == non_message_object†and it will return false + instead of throwing an exception. + * JRuby: fixed #hashCode to properly reflect the values in the message. + + Javascript + * Deserialization of repeated fields no longer has quadratic performance + behavior. + * UTF-8 encoding/decoding now properly supports high codepoints. + * Added convenience methods for some well-known types: Any, Struct, and + Timestamp. These make it easier to convert data between native JavaScript + types and the well-known protobuf types. + +2016-09-23 version 3.1.0 (C++/Java/Python/PHP/Ruby/Objective-C/C#/JavaScript/Lite) + General + * Proto3 support in PHP (alpha). + * Various bug fixes. + + C++ + * Added MessageLite::ByteSizeLong() that’s equivalent to + MessageLite::ByteSize() but returns the value in size_t. Useful to check + whether a message is over the 2G size limit that protobuf can support. + * Moved default_instances to global variables. This allows default_instance + addresses to be known at compile time. + * Adding missing generic gcc 64-bit atomicops. + * Restore New*Callback into google::protobuf namespace since these are used + by the service stubs code + * JSON support. + * Fixed some conformance issues. + * Fixed a JSON serialization bug for bytes fields. + + Java + * Fixed a bug in TextFormat that doesn’t accept empty repeated fields (i.e., + “field: [ ]â€). + * JSON support + * Fixed JsonFormat to do correct snake_case-to-camelCase conversion for + non-style-conforming field names. + * Fixed JsonFormat to parse empty Any message correctly. + * Added an option to JsonFormat.Parser to ignore unknown fields. + * Experimental API + * Added UnsafeByteOperations.unsafeWrap(byte[]) to wrap a byte array into + ByteString without copy. + + Python + * JSON support + * Fixed some conformance issues. + + PHP (Alpha) + * We have added the proto3 support for PHP via both a pure PHP package and a + native c extension. The pure PHP package is intended to provide usability + to wider range of PHP platforms, while the c extension is intended to + provide higher performance. Both implementations provide the same runtime + APIs and share the same generated code. Users don’t need to re-generate + code for the same proto definition when they want to switch the + implementation later. The pure PHP package is included in the php/src + directory, and the c extension is included in the php/ext directory. + + Both implementations provide idiomatic PHP APIs: + * All messages and enums are defined as PHP classes. + * All message fields can only be accessed via getter/setter. + * Both repeated field elements and map elements are stored in containers + that act like a normal PHP array. + + Unlike several existing third-party PHP implementations for protobuf, our + implementations are built on a "strongly-typed" philosophy: message fields + and array/map containers will throw exceptions eagerly when values of the + incorrect type (not including those that can be type converted, e.g., + double <-> integer <-> numeric string) are inserted. + + Currently, pure PHP runtime supports php5.5, 5.6 and 7 on linux. C + extension runtime supports php5.5 and 5.6 on linux. + + See php/README.md for more details about installment. See + https://developers.google.com/protocol-buffers/docs/phptutorial for more + details about APIs. + + Objective-C + * Helpers are now provided for working the Any well known type (see + GPBWellKnownTypes.h for the api additions). + * Some improvements in startup code (especially when extensions aren’t used). + + Javascript + * Fixed missing import of jspb.Map + * Fixed valueWriterFn variable name + + Ruby + * Fixed hash computation for JRuby's RubyMessage + * Make sure map parsing frames are GC-rooted. + * Added API support for well-known types. + + C# + * Removed check on dependency in the C# reflection API. + +2016-09-06 version 3.0.2 (C++/Java/Python/Ruby/Objective-C/C#/JavaScript/Lite) + General + * Various bug fixes. + + Objective C + * Fix for oneofs in proto3 syntax files where fields were set to the zero + value. + * Fix for embedded null character in strings. + * CocoaDocs support + + Ruby + * Fixed memory corruption bug in parsing that could occur under GC pressure. + + Javascript + * jspb.Map is now properly exported to CommonJS modules. + + C# + * Removed legacy_enum_values flag. + + +2016-07-27 version 3.0.0 (C++/Java/Python/Ruby/Objective-C/C#/JavaScript/Lite) + General + * This log only contains changes since the beta-4 release. Summarized change + log since the last stable release (v2.6.1) can be found in the github + release page. + + Compatibility Notice + * v3.0.0 is the first API stable release of the v3.x series. We do not expect + any future API breaking changes. + * For C++, Java Lite and Objective-C, source level compatibility is + guaranteed. Upgrading from v3.0.0 to newer minor version releases will be + source compatible. For example, if your code compiles against protobuf + v3.0.0, it will continue to compile after you upgrade protobuf library to + v3.1.0. + * For other languages, both source level compatibility and binary level + compatibility are guaranteed. For example, if you have a Java binary built + against protobuf v3.0.0. After switching the protobuf runtime binary to + v3.1.0, your built binary should continue to work. + * Compatibility is only guaranteed for documented API and documented + behaviors. If you are using undocumented API (e.g., use anything in the C++ + internal namespace), it can be broken by minor version releases in an + undetermined manner. + + Ruby + * When you assign a string field `a.string_field = "X"`, we now call + #encode(UTF-8) on the string and freeze the copy. This saves you from + needing to ensure the string is already encoded as UTF-8. It also prevents + you from mutating the string after it has been assigned (this is how we + ensure it stays valid UTF-8). + * The generated file for `foo.proto` is now `foo_pb.rb` instead of just + `foo.rb`. This makes it easier to see which imports/requires are from + protobuf generated code, and also prevents conflicts with any `foo.rb` file + you might have written directly in Ruby. It is a backward-incompatible + change: you will need to update all of your `require` statements. + * For package names like `foo_bar`, we now translate this to the Ruby module + `FooBar`. This is more idiomatic Ruby than what we used to do (`Foo_bar`). + + JavaScript + * Scalar fields like numbers and boolean now return defaults instead of + `undefined` or `null` when they are unset. You can test for presence + explicitly by calling `hasFoo()`, which we now generate for scalar fields. + + Java Lite + * Java Lite is now implemented as a separate plugin, maintained in the + `javalite` branch. Both lite runtime and protoc artifacts will be available + in Maven. + + C# + * Target platforms now .NET 4.5, selected portable subsets and .NET Core. + * legacy_enum_values option is no longer supported. + +2016-07-15 version 3.0.0-beta-4 (C++/Java/Python/Ruby/Objective-C/C#/JavaScript) + General + * Added a deterministic serialization API for C++. The deterministic + serialization guarantees that given a binary, equal messages will be + serialized to the same bytes. This allows applications like MapReduce to + group equal messages based on the serialized bytes. The deterministic + serialization is, however, NOT canonical across languages; it is also + unstable across different builds with schema changes due to unknown fields. + Users who need canonical serialization, e.g. persistent storage in a + canonical form, fingerprinting, etc, should define their own + canonicalization specification and implement the serializer using reflection + APIs rather than relying on this API. + * Added OneofOptions. You can now define custom options for oneof groups. + import "google/protobuf/descriptor.proto"; + extend google.protobuf.OneofOptions { + optional int32 my_oneof_extension = 12345; + } + message Foo { + oneof oneof_group { + (my_oneof_extension) = 54321; + ... + } + } + + C++ (beta) + * Introduced a deterministic serialization API in + CodedOutputStream::SetSerializationDeterministic(bool). See the notes about + deterministic serialization in the General section. + * Added google::protobuf::Map::swap() to swap two map fields. + * Fixed a memory leak when calling Reflection::ReleaseMessage() on a message + allocated on arena. + * Improved error reporting when parsing text format protos. + * JSON + - Added a new parser option to ignore unknown fields when parsing JSON. + - Added convenient methods for message to/from JSON conversion. + * Various performance optimizations. + + Java (beta) + * File option "java_generate_equals_and_hash" is now deprecated. equals() and + hashCode() methods are generated by default. + * Added a new JSON printer option "omittingInsignificantWhitespace" to produce + a more compact JSON output. The printer will pretty-print by default. + * Updated Java runtime to be compatible with 2.5.0/2.6.1 generated protos. + + Python (beta) + * Added support to pretty print Any messages in text format. + * Added a flag to ignore unknown fields when parsing JSON. + * Bugfix: "@type" field of a JSON Any message is now correctly put before + other fields. + + Objective-C (beta) + * Updated the code to support compiling with more compiler warnings + enabled. (Issue 1616) + * Exposing more detailed errors for parsing failures. (PR 1623) + * Small (breaking) change to the naming of some methods on the support classes + for map<>. There were collisions with the system provided KVO support, so + the names were changed to avoid those issues. (PR 1699) + * Fixed for proper Swift bridging of error handling during parsing. (PR 1712) + * Complete support for generating sources that will go into a Framework and + depend on generated sources from other Frameworks. (Issue 1457) + + C# (beta) + * RepeatedField optimizations. + * Support for .NET Core. + * Minor bug fixes. + * Ability to format a single value in JsonFormatter (advanced usage only). + * Modifications to attributes applied to generated code. + + Javascript (alpha) + * Maps now have a real map API instead of being treated as repeated fields. + * Well-known types are now provided in the google-protobuf package, and the + code generator knows to require() them from that package. + * Bugfix: non-canonical varints are correctly decoded. + + Ruby (alpha) + * Accessors for oneof fields now return default values instead of nil. + + Java Lite + * Java lite support is removed from protocol compiler. It will be supported + as a protocol compiler plugin in a separate code branch. + 2016-05-16 version 3.0.0-beta-3 (C++/Java/Python/Ruby/Nano/Objective-C/C#/JavaScript) General * Supported Proto3 lite-runtime in C++/Java for mobile platforms. @@ -1077,7 +2018,7 @@ 2008-09-29 version 2.0.2: General - * License changed from Apache 2.0 to New BSD. + * License changed from Apache 2.0 to 3-Clause BSD. * It is now possible to define custom "options", which are basically annotations which may be placed on definitions in a .proto file. For example, you might define a field option called "foo" like so: diff --git a/third_party/protobuf/CONTRIBUTING.md b/third_party/protobuf/CONTRIBUTING.md new file mode 100644 index 000000000000..db1ff31cac6c --- /dev/null +++ b/third_party/protobuf/CONTRIBUTING.md @@ -0,0 +1,98 @@ +# Contributing to Protocol Buffers + +We welcome your contributions to protocol buffers. This doc describes the +process to contribute patches to protobuf and the general guidelines we +expect contributors to follow. + +## Before You Start + +We accept patches in the form of github pull requests. If you are new to +github, please read [How to create github pull requests](https://help.github.com/articles/about-pull-requests/) +first. + +### Contributor License Agreements + +Contributions to this project must be accompanied by a Contributor License +Agreement. You (or your employer) retain the copyright to your contribution, +this simply gives us permission to use and redistribute your contributions +as part of the project. + +* If you are an individual writing original source code and you're sure you + own the intellectual property, then you'll need to sign an [individual CLA](https://cla.developers.google.com/about/google-individual?csw=1). +* If you work for a company that wants to allow you to contribute your work, + then you'll need to sign a [corporate CLA](https://cla.developers.google.com/about/google-corporate?csw=1). + +### Coding Style + +This project follows [Google’s Coding Style Guides](https://github.com/google/styleguide). +Before sending out your pull request, please familiarize yourself with the +corresponding style guides and make sure the proposed code change is style +conforming. + +## Contributing Process + +Most pull requests should go to the master branch and the change will be +included in the next major/minor version release (e.g., 3.6.0 release). If you +need to include a bug fix in a patch release (e.g., 3.5.2), make sure it’s +already merged to master, and then create a pull request cherry-picking the +commits from master branch to the release branch (e.g., branch 3.5.x). + +For each pull request, a protobuf team member will be assigned to review the +pull request. For minor cleanups, the pull request may be merged right away +after an initial review. For larger changes, you will likely receive multiple +rounds of comments and it may take some time to complete. We will try to keep +our response time within 7-days but if you don’t get any response in a few +days, feel free to comment on the threads to get our attention. We also expect +you to respond to our comments within a reasonable amount of time. If we don’t +hear from you for 2 weeks or longer, we may close the pull request. You can +still send the pull request again once you have time to work on it. + +Once a pull request is merged, we will take care of the rest and get it into +the final release. + +## Pull Request Guidelines + +* If you are a Googler, it is preferable to first create an internal CL and + have it reviewed and submitted. The code propagation process will deliver the + change to GitHub. +* Create small PRs that are narrowly focused on addressing a single concern. + We often receive PRs that are trying to fix several things at a time, but if + only one fix is considered acceptable, nothing gets merged and both author's + & review's time is wasted. Create more PRs to address different concerns and + everyone will be happy. +* For speculative changes, consider opening an issue and discussing it first. + If you are suggesting a behavioral or API change, make sure you get explicit + support from a protobuf team member before sending us the pull request. +* Provide a good PR description as a record of what change is being made and + why it was made. Link to a GitHub issue if it exists. +* Don't fix code style and formatting unless you are already changing that + line to address an issue. PRs with irrelevant changes won't be merged. If + you do want to fix formatting or style, do that in a separate PR. +* Unless your PR is trivial, you should expect there will be reviewer comments + that you'll need to address before merging. We expect you to be reasonably + responsive to those comments, otherwise the PR will be closed after 2-3 weeks + of inactivity. +* Maintain clean commit history and use meaningful commit messages. PRs with + messy commit history are difficult to review and won't be merged. Use rebase + -i upstream/master to curate your commit history and/or to bring in latest + changes from master (but avoid rebasing in the middle of a code review). +* Keep your PR up to date with upstream/master (if there are merge conflicts, + we can't really merge your change). +* All tests need to be passing before your change can be merged. We recommend + you run tests locally before creating your PR to catch breakages early on. + Ultimately, the green signal will be provided by our testing infrastructure. + The reviewer will help you if there are test failures that seem not related + to the change you are making. + +## Reviewer Guidelines + +* Make sure that all tests are passing before approval. +* Apply the "release notes: yes" label if the pull request's description should + be included in the next release (e.g., any new feature / bug fix). + Apply the "release notes: no" label if the pull request's description should + not be included in the next release (e.g., refactoring changes that does not + change behavior, integration from Google internal, updating tests, etc.). +* Apply the appropriate language label (e.g., C++, Java, Python, etc.) to the + pull request. This will make it easier to identify which languages the pull + request affects, allowing us to better identify appropriate reviewer, create + a better release note, and make it easier to identify issues in the future. diff --git a/third_party/protobuf/DEPS b/third_party/protobuf/DEPS index 6e156dcd36ef..f6ed68493972 100644 --- a/third_party/protobuf/DEPS +++ b/third_party/protobuf/DEPS @@ -1,3 +1,6 @@ skip_child_includes = [ + 'benchmarks', + 'conformance', 'objectivec', + 'src', ] diff --git a/third_party/protobuf/LICENSE b/third_party/protobuf/LICENSE index f028c8232420..19b305b00060 100644 --- a/third_party/protobuf/LICENSE +++ b/third_party/protobuf/LICENSE @@ -1,14 +1,4 @@ -This license applies to all parts of Protocol Buffers except the following: - - - Atomicops support for generic gcc, located in - src/google/protobuf/stubs/atomicops_internals_generic_gcc.h. - This file is copyrighted by Red Hat Inc. - - - Atomicops support for AIX/POWER, located in - src/google/protobuf/stubs/atomicops_internals_power.h. - This file is copyrighted by Bloomberg Finance LP. - -Copyright 2014, Google Inc. All rights reserved. +Copyright 2008 Google Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are diff --git a/third_party/protobuf/METADATA b/third_party/protobuf/METADATA index 56766e3fa382..3d0cbdc659a7 100644 --- a/third_party/protobuf/METADATA +++ b/third_party/protobuf/METADATA @@ -7,12 +7,12 @@ description: third_party { identifier { type: "ChromiumVersion" - value: "58.0.3029.140" # from https://chromereleases.googleblog.com/2017/05/stable-channel-update-for-chrome-os_18.html + value: "80.0.3987.162" # from https://chromereleases.googleblog.com/2020/03/stable-channel-update-for-desktop_31.html } identifier { type: "Git" value: "https://chromium.googlesource.com/chromium/src.git" - version: "236f2f507f07b8d203231be06d10b2ebddc5e520" + version: "f12b46f00f17488ad16cb242bf4f248bdde9618b" } identifier { type: "UpstreamSubdir" diff --git a/third_party/protobuf/Makefile.am b/third_party/protobuf/Makefile.am index 3e9888166f81..c03b45c78a98 100644 --- a/third_party/protobuf/Makefile.am +++ b/third_party/protobuf/Makefile.am @@ -8,8 +8,8 @@ AUTOMAKE_OPTIONS = foreign # the right time. SUBDIRS = . src -# Always include gmock in distributions. -DIST_SUBDIRS = $(subdirs) src conformance benchmarks +# Always include third_party directories in distributions. +DIST_SUBDIRS = src conformance benchmarks third_party/googletest # Build gmock before we build protobuf tests. We don't add gmock to SUBDIRS # because then "make check" would also build and run all of gmock's own tests, @@ -18,8 +18,8 @@ DIST_SUBDIRS = $(subdirs) src conformance benchmarks # the installed version of gmock if there is one. check-local: @echo "Making lib/libgmock.a lib/libgmock_main.a in gmock" - @cd gmock && $(MAKE) $(AM_MAKEFLAGS) lib/libgmock.la lib/libgmock_main.la - @cd gmock/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la + @cd third_party/googletest/googletest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la + @cd third_party/googletest/googlemock && $(MAKE) $(AM_MAKEFLAGS) lib/libgmock.la lib/libgmock_main.la # We would like to clean gmock when "make clean" is invoked. But we have to # be careful because clean-local is also invoked during "make distclean", but @@ -28,9 +28,9 @@ check-local: # cd to the directory again and "make clean" it will fail. So, check that the # Makefile exists before recursing. clean-local: - @if test -e gmock/Makefile; then \ - echo "Making clean in gmock"; \ - cd gmock && $(MAKE) $(AM_MAKEFLAGS) clean; \ + @if test -e third_party/googletest/Makefile; then \ + echo "Making clean in googletest"; \ + cd third_party/googletest && $(MAKE) $(AM_MAKEFLAGS) clean; \ fi; \ if test -e conformance/Makefile; then \ echo "Making clean in conformance"; \ @@ -49,58 +49,78 @@ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = protobuf.pc protobuf-lite.pc csharp_EXTRA_DIST= \ + global.json \ csharp/.gitignore \ csharp/CHANGES.txt \ + csharp/Google.Protobuf.Tools.targets \ + csharp/Google.Protobuf.Tools.nuspec \ csharp/README.md \ csharp/build_packages.bat \ + csharp/build_tools.sh \ + csharp/buildall.bat \ csharp/buildall.sh \ csharp/generate_protos.sh \ + csharp/install_dotnet_sdk.ps1 \ csharp/keys/Google.Protobuf.public.snk \ + csharp/keys/Google.Protobuf.snk \ csharp/keys/README.md \ + csharp/protos/README.md \ + csharp/protos/map_unittest_proto3.proto \ + csharp/protos/unittest_custom_options_proto3.proto \ + csharp/protos/unittest_import_public_proto3.proto \ + csharp/protos/unittest_import_proto3.proto \ csharp/protos/unittest_issues.proto \ + csharp/protos/unittest_proto3.proto \ csharp/src/AddressBook/AddPerson.cs \ - csharp/src/AddressBook/AddressBook.csproj \ csharp/src/AddressBook/Addressbook.cs \ + csharp/src/AddressBook/AddressBook.csproj \ csharp/src/AddressBook/ListPeople.cs \ csharp/src/AddressBook/Program.cs \ - csharp/src/AddressBook/Properties/AssemblyInfo.cs \ csharp/src/AddressBook/SampleUsage.cs \ - csharp/src/AddressBook/app.config \ - csharp/src/Google.Protobuf.Conformance/App.config \ + csharp/src/Google.Protobuf.Benchmarks/SerializationConfig.cs \ + csharp/src/Google.Protobuf.Benchmarks/SerializationBenchmark.cs \ + csharp/src/Google.Protobuf.Benchmarks/Program.cs \ + csharp/src/Google.Protobuf.Benchmarks/Google.Protobuf.Benchmarks.csproj \ + csharp/src/Google.Protobuf.Benchmarks/Benchmarks.cs \ + csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs \ csharp/src/Google.Protobuf.Conformance/Conformance.cs \ csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj \ csharp/src/Google.Protobuf.Conformance/Program.cs \ - csharp/src/Google.Protobuf.Conformance/Properties/AssemblyInfo.cs \ csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj \ csharp/src/Google.Protobuf.JsonDump/Program.cs \ - csharp/src/Google.Protobuf.JsonDump/Properties/AssemblyInfo.cs \ - csharp/src/Google.Protobuf.JsonDump/app.config \ csharp/src/Google.Protobuf.Test/ByteStringTest.cs \ csharp/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs \ csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs \ csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs \ csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs \ + csharp/src/Google.Protobuf.Test/Collections/ProtobufEqualityComparersTest.cs \ csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs \ csharp/src/Google.Protobuf.Test/Compatibility/PropertyInfoExtensionsTest.cs \ + csharp/src/Google.Protobuf.Test/Compatibility/StreamExtensionsTest.cs \ csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs \ csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs \ csharp/src/Google.Protobuf.Test/EqualityTester.cs \ csharp/src/Google.Protobuf.Test/FieldCodecTest.cs \ + csharp/src/Google.Protobuf.Test/FieldMaskTreeTest.cs \ csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs \ csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj \ csharp/src/Google.Protobuf.Test/IssuesTest.cs \ csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs \ csharp/src/Google.Protobuf.Test/JsonParserTest.cs \ csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs \ - csharp/src/Google.Protobuf.Test/Properties/AppManifest.xml \ - csharp/src/Google.Protobuf.Test/Properties/AssemblyInfo.cs \ + csharp/src/Google.Protobuf.Test/Reflection/CustomOptionsTest.cs \ + csharp/src/Google.Protobuf.Test/Reflection/DescriptorDeclarationTest.cs \ csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs \ csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs \ csharp/src/Google.Protobuf.Test/Reflection/TypeRegistryTest.cs \ csharp/src/Google.Protobuf.Test/SampleEnum.cs \ csharp/src/Google.Protobuf.Test/SampleMessages.cs \ + csharp/src/Google.Protobuf.Test/SampleNaNs.cs \ csharp/src/Google.Protobuf.Test/TestCornerCases.cs \ + csharp/src/Google.Protobuf.Test/TestProtos/ForeignMessagePartial.cs \ csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs \ + csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs \ + csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs \ csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs \ csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs \ csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs \ @@ -108,25 +128,37 @@ csharp_EXTRA_DIST= \ csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs \ csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs \ csharp/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs \ + csharp/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs \ csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs \ csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs \ - csharp/src/Google.Protobuf.Test/packages.config \ + csharp/src/Google.Protobuf.Test/UnknownFieldSetTest.cs \ + csharp/src/Google.Protobuf.Test/testprotos.pb \ csharp/src/Google.Protobuf.sln \ csharp/src/Google.Protobuf/ByteArray.cs \ csharp/src/Google.Protobuf/ByteString.cs \ csharp/src/Google.Protobuf/CodedInputStream.cs \ csharp/src/Google.Protobuf/CodedOutputStream.ComputeSize.cs \ csharp/src/Google.Protobuf/CodedOutputStream.cs \ + csharp/src/Google.Protobuf/Collections/Lists.cs \ csharp/src/Google.Protobuf/Collections/MapField.cs \ + csharp/src/Google.Protobuf/Collections/ProtobufEqualityComparers.cs \ csharp/src/Google.Protobuf/Collections/ReadOnlyDictionary.cs \ csharp/src/Google.Protobuf/Collections/RepeatedField.cs \ + csharp/src/Google.Protobuf/Compatibility/MethodInfoExtensions.cs \ csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs \ + csharp/src/Google.Protobuf/Compatibility/StreamExtensions.cs \ csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs \ + csharp/src/Google.Protobuf/Extension.cs \ + csharp/src/Google.Protobuf/ExtensionRegistry.cs \ + csharp/src/Google.Protobuf/ExtensionSet.cs \ + csharp/src/Google.Protobuf/ExtensionValue.cs \ csharp/src/Google.Protobuf/FieldCodec.cs \ + csharp/src/Google.Protobuf/FieldMaskTree.cs \ csharp/src/Google.Protobuf/FrameworkPortability.cs \ csharp/src/Google.Protobuf/Google.Protobuf.csproj \ - csharp/src/Google.Protobuf/Google.Protobuf.nuspec \ + csharp/src/Google.Protobuf/ICustomDiagnosticMessage.cs \ csharp/src/Google.Protobuf/IDeepCloneable.cs \ + csharp/src/Google.Protobuf/IExtendableMessage.cs \ csharp/src/Google.Protobuf/IMessage.cs \ csharp/src/Google.Protobuf/InvalidJsonException.cs \ csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs \ @@ -137,15 +169,20 @@ csharp_EXTRA_DIST= \ csharp/src/Google.Protobuf/LimitedInputStream.cs \ csharp/src/Google.Protobuf/MessageExtensions.cs \ csharp/src/Google.Protobuf/MessageParser.cs \ + csharp/src/Google.Protobuf/ObjectIntPair.cs \ csharp/src/Google.Protobuf/ProtoPreconditions.cs \ csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs \ + csharp/src/Google.Protobuf/Reflection/CustomOptions.cs \ csharp/src/Google.Protobuf/Reflection/Descriptor.cs \ csharp/src/Google.Protobuf/Reflection/DescriptorBase.cs \ + csharp/src/Google.Protobuf/Reflection/DescriptorDeclaration.cs \ csharp/src/Google.Protobuf/Reflection/DescriptorPool.cs \ csharp/src/Google.Protobuf/Reflection/DescriptorUtil.cs \ csharp/src/Google.Protobuf/Reflection/DescriptorValidationException.cs \ csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs \ csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs \ + csharp/src/Google.Protobuf/Reflection/ExtensionAccessor.cs \ + csharp/src/Google.Protobuf/Reflection/ExtensionCollection.cs \ csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs \ csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs \ csharp/src/Google.Protobuf/Reflection/FieldType.cs \ @@ -160,7 +197,6 @@ csharp_EXTRA_DIST= \ csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs \ csharp/src/Google.Protobuf/Reflection/OriginalNameAttribute.cs \ csharp/src/Google.Protobuf/Reflection/PackageDescriptor.cs \ - csharp/src/Google.Protobuf/Reflection/PartialClasses.cs \ csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs \ csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs \ csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs \ @@ -173,6 +209,7 @@ csharp_EXTRA_DIST= \ csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs \ csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs \ csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs \ + csharp/src/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs \ csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs \ csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs \ csharp/src/Google.Protobuf/WellKnownTypes/TimeExtensions.cs \ @@ -183,11 +220,12 @@ csharp_EXTRA_DIST= \ csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs \ csharp/src/Google.Protobuf/WellKnownTypes/WrappersPartial.cs \ csharp/src/Google.Protobuf/WireFormat.cs \ - csharp/src/Google.Protobuf/packages.config \ - csharp/src/packages/repositories.config + csharp/src/Google.Protobuf/UnknownField.cs \ + csharp/src/Google.Protobuf/UnknownFieldSet.cs java_EXTRA_DIST= \ java/README.md \ + java/bom/pom.xml \ java/core/generate-sources-build.xml \ java/core/generate-test-sources-build.xml \ java/core/pom.xml \ @@ -195,84 +233,153 @@ java_EXTRA_DIST= java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java \ java/core/src/main/java/com/google/protobuf/AbstractParser.java \ java/core/src/main/java/com/google/protobuf/AbstractProtobufList.java \ + java/core/src/main/java/com/google/protobuf/AllocatedBuffer.java \ + java/core/src/main/java/com/google/protobuf/Android.java \ + java/core/src/main/java/com/google/protobuf/ArrayDecoders.java \ + java/core/src/main/java/com/google/protobuf/BinaryReader.java \ + java/core/src/main/java/com/google/protobuf/BinaryWriter.java \ java/core/src/main/java/com/google/protobuf/BlockingRpcChannel.java \ java/core/src/main/java/com/google/protobuf/BlockingService.java \ java/core/src/main/java/com/google/protobuf/BooleanArrayList.java \ + java/core/src/main/java/com/google/protobuf/BufferAllocator.java \ java/core/src/main/java/com/google/protobuf/ByteBufferWriter.java \ java/core/src/main/java/com/google/protobuf/ByteOutput.java \ java/core/src/main/java/com/google/protobuf/ByteString.java \ java/core/src/main/java/com/google/protobuf/CodedInputStream.java \ + java/core/src/main/java/com/google/protobuf/CodedInputStreamReader.java \ java/core/src/main/java/com/google/protobuf/CodedOutputStream.java \ + java/core/src/main/java/com/google/protobuf/CodedOutputStreamWriter.java \ + java/core/src/main/java/com/google/protobuf/DescriptorMessageInfoFactory.java \ java/core/src/main/java/com/google/protobuf/Descriptors.java \ + java/core/src/main/java/com/google/protobuf/DiscardUnknownFieldsParser.java \ java/core/src/main/java/com/google/protobuf/DoubleArrayList.java \ java/core/src/main/java/com/google/protobuf/DynamicMessage.java \ + java/core/src/main/java/com/google/protobuf/ExperimentalApi.java \ java/core/src/main/java/com/google/protobuf/Extension.java \ java/core/src/main/java/com/google/protobuf/ExtensionLite.java \ java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java \ + java/core/src/main/java/com/google/protobuf/ExtensionRegistryFactory.java \ java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java \ + java/core/src/main/java/com/google/protobuf/ExtensionSchema.java \ + java/core/src/main/java/com/google/protobuf/ExtensionSchemaFull.java \ + java/core/src/main/java/com/google/protobuf/ExtensionSchemaLite.java \ + java/core/src/main/java/com/google/protobuf/ExtensionSchemas.java \ + java/core/src/main/java/com/google/protobuf/FieldInfo.java \ java/core/src/main/java/com/google/protobuf/FieldSet.java \ + java/core/src/main/java/com/google/protobuf/FieldType.java \ java/core/src/main/java/com/google/protobuf/FloatArrayList.java \ java/core/src/main/java/com/google/protobuf/GeneratedMessage.java \ + java/core/src/main/java/com/google/protobuf/GeneratedMessageInfoFactory.java \ java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java \ + java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java \ java/core/src/main/java/com/google/protobuf/IntArrayList.java \ java/core/src/main/java/com/google/protobuf/Internal.java \ java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java \ + java/core/src/main/java/com/google/protobuf/IterableByteBufferInputStream.java \ + java/core/src/main/java/com/google/protobuf/JavaType.java \ java/core/src/main/java/com/google/protobuf/LazyField.java \ java/core/src/main/java/com/google/protobuf/LazyFieldLite.java \ java/core/src/main/java/com/google/protobuf/LazyStringArrayList.java \ java/core/src/main/java/com/google/protobuf/LazyStringList.java \ + java/core/src/main/java/com/google/protobuf/ListFieldSchema.java \ java/core/src/main/java/com/google/protobuf/LongArrayList.java \ + java/core/src/main/java/com/google/protobuf/ManifestSchemaFactory.java \ java/core/src/main/java/com/google/protobuf/MapEntry.java \ java/core/src/main/java/com/google/protobuf/MapEntryLite.java \ java/core/src/main/java/com/google/protobuf/MapField.java \ java/core/src/main/java/com/google/protobuf/MapFieldLite.java \ + java/core/src/main/java/com/google/protobuf/MapFieldSchema.java \ + java/core/src/main/java/com/google/protobuf/MapFieldSchemaFull.java \ + java/core/src/main/java/com/google/protobuf/MapFieldSchemaLite.java \ + java/core/src/main/java/com/google/protobuf/MapFieldSchemas.java \ java/core/src/main/java/com/google/protobuf/Message.java \ + java/core/src/main/java/com/google/protobuf/MessageInfo.java \ + java/core/src/main/java/com/google/protobuf/MessageInfoFactory.java \ java/core/src/main/java/com/google/protobuf/MessageLite.java \ java/core/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java \ java/core/src/main/java/com/google/protobuf/MessageLiteToString.java \ java/core/src/main/java/com/google/protobuf/MessageOrBuilder.java \ java/core/src/main/java/com/google/protobuf/MessageReflection.java \ + java/core/src/main/java/com/google/protobuf/MessageSchema.java \ + java/core/src/main/java/com/google/protobuf/MessageSetSchema.java \ java/core/src/main/java/com/google/protobuf/MutabilityOracle.java \ + java/core/src/main/java/com/google/protobuf/NewInstanceSchema.java \ + java/core/src/main/java/com/google/protobuf/NewInstanceSchemaFull.java \ + java/core/src/main/java/com/google/protobuf/NewInstanceSchemaLite.java \ + java/core/src/main/java/com/google/protobuf/NewInstanceSchemas.java \ java/core/src/main/java/com/google/protobuf/NioByteString.java \ + java/core/src/main/java/com/google/protobuf/OneofInfo.java \ java/core/src/main/java/com/google/protobuf/Parser.java \ + java/core/src/main/java/com/google/protobuf/PrimitiveNonBoxingCollection.java \ + java/core/src/main/java/com/google/protobuf/ProtoSyntax.java \ + java/core/src/main/java/com/google/protobuf/Protobuf.java \ java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java \ + java/core/src/main/java/com/google/protobuf/ProtobufLists.java \ java/core/src/main/java/com/google/protobuf/ProtocolMessageEnum.java \ java/core/src/main/java/com/google/protobuf/ProtocolStringList.java \ + java/core/src/main/java/com/google/protobuf/RawMessageInfo.java \ + java/core/src/main/java/com/google/protobuf/Reader.java \ java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java \ + java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3.java \ java/core/src/main/java/com/google/protobuf/RopeByteString.java \ java/core/src/main/java/com/google/protobuf/RpcCallback.java \ java/core/src/main/java/com/google/protobuf/RpcChannel.java \ java/core/src/main/java/com/google/protobuf/RpcController.java \ java/core/src/main/java/com/google/protobuf/RpcUtil.java \ + java/core/src/main/java/com/google/protobuf/Schema.java \ + java/core/src/main/java/com/google/protobuf/SchemaFactory.java \ + java/core/src/main/java/com/google/protobuf/SchemaUtil.java \ java/core/src/main/java/com/google/protobuf/Service.java \ java/core/src/main/java/com/google/protobuf/ServiceException.java \ java/core/src/main/java/com/google/protobuf/SingleFieldBuilder.java \ + java/core/src/main/java/com/google/protobuf/SingleFieldBuilderV3.java \ java/core/src/main/java/com/google/protobuf/SmallSortedMap.java \ + java/core/src/main/java/com/google/protobuf/StructuralMessageInfo.java \ java/core/src/main/java/com/google/protobuf/TextFormat.java \ java/core/src/main/java/com/google/protobuf/TextFormatEscaper.java \ java/core/src/main/java/com/google/protobuf/TextFormatParseInfoTree.java \ java/core/src/main/java/com/google/protobuf/TextFormatParseLocation.java \ java/core/src/main/java/com/google/protobuf/UninitializedMessageException.java \ + java/core/src/main/java/com/google/protobuf/UnknownFieldSchema.java \ java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java \ java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java \ + java/core/src/main/java/com/google/protobuf/UnknownFieldSetLiteSchema.java \ + java/core/src/main/java/com/google/protobuf/UnknownFieldSetSchema.java \ java/core/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java \ java/core/src/main/java/com/google/protobuf/UnsafeByteOperations.java \ + java/core/src/main/java/com/google/protobuf/UnsafeUtil.java \ java/core/src/main/java/com/google/protobuf/Utf8.java \ java/core/src/main/java/com/google/protobuf/WireFormat.java \ + java/core/src/main/java/com/google/protobuf/Writer.java \ java/core/src/test/java/com/google/protobuf/AbstractMessageTest.java \ + java/core/src/test/java/com/google/protobuf/AbstractProto2LiteSchemaTest.java \ + java/core/src/test/java/com/google/protobuf/AbstractProto2SchemaTest.java \ + java/core/src/test/java/com/google/protobuf/AbstractProto3LiteSchemaTest.java \ + java/core/src/test/java/com/google/protobuf/AbstractProto3SchemaTest.java \ + java/core/src/test/java/com/google/protobuf/AbstractSchemaTest.java \ java/core/src/test/java/com/google/protobuf/AnyTest.java \ + java/core/src/test/java/com/google/protobuf/ArrayDecodersTest.java \ + java/core/src/test/java/com/google/protobuf/BinaryProtocolTest.java \ java/core/src/test/java/com/google/protobuf/BooleanArrayListTest.java \ java/core/src/test/java/com/google/protobuf/BoundedByteStringTest.java \ java/core/src/test/java/com/google/protobuf/ByteBufferWriterTest.java \ java/core/src/test/java/com/google/protobuf/ByteStringTest.java \ + java/core/src/test/java/com/google/protobuf/CachedFieldSizeTest.java \ java/core/src/test/java/com/google/protobuf/CheckUtf8Test.java \ + java/core/src/test/java/com/google/protobuf/CodedAdapterTest.java \ java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java \ java/core/src/test/java/com/google/protobuf/CodedOutputStreamTest.java \ + java/core/src/test/java/com/google/protobuf/DecodeUtf8Test.java \ java/core/src/test/java/com/google/protobuf/DeprecatedFieldTest.java \ java/core/src/test/java/com/google/protobuf/DescriptorsTest.java \ + java/core/src/test/java/com/google/protobuf/DiscardUnknownFieldsTest.java \ java/core/src/test/java/com/google/protobuf/DoubleArrayListTest.java \ java/core/src/test/java/com/google/protobuf/DynamicMessageTest.java \ java/core/src/test/java/com/google/protobuf/EnumTest.java \ + java/core/src/test/java/com/google/protobuf/ExperimentalMessageFactory.java \ + java/core/src/test/java/com/google/protobuf/ExperimentalSerializationUtil.java \ + java/core/src/test/java/com/google/protobuf/ExperimentalTestDataProvider.java \ + java/core/src/test/java/com/google/protobuf/ExtensionRegistryFactoryTest.java \ java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java \ java/core/src/test/java/com/google/protobuf/FloatArrayListTest.java \ java/core/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java \ @@ -286,42 +393,70 @@ java_EXTRA_DIST= java/core/src/test/java/com/google/protobuf/LazyStringArrayListTest.java \ java/core/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java \ java/core/src/test/java/com/google/protobuf/LiteEqualsAndHashTest.java \ - java/core/src/test/java/com/google/protobuf/LiteTest.java \ java/core/src/test/java/com/google/protobuf/LiteralByteStringTest.java \ java/core/src/test/java/com/google/protobuf/LongArrayListTest.java \ java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java \ java/core/src/test/java/com/google/protobuf/MapForProto2Test.java \ + java/core/src/test/java/com/google/protobuf/MapLiteTest.java \ java/core/src/test/java/com/google/protobuf/MapTest.java \ java/core/src/test/java/com/google/protobuf/MessageTest.java \ java/core/src/test/java/com/google/protobuf/NestedBuildersTest.java \ java/core/src/test/java/com/google/protobuf/NioByteStringTest.java \ + java/core/src/test/java/com/google/protobuf/PackedFieldTest.java \ + java/core/src/test/java/com/google/protobuf/ParseExceptionsTest.java \ + java/core/src/test/java/com/google/protobuf/ParserLiteTest.java \ java/core/src/test/java/com/google/protobuf/ParserTest.java \ + java/core/src/test/java/com/google/protobuf/Proto2ExtensionLookupSchemaTest.java \ + java/core/src/test/java/com/google/protobuf/Proto2LiteSchemaTest.java \ + java/core/src/test/java/com/google/protobuf/Proto2MessageFactory.java \ + java/core/src/test/java/com/google/protobuf/Proto2MessageInfoFactory.java \ + java/core/src/test/java/com/google/protobuf/Proto2MessageLiteFactory.java \ + java/core/src/test/java/com/google/protobuf/Proto2SchemaTest.java \ + java/core/src/test/java/com/google/protobuf/Proto2UnknownEnumValueTest.java \ + java/core/src/test/java/com/google/protobuf/Proto3LiteSchemaTest.java \ + java/core/src/test/java/com/google/protobuf/Proto3MessageFactory.java \ + java/core/src/test/java/com/google/protobuf/Proto3MessageInfoFactory.java \ + java/core/src/test/java/com/google/protobuf/Proto3MessageLiteFactory.java \ + java/core/src/test/java/com/google/protobuf/Proto3MessageLiteInfoFactory.java \ + java/core/src/test/java/com/google/protobuf/Proto3SchemaTest.java \ java/core/src/test/java/com/google/protobuf/ProtobufArrayListTest.java \ - java/core/src/test/java/com/google/protobuf/RepeatedFieldBuilderTest.java \ + java/core/src/test/java/com/google/protobuf/RepeatedFieldBuilderV3Test.java \ java/core/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java \ java/core/src/test/java/com/google/protobuf/RopeByteStringTest.java \ java/core/src/test/java/com/google/protobuf/ServiceTest.java \ - java/core/src/test/java/com/google/protobuf/SingleFieldBuilderTest.java \ + java/core/src/test/java/com/google/protobuf/SingleFieldBuilderV3Test.java \ java/core/src/test/java/com/google/protobuf/SmallSortedMapTest.java \ java/core/src/test/java/com/google/protobuf/TestBadIdentifiers.java \ + java/core/src/test/java/com/google/protobuf/TestBadIdentifiersLite.java \ + java/core/src/test/java/com/google/protobuf/TestSchemas.java \ + java/core/src/test/java/com/google/protobuf/TestSchemasLite.java \ java/core/src/test/java/com/google/protobuf/TestUtil.java \ + java/core/src/test/java/com/google/protobuf/TestUtilLite.java \ java/core/src/test/java/com/google/protobuf/TextFormatParseInfoTreeTest.java \ java/core/src/test/java/com/google/protobuf/TextFormatParseLocationTest.java \ java/core/src/test/java/com/google/protobuf/TextFormatTest.java \ java/core/src/test/java/com/google/protobuf/UnknownEnumValueTest.java \ - java/core/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java \ java/core/src/test/java/com/google/protobuf/UnknownFieldSetTest.java \ java/core/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java \ + java/core/src/test/java/com/google/protobuf/Utf8Test.java \ + java/core/src/test/java/com/google/protobuf/Utf8Utils.java \ java/core/src/test/java/com/google/protobuf/WellKnownTypesTest.java \ + java/core/src/test/java/com/google/protobuf/WireFormatLiteTest.java \ java/core/src/test/java/com/google/protobuf/WireFormatTest.java \ + java/core/src/test/java/com/google/protobuf/WrappersLiteOfMethodTest.java \ + java/core/src/test/java/com/google/protobuf/WrappersOfMethodTest.java \ java/core/src/test/proto/com/google/protobuf/any_test.proto \ + java/core/src/test/proto/com/google/protobuf/cached_field_size_test.proto \ + java/core/src/test/proto/com/google/protobuf/deprecated_file.proto \ java/core/src/test/proto/com/google/protobuf/field_presence_test.proto \ java/core/src/test/proto/com/google/protobuf/lazy_fields_lite.proto \ java/core/src/test/proto/com/google/protobuf/lite_equals_and_hash.proto \ java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto \ java/core/src/test/proto/com/google/protobuf/map_for_proto2_test.proto \ java/core/src/test/proto/com/google/protobuf/map_initialization_order_test.proto \ + java/core/src/test/proto/com/google/protobuf/map_lite_test.proto \ java/core/src/test/proto/com/google/protobuf/map_test.proto \ + java/core/src/test/proto/com/google/protobuf/message_lite_extension_util_test.proto\ java/core/src/test/proto/com/google/protobuf/multiple_files_test.proto \ java/core/src/test/proto/com/google/protobuf/nested_builders_test.proto \ java/core/src/test/proto/com/google/protobuf/nested_extension.proto \ @@ -331,63 +466,44 @@ java_EXTRA_DIST= java/core/src/test/proto/com/google/protobuf/outer_class_name_test.proto \ java/core/src/test/proto/com/google/protobuf/outer_class_name_test2.proto \ java/core/src/test/proto/com/google/protobuf/outer_class_name_test3.proto \ + java/core/src/test/proto/com/google/protobuf/packed_field_test.proto \ + java/core/src/test/proto/com/google/protobuf/proto2_message.proto \ + java/core/src/test/proto/com/google/protobuf/proto2_message_lite.proto \ + java/core/src/test/proto/com/google/protobuf/proto2_unknown_enum_values.proto \ + java/core/src/test/proto/com/google/protobuf/proto3_message.proto \ + java/core/src/test/proto/com/google/protobuf/proto3_message_lite.proto \ java/core/src/test/proto/com/google/protobuf/test_bad_identifiers.proto \ java/core/src/test/proto/com/google/protobuf/test_check_utf8.proto \ java/core/src/test/proto/com/google/protobuf/test_check_utf8_size.proto \ java/core/src/test/proto/com/google/protobuf/test_custom_options.proto \ java/core/src/test/proto/com/google/protobuf/test_extra_interfaces.proto \ + java/core/src/test/proto/com/google/protobuf/wrappers_test.proto \ + java/lite.md \ + java/lite/generate-sources-build.xml \ + java/lite/generate-test-sources-build.xml \ + java/lite/lite.awk \ java/lite/pom.xml \ + java/lite/process-lite-sources-build.xml \ + java/lite/src/test/java/com/google/protobuf/LiteTest.java \ + java/lite/src/test/java/com/google/protobuf/Proto2MessageLiteInfoFactory.java \ java/pom.xml \ java/util/pom.xml \ + java/util/src/main/java/com/google/protobuf/util/Durations.java \ java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java \ java/util/src/main/java/com/google/protobuf/util/FieldMaskUtil.java \ java/util/src/main/java/com/google/protobuf/util/JsonFormat.java \ java/util/src/main/java/com/google/protobuf/util/TimeUtil.java \ + java/util/src/main/java/com/google/protobuf/util/Structs.java \ + java/util/src/main/java/com/google/protobuf/util/Timestamps.java \ + java/util/src/main/java/com/google/protobuf/util/Values.java \ java/util/src/test/java/com/google/protobuf/util/FieldMaskTreeTest.java \ java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java \ java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java \ + java/util/src/test/java/com/google/protobuf/util/StructsTest.java \ java/util/src/test/java/com/google/protobuf/util/TimeUtilTest.java \ + java/util/src/test/java/com/google/protobuf/util/ValuesTest.java \ java/util/src/test/proto/com/google/protobuf/util/json_test.proto -javanano_EXTRA_DIST= \ - javanano/src/main/java/com/google/protobuf/nano/CodedOutputByteBufferNano.java \ - javanano/src/main/java/com/google/protobuf/nano/FieldData.java \ - javanano/src/main/java/com/google/protobuf/nano/FieldArray.java \ - javanano/src/main/java/com/google/protobuf/nano/WireFormatNano.java \ - javanano/src/main/java/com/google/protobuf/nano/Extension.java \ - javanano/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java \ - javanano/src/main/java/com/google/protobuf/nano/UnknownFieldData.java \ - javanano/src/main/java/com/google/protobuf/nano/MessageNano.java \ - javanano/src/main/java/com/google/protobuf/nano/InternalNano.java \ - javanano/src/main/java/com/google/protobuf/nano/InvalidProtocolBufferNanoException.java \ - javanano/src/main/java/com/google/protobuf/nano/MapFactories.java \ - javanano/src/main/java/com/google/protobuf/nano/ExtendableMessageNano.java \ - javanano/src/main/java/com/google/protobuf/nano/MessageNanoPrinter.java \ - javanano/src/test/java/com/google/protobuf/nano/unittest_accessors_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/unittest_enum_class_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/unittest_reference_types_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/unittest_extension_repeated_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/unittest_has_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/unittest_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/unittest_multiple_nameclash_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/unittest_single_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/NanoTest.java \ - javanano/src/test/java/com/google/protobuf/nano/unittest_simple_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/unittest_import_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/unittest_repeated_merge_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/unittest_extension_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/unittest_repeated_packables_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/unittest_extension_singular_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/unittest_recursive_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/unittest_extension_packed_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/unittest_enum_validity_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/unittest_stringutf8_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/unittest_multiple_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/unittest_enum_class_multiple_nano.proto \ - javanano/src/test/java/com/google/protobuf/nano/map_test.proto \ - javanano/README.md \ - javanano/pom.xml - objectivec_EXTRA_DIST= \ objectivec/DevTools/check_version_stamps.sh \ objectivec/DevTools/compile_testing_protos.sh \ @@ -460,23 +576,81 @@ objectivec_EXTRA_DIST= \ objectivec/GPBWireFormat.m \ objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj \ objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/contents.xcworkspacedata \ + objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist \ objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings \ - objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcbaselines/8BBEA4A5147C727100C4ADB7.xcbaseline/FFE465CA-0E74-40E8-9F09-500B66B7DCB2.plist \ - objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcbaselines/8BBEA4A5147C727100C4ADB7.xcbaseline/Info.plist \ objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme \ objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme \ objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj \ objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/contents.xcworkspacedata \ + objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist \ objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings \ objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme \ objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme \ + objectivec/ProtocolBuffers_tvOS.xcodeproj/project.pbxproj \ + objectivec/ProtocolBuffers_tvOS.xcodeproj/project.xcworkspace/contents.xcworkspacedata \ + objectivec/ProtocolBuffers_tvOS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist \ + objectivec/ProtocolBuffers_tvOS.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings \ + objectivec/ProtocolBuffers_tvOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme \ + objectivec/ProtocolBuffers_tvOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme \ objectivec/README.md \ + objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.pbxproj \ + objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata \ + objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/OSXCocoaPodsTester.xcscheme \ + objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.h \ + objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.m \ + objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json \ + objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Base.lproj/MainMenu.xib \ + objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Info.plist \ + objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/main.m \ + objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-framework \ + objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-static \ + objectivec/Tests/CocoaPods/README.md \ + objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-framework \ + objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-static \ + objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.pbxproj \ + objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata \ + objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/iOSCocoaPodsTester.xcscheme \ + objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.h \ + objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.m \ + objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json \ + objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/LaunchScreen.storyboard \ + objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/Main.storyboard \ + objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Info.plist \ + objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.h \ + objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.m \ + objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/main.m \ + objectivec/Tests/CocoaPods/run_tests.sh \ objectivec/Tests/golden_message \ objectivec/Tests/golden_packed_fields_message \ objectivec/Tests/GPBARCUnittestProtos.m \ objectivec/Tests/GPBArrayTests.m \ objectivec/Tests/GPBCodedInputStreamTests.m \ objectivec/Tests/GPBCodedOuputStreamTests.m \ + objectivec/Tests/GPBCompileTest01.m \ + objectivec/Tests/GPBCompileTest02.m \ + objectivec/Tests/GPBCompileTest03.m \ + objectivec/Tests/GPBCompileTest04.m \ + objectivec/Tests/GPBCompileTest05.m \ + objectivec/Tests/GPBCompileTest06.m \ + objectivec/Tests/GPBCompileTest07.m \ + objectivec/Tests/GPBCompileTest08.m \ + objectivec/Tests/GPBCompileTest09.m \ + objectivec/Tests/GPBCompileTest10.m \ + objectivec/Tests/GPBCompileTest11.m \ + objectivec/Tests/GPBCompileTest12.m \ + objectivec/Tests/GPBCompileTest13.m \ + objectivec/Tests/GPBCompileTest14.m \ + objectivec/Tests/GPBCompileTest15.m \ + objectivec/Tests/GPBCompileTest16.m \ + objectivec/Tests/GPBCompileTest17.m \ + objectivec/Tests/GPBCompileTest18.m \ + objectivec/Tests/GPBCompileTest19.m \ + objectivec/Tests/GPBCompileTest20.m \ + objectivec/Tests/GPBCompileTest21.m \ + objectivec/Tests/GPBCompileTest22.m \ + objectivec/Tests/GPBCompileTest23.m \ + objectivec/Tests/GPBCompileTest24.m \ + objectivec/Tests/GPBCompileTest25.m \ objectivec/Tests/GPBConcurrencyTests.m \ objectivec/Tests/GPBDescriptorTests.m \ objectivec/Tests/GPBDictionaryTests+Bool.m \ @@ -485,7 +659,9 @@ objectivec_EXTRA_DIST= \ objectivec/Tests/GPBDictionaryTests+String.m \ objectivec/Tests/GPBDictionaryTests+UInt32.m \ objectivec/Tests/GPBDictionaryTests+UInt64.m \ + objectivec/Tests/GPBDictionaryTests.m \ objectivec/Tests/GPBDictionaryTests.pddm \ + objectivec/Tests/GPBExtensionRegistryTest.m \ objectivec/Tests/GPBMessageTests+Merge.m \ objectivec/Tests/GPBMessageTests+Runtime.m \ objectivec/Tests/GPBMessageTests+Serialization.m \ @@ -496,28 +672,26 @@ objectivec_EXTRA_DIST= \ objectivec/Tests/GPBTestUtilities.h \ objectivec/Tests/GPBTestUtilities.m \ objectivec/Tests/GPBUnittestProtos.m \ + objectivec/Tests/GPBUnittestProtos2.m \ objectivec/Tests/GPBUnknownFieldSetTest.m \ objectivec/Tests/GPBUtilitiesTests.m \ objectivec/Tests/GPBWellKnownTypesTest.m \ objectivec/Tests/GPBWireFormatTests.m \ - objectivec/Tests/iOSTestHarness/AppDelegate.m \ - objectivec/Tests/iOSTestHarness/en.lproj/InfoPlist.strings \ - objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/Contents.json \ - objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6.png \ - objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6_2x.png \ - objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7.png \ - objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7_2x.png \ - objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6.png \ - objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6_2x.png \ - objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_2x.png \ - objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_3x.png \ - objectivec/Tests/iOSTestHarness/Images.xcassets/LaunchImage.launchimage/Contents.json \ - objectivec/Tests/iOSTestHarness/Info.plist \ - objectivec/Tests/iOSTestHarness/LaunchScreen.xib \ + objectivec/Tests/text_format_extensions_unittest_data.txt \ objectivec/Tests/text_format_map_unittest_data.txt \ objectivec/Tests/text_format_unittest_data.txt \ objectivec/Tests/unittest_cycle.proto \ + objectivec/Tests/unittest_deprecated.proto \ + objectivec/Tests/unittest_deprecated_file.proto \ + objectivec/Tests/unittest_extension_chain_a.proto \ + objectivec/Tests/unittest_extension_chain_b.proto \ + objectivec/Tests/unittest_extension_chain_c.proto \ + objectivec/Tests/unittest_extension_chain_d.proto \ + objectivec/Tests/unittest_extension_chain_e.proto \ + objectivec/Tests/unittest_extension_chain_f.proto \ + objectivec/Tests/unittest_extension_chain_g.proto \ objectivec/Tests/unittest_objc.proto \ + objectivec/Tests/unittest_objc_options.proto \ objectivec/Tests/unittest_objc_startup.proto \ objectivec/Tests/unittest_runtime_proto2.proto \ objectivec/Tests/unittest_runtime_proto3.proto \ @@ -525,10 +699,196 @@ objectivec_EXTRA_DIST= \ objectivec/Tests/UnitTests-Info.plist \ Protobuf.podspec +php_EXTRA_DIST= \ + composer.json \ + php/README.md \ + php/composer.json \ + php/ext/google/protobuf/array.c \ + php/ext/google/protobuf/builtin_descriptors.inc \ + php/ext/google/protobuf/config.m4 \ + php/ext/google/protobuf/def.c \ + php/ext/google/protobuf/encode_decode.c \ + php/ext/google/protobuf/map.c \ + php/ext/google/protobuf/message.c \ + php/ext/google/protobuf/package.xml \ + php/ext/google/protobuf/protobuf.c \ + php/ext/google/protobuf/protobuf.h \ + php/ext/google/protobuf/storage.c \ + php/ext/google/protobuf/type_check.c \ + php/ext/google/protobuf/upb.c \ + php/ext/google/protobuf/upb.h \ + php/ext/google/protobuf/utf8.c \ + php/ext/google/protobuf/utf8.h \ + php/generate_descriptor_protos.sh \ + php/phpunit.xml \ + php/release.sh \ + php/src/GPBMetadata/Google/Protobuf/Any.php \ + php/src/GPBMetadata/Google/Protobuf/Api.php \ + php/src/GPBMetadata/Google/Protobuf/Duration.php \ + php/src/GPBMetadata/Google/Protobuf/FieldMask.php \ + php/src/GPBMetadata/Google/Protobuf/GPBEmpty.php \ + php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php \ + php/src/GPBMetadata/Google/Protobuf/SourceContext.php \ + php/src/GPBMetadata/Google/Protobuf/Struct.php \ + php/src/GPBMetadata/Google/Protobuf/Timestamp.php \ + php/src/GPBMetadata/Google/Protobuf/Type.php \ + php/src/GPBMetadata/Google/Protobuf/Wrappers.php \ + php/src/Google/Protobuf/Any.php \ + php/src/Google/Protobuf/Api.php \ + php/src/Google/Protobuf/BoolValue.php \ + php/src/Google/Protobuf/BytesValue.php \ + php/src/Google/Protobuf/Descriptor.php \ + php/src/Google/Protobuf/DescriptorPool.php \ + php/src/Google/Protobuf/DoubleValue.php \ + php/src/Google/Protobuf/Duration.php \ + php/src/Google/Protobuf/Enum.php \ + php/src/Google/Protobuf/EnumDescriptor.php \ + php/src/Google/Protobuf/EnumValue.php \ + php/src/Google/Protobuf/EnumValueDescriptor.php \ + php/src/Google/Protobuf/Field.php \ + php/src/Google/Protobuf/FieldDescriptor.php \ + php/src/Google/Protobuf/FieldMask.php \ + php/src/Google/Protobuf/Field/Cardinality.php \ + php/src/Google/Protobuf/Field_Cardinality.php \ + php/src/Google/Protobuf/Field/Kind.php \ + php/src/Google/Protobuf/Field_Kind.php \ + php/src/Google/Protobuf/FloatValue.php \ + php/src/Google/Protobuf/GPBEmpty.php \ + php/src/Google/Protobuf/Int32Value.php \ + php/src/Google/Protobuf/Int64Value.php \ + php/src/Google/Protobuf/Internal/CodedInputStream.php \ + php/src/Google/Protobuf/Internal/CodedOutputStream.php \ + php/src/Google/Protobuf/Internal/Descriptor.php \ + php/src/Google/Protobuf/Internal/DescriptorPool.php \ + php/src/Google/Protobuf/Internal/DescriptorProto.php \ + php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php \ + php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php \ + php/src/Google/Protobuf/Internal/EnumBuilderContext.php \ + php/src/Google/Protobuf/Internal/EnumDescriptor.php \ + php/src/Google/Protobuf/Internal/EnumDescriptorProto.php \ + php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php \ + php/src/Google/Protobuf/Internal/EnumOptions.php \ + php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php \ + php/src/Google/Protobuf/Internal/EnumValueOptions.php \ + php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php \ + php/src/Google/Protobuf/Internal/FieldDescriptorProto.php \ + php/src/Google/Protobuf/Internal/FieldDescriptor.php \ + php/src/Google/Protobuf/Internal/FieldDescriptorProto.php \ + php/src/Google/Protobuf/Internal/FieldDescriptorProto/Label.php \ + php/src/Google/Protobuf/Internal/FieldDescriptorProto/Type.php \ + php/src/Google/Protobuf/Internal/FieldOptions.php \ + php/src/Google/Protobuf/Internal/FieldOptions/CType.php \ + php/src/Google/Protobuf/Internal/FieldOptions/JSType.php \ + php/src/Google/Protobuf/Internal/FileDescriptor.php \ + php/src/Google/Protobuf/Internal/FileDescriptorProto.php \ + php/src/Google/Protobuf/Internal/FileDescriptorSet.php \ + php/src/Google/Protobuf/Internal/FileOptions.php \ + php/src/Google/Protobuf/Internal/FileOptions/OptimizeMode.php \ + php/src/Google/Protobuf/Internal/GPBDecodeException.php \ + php/src/Google/Protobuf/Internal/GPBJsonWire.php \ + php/src/Google/Protobuf/Internal/GPBLabel.php \ + php/src/Google/Protobuf/Internal/GPBType.php \ + php/src/Google/Protobuf/Internal/GPBUtil.php \ + php/src/Google/Protobuf/Internal/GPBWire.php \ + php/src/Google/Protobuf/Internal/GPBWireType.php \ + php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php \ + php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php \ + php/src/Google/Protobuf/Internal/GetPublicDescriptorTrait.php \ + php/src/Google/Protobuf/Internal/HasPublicDescriptorTrait.php \ + php/src/Google/Protobuf/Internal/MapEntry.php \ + php/src/Google/Protobuf/Internal/MapField.php \ + php/src/Google/Protobuf/Internal/MapFieldIter.php \ + php/src/Google/Protobuf/Internal/Message.php \ + php/src/Google/Protobuf/Internal/MessageBuilderContext.php \ + php/src/Google/Protobuf/Internal/MessageOptions.php \ + php/src/Google/Protobuf/Internal/MethodDescriptorProto.php \ + php/src/Google/Protobuf/Internal/MethodOptions.php \ + php/src/Google/Protobuf/Internal/MethodOptions/IdempotencyLevel.php \ + php/src/Google/Protobuf/Internal/OneofDescriptor.php \ + php/src/Google/Protobuf/Internal/OneofDescriptorProto.php \ + php/src/Google/Protobuf/Internal/OneofField.php \ + php/src/Google/Protobuf/Internal/OneofOptions.php \ + php/src/Google/Protobuf/Internal/RawInputStream.php \ + php/src/Google/Protobuf/Internal/RepeatedField.php \ + php/src/Google/Protobuf/Internal/RepeatedFieldIter.php \ + php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php \ + php/src/Google/Protobuf/Internal/ServiceOptions.php \ + php/src/Google/Protobuf/Internal/SourceCodeInfo.php \ + php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php \ + php/src/Google/Protobuf/Internal/UninterpretedOption.php \ + php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php \ + php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php \ + php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php \ + php/src/Google/Protobuf/Internal/EnumDescriptorProto_EnumReservedRange.php \ + php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php \ + php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php \ + php/src/Google/Protobuf/Internal/FieldOptions_CType.php \ + php/src/Google/Protobuf/Internal/FieldOptions_JSType.php \ + php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php \ + php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php \ + php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php \ + php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php \ + php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php \ + php/src/Google/Protobuf/ListValue.php \ + php/src/Google/Protobuf/Method.php \ + php/src/Google/Protobuf/Mixin.php \ + php/src/Google/Protobuf/NullValue.php \ + php/src/Google/Protobuf/OneofDescriptor.php \ + php/src/Google/Protobuf/Option.php \ + php/src/Google/Protobuf/SourceContext.php \ + php/src/Google/Protobuf/StringValue.php \ + php/src/Google/Protobuf/Struct.php \ + php/src/Google/Protobuf/Syntax.php \ + php/src/Google/Protobuf/Timestamp.php \ + php/src/Google/Protobuf/Type.php \ + php/src/Google/Protobuf/UInt32Value.php \ + php/src/Google/Protobuf/UInt64Value.php \ + php/src/Google/Protobuf/Value.php \ + php/src/phpdoc.dist.xml \ + php/tests/array_test.php \ + php/tests/autoload.php \ + php/tests/bootstrap_phpunit.php \ + php/tests/compatibility_test.sh \ + php/tests/compile_extension.sh \ + php/tests/descriptors_test.php \ + php/tests/encode_decode_test.php \ + php/tests/gdb_test.sh \ + php/tests/generated_class_test.php \ + php/tests/generated_phpdoc_test.php \ + php/tests/generated_service_test.php \ + php/tests/map_field_test.php \ + php/tests/memory_leak_test.php \ + php/tests/php_implementation_test.php \ + php/tests/proto/empty/echo.proto \ + php/tests/proto/test.proto \ + php/tests/proto/test_descriptors.proto \ + php/tests/proto/test_empty_php_namespace.proto \ + php/tests/proto/test_import_descriptor_proto.proto \ + php/tests/proto/test_include.proto \ + php/tests/proto/test_no_namespace.proto \ + php/tests/proto/test_php_namespace.proto \ + php/tests/proto/test_prefix.proto \ + php/tests/proto/test_reserved_enum_lower.proto \ + php/tests/proto/test_reserved_enum_upper.proto \ + php/tests/proto/test_reserved_enum_value_lower.proto \ + php/tests/proto/test_reserved_enum_value_upper.proto \ + php/tests/proto/test_reserved_message_lower.proto \ + php/tests/proto/test_reserved_message_upper.proto \ + php/tests/proto/test_service.proto \ + php/tests/proto/test_service_namespace.proto \ + php/tests/proto/test_wrapper_type_setters.proto \ + php/tests/test.sh \ + php/tests/test_base.php \ + php/tests/test_util.php \ + php/tests/undefined_test.php \ + php/tests/well_known_test.php \ + php/tests/wrapper_type_setters_test.php + python_EXTRA_DIST= \ python/MANIFEST.in \ python/google/__init__.py \ python/google/protobuf/__init__.py \ + python/google/protobuf/compiler/__init__.py \ python/google/protobuf/descriptor.py \ python/google/protobuf/descriptor_database.py \ python/google/protobuf/descriptor_pool.py \ @@ -547,13 +907,16 @@ python_EXTRA_DIST= \ python/google/protobuf/internal/descriptor_test.py \ python/google/protobuf/internal/encoder.py \ python/google/protobuf/internal/enum_type_wrapper.py \ + python/google/protobuf/internal/extension_dict.py \ python/google/protobuf/internal/factory_test1.proto \ python/google/protobuf/internal/factory_test2.proto \ + python/google/protobuf/internal/file_options_test.proto \ python/google/protobuf/internal/generator_test.py \ python/google/protobuf/internal/import_test_package/__init__.py \ python/google/protobuf/internal/import_test_package/inner.proto \ python/google/protobuf/internal/import_test_package/outer.proto \ python/google/protobuf/internal/json_format_test.py \ + python/google/protobuf/internal/keywords_test.py \ python/google/protobuf/internal/message_factory_test.py \ python/google/protobuf/internal/message_listener.py \ python/google/protobuf/internal/message_set_extensions.proto \ @@ -562,14 +925,17 @@ python_EXTRA_DIST= \ python/google/protobuf/internal/more_extensions.proto \ python/google/protobuf/internal/more_extensions_dynamic.proto \ python/google/protobuf/internal/more_messages.proto \ + python/google/protobuf/internal/no_package.proto \ python/google/protobuf/internal/packed_field_test.proto \ python/google/protobuf/internal/proto_builder_test.py \ python/google/protobuf/internal/python_message.py \ + python/google/protobuf/internal/python_protobuf.cc \ python/google/protobuf/internal/reflection_test.py \ python/google/protobuf/internal/service_reflection_test.py \ python/google/protobuf/internal/symbol_database_test.py \ python/google/protobuf/internal/test_bad_identifiers.proto \ python/google/protobuf/internal/test_util.py \ + python/google/protobuf/internal/testing_refleaks.py \ python/google/protobuf/internal/text_encoding_test.py \ python/google/protobuf/internal/text_format_test.py \ python/google/protobuf/internal/type_checkers.py \ @@ -583,6 +949,8 @@ python_EXTRA_DIST= \ python/google/protobuf/json_format.py \ python/google/protobuf/message.py \ python/google/protobuf/message_factory.py \ + python/google/protobuf/python_protobuf.h \ + python/google/protobuf/proto_api.h \ python/google/protobuf/proto_builder.py \ python/google/protobuf/pyext/README \ python/google/protobuf/pyext/__init__.py \ @@ -601,13 +969,20 @@ python_EXTRA_DIST= \ python/google/protobuf/pyext/map_container.h \ python/google/protobuf/pyext/message.cc \ python/google/protobuf/pyext/message.h \ + python/google/protobuf/pyext/field.cc \ + python/google/protobuf/pyext/field.h \ + python/google/protobuf/pyext/unknown_fields.cc \ + python/google/protobuf/pyext/unknown_fields.h \ + python/google/protobuf/pyext/message_factory.cc \ + python/google/protobuf/pyext/message_factory.h \ + python/google/protobuf/pyext/message_module.cc \ python/google/protobuf/pyext/proto2_api_test.proto \ python/google/protobuf/pyext/python.proto \ - python/google/protobuf/pyext/python_protobuf.h \ python/google/protobuf/pyext/repeated_composite_container.cc \ python/google/protobuf/pyext/repeated_composite_container.h \ python/google/protobuf/pyext/repeated_scalar_container.cc \ python/google/protobuf/pyext/repeated_scalar_container.h \ + python/google/protobuf/pyext/safe_numerics.h \ python/google/protobuf/pyext/scoped_pyobject_ptr.h \ python/google/protobuf/reflection.py \ python/google/protobuf/service.py \ @@ -615,7 +990,10 @@ python_EXTRA_DIST= \ python/google/protobuf/symbol_database.py \ python/google/protobuf/text_encoding.py \ python/google/protobuf/text_format.py \ + python/google/protobuf/util/__init__.py \ + python/release.sh \ python/mox.py \ + python/setup.cfg \ python/setup.py \ python/stubout.py \ python/tox.ini \ @@ -623,10 +1001,18 @@ python_EXTRA_DIST= \ ruby_EXTRA_DIST= \ ruby/Gemfile \ - ruby/Gemfile.lock \ ruby/.gitignore \ ruby/README.md \ ruby/Rakefile \ + ruby/compatibility_tests/v3.0.0/tests/test_import.proto \ + ruby/compatibility_tests/v3.0.0/tests/stress.rb \ + ruby/compatibility_tests/v3.0.0/tests/repeated_field_test.rb \ + ruby/compatibility_tests/v3.0.0/tests/generated_code_test.rb \ + ruby/compatibility_tests/v3.0.0/tests/generated_code.proto \ + ruby/compatibility_tests/v3.0.0/tests/basic.rb \ + ruby/compatibility_tests/v3.0.0/test.sh \ + ruby/compatibility_tests/v3.0.0/Rakefile \ + ruby/compatibility_tests/v3.0.0/README.md \ ruby/ext/google/protobuf_c/defs.c \ ruby/ext/google/protobuf_c/encode_decode.c \ ruby/ext/google/protobuf_c/extconf.rb \ @@ -638,9 +1024,11 @@ ruby_EXTRA_DIST= \ ruby/ext/google/protobuf_c/storage.c \ ruby/ext/google/protobuf_c/upb.c \ ruby/ext/google/protobuf_c/upb.h \ + ruby/ext/google/protobuf_c/wrap_memcpy.c \ ruby/google-protobuf.gemspec \ ruby/lib/google/protobuf/message_exts.rb \ ruby/lib/google/protobuf/repeated_field.rb \ + ruby/lib/google/protobuf/well_known_types.rb \ ruby/lib/google/protobuf.rb \ ruby/pom.xml \ ruby/src/main/java/com/google/protobuf/jruby/RubyBuilder.java \ @@ -661,48 +1049,133 @@ ruby_EXTRA_DIST= \ ruby/src/main/java/com/google/protobuf/jruby/Utils.java \ ruby/src/main/java/google/ProtobufJavaService.java \ ruby/src/main/sentinel.proto \ + ruby/tests/basic_proto2.rb \ + ruby/tests/basic_test_proto2.proto \ + ruby/tests/basic_test.proto \ ruby/tests/basic.rb \ + ruby/tests/common_tests.rb \ + ruby/tests/encode_decode_test.rb \ + ruby/tests/gc_test.rb \ ruby/tests/repeated_field_test.rb \ ruby/tests/stress.rb \ + ruby/tests/generated_code_proto2_test.rb \ + ruby/tests/generated_code_proto2.proto \ ruby/tests/generated_code.proto \ + ruby/tests/test_import_proto2.proto \ + ruby/tests/test_import.proto \ + ruby/tests/test_ruby_package_proto2.proto \ + ruby/tests/test_ruby_package.proto \ ruby/tests/generated_code_test.rb \ + ruby/tests/well_known_types_test.rb \ + ruby/tests/type_errors.rb \ ruby/travis-test.sh -js_EXTRA_DIST= \ - js/README.md \ - js/binary/arith.js \ - js/binary/arith_test.js \ - js/binary/constants.js \ - js/binary/decoder.js \ - js/binary/decoder_test.js \ - js/binary/proto_test.js \ - js/binary/reader.js \ - js/binary/reader_test.js \ - js/binary/utils.js \ - js/binary/utils_test.js \ - js/binary/writer.js \ - js/binary/writer_test.js \ - js/data.proto \ - js/debug.js \ - js/debug_test.js \ - js/gulpfile.js \ - js/jasmine.json \ - js/message.js \ - js/message_test.js \ - js/node_loader.js \ - js/package.json \ - js/proto3_test.js \ - js/proto3_test.proto \ - js/test.proto \ - js/test2.proto \ - js/test3.proto \ - js/test4.proto \ - js/test5.proto \ - js/test_bootstrap.js \ - js/testbinary.proto \ +js_EXTRA_DIST= \ + js/README.md \ + js/binary/arith.js \ + js/binary/arith_test.js \ + js/binary/constants.js \ + js/binary/decoder.js \ + js/binary/decoder_test.js \ + js/binary/encoder.js \ + js/binary/message_test.js \ + js/binary/proto_test.js \ + js/binary/reader.js \ + js/binary/reader_test.js \ + js/binary/utils.js \ + js/binary/utils_test.js \ + js/binary/writer.js \ + js/binary/writer_test.js \ + js/commonjs/export.js \ + js/commonjs/export_asserts.js \ + js/commonjs/export_testdeps.js \ + js/commonjs/import_test.js \ + js/commonjs/jasmine.json \ + js/commonjs/rewrite_tests_for_commonjs.js \ + js/commonjs/strict_test.js \ + js/commonjs/test6/test6.proto \ + js/commonjs/test7/test7.proto \ + js/compatibility_tests/v3.0.0/binary/arith_test.js \ + js/compatibility_tests/v3.0.0/binary/decoder_test.js \ + js/compatibility_tests/v3.0.0/binary/proto_test.js \ + js/compatibility_tests/v3.0.0/binary/reader_test.js \ + js/compatibility_tests/v3.0.0/binary/utils_test.js \ + js/compatibility_tests/v3.0.0/binary/writer_test.js \ + js/compatibility_tests/v3.0.0/commonjs/export_asserts.js \ + js/compatibility_tests/v3.0.0/commonjs/export_testdeps.js \ + js/compatibility_tests/v3.0.0/commonjs/import_test.js \ + js/compatibility_tests/v3.0.0/commonjs/jasmine.json \ + js/compatibility_tests/v3.0.0/commonjs/rewrite_tests_for_commonjs.js \ + js/compatibility_tests/v3.0.0/commonjs/test6/test6.proto \ + js/compatibility_tests/v3.0.0/commonjs/test7/test7.proto \ + js/compatibility_tests/v3.0.0/data.proto \ + js/compatibility_tests/v3.0.0/debug_test.js \ + js/compatibility_tests/v3.0.0/jasmine1.json \ + js/compatibility_tests/v3.0.0/jasmine2.json \ + js/compatibility_tests/v3.0.0/jasmine3.json \ + js/compatibility_tests/v3.0.0/message_test.js \ + js/compatibility_tests/v3.0.0/proto3_test.js \ + js/compatibility_tests/v3.0.0/proto3_test.proto \ + js/compatibility_tests/v3.0.0/test2.proto \ + js/compatibility_tests/v3.0.0/test3.proto \ + js/compatibility_tests/v3.0.0/test4.proto \ + js/compatibility_tests/v3.0.0/test5.proto \ + js/compatibility_tests/v3.0.0/testbinary.proto \ + js/compatibility_tests/v3.0.0/testempty.proto \ + js/compatibility_tests/v3.0.0/test.proto \ + js/compatibility_tests/v3.0.0/test.sh \ + js/compatibility_tests/v3.1.0/testempty.proto \ + js/compatibility_tests/v3.1.0/testbinary.proto \ + js/compatibility_tests/v3.1.0/test5.proto \ + js/compatibility_tests/v3.1.0/test4.proto \ + js/compatibility_tests/v3.1.0/test3.proto \ + js/compatibility_tests/v3.1.0/test2.proto \ + js/compatibility_tests/v3.1.0/test.proto \ + js/compatibility_tests/v3.1.0/proto3_test.proto \ + js/compatibility_tests/v3.1.0/proto3_test.js \ + js/compatibility_tests/v3.1.0/message_test.js \ + js/compatibility_tests/v3.1.0/maps_test.js \ + js/compatibility_tests/v3.1.0/debug_test.js \ + js/compatibility_tests/v3.1.0/data.proto \ + js/compatibility_tests/v3.1.0/commonjs/test7/test7.proto \ + js/compatibility_tests/v3.1.0/commonjs/test6/test6.proto \ + js/compatibility_tests/v3.1.0/binary/writer_test.js \ + js/compatibility_tests/v3.1.0/binary/utils_test.js \ + js/compatibility_tests/v3.1.0/binary/reader_test.js \ + js/compatibility_tests/v3.1.0/binary/proto_test.js \ + js/compatibility_tests/v3.1.0/binary/decoder_test.js \ + js/compatibility_tests/v3.1.0/binary/arith_test.js \ + js/data.proto \ + js/debug.js \ + js/debug_test.js \ + js/gulpfile.js \ + js/jasmine.json \ + js/map.js \ + js/maps_test.js \ + js/message.js \ + js/message_test.js \ + js/node_loader.js \ + js/package.json \ + js/proto3_test.js \ + js/proto3_test.proto \ + js/test.proto \ + js/test2.proto \ + js/test3.proto \ + js/test4.proto \ + js/test5.proto \ + js/test8.proto \ + js/test9.proto \ + js/test10.proto \ + js/test11.proto \ + js/test12.proto \ + js/test13.proto \ + js/test14.proto \ + js/test15.proto \ + js/test_bootstrap.js \ + js/testbinary.proto \ js/testempty.proto -all_EXTRA_DIST=$(csharp_EXTRA_DIST) $(java_EXTRA_DIST) $(javanano_EXTRA_DIST) $(objectivec_EXTRA_DIST) $(python_EXTRA_DIST) $(ruby_EXTRA_DIST) $(js_EXTRA_DIST) +all_EXTRA_DIST=$(csharp_EXTRA_DIST) $(java_EXTRA_DIST) $(objectivec_EXTRA_DIST) $(php_EXTRA_DIST) $(python_EXTRA_DIST) $(ruby_EXTRA_DIST) $(js_EXTRA_DIST) EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \ autogen.sh \ @@ -713,10 +1186,11 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \ CHANGES.txt \ update_file_lists.sh \ BUILD \ - gmock.BUILD \ WORKSPACE \ cmake/CMakeLists.txt \ cmake/README.md \ + cmake/conformance.cmake \ + cmake/examples.cmake \ cmake/extract_includes.bat.in \ cmake/install.cmake \ cmake/libprotobuf.cmake \ @@ -724,29 +1198,48 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \ cmake/libprotoc.cmake \ cmake/protobuf-config-version.cmake.in \ cmake/protobuf-config.cmake.in \ + cmake/protobuf-lite.pc.cmake \ cmake/protobuf-module.cmake.in \ + cmake/protobuf-options.cmake \ + cmake/protobuf.pc.cmake \ cmake/protoc.cmake \ cmake/tests.cmake \ + cmake/version.rc.in \ + compiler_config_setting.bzl \ editors/README.txt \ editors/proto.vim \ editors/protobuf-mode.el \ - examples/README.txt \ + examples/AddPerson.java \ + examples/BUILD \ + examples/CMakeLists.txt \ + examples/ListPeople.java \ examples/Makefile \ - examples/addressbook.proto \ + examples/README.md \ + examples/WORKSPACE \ examples/add_person.cc \ + examples/add_person.dart \ examples/add_person.go \ + examples/add_person.py \ examples/add_person_test.go \ + examples/addressbook.proto \ examples/list_people.cc \ + examples/list_people.dart \ examples/list_people.go \ - examples/AddPerson.java \ - examples/ListPeople.java \ - examples/add_person.py \ examples/list_people.py \ examples/list_people_test.go \ + examples/pubspec.yaml \ + examples/third_party/zlib.BUILD \ protobuf.bzl \ + protobuf_deps.bzl \ + python/release/wheel/build_wheel_manylinux.sh \ + python/release/wheel/Dockerfile \ + python/release/wheel/protobuf_optimized_pip.sh \ + python/release/wheel/README.md \ six.BUILD \ + third_party/zlib.BUILD \ util/python/BUILD + # Deletes all the files generated by autogen.sh. MAINTAINERCLEANFILES = \ aclocal.m4 \ diff --git a/third_party/protobuf/OWNERS b/third_party/protobuf/OWNERS index f52d95fff54b..979e0de6958d 100644 --- a/third_party/protobuf/OWNERS +++ b/third_party/protobuf/OWNERS @@ -1,4 +1,6 @@ +ajwong@chromium.org +lgrey@chromium.org +nyquist@chromium.org pkasting@chromium.org -xyzzyz@chromium.org # COMPONENT: Internals diff --git a/third_party/protobuf/Protobuf.podspec b/third_party/protobuf/Protobuf.podspec index 0bbd06df0172..a195f83a479d 100644 --- a/third_party/protobuf/Protobuf.podspec +++ b/third_party/protobuf/Protobuf.podspec @@ -5,36 +5,38 @@ # dependent projects use the :git notation to refer to the library. Pod::Spec.new do |s| s.name = 'Protobuf' - s.version = '3.0.0-beta-2' + s.version = '3.9.0' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' - s.homepage = 'https://github.com/google/protobuf' - s.license = 'New BSD' + s.homepage = 'https://github.com/protocolbuffers/protobuf' + s.license = '3-Clause BSD License' s.authors = { 'The Protocol Buffers contributors' => 'protobuf@googlegroups.com' } + s.cocoapods_version = '>= 1.0' - s.source = { :git => 'https://github.com/google/protobuf.git', + s.source = { :git => 'https://github.com/protocolbuffers/protobuf.git', :tag => "v#{s.version}" } s.source_files = 'objectivec/*.{h,m}', 'objectivec/google/protobuf/Any.pbobjc.{h,m}', 'objectivec/google/protobuf/Api.pbobjc.{h,m}', - 'objectivec/google/protobuf/Duration.pbobjc.h', + 'objectivec/google/protobuf/Duration.pbobjc.{h,m}', 'objectivec/google/protobuf/Empty.pbobjc.{h,m}', 'objectivec/google/protobuf/FieldMask.pbobjc.{h,m}', 'objectivec/google/protobuf/SourceContext.pbobjc.{h,m}', 'objectivec/google/protobuf/Struct.pbobjc.{h,m}', - 'objectivec/google/protobuf/Timestamp.pbobjc.h', + 'objectivec/google/protobuf/Timestamp.pbobjc.{h,m}', 'objectivec/google/protobuf/Type.pbobjc.{h,m}', 'objectivec/google/protobuf/Wrappers.pbobjc.{h,m}' - # Timestamp.pbobjc.m and Duration.pbobjc.m are #imported by GPBWellKnownTypes.m. So we can't - # compile them (duplicate symbols), but we need them available for the importing: - s.preserve_paths = 'objectivec/google/protobuf/Duration.pbobjc.m', - 'objectivec/google/protobuf/Timestamp.pbobjc.m' # The following would cause duplicate symbol definitions. GPBProtocolBuffers is expected to be # left out, as it's an umbrella implementation file. s.exclude_files = 'objectivec/GPBProtocolBuffers.m' - s.header_mappings_dir = 'objectivec' - s.ios.deployment_target = '7.1' + # Set a CPP symbol so the code knows to use framework imports. + s.user_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1' } + s.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1' } + + s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' + s.tvos.deployment_target = '9.0' + s.watchos.deployment_target = '2.0' s.requires_arc = false end diff --git a/third_party/protobuf/README.chromium b/third_party/protobuf/README.chromium index 8838fbc2715f..a42e244383f0 100644 --- a/third_party/protobuf/README.chromium +++ b/third_party/protobuf/README.chromium @@ -3,14 +3,14 @@ Short Name: protobuf URL: https://github.com/google/protobuf License: BSD License File: LICENSE -Version: 3.0.0-beta-3 -Revision: 3470b6895aa659b7559ed678e029a5338e535f14 +Version: 3.9.0 +Revision: cf242503ec157a7dda8a6eda48712dd26c81d2e6 Security Critical: yes Steps used to create the current version: -1. Pull the release from https://github.com/google/protobuf/releases -2. Add build files (BUILD.gn, proto_library.gni, protobuf.gyp, - protobuf_lite.gypi, protobuf_nacl.gyp). +1. Pull the release from https://github.com/google/protobuf/releases (Source + code zip) +2. Add build files (BUILD.gn, proto_library.gni). Be sure to update the list of source files, as additional .cc files and headers might have been added -- you need to find the transitive closure of @@ -18,25 +18,34 @@ Steps used to create the current version: Other things to care about are defines required by protobuf on various platforms, warnings generated by compilers, and new dependencies introduced. -3. Get open-source library six.py from https://pypi.python.org/pypi/six/ and add +3. Add DEPS and OWNERS. +4. Add mirclient.cc and mirclient.map. +5. Add gen_extra_chromium_files. +6. Get open-source library six.py from https://pypi.python.org/pypi/six/ and add it to protobuf/third_party/six/six.py. -4. Apply patches in patches/ (see the description below): +7. Apply patches in patches/ (see the description below): $ for patch in patches/*; do patch -s -p1 < $patch; done For future releases, it will be worth looking into which patches still need - to be applied. -5. Generate descriptor_pb2.py using something like the following steps. Make - sure you've regenerated your buildfiles and will build protoc from the - newly-modified sources above. + to be applied. In case of conflict, update those patches accordingly and save + them back in place (i.e. in patches directory). +8. Generate descriptor_pb2.py using the script "gen_extra_chromium_files" in +the same directory as this file. - $ cd $SRC_DIR - $ ninja -C out/Debug protoc - $ cd third_party/protobuf/src - $ ../../../out/Debug/protoc --python_out=../python google/protobuf/descriptor.proto +9. Add an __init__.py to protobuf/ that adds third_party/six/ to Python path. +10. Update README.chromium. -6. Add an __init__.py to protobuf/ that adds third_party/six/ to Python path. -7. Update README.chromium. +Note about libmirclient: + +On Ubuntu, Chromium has an indirect dependency on the system +libprotobuf-lite through libmirclient (through GTK). The symbols in +the system library conflict with Chromium's libprotobuf-lite used on +component builds. + +mirclient.* are added to stub out libmirclient.so.9 to prevent loading +the system libprotobuf-lite. Chromium's replacement libmirclient will +get loaded, but its symbols will never be used directly or indirectly. Description of the patches: @@ -55,14 +64,6 @@ Description of the patches: protobuf symbols in Linux .so libraries, so that protobuf can be built as a component (see http://crrev.com/179806). -- 0005-fix-include-js-generator.protobuf - - During merge with internal branch, the <> in one of the #includes were - accidentally replaced with "", which results in a failure in checkdeps. - - Fixed in https://github.com/google/protobuf/pull/1547. - -- 0007-uninline_googleonce.patch - 0008-uninline_get_empty_string.patch - 0009-uninline-arenastring.patch - 0010-uninline-generated-code.patch @@ -70,9 +71,34 @@ Description of the patches: These patches uninline some functions, resulting in a significant reduction (somewhere between 500 KB and 1 MB) of binary size. -- 0011-libprotobuf_export.patch +- 0021-Fix-protobuf-s-library-.gitinore-file.patch + + Un-ignores python/google/protobuf/descriptor_pb2.py + +- 0026-json_objectwriter_override.patch + + Corrects/adds override in json_objectwriter.h and + default_value_objectwriter.h + (https://github.com/protocolbuffers/protobuf/pull/6515). + +- 0027-explicit-namespace.patch + + clang-cl requires friend class declarations to be fully namespaced. + (https://github.com/protocolbuffers/protobuf/pull/6516) + +- 0028-fix-repeated-field-export.patch + + clang and clang-cl differ on how to do template instantiation exporting (see + https://crbug.com/994001). This adds some macro magic copied from chromium + //base/export_template.h. + (https://github.com/protocolbuffers/protobuf/pull/6535) + +- 0029-Fix-order-for-mutex-macros.patch + + __declspec(dllexport) must come after __atrribute__(()) on clang-cl + (https://github.com/protocolbuffers/protobuf/pull/6524) + +- 0030-fix-use_unaligned-not-defined-warning.patch - During merge with internal branch, the dll export attribute was accidentally - removed in C++11 mode. + Fixes "GOOGLE_PROTOBUF_USE_UNALIGNED is not defined" compilation warning - Fixed in https://github.com/google/protobuf/pull/1549 diff --git a/third_party/protobuf/README.md b/third_party/protobuf/README.md index ba9c589d2bfd..049b8cc94ed0 100644 --- a/third_party/protobuf/README.md +++ b/third_party/protobuf/README.md @@ -1,8 +1,6 @@ Protocol Buffers - Google's data interchange format =================================================== -[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf) [![Build status](https://ci.appveyor.com/api/projects/status/73ctee6ua4w2ruin?svg=true)](https://ci.appveyor.com/project/protobuf/protobuf) - Copyright 2008 Google Inc. https://developers.google.com/protocol-buffers/ @@ -28,7 +26,7 @@ with the C++ runtime. For non-C++ users, the simplest way to install the protocol compiler is to download a pre-built binary from our release page: - [https://github.com/google/protobuf/releases](https://github.com/google/protobuf/releases) + [https://github.com/protocolbuffers/protobuf/releases](https://github.com/protocolbuffers/protobuf/releases) In the downloads section of each release, you can find pre-built binaries in zip packages: protoc-$VERSION-$PLATFORM.zip. It contains the protoc binary @@ -37,7 +35,7 @@ as well as a set of standard .proto files distributed along with protobuf. If you are looking for an old version that is not available in the release page, check out the maven repo here: - [http://repo1.maven.org/maven2/com/google/protobuf/protoc/](http://repo1.maven.org/maven2/com/google/protobuf/protoc/) + [https://repo1.maven.org/maven2/com/google/protobuf/protoc/](https://repo1.maven.org/maven2/com/google/protobuf/protoc/) These pre-built binaries are only provided for released versions. If you want to use the github master version at HEAD, or you need to modify protobuf code, @@ -54,24 +52,34 @@ Protobuf supports several different programming languages. For each programming language, you can find instructions in the corresponding source directory about how to install protobuf runtime for that specific language: -| Language | Source | -|--------------------------------------|-------------------------------------------------------| -| C++ (include C++ runtime and protoc) | [src](src) | -| Java | [java](java) | -| Python | [python](python) | -| Objective-C | [objectivec](objectivec) | -| C# | [csharp](csharp) | -| JavaNano | [javanano](javanano) | -| JavaScript | [js](js) | -| Ruby | [ruby](ruby) | -| Go | [golang/protobuf](https://github.com/golang/protobuf) | -| PHP | TBD | +| Language | Source | Ubuntu | MacOS | Windows | +|--------------------------------------|-------------------------------------------------------------|--------|-------|---------| +| C++ (include C++ runtime and protoc) | [src](src) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-cpp_distcheck.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fcpp_distcheck%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-bazel.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fbazel%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-dist_install.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fdist_install%2Fcontinuous) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-cpp.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fcpp%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-cpp_distcheck.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fcpp_distcheck%2Fcontinuous) | [![Build status](https://ci.appveyor.com/api/projects/status/73ctee6ua4w2ruin?svg=true)](https://ci.appveyor.com/project/protobuf/protobuf) | +| Java | [java](java) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-java_compatibility.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fjava_compatibility%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-java_jdk7.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fjava_jdk7%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-java_oracle7.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fjava_oracle7%2Fcontinuous) | | | +| Python | [python](python) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python27.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython27%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python33.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython33%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python34.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython34%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python35.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython35%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python36.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython36%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python37.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython37%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python_compatibility.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython_compatibility%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python27_cpp.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython27_cpp%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python33_cpp.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython33_cpp%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python34_cpp.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython34_cpp%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python35_cpp.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython35_cpp%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python36_cpp.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython36_cpp%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python37_cpp.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython37_cpp%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python-release.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython_release%2Fcontinuous) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-python.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fpython%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-python_cpp.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fpython_cpp%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-python-release.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fpython_release%2Fcontinuous) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/windows-python-release.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fwindows%2Fpython_release%2Fcontinuous) | +| Objective-C | [objectivec](objectivec) | | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-objectivec_cocoapods_integration.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fobjectivec_cocoapods_integration%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-objectivec_ios_debug.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fobjectivec_ios_debug%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-objectivec_ios_release.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fobjectivec_ios_release%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-objectivec_osx.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fobjectivec_osx%2Fcontinuous) | | +| C# | [csharp](csharp) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-csharp.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fcsharp%2Fcontinuous) | | [![Build status](https://ci.appveyor.com/api/projects/status/73ctee6ua4w2ruin?svg=true)](https://ci.appveyor.com/project/protobuf/protobuf)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/windows-csharp-release.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fwindows%2Fcsharp_release%2Fcontinuous) | +| JavaScript | [js](js) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-javascript.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fjavascript%2Fcontinuous) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-javascript.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fjavascript%2Fcontinuous) | | +| Ruby | [ruby](ruby) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-ruby23.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fruby23%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-ruby24.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fruby24%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-ruby25.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fruby25%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-ruby26.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fruby26%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-ruby-release.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fruby_release%2Fcontinuous) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-ruby23.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fruby23%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-ruby24.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fruby24%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-ruby25.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fruby25%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-ruby26.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fruby26%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-ruby-release.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fruby_release%2Fcontinuous) | | +| Go | [golang/protobuf](https://github.com/golang/protobuf) | | | | +| PHP | [php](php) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-php_all.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fphp_all%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-32-bit.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2F32-bit%2Fcontinuous) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-php5.6_mac.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fphp5.6_mac%2Fcontinuous)
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-php7.0_mac.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fphp7.0_mac%2Fcontinuous) | | +| Dart | [dart-lang/protobuf](https://github.com/dart-lang/protobuf) | [![Build Status](https://travis-ci.org/dart-lang/protobuf.svg?branch=master)](https://travis-ci.org/dart-lang/protobuf) | | | + +Quick Start +----------- + +The best way to learn how to use protobuf is to follow the tutorials in our +developer guide: +https://developers.google.com/protocol-buffers/docs/tutorials -Usage ------ +If you want to learn from code examples, take a look at the examples in the +[examples](examples) directory. + +Documentation +------------- The complete documentation for Protocol Buffers is available via the web at: - https://developers.google.com/protocol-buffers/ +https://developers.google.com/protocol-buffers/ diff --git a/third_party/protobuf/WORKSPACE b/third_party/protobuf/WORKSPACE index 065dc8198458..36876800242d 100644 --- a/third_party/protobuf/WORKSPACE +++ b/third_party/protobuf/WORKSPACE @@ -1,15 +1,29 @@ -new_http_archive( - name = "gmock_archive", - url = "https://googlemock.googlecode.com/files/gmock-1.7.0.zip", - sha256 = "26fcbb5925b74ad5fc8c26b0495dfc96353f4d553492eb97e85a8a6d2f43095b", - build_file = "gmock.BUILD", +workspace(name = "com_google_protobuf") + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("//:protobuf_deps.bzl", "protobuf_deps") + +# Load common dependencies. +protobuf_deps() + +new_local_repository( + name = "submodule_gmock", + build_file = "@//:third_party/googletest/BUILD.bazel", + path = "third_party/googletest", ) -new_http_archive( +http_archive( name = "six_archive", - url = "https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55", + build_file = "@//:six.BUILD", sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a", - build_file = "six.BUILD", + urls = ["https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55"], +) + +http_archive( + name = "bazel_skylib", + sha256 = "bbccf674aa441c266df9894182d80de104cabd19be98be002f6d478aaa31574d", + strip_prefix = "bazel-skylib-2169ae1c374aab4a09aa90e65efe1a3aad4e279b", + urls = ["https://github.com/bazelbuild/bazel-skylib/archive/2169ae1c374aab4a09aa90e65efe1a3aad4e279b.tar.gz"], ) bind( @@ -19,12 +33,12 @@ bind( bind( name = "gtest", - actual = "@gmock_archive//:gtest", + actual = "@submodule_gmock//:gtest", ) bind( name = "gtest_main", - actual = "@gmock_archive//:gtest_main", + actual = "@submodule_gmock//:gtest_main", ) bind( @@ -33,8 +47,8 @@ bind( ) maven_jar( - name = "guava_maven", - artifact = "com.google.guava:guava:18.0", + name = "guava_maven", + artifact = "com.google.guava:guava:18.0", ) bind( @@ -43,11 +57,21 @@ bind( ) maven_jar( - name = "gson_maven", - artifact = "com.google.code.gson:gson:2.3", + name = "gson_maven", + artifact = "com.google.code.gson:gson:2.7", ) bind( name = "gson", actual = "@gson_maven//jar", ) + +maven_jar( + name = "error_prone_annotations_maven", + artifact = "com.google.errorprone:error_prone_annotations:2.3.2", +) + +bind( + name = "error_prone_annotations", + actual = "@error_prone_annotations_maven//jar", +) diff --git a/third_party/protobuf/appveyor.bat b/third_party/protobuf/appveyor.bat index 9a46b9289217..7a35ceb4d678 100644 --- a/third_party/protobuf/appveyor.bat +++ b/third_party/protobuf/appveyor.bat @@ -1,16 +1,28 @@ setlocal +IF %platform%==MinGW GOTO build_mingw IF %language%==cpp GOTO build_cpp IF %language%==csharp GOTO build_csharp -echo Unsupported language %language%. Exiting. +echo Unsupported language %language% and platform %platform%. Exiting. goto :error +:build_mingw +echo Building MinGW +set PATH=C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;%PATH:C:\Program Files\Git\usr\bin;=% +mkdir build_mingw +cd build_mingw +cmake -G "%generator%" -Dprotobuf_BUILD_SHARED_LIBS=%BUILD_DLL% -Dprotobuf_UNICODE=%UNICODE% -Dprotobuf_BUILD_TESTS=0 ../cmake +mingw32-make -j8 all || goto error +rem cd %configuration% +rem tests.exe || goto error +goto :EOF + :build_cpp echo Building C++ mkdir build_msvc cd build_msvc -cmake -G "%generator%" -Dprotobuf_BUILD_SHARED_LIBS=%BUILD_DLL% ../cmake +cmake -G "%generator%" -Dprotobuf_BUILD_SHARED_LIBS=%BUILD_DLL% -Dprotobuf_UNICODE=%UNICODE% ../cmake msbuild protobuf.sln /p:Platform=%vcplatform% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" || goto error cd %configuration% tests.exe || goto error @@ -19,9 +31,16 @@ goto :EOF :build_csharp echo Building C# cd csharp\src -nuget restore -msbuild Google.Protobuf.sln /p:Platform="Any CPU" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" || goto error -nunit-console Google.Protobuf.Test\bin\%configuration%\Google.Protobuf.Test.dll || goto error +REM The platform environment variable is implicitly used by msbuild; +REM we don't want it. +set platform= +dotnet restore +dotnet build -c %configuration% || goto error + +echo Testing C# +dotnet test -c %configuration% -f netcoreapp2.1 Google.Protobuf.Test\Google.Protobuf.Test.csproj || goto error +dotnet test -c %configuration% -f net451 Google.Protobuf.Test\Google.Protobuf.Test.csproj || goto error + goto :EOF :error diff --git a/third_party/protobuf/appveyor.yml b/third_party/protobuf/appveyor.yml index c84ecae2f383..91f737a8c019 100644 --- a/third_party/protobuf/appveyor.yml +++ b/third_party/protobuf/appveyor.yml @@ -1,27 +1,42 @@ -# Only test one combination: "Visual Studio 12 + Win64 + Debug + DLL". We can -# test more combinations but AppVeyor just takes too long to finish (each -# combination takes ~15mins). -platform: - - Win64 - configuration: - Debug environment: matrix: - - language: cpp + # Only test few combinations: "Visual Studio 2015 (14) + Win64/MinGW + Debug + DLL". We can + # test more combinations but AppVeyor just takes too long to finish (each + # combination takes ~15mins). + - platform: MinGW + language: cpp + image: Visual Studio 2015 + + - platform: Win64 + language: cpp + image: Visual Studio 2015 BUILD_DLL: ON + UNICODE: ON + + - platform: Win64 + language: cpp + image: Visual Studio 2017 + BUILD_DLL: OFF + UNICODE: ON + + - platform: Win64 + language: csharp + image: Visual Studio 2017 - - language: csharp +# Our build scripts run tests automatically; we don't want AppVeyor +# to try to detect them itself. +test: off install: - - ps: Start-FileDownload https://googlemock.googlecode.com/files/gmock-1.7.0.zip - - 7z x gmock-1.7.0.zip - - rename gmock-1.7.0 gmock + - git submodule update --init --recursive before_build: - - if %platform%==Win32 set generator=Visual Studio 12 - - if %platform%==Win64 set generator=Visual Studio 12 Win64 + - if %platform%==MinGW set generator=MinGW Makefiles + - if %platform%==Win32 set generator=Visual Studio 14 + - if %platform%==Win64 set generator=Visual Studio 14 Win64 - if %platform%==Win32 set vcplatform=Win32 - if %platform%==Win64 set vcplatform=x64 diff --git a/third_party/protobuf/autogen.sh b/third_party/protobuf/autogen.sh index 5b4c29f8c06f..d00d21727c2d 100755 --- a/third_party/protobuf/autogen.sh +++ b/third_party/protobuf/autogen.sh @@ -17,7 +17,6 @@ if [ ! -z "$@" ]; then done fi - # Check that we're being run from the right directory. if test ! -f src/google/protobuf/stubs/common.h; then cat >&2 << __EOF__ @@ -27,18 +26,13 @@ __EOF__ exit 1 fi -# Check that gmock is present. Usually it is already there since the -# directory is set up as an SVN external. -if test ! -e gmock; then - echo "Google Mock not present. Fetching gmock-1.7.0 from the web..." - curl $curlopts -O https://googlemock.googlecode.com/files/gmock-1.7.0.zip - unzip -q gmock-1.7.0.zip - rm gmock-1.7.0.zip - mv gmock-1.7.0 gmock -fi - set -ex +# The absence of a m4 directory in googletest causes autoreconf to fail when +# building under the CentOS docker image. It's a warning in regular build on +# Ubuntu/gLinux as well. +mkdir -p third_party/googletest/m4 + # TODO(kenton): Remove the ",no-obsolete" part and fix the resulting warnings. autoreconf -f -i -Wall,no-obsolete diff --git a/third_party/protobuf/benchmarks/Makefile.am b/third_party/protobuf/benchmarks/Makefile.am index f730afe57644..423349720ae9 100644 --- a/third_party/protobuf/benchmarks/Makefile.am +++ b/third_party/protobuf/benchmarks/Makefile.am @@ -1,69 +1,658 @@ +benchmarks_protoc_inputs_benchmark_wrapper = \ + benchmarks.proto -benchmarks_protoc_inputs = \ - benchmarks.proto \ - benchmark_messages_proto3.proto +benchmarks_protoc_inputs = \ + datasets/google_message1/proto3/benchmark_message1_proto3.proto -benchmarks_protoc_inputs_proto2 = \ - benchmark_messages_proto2.proto +benchmarks_protoc_inputs_proto2 = \ + datasets/google_message1/proto2/benchmark_message1_proto2.proto \ + datasets/google_message2/benchmark_message2.proto \ + datasets/google_message3/benchmark_message3.proto \ + datasets/google_message3/benchmark_message3_1.proto \ + datasets/google_message3/benchmark_message3_2.proto \ + datasets/google_message3/benchmark_message3_3.proto \ + datasets/google_message3/benchmark_message3_4.proto \ + datasets/google_message3/benchmark_message3_5.proto \ + datasets/google_message3/benchmark_message3_6.proto \ + datasets/google_message3/benchmark_message3_7.proto \ + datasets/google_message3/benchmark_message3_8.proto \ + datasets/google_message4/benchmark_message4.proto \ + datasets/google_message4/benchmark_message4_1.proto \ + datasets/google_message4/benchmark_message4_2.proto \ + datasets/google_message4/benchmark_message4_3.proto -benchmarks_protoc_outputs = \ - benchmarks.pb.cc \ - benchmarks.pb.h \ - benchmark_messages_proto3.pb.cc \ - benchmark_messages_proto3.pb.h +make_tmp_dir: + mkdir -p 'tmp/java/src/main/java' + touch make_tmp_dir -benchmarks_protoc_outputs_proto2 = \ - benchmark_messages_proto2.pb.cc \ - benchmark_messages_proto2.pb.h -bin_PROGRAMS = generate-datasets +# We have to cd to $(srcdir) before executing protoc because $(protoc_inputs) is +# relative to srcdir, which may not be the same as the current directory when +# building out-of-tree. +protoc_middleman: make_tmp_dir $(top_srcdir)/src/protoc$(EXEEXT) $(benchmarks_protoc_inputs) $(well_known_type_protoc_inputs) $(benchmarks_protoc_inputs_benchmark_wrapper) + oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd/cpp --java_out=$$oldpwd/tmp/java/src/main/java --python_out=$$oldpwd/tmp $(benchmarks_protoc_inputs) $(benchmarks_protoc_inputs_benchmark_wrapper) ) + touch protoc_middleman + +protoc_middleman2: make_tmp_dir $(top_srcdir)/src/protoc$(EXEEXT) $(benchmarks_protoc_inputs_proto2) $(well_known_type_protoc_inputs) + oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd/cpp --java_out=$$oldpwd/tmp/java/src/main/java --python_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2) ) + touch protoc_middleman2 + +all_data = $$(find $$(cd $(srcdir) && pwd) -type f -name "dataset.*.pb" -not -path "$$(cd $(srcdir) && pwd)/tmp/*") + +############# CPP RULES ############## -generate_datasets_LDADD = $(top_srcdir)/src/libprotobuf.la -generate_datasets_SOURCES = generate_datasets.cc -generate_datasets_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir) -nodist_generate_datasets_SOURCES = \ - $(benchmarks_protoc_outputs) \ - $(benchmarks_protoc_outputs_proto2) +benchmarks_protoc_outputs = \ + cpp/benchmarks.pb.cc \ + cpp/datasets/google_message1/proto3/benchmark_message1_proto3.pb.cc + +benchmarks_protoc_outputs_header = \ + cpp/benchmarks.pb.h \ + cpp/datasets/google_message1/proto3/benchmark_message1_proto3.pb.h + +benchmarks_protoc_outputs_proto2_header = \ + cpp/datasets/google_message1/proto2/benchmark_message1_proto2.pb.h \ + cpp/datasets/google_message2/benchmark_message2.pb.h \ + cpp/datasets/google_message3/benchmark_message3.pb.h \ + cpp/datasets/google_message3/benchmark_message3_1.pb.h \ + cpp/datasets/google_message3/benchmark_message3_2.pb.h \ + cpp/datasets/google_message3/benchmark_message3_3.pb.h \ + cpp/datasets/google_message3/benchmark_message3_4.pb.h \ + cpp/datasets/google_message3/benchmark_message3_5.pb.h \ + cpp/datasets/google_message3/benchmark_message3_6.pb.h \ + cpp/datasets/google_message3/benchmark_message3_7.pb.h \ + cpp/datasets/google_message3/benchmark_message3_8.pb.h \ + cpp/datasets/google_message4/benchmark_message4.pb.h \ + cpp/datasets/google_message4/benchmark_message4_1.pb.h \ + cpp/datasets/google_message4/benchmark_message4_2.pb.h \ + cpp/datasets/google_message4/benchmark_message4_3.pb.h + +benchmarks_protoc_outputs_proto2 = \ + cpp/datasets/google_message1/proto2/benchmark_message1_proto2.pb.cc \ + cpp/datasets/google_message2/benchmark_message2.pb.cc \ + cpp/datasets/google_message3/benchmark_message3.pb.cc \ + cpp/datasets/google_message3/benchmark_message3_1.pb.cc \ + cpp/datasets/google_message3/benchmark_message3_2.pb.cc \ + cpp/datasets/google_message3/benchmark_message3_3.pb.cc \ + cpp/datasets/google_message3/benchmark_message3_4.pb.cc \ + cpp/datasets/google_message3/benchmark_message3_5.pb.cc \ + cpp/datasets/google_message3/benchmark_message3_6.pb.cc \ + cpp/datasets/google_message3/benchmark_message3_7.pb.cc \ + cpp/datasets/google_message3/benchmark_message3_8.pb.cc \ + cpp/datasets/google_message4/benchmark_message4.pb.cc \ + cpp/datasets/google_message4/benchmark_message4_1.pb.cc \ + cpp/datasets/google_message4/benchmark_message4_2.pb.cc \ + cpp/datasets/google_message4/benchmark_message4_3.pb.cc + + +$(benchmarks_protoc_outputs): protoc_middleman +$(benchmarks_protoc_outputs_header): protoc_middleman +$(benchmarks_protoc_outputs_proto2): protoc_middleman2 +$(benchmarks_protoc_outputs_proto2_header): protoc_middleman2 +initialize_submodule: + oldpwd=`pwd` + cd $(top_srcdir) && git submodule update --init -r third_party/benchmark && \ + cd third_party/benchmark && cmake -DCMAKE_BUILD_TYPE=Release && make + cd $$oldpwd + touch initialize_submodule + +$(top_srcdir)/third_party/benchmark/src/libbenchmark.a: initialize_submodule + +AM_CXXFLAGS = $(NO_OPT_CXXFLAGS) $(PROTOBUF_OPT_FLAG) -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare + +bin_PROGRAMS = cpp-benchmark + +cpp_benchmark_LDADD = $(top_srcdir)/src/libprotobuf.la $(top_srcdir)/third_party/benchmark/src/libbenchmark.a +cpp_benchmark_SOURCES = cpp/cpp_benchmark.cc +cpp_benchmark_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)/cpp -I$(top_srcdir)/third_party/benchmark/include # Explicit deps because BUILT_SOURCES are only done before a "make all/check" # so a direct "make test_cpp" could fail if parallel enough. # See: https://www.gnu.org/software/automake/manual/html_node/Built-Sources-Example.html#Recording-Dependencies-manually -generate_datasets-generate_datasets.$(OBJEXT): benchmarks.pb.h +cpp/cpp_benchmark-cpp_benchmark.$(OBJEXT): $(benchmarks_protoc_outputs) $(benchmarks_protoc_outputs_proto2) $(benchmarks_protoc_outputs_header) $(benchmarks_protoc_outputs_proto2_header) $(top_srcdir)/src/libprotobuf.la $(top_srcdir)/third_party/benchmark/src/libbenchmark.a +cpp/benchmark-cpp_benchmark.$(OBJEXT): $(benchmarks_protoc_outputs) $(benchmarks_protoc_outputs_proto2) $(benchmarks_protoc_outputs_header) $(benchmarks_protoc_outputs_proto2_header) $(top_srcdir)/src/libprotobuf.la $(top_srcdir)/third_party/benchmark/src/libbenchmark.a +nodist_cpp_benchmark_SOURCES = \ + $(benchmarks_protoc_outputs) \ + $(benchmarks_protoc_outputs_proto2) \ + $(benchmarks_protoc_outputs_proto2_header) \ + $(benchmarks_protoc_outputs_header) -$(benchmarks_protoc_outputs): protoc_middleman -$(benchmarks_protoc_outputs_proto2): protoc_middleman2 +cpp: protoc_middleman protoc_middleman2 cpp-benchmark initialize_submodule + ./cpp-benchmark $(all_data) -CLEANFILES = \ - $(benchmarks_protoc_outputs) \ - $(benchmarks_protoc_outputs_proto2) \ - protoc_middleman \ - protoc_middleman2 \ - dataset.* +############ CPP RULES END ############ -MAINTAINERCLEANFILES = \ - Makefile.in +############# JAVA RULES ############## -if USE_EXTERNAL_PROTOC +java_benchmark_testing_files = \ + java/src/main/java/com/google/protobuf/ProtoCaliperBenchmark.java -protoc_middleman: $(benchmarks_protoc_inputs) - $(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. $(benchmarks_protoc_inputs) - touch protoc_middleman +javac_middleman: $(java_benchmark_testing_files) protoc_middleman protoc_middleman2 + cp -r $(srcdir)/java tmp + mkdir -p tmp/java/lib + cp $(top_srcdir)/java/core/target/*.jar tmp/java/lib/protobuf-java.jar + cd tmp/java && mvn clean compile assembly:single -Dprotobuf.version=$(PACKAGE_VERSION) && cd ../.. + @touch javac_middleman -protoc_middleman2: $(benchmarks_protoc_inputs_proto2) - $(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. $(benchmarks_protoc_inputs_proto2) - touch protoc_middleman2 +java-benchmark: javac_middleman + @echo "Writing shortcut script java-benchmark..." + @echo '#! /bin/bash' > java-benchmark + @echo 'all_data=""' >> java-benchmark + @echo 'conf=()' >> java-benchmark + @echo 'data_files=""' >> java-benchmark + @echo 'for arg in $$@; do if [[ $${arg:0:1} == "-" ]]; then conf+=($$arg); else data_files+="$$arg,"; fi; done' >> java-benchmark + @echo 'java -cp '\"tmp/java/target/*:$(top_srcdir)/java/core/target/*:$(top_srcdir)/java/util/target/*\"" \\" >>java-benchmark + @echo ' com.google.caliper.runner.CaliperMain com.google.protobuf.ProtoCaliperBenchmark -i runtime '"\\" >> java-benchmark + @echo ' -b serializeToByteArray,serializeToMemoryStream,deserializeFromByteArray,deserializeFromMemoryStream '"\\" >> java-benchmark + @echo ' -DdataFile=$${data_files:0:-1} $${conf[*]}' >> java-benchmark + @chmod +x java-benchmark -else +java: protoc_middleman protoc_middleman2 java-benchmark + ./java-benchmark $(all_data) -# We have to cd to $(srcdir) before executing protoc because $(protoc_inputs) is -# relative to srcdir, which may not be the same as the current directory when -# building out-of-tree. -protoc_middleman: $(top_srcdir)/src/protoc$(EXEEXT) $(benchmarks_protoc_inputs) $(well_known_type_protoc_inputs) - oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd $(benchmarks_protoc_inputs) ) - touch protoc_middleman +############# JAVA RULES END ############## -protoc_middleman2: $(top_srcdir)/src/protoc$(EXEEXT) $(benchmarks_protoc_inputs_proto2) $(well_known_type_protoc_inputs) - oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd $(benchmarks_protoc_inputs_proto2) ) - touch protoc_middleman -endif +############# PYTHON RULES ############## + +python_add_init: protoc_middleman protoc_middleman2 + all_file=`find tmp -type f -regex '.*\.py'` && \ + for file in $${all_file[@]}; do \ + path="$${file%/*}"; \ + while true; do \ + touch "$$path/__init__.py" && chmod +x "$$path/__init__.py"; \ + if [[ $$path != *"/"* ]]; then break; fi; \ + path=$${path%/*}; \ + done \ + done + +python_cpp_pkg_flags = `pkg-config --cflags --libs python` + +lib_LTLIBRARIES = libbenchmark_messages.la +libbenchmark_messages_la_SOURCES = python/python_benchmark_messages.cc +libbenchmark_messages_la_LIBADD = $(top_srcdir)/src/.libs/libprotobuf.la +libbenchmark_messages_la_LDFLAGS = -version-info 1:0:0 -export-dynamic +libbenchmark_messages_la_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)/cpp $(python_cpp_pkg_flags) +libbenchmark_messages_la-python_benchmark_messages.$(OBJEXT): $(benchmarks_protoc_outputs_header) $(benchmarks_protoc_outputs_proto2_header) $(benchmarks_protoc_outputs) $(benchmarks_protoc_outputs_proto2) +nodist_libbenchmark_messages_la_SOURCES = \ + $(benchmarks_protoc_outputs) \ + $(benchmarks_protoc_outputs_proto2) \ + $(benchmarks_protoc_outputs_proto2_header) \ + $(benchmarks_protoc_outputs_header) + +python-pure-python-benchmark: python_add_init + @echo "Writing shortcut script python-pure-python-benchmark..." + @echo '#! /bin/bash' > python-pure-python-benchmark + @echo export LD_LIBRARY_PATH=$(top_srcdir)/src/.libs >> python-pure-python-benchmark + @echo export DYLD_LIBRARY_PATH=$(top_srcdir)/src/.libs >> python-pure-python-benchmark + @echo export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=\'python\' >> python-pure-python-benchmark + @echo cp $(srcdir)/python/py_benchmark.py tmp >> python-pure-python-benchmark + @echo python tmp/py_benchmark.py '$$@' >> python-pure-python-benchmark + @chmod +x python-pure-python-benchmark + +python-cpp-reflection-benchmark: python_add_init + @echo "Writing shortcut script python-cpp-reflection-benchmark..." + @echo '#! /bin/bash' > python-cpp-reflection-benchmark + @echo export LD_LIBRARY_PATH=$(top_srcdir)/src/.libs >> python-cpp-reflection-benchmark + @echo export DYLD_LIBRARY_PATH=$(top_srcdir)/src/.libs >> python-cpp-reflection-benchmark + @echo export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=\'cpp\' >> python-cpp-reflection-benchmark + @echo cp $(srcdir)/python/py_benchmark.py tmp >> python-cpp-reflection-benchmark + @echo python tmp/py_benchmark.py '$$@' >> python-cpp-reflection-benchmark + @chmod +x python-cpp-reflection-benchmark + +python-cpp-generated-code-benchmark: python_add_init libbenchmark_messages.la + @echo "Writing shortcut script python-cpp-generated-code-benchmark..." + @echo '#! /bin/bash' > python-cpp-generated-code-benchmark + @echo export LD_LIBRARY_PATH=$(top_srcdir)/src/.libs >> python-cpp-generated-code-benchmark + @echo export DYLD_LIBRARY_PATH=$(top_srcdir)/src/.libs >> python-cpp-generated-code-benchmark + @echo export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=\'cpp\' >> python-cpp-generated-code-benchmark + @echo cp $(srcdir)/python/py_benchmark.py tmp >> python-cpp-generated-code-benchmark + @echo python tmp/py_benchmark.py --cpp_generated '$$@' >> python-cpp-generated-code-benchmark + @chmod +x python-cpp-generated-code-benchmark + +python-pure-python: python-pure-python-benchmark + ./python-pure-python-benchmark $(all_data) + +python-cpp-reflection: python-cpp-reflection-benchmark + ./python-cpp-reflection-benchmark $(all_data) + +python-cpp-generated-code: python-cpp-generated-code-benchmark + ./python-cpp-generated-code-benchmark $(all_data) + +############# PYTHON RULES END ############## + +############# GO RULES BEGIN ############## + +benchmarks_protoc_inputs_proto2_message1 = \ + datasets/google_message1/proto2/benchmark_message1_proto2.proto + +benchmarks_protoc_inputs_proto2_message2 = \ + datasets/google_message2/benchmark_message2.proto + +benchmarks_protoc_inputs_proto2_message3 = \ + datasets/google_message3/benchmark_message3.proto \ + datasets/google_message3/benchmark_message3_1.proto \ + datasets/google_message3/benchmark_message3_2.proto \ + datasets/google_message3/benchmark_message3_3.proto \ + datasets/google_message3/benchmark_message3_4.proto \ + datasets/google_message3/benchmark_message3_5.proto \ + datasets/google_message3/benchmark_message3_6.proto \ + datasets/google_message3/benchmark_message3_7.proto \ + datasets/google_message3/benchmark_message3_8.proto + +benchmarks_protoc_inputs_proto2_message4 = \ + datasets/google_message4/benchmark_message4.proto \ + datasets/google_message4/benchmark_message4_1.proto \ + datasets/google_message4/benchmark_message4_2.proto \ + datasets/google_message4/benchmark_message4_3.proto + +go_protoc_middleman: make_tmp_dir $(top_srcdir)/src/protoc$(EXEEXT) $(benchmarks_protoc_inputs) $(well_known_type_protoc_inputs) $(benchmarks_protoc_inputs_proto2_message1) $(benchmarks_protoc_inputs_proto2_message2) $(benchmarks_protoc_inputs_proto2_message3) $(benchmarks_protoc_inputs_proto2_message4) $(well_known_type_protoc_inputs) + oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs) ) + oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_benchmark_wrapper) ) + oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2_message1) ) + oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2_message2) ) + oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2_message3) ) + oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2_message4) ) + touch go_protoc_middleman + +go-benchmark: go_protoc_middleman + @echo "Writing shortcut script go-benchmark..." + @echo '#! /bin/bash' > go-benchmark + @echo 'cd $(srcdir)/go' >> go-benchmark + @echo 'all_data=""' >> go-benchmark + @echo 'conf=()' >> go-benchmark + @echo 'data_files=()' >> go-benchmark + @echo 'for arg in $$@; do if [[ $${arg:0:1} == "-" ]]; then conf+=($$arg); else data_files+=("$$arg"); fi; done' >> go-benchmark + @echo 'go test -bench=. $${conf[*]} -- $${data_files[*]}' >> go-benchmark + @echo 'cd ..' >> go-benchmark + @chmod +x go-benchmark + +go: go_protoc_middleman go-benchmark + ./go-benchmark $(all_data) + +############# GO RULES END ############## + +############# GOGO RULES BEGIN ############ + +cpp_no_group_benchmarks_protoc_outputs_header = \ + gogo/cpp_no_group/benchmarks.pb.h \ + gogo/cpp_no_group/datasets/google_message1/proto3/benchmark_message1_proto3.pb.h + +cpp_no_group_benchmarks_protoc_outputs = \ + gogo/cpp_no_group/benchmarks.pb.cc \ + gogo/cpp_no_group/datasets/google_message1/proto3/benchmark_message1_proto3.pb.cc + +cpp_no_group_benchmarks_protoc_outputs_proto2_header = \ + gogo/cpp_no_group/datasets/google_message1/proto2/benchmark_message1_proto2.pb.h \ + gogo/cpp_no_group/datasets/google_message2/benchmark_message2.pb.h \ + gogo/cpp_no_group/datasets/google_message3/benchmark_message3.pb.h \ + gogo/cpp_no_group/datasets/google_message3/benchmark_message3_1.pb.h \ + gogo/cpp_no_group/datasets/google_message3/benchmark_message3_2.pb.h \ + gogo/cpp_no_group/datasets/google_message3/benchmark_message3_3.pb.h \ + gogo/cpp_no_group/datasets/google_message3/benchmark_message3_4.pb.h \ + gogo/cpp_no_group/datasets/google_message3/benchmark_message3_5.pb.h \ + gogo/cpp_no_group/datasets/google_message3/benchmark_message3_6.pb.h \ + gogo/cpp_no_group/datasets/google_message3/benchmark_message3_7.pb.h \ + gogo/cpp_no_group/datasets/google_message3/benchmark_message3_8.pb.h \ + gogo/cpp_no_group/datasets/google_message4/benchmark_message4.pb.h \ + gogo/cpp_no_group/datasets/google_message4/benchmark_message4_1.pb.h \ + gogo/cpp_no_group/datasets/google_message4/benchmark_message4_2.pb.h \ + gogo/cpp_no_group/datasets/google_message4/benchmark_message4_3.pb.h + +cpp_no_group_benchmarks_protoc_outputs_proto2 = \ + gogo/cpp_no_group/datasets/google_message1/proto2/benchmark_message1_proto2.pb.cc \ + gogo/cpp_no_group/datasets/google_message2/benchmark_message2.pb.cc \ + gogo/cpp_no_group/datasets/google_message3/benchmark_message3.pb.cc \ + gogo/cpp_no_group/datasets/google_message3/benchmark_message3_1.pb.cc \ + gogo/cpp_no_group/datasets/google_message3/benchmark_message3_2.pb.cc \ + gogo/cpp_no_group/datasets/google_message3/benchmark_message3_3.pb.cc \ + gogo/cpp_no_group/datasets/google_message3/benchmark_message3_4.pb.cc \ + gogo/cpp_no_group/datasets/google_message3/benchmark_message3_5.pb.cc \ + gogo/cpp_no_group/datasets/google_message3/benchmark_message3_6.pb.cc \ + gogo/cpp_no_group/datasets/google_message3/benchmark_message3_7.pb.cc \ + gogo/cpp_no_group/datasets/google_message3/benchmark_message3_8.pb.cc \ + gogo/cpp_no_group/datasets/google_message4/benchmark_message4.pb.cc \ + gogo/cpp_no_group/datasets/google_message4/benchmark_message4_1.pb.cc \ + gogo/cpp_no_group/datasets/google_message4/benchmark_message4_2.pb.cc \ + gogo/cpp_no_group/datasets/google_message4/benchmark_message4_3.pb.cc + +$(cpp_no_group_benchmarks_protoc_outputs): cpp_no_group_protoc_middleman +$(cpp_no_group_benchmarks_protoc_outputs_header): cpp_no_group_protoc_middleman +$(cpp_no_group_benchmarks_protoc_outputs_proto2): cpp_no_group_protoc_middleman +$(cpp_no_group_benchmarks_protoc_outputs_proto2_header): cpp_no_group_protoc_middleman + +generate_cpp_no_group_benchmark_code: + cp $(srcdir)/cpp/cpp_benchmark.cc gogo/cpp_no_group/cpp_benchmark.cc + sed -i -e "s/\#include \"datasets/\#include \"gogo\/cpp_no_group\/datasets/g" gogo/cpp_no_group/cpp_benchmark.cc + sed -i -e "s/\#include \"benchmarks.pb.h/\#include \"gogo\/cpp_no_group\/benchmarks.pb.h/g" gogo/cpp_no_group/cpp_benchmark.cc + touch generate_cpp_no_group_benchmark_code + +bin_PROGRAMS += cpp-no-group-benchmark +cpp_no_group_benchmark_LDADD = $(top_srcdir)/src/libprotobuf.la $(top_srcdir)/third_party/benchmark/src/libbenchmark.a +cpp_no_group_benchmark_SOURCES = gogo/cpp_no_group/cpp_benchmark.cc +cpp_no_group_benchmark_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)/gogo/cpp_no_group -I$(top_srcdir)/third_party/benchmark/include +# Explicit deps because BUILT_SOURCES are only done before a "make all/check" +# so a direct "make test_cpp" could fail if parallel enough. +# See: https://www.gnu.org/software/automake/manual/html_node/Built-Sources-Example.html#Recording-Dependencies-manually +gogo/cpp_no_group/cpp_no_group_benchmark-cpp_benchmark.$(OBJEXT): $(cpp_no_group_benchmarks_protoc_outputs) $(cpp_no_group_benchmarks_protoc_outputs_proto2) $(cpp_no_group_benchmarks_protoc_outputs_header) \ + $(cpp_no_group_benchmarks_protoc_outputs_proto2_header) $(top_srcdir)/third_party/benchmark/src/libbenchmark.a generate_cpp_no_group_benchmark_code +gogo/cpp_no_group/cpp_benchmark.cc: generate_cpp_no_group_benchmark_code +nodist_cpp_no_group_benchmark_SOURCES = \ + $(cpp_no_group_benchmarks_protoc_outputs_proto2) \ + $(cpp_no_group_benchmarks_protoc_outputs) \ + $(cpp_no_group_benchmarks_protoc_outputs_header) \ + $(cpp_no_group_benchmarks_protoc_outputs_proto2_header) + +cpp_no_group: cpp_no_group_protoc_middleman generate_gogo_data cpp-no-group-benchmark + ./cpp-no-group-benchmark $(gogo_data) + +gogo_proto_middleman: protoc-gen-gogoproto + mkdir -p "tmp/gogo_proto" + oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I$(srcdir) -I$(top_srcdir) --plugin=protoc-gen-gogoproto --gogoproto_out=$$oldpwd/tmp/gogo_proto $(benchmarks_protoc_inputs) $(benchmarks_protoc_inputs_benchmark_wrapper) $(benchmarks_protoc_inputs_proto2) ) + touch gogo_proto_middleman + +gogo_data = $$(for data in $(all_data); do echo "tmp/gogo_data$${data\#$(srcdir)}"; done | xargs) + +generate_gogo_data: protoc_middleman protoc_middleman2 gogo-data-scrubber + mkdir -p `dirname $(gogo_data)` + ./gogo-data-scrubber $(all_data) $(gogo_data) + touch generate_gogo_data + +make_tmp_dir_gogo: + mkdir -p tmp/go_no_group/benchmark_code + mkdir -p tmp/gogofast/benchmark_code + mkdir -p tmp/gogofaster/benchmark_code + mkdir -p tmp/gogoslick/benchmark_code + touch make_tmp_dir_gogo + +go_no_group_protoc_middleman: make_tmp_dir_gogo $(top_srcdir)/src/protoc$(EXEEXT) gogo_proto_middleman $(well_known_type_protoc_inputs) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --go_out=$$oldpwd/tmp/go_no_group $(benchmarks_protoc_inputs) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --go_out=$$oldpwd/tmp/go_no_group $(benchmarks_protoc_inputs_benchmark_wrapper) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --go_out=$$oldpwd/tmp/go_no_group $(benchmarks_protoc_inputs_proto2_message1) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --go_out=$$oldpwd/tmp/go_no_group $(benchmarks_protoc_inputs_proto2_message2) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --go_out=$$oldpwd/tmp/go_no_group $(benchmarks_protoc_inputs_proto2_message3) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --go_out=$$oldpwd/tmp/go_no_group $(benchmarks_protoc_inputs_proto2_message4) ) + touch go_no_group_protoc_middleman + +cpp_no_group_protoc_middleman: make_tmp_dir_gogo $(top_srcdir)/src/protoc$(EXEEXT) gogo_proto_middleman $(well_known_type_protoc_inputs) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --cpp_out=$$oldpwd/gogo/cpp_no_group $(benchmarks_protoc_inputs) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --cpp_out=$$oldpwd/gogo/cpp_no_group $(benchmarks_protoc_inputs_benchmark_wrapper) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --cpp_out=$$oldpwd/gogo/cpp_no_group $(benchmarks_protoc_inputs_proto2_message1) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --cpp_out=$$oldpwd/gogo/cpp_no_group $(benchmarks_protoc_inputs_proto2_message2) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --cpp_out=$$oldpwd/gogo/cpp_no_group $(benchmarks_protoc_inputs_proto2_message3) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --cpp_out=$$oldpwd/gogo/cpp_no_group $(benchmarks_protoc_inputs_proto2_message4) ) + touch cpp_no_group_protoc_middleman + +gogofast_protoc_middleman: make_tmp_dir_gogo $(top_srcdir)/src/protoc$(EXEEXT) gogo_proto_middleman $(well_known_type_protoc_inputs) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofast_out=$$oldpwd/tmp/gogofast $(benchmarks_protoc_inputs) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofast_out=$$oldpwd/tmp/gogofast $(benchmarks_protoc_inputs_benchmark_wrapper) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofast_out=$$oldpwd/tmp/gogofast $(benchmarks_protoc_inputs_proto2_message1) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofast_out=$$oldpwd/tmp/gogofast $(benchmarks_protoc_inputs_proto2_message2) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofast_out=$$oldpwd/tmp/gogofast $(benchmarks_protoc_inputs_proto2_message3) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofast_out=$$oldpwd/tmp/gogofast $(benchmarks_protoc_inputs_proto2_message4) ) + touch gogofast_protoc_middleman + +gogofaster_protoc_middleman: make_tmp_dir_gogo $(top_srcdir)/src/protoc$(EXEEXT) gogo_proto_middleman $(well_known_type_protoc_inputs) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofaster_out=$$oldpwd/tmp/gogofaster $(benchmarks_protoc_inputs) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofaster_out=$$oldpwd/tmp/gogofaster $(benchmarks_protoc_inputs_benchmark_wrapper) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofaster_out=$$oldpwd/tmp/gogofaster $(benchmarks_protoc_inputs_proto2_message1) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofaster_out=$$oldpwd/tmp/gogofaster $(benchmarks_protoc_inputs_proto2_message2) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofaster_out=$$oldpwd/tmp/gogofaster $(benchmarks_protoc_inputs_proto2_message3) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofaster_out=$$oldpwd/tmp/gogofaster $(benchmarks_protoc_inputs_proto2_message4) ) + touch gogofaster_protoc_middleman + +gogoslick_protoc_middleman: make_tmp_dir_gogo $(top_srcdir)/src/protoc$(EXEEXT) gogo_proto_middleman $(well_known_type_protoc_inputs) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogoslick_out=$$oldpwd/tmp/gogoslick $(benchmarks_protoc_inputs) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogoslick_out=$$oldpwd/tmp/gogoslick $(benchmarks_protoc_inputs_benchmark_wrapper) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogoslick_out=$$oldpwd/tmp/gogoslick $(benchmarks_protoc_inputs_proto2_message1) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogoslick_out=$$oldpwd/tmp/gogoslick $(benchmarks_protoc_inputs_proto2_message2) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogoslick_out=$$oldpwd/tmp/gogoslick $(benchmarks_protoc_inputs_proto2_message3) ) + oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogoslick_out=$$oldpwd/tmp/gogoslick $(benchmarks_protoc_inputs_proto2_message4) ) + touch gogoslick_protoc_middleman + +generate-gogo-benchmark-code: + @echo '#! /bin/bash' > generate-gogo-benchmark-code + @echo 'cp $(srcdir)/go/go_benchmark_test.go tmp/$$1/benchmark_code/$$1_benchmark1_test.go' >> generate-gogo-benchmark-code + @echo 'sed -i -e "s/\.\.\/tmp/../g" tmp/$$1/benchmark_code/$$1_benchmark1_test.go' >> generate-gogo-benchmark-code + @echo 'sed -i -e "s/b\.Run(\"\(.*\)\"/b.Run(\"\1\_$$1\"/g" tmp/$$1/benchmark_code/$$1_benchmark1_test.go' >> generate-gogo-benchmark-code + @echo 'if [[ $$2 == 1 ]]; then sed -i -e "s/github\.com\/golang/github.com\/gogo/g" tmp/$$1/benchmark_code/$$1_benchmark1_test.go; fi ' >> generate-gogo-benchmark-code + @chmod +x generate-gogo-benchmark-code + +generate_all_gogo_benchmark_code: generate-gogo-benchmark-code make_tmp_dir_gogo + ./generate-gogo-benchmark-code go_no_group 0 + ./generate-gogo-benchmark-code gogofast 1 + ./generate-gogo-benchmark-code gogofaster 1 + ./generate-gogo-benchmark-code gogoslick 1 + +gogo-benchmark: + @echo "Writing shortcut script gogo-benchmark..." + @echo '#! /bin/bash' > gogo-benchmark + @echo 'cd tmp/$$1/benchmark_code' >> gogo-benchmark + @echo 'shift' >> gogo-benchmark + @echo 'all_data=""' >> gogo-benchmark + @echo 'for data_file in $$@; do all_data="$$all_data ../../../$$data_file"; done' >> gogo-benchmark + @echo 'go test -bench=. -- $$all_data' >> gogo-benchmark + @echo 'cd ../..' >> gogo-benchmark + @chmod +x gogo-benchmark + +go_no_group: go_no_group_protoc_middleman generate_gogo_data generate_all_gogo_benchmark_code gogo-benchmark + ./gogo-benchmark go_no_group $(gogo_data) + +gogofast: gogofast_protoc_middleman generate_gogo_data gogo-benchmark generate_all_gogo_benchmark_code + ./gogo-benchmark gogofast $(gogo_data) + +gogofaster: gogofaster_protoc_middleman generate_gogo_data gogo-benchmark generate_all_gogo_benchmark_code + ./gogo-benchmark gogofaster $(gogo_data) + +gogoslick: gogoslick_protoc_middleman generate_gogo_data gogo-benchmark generate_all_gogo_benchmark_code + ./gogo-benchmark gogoslick $(gogo_data) + + +############# GOGO RULES END ############ + + +############ UTIL RULES BEGIN ############ + +bin_PROGRAMS += protoc-gen-gogoproto gogo-data-scrubber protoc-gen-proto2_to_proto3 proto3-data-stripper + +protoc_gen_gogoproto_LDADD = $(top_srcdir)/src/libprotobuf.la $(top_srcdir)/src/libprotoc.la +protoc_gen_gogoproto_SOURCES = util/protoc-gen-gogoproto.cc +protoc_gen_gogoproto_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)/cpp -I$(srcdir)/util + +gogo_data_scrubber_LDADD = $(top_srcdir)/src/libprotobuf.la +gogo_data_scrubber_SOURCES = util/gogo_data_scrubber.cc +gogo_data_scrubber_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)/cpp -I$(srcdir)/util +util/gogo_data_scrubber-gogo_data_scrubber.$(OBJEXT): $(benchmarks_protoc_outputs) $(benchmarks_protoc_outputs_proto2) $(benchmarks_protoc_outputs_header) $(benchmarks_protoc_outputs_proto2_header) +nodist_gogo_data_scrubber_SOURCES = \ + $(benchmarks_protoc_outputs) \ + $(benchmarks_protoc_outputs_proto2) \ + $(benchmarks_protoc_outputs_proto2_header) \ + $(benchmarks_protoc_outputs_header) + +protoc_gen_proto2_to_proto3_LDADD = $(top_srcdir)/src/libprotobuf.la $(top_srcdir)/src/libprotoc.la +protoc_gen_proto2_to_proto3_SOURCES = util/protoc-gen-proto2_to_proto3.cc +protoc_gen_proto2_to_proto3_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)/cpp -I$(srcdir)/util + +proto3_data_stripper_LDADD = $(top_srcdir)/src/libprotobuf.la +proto3_data_stripper_SOURCES = util/proto3_data_stripper.cc +proto3_data_stripper_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)/cpp -I$(srcdir)/util +util/proto3_data_stripper-proto3_data_stripper.$(OBJEXT): $(benchmarks_protoc_outputs) $(benchmarks_protoc_outputs_proto2) $(benchmarks_protoc_outputs_header) $(benchmarks_protoc_outputs_proto2_header) +nodist_proto3_data_stripper_SOURCES = \ + $(benchmarks_protoc_outputs) \ + $(benchmarks_protoc_outputs_proto2) \ + $(benchmarks_protoc_outputs_proto2_header) \ + $(benchmarks_protoc_outputs_header) + + +############ UTIL RULES END ############ + +############ PROTO3 PREPARATION BEGIN ############# + +proto3_proto_middleman: protoc-gen-proto2_to_proto3 + mkdir -p "tmp/proto3_proto" + oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I$(srcdir) -I$(top_srcdir) --plugin=protoc-gen-proto2_to_proto3 --proto2_to_proto3_out=$$oldpwd/tmp/proto3_proto $(benchmarks_protoc_inputs) $(benchmarks_protoc_inputs_benchmark_wrapper) $(benchmarks_protoc_inputs_proto2) ) + touch proto3_proto_middleman + +full_srcdir = $$(cd $(srcdir) && pwd) +proto3_data = $$(for data in $(all_data); do echo $(full_srcdir)"/tmp/proto3_data$${data\#$(full_srcdir)}"; done | xargs) + +generate_proto3_data: protoc_middleman protoc_middleman2 proto3-data-stripper + mkdir -p `dirname $(proto3_data)` + ./proto3-data-stripper $(all_data) $(proto3_data) + touch generate_proto3_data + +############ PROTO3 PREPARATION END ############# + +############ PHP RULES BEGIN ################# + +proto3_middleman_php: proto3_proto_middleman + mkdir -p "tmp/php" + oldpwd=`pwd` && ( cd tmp/proto3_proto && $$oldpwd/../src/protoc$(EXEEXT) -I$(srcdir) -I$(top_srcdir) --php_out=$$oldpwd/tmp/php $(benchmarks_protoc_inputs) $(benchmarks_protoc_inputs_benchmark_wrapper) $(benchmarks_protoc_inputs_proto2) ) + touch proto3_middleman_php + +php-benchmark: proto3_middleman_php generate_proto3_data + mkdir -p "tmp/php/Google/Protobuf/Benchmark" && cp php/PhpBenchmark.php "tmp/php/Google/Protobuf/Benchmark" + cp php/autoload.php "tmp/php" + @echo "Writing shortcut script php-benchmark..." + @echo '#! /bin/bash' > php-benchmark + @echo 'export PROTOBUF_PHP_SRCDIR="$$(cd $(top_srcdir) && pwd)/php/src"' >> php-benchmark + @echo 'cd tmp/php' >> php-benchmark + @echo 'export CURRENT_DIR=$$(pwd)' >> php-benchmark + @echo 'php -d auto_prepend_file="autoload.php" -d include_path="$$(pwd)" Google/Protobuf/Benchmark/PhpBenchmark.php $$@' >> php-benchmark + @echo 'cd ../..' >> php-benchmark + @chmod +x php-benchmark + +php: php-benchmark proto3_middleman_php + ./php-benchmark --behavior_prefix="php" $(proto3_data) + +php_c_extension: + cd $(top_srcdir)/php/ext/google/protobuf && phpize && ./configure CFLAGS='-O3' && make -j8 + +php-c-benchmark: proto3_middleman_php generate_proto3_data php_c_extension php_c_extension + mkdir -p "tmp/php/Google/Protobuf/Benchmark" && cp php/PhpBenchmark.php "tmp/php/Google/Protobuf/Benchmark" + cp php/autoload.php "tmp/php" + @echo "Writing shortcut script php-c-benchmark..." + @echo '#! /bin/bash' > php-c-benchmark + @echo 'export PROTOBUF_PHP_SRCDIR="$$(cd $(top_srcdir) && pwd)/php/src"' >> php-c-benchmark + @echo 'export PROTOBUF_PHP_EXTDIR="$$PROTOBUF_PHP_SRCDIR/../ext/google/protobuf/modules"' >> php-c-benchmark + @echo 'cd tmp/php' >> php-c-benchmark + @echo 'export CURRENT_DIR=$$(pwd)' >> php-c-benchmark + @echo 'php -d auto_prepend_file="autoload.php" -d include_path="$$(pwd)" -d extension="$$PROTOBUF_PHP_EXTDIR/protobuf.so" Google/Protobuf/Benchmark/PhpBenchmark.php $$@' >> php-c-benchmark + @echo 'cd ../..' >> php-c-benchmark + @chmod +x php-c-benchmark + +php_c: php-c-benchmark proto3_middleman_php + ./php-c-benchmark --behavior_prefix="php_c" $(proto3_data) + + +############ PHP RULES END ################# + +############ protobuf.js RULE BEGIN ############# + +pbjs_preparation: + mkdir -p tmp/protobuf.js + cd tmp/protobuf.js && git clone https://github.com/dcodeIO/protobuf.js.git && \ + cd protobuf.js && npm install && npm run build + cd tmp/protobuf.js && npm install benchmark + cp protobuf.js/* tmp/protobuf.js + cp js/benchmark_suite.js tmp/protobuf.js + touch pbjs_preparation + +pbjs_middleman: pbjs_preparation + export OLDDIR=$$(pwd) && cd tmp/protobuf.js && node generate_pbjs_files.js --target static-module --include_path=$$OLDDIR -o generated_bundle_code.js $(benchmarks_protoc_inputs) $(benchmarks_protoc_inputs_benchmark_wrapper) $(benchmarks_protoc_inputs_proto2) + touch pbjs_middleman + +pbjs-benchmark: pbjs_middleman + @echo '#! /bin/bash' > pbjs-benchmark + @echo 'cd tmp/protobuf.js' >> pbjs-benchmark + @echo 'sed -i "s/protobufjs/.\/protobuf.js/g" generated_bundle_code.js' >> pbjs-benchmark + @echo 'env NODE_PATH=".:./node_modules:$$NODE_PATH" node protobufjs_benchmark.js $$@' >> pbjs-benchmark + @chmod +x pbjs-benchmark + +pbjs: pbjs-benchmark + ./pbjs-benchmark $(all_data) + +############ protobuf.js RULE END ############# + +############ JS RULE BEGIN ############# + +js_preparation: + mkdir -p tmp/js + oldpwd=$$(pwd) && cd $(top_srcdir)/js && npm install && npm test + cd tmp/js && npm install benchmark + cp js/* tmp/js + touch js_preparation + +js_middleman: js_preparation + oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --js_out=import_style=commonjs,binary:$$oldpwd/tmp/js $(benchmarks_protoc_inputs) $(benchmarks_protoc_inputs_benchmark_wrapper) $(benchmarks_protoc_inputs_proto2)) + touch js_middleman + +js-benchmark: js_middleman + @echo '#! /bin/bash' > js-benchmark + @echo 'export TOP_JS_SRCDIR=$$(cd $(top_srcdir)/js && pwd)' >> js-benchmark + @echo 'cd tmp/js' >> js-benchmark + @echo 'env NODE_PATH="$$TOP_JS_SRCDIR:.:./node_modules:$$NODE_PATH" node --max-old-space-size=4096 js_benchmark.js $$@' >> js-benchmark + @chmod +x js-benchmark + +js: js-benchmark + ./js-benchmark $(all_data) + +############ JS RULE END ############# + +MAINTAINERCLEANFILES = \ + Makefile.in + +CLEANFILES = \ + $(benchmarks_protoc_outputs) \ + $(benchmarks_protoc_outputs_header) \ + $(benchmarks_protoc_outputs_proto2) \ + $(benchmarks_protoc_outputs_proto2_header) \ + initialize_submodule \ + make_tmp_dir \ + protoc_middleman \ + protoc_middleman2 \ + javac_middleman \ + java-benchmark \ + python_cpp_proto_library \ + python-pure-python-benchmark \ + python-cpp-reflection-benchmark \ + python-cpp-generated-code-benchmark \ + go-benchmark \ + go_protoc_middleman \ + make_tmp_dir_gogo \ + gogo_proto_middleman \ + generate_gogo_data \ + go_no_group_protoc_middleman \ + go_no_group \ + go-no-group-benchmark \ + $(cpp_no_group_benchmarks_protoc_outputs_header) \ + $(cpp_no_group_benchmarks_protoc_outputs) \ + $(cpp_no_group_benchmarks_protoc_outputs_proto2_header) \ + $(cpp_no_group_benchmarks_protoc_outputs_proto2) \ + generate_all_gogo_benchmark_code \ + generate-gogo-benchmark-code \ + cpp_no_group_protoc_middleman \ + generate_cpp_no_group_benchmark_code \ + generate_gogo_benchmark_code \ + gogofast_protoc_middleman \ + gogofast \ + gogofaster_protoc_middleman \ + gogofaster \ + gogoslick_protoc_middleman \ + gogoslick \ + gogo-benchmark \ + gogo/cpp_no_group/cpp_benchmark.* \ + proto3_proto_middleman \ + generate_proto3_data \ + php-benchmark \ + php-c-benchmark \ + proto3_middleman_php \ + pbjs_preparation \ + pbjs_middleman \ + pbjs-benchmark \ + js_preparation \ + js_middleman \ + js-benchmark + +clean-local: + -rm -rf tmp/* + diff --git a/third_party/protobuf/benchmarks/ProtoBench.java b/third_party/protobuf/benchmarks/ProtoBench.java deleted file mode 100644 index 86d62feb67a3..000000000000 --- a/third_party/protobuf/benchmarks/ProtoBench.java +++ /dev/null @@ -1,203 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2009 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. - -package com.google.protocolbuffers; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.lang.reflect.Method; - -import com.google.protobuf.ByteString; -import com.google.protobuf.CodedInputStream; -import com.google.protobuf.CodedOutputStream; -import com.google.protobuf.Message; - -public class ProtoBench { - - private static final long MIN_SAMPLE_TIME_MS = 2 * 1000; - private static final long TARGET_TIME_MS = 30 * 1000; - - private ProtoBench() { - // Prevent instantiation - } - - public static void main(String[] args) { - if (args.length < 2 || (args.length % 2) != 0) { - System.err.println("Usage: ProtoBench "); - System.err.println("The descriptor type name is the fully-qualified message name,"); - System.err.println("e.g. com.google.protocolbuffers.benchmark.Message1"); - System.err.println("(You can specify multiple pairs of descriptor type name and input data.)"); - System.exit(1); - } - boolean success = true; - for (int i = 0; i < args.length; i += 2) { - success &= runTest(args[i], args[i + 1]); - } - System.exit(success ? 0 : 1); - } - - /** - * Runs a single test. Error messages are displayed to stderr, and the return value - * indicates general success/failure. - */ - public static boolean runTest(String type, String file) { - System.out.println("Benchmarking " + type + " with file " + file); - final Message defaultMessage; - try { - Class clazz = Class.forName(type); - Method method = clazz.getDeclaredMethod("getDefaultInstance"); - defaultMessage = (Message) method.invoke(null); - } catch (Exception e) { - // We want to do the same thing with all exceptions. Not generally nice, - // but this is slightly different. - System.err.println("Unable to get default message for " + type); - return false; - } - - try { - final byte[] inputData = readAllBytes(file); - final ByteArrayInputStream inputStream = new ByteArrayInputStream(inputData); - final ByteString inputString = ByteString.copyFrom(inputData); - final Message sampleMessage = defaultMessage.newBuilderForType().mergeFrom(inputString).build(); - FileOutputStream devNullTemp = null; - CodedOutputStream reuseDevNullTemp = null; - try { - devNullTemp = new FileOutputStream("/dev/null"); - reuseDevNullTemp = CodedOutputStream.newInstance(devNullTemp); - } catch (FileNotFoundException e) { - // ignore: this is probably Windows, where /dev/null does not exist - } - final FileOutputStream devNull = devNullTemp; - final CodedOutputStream reuseDevNull = reuseDevNullTemp; - benchmark("Serialize to byte string", inputData.length, new Action() { - public void execute() { sampleMessage.toByteString(); } - }); - benchmark("Serialize to byte array", inputData.length, new Action() { - public void execute() { sampleMessage.toByteArray(); } - }); - benchmark("Serialize to memory stream", inputData.length, new Action() { - public void execute() throws IOException { - sampleMessage.writeTo(new ByteArrayOutputStream()); - } - }); - if (devNull != null) { - benchmark("Serialize to /dev/null with FileOutputStream", inputData.length, new Action() { - public void execute() throws IOException { - sampleMessage.writeTo(devNull); - } - }); - benchmark("Serialize to /dev/null reusing FileOutputStream", inputData.length, new Action() { - public void execute() throws IOException { - sampleMessage.writeTo(reuseDevNull); - reuseDevNull.flush(); // force the write to the OutputStream - } - }); - } - benchmark("Deserialize from byte string", inputData.length, new Action() { - public void execute() throws IOException { - defaultMessage.newBuilderForType().mergeFrom(inputString).build(); - } - }); - benchmark("Deserialize from byte array", inputData.length, new Action() { - public void execute() throws IOException { - defaultMessage.newBuilderForType() - .mergeFrom(CodedInputStream.newInstance(inputData)).build(); - } - }); - benchmark("Deserialize from memory stream", inputData.length, new Action() { - public void execute() throws IOException { - defaultMessage.newBuilderForType() - .mergeFrom(CodedInputStream.newInstance(inputStream)).build(); - inputStream.reset(); - } - }); - System.out.println(); - return true; - } catch (Exception e) { - System.err.println("Error: " + e.getMessage()); - System.err.println("Detailed exception information:"); - e.printStackTrace(System.err); - return false; - } - } - - private static void benchmark(String name, long dataSize, Action action) throws IOException { - // Make sure it's JITted "reasonably" hard before running the first progress test - for (int i=0; i < 100; i++) { - action.execute(); - } - - // Run it progressively more times until we've got a reasonable sample - int iterations = 1; - long elapsed = timeAction(action, iterations); - while (elapsed < MIN_SAMPLE_TIME_MS) { - iterations *= 2; - elapsed = timeAction(action, iterations); - } - - // Upscale the sample to the target time. Do this in floating point arithmetic - // to avoid overflow issues. - iterations = (int) ((TARGET_TIME_MS / (double) elapsed) * iterations); - elapsed = timeAction(action, iterations); - System.out.println(name + ": " + iterations + " iterations in " - + (elapsed/1000f) + "s; " - + (iterations * dataSize) / (elapsed * 1024 * 1024 / 1000f) - + "MB/s"); - } - - private static long timeAction(Action action, int iterations) throws IOException { - System.gc(); - long start = System.currentTimeMillis(); - for (int i = 0; i < iterations; i++) { - action.execute(); - } - long end = System.currentTimeMillis(); - return end - start; - } - - private static byte[] readAllBytes(String filename) throws IOException { - RandomAccessFile file = new RandomAccessFile(new File(filename), "r"); - byte[] content = new byte[(int) file.length()]; - file.readFully(content); - return content; - } - - /** - * Interface used to capture a single action to benchmark. - */ - interface Action { - void execute() throws IOException; - } -} diff --git a/third_party/protobuf/benchmarks/README.md b/third_party/protobuf/benchmarks/README.md index c902780582a0..9711fa167d35 100644 --- a/third_party/protobuf/benchmarks/README.md +++ b/third_party/protobuf/benchmarks/README.md @@ -3,23 +3,238 @@ This directory contains benchmarking schemas and data sets that you can use to test a variety of performance scenarios against your -protobuf language runtime. +protobuf language runtime. If you are looking for performance +numbers of officially support languages, see [here]( +https://github.com/protocolbuffers/protobuf/blob/master/docs/performance.md) -The schema for the datasets is described in `benchmarks.proto`. +## Prerequisite + +First, you need to follow the instruction in the root directory's README to +build your language's protobuf, then: + +### CPP +You need to install [cmake](https://cmake.org/) before building the benchmark. + +We are using [google/benchmark](https://github.com/google/benchmark) as the +benchmark tool for testing cpp. This will be automaticly made during build the +cpp benchmark. + +The cpp protobuf performance can be improved by linking with [tcmalloc library]( +https://gperftools.github.io/gperftools/tcmalloc.html). For using tcmalloc, you +need to build [gpertools](https://github.com/gperftools/gperftools) to generate +libtcmallc.so library. + +### Java +We're using maven to build the java benchmarks, which is the same as to build +the Java protobuf. There're no other tools need to install. We're using +[google/caliper](https://github.com/google/caliper) as benchmark tool, which +can be automaticly included by maven. + +### Python +We're using python C++ API for testing the generated +CPP proto version of python protobuf, which is also a prerequisite for Python +protobuf cpp implementation. You need to install the correct version of Python +C++ extension package before run generated CPP proto version of Python +protobuf's benchmark. e.g. under Ubuntu, you need to + +``` +$ sudo apt-get install python-dev +$ sudo apt-get install python3-dev +``` +And you also need to make sure `pkg-config` is installed. + +### Go +Go protobufs are maintained at [github.com/golang/protobuf]( +http://github.com/golang/protobuf). If not done already, you need to install the +toolchain and the Go protoc-gen-go plugin for protoc. + +To install protoc-gen-go, run: + +``` +$ go get -u github.com/golang/protobuf/protoc-gen-go +$ export PATH=$PATH:$(go env GOPATH)/bin +``` + +The first command installs `protoc-gen-go` into the `bin` directory in your local `GOPATH`. +The second command adds the `bin` directory to your `PATH` so that `protoc` can locate the plugin later. + +### PHP +PHP benchmark's requirement is the same as PHP protobuf's requirements. The benchmark will automaticly +include PHP protobuf's src and build the c extension if required. + +### Node.js +Node.js benchmark need [node](https://nodejs.org/en/)(higher than V6) and [npm](https://www.npmjs.com/) package manager installed. This benchmark is using the [benchmark](https://www.npmjs.com/package/benchmark) framework to test, which needn't to manually install. And another prerequisite is [protobuf js](https://github.com/protocolbuffers/protobuf/tree/master/js), which needn't to manually install either + +### C# +The C# benchmark code is built as part of the main Google.Protobuf +solution. It requires the .NET Core SDK, and depends on +[BenchmarkDotNet](https://github.com/dotnet/BenchmarkDotNet), which +will be downloaded automatically. + +### Big data + +There's some optional big testing data which is not included in the directory +initially, you need to run the following command to download the testing data: + +``` +$ ./download_data.sh +``` + +After doing this the big data file will automatically generated in the +benchmark directory. + +## Run instructions + +To run all the benchmark dataset: -Generate the data sets like so: +### Java: ``` -$ make -$ ./generate-datasets -Wrote dataset: dataset.google_message1_proto3.pb -Wrote dataset: dataset.google_message1_proto2.pb -Wrote dataset: dataset.google_message2.pb -$ +$ make java ``` -Each data set will be written to its own file. Benchmarks will -likely want to run several benchmarks against each data set (parse, +### CPP: + +``` +$ make cpp +``` + +For linking with tcmalloc: + +``` +$ env LD_PRELOAD={directory to libtcmalloc.so} make cpp +``` + +### Python: + +We have three versions of python protobuf implementation: pure python, cpp +reflection and cpp generated code. To run these version benchmark, you need to: + +#### Pure Python: + +``` +$ make python-pure-python +``` + +#### CPP reflection: + +``` +$ make python-cpp-reflection +``` + +#### CPP generated code: + +``` +$ make python-cpp-generated-code +``` + +### Go +``` +$ make go +``` + + +### PHP +We have two version of php protobuf implemention: pure php, php with c extension. To run these version benchmark, you need to: +#### Pure PHP +``` +$ make php +``` +#### PHP with c extension +``` +$ make php_c +``` + +### Node.js +``` +$ make js +``` + +To run a specific dataset or run with specific options: + +### Java: + +``` +$ make java-benchmark +$ ./java-benchmark $(specific generated dataset file name) [$(caliper options)] +``` + +### CPP: + +``` +$ make cpp-benchmark +$ ./cpp-benchmark $(specific generated dataset file name) [$(benchmark options)] +``` + +### Python: + +For Python benchmark we have `--json` for outputing the json result + +#### Pure Python: + +``` +$ make python-pure-python-benchmark +$ ./python-pure-python-benchmark [--json] $(specific generated dataset file name) +``` + +#### CPP reflection: + +``` +$ make python-cpp-reflection-benchmark +$ ./python-cpp-reflection-benchmark [--json] $(specific generated dataset file name) +``` + +#### CPP generated code: + +``` +$ make python-cpp-generated-code-benchmark +$ ./python-cpp-generated-code-benchmark [--json] $(specific generated dataset file name) +``` + +### Go: +``` +$ make go-benchmark +$ ./go-benchmark $(specific generated dataset file name) [go testing options] +``` + +### PHP +#### Pure PHP +``` +$ make php-benchmark +$ ./php-benchmark $(specific generated dataset file name) +``` +#### PHP with c extension +``` +$ make php-c-benchmark +$ ./php-c-benchmark $(specific generated dataset file name) +``` + +### Node.js +``` +$ make js-benchmark +$ ./js-benchmark $(specific generated dataset file name) +``` + +### C# +From `csharp/src/Google.Protobuf.Benchmarks`, run: + +``` +$ dotnet run -c Release +``` + +We intend to add support for this within the makefile in due course. + +## Benchmark datasets + +Each data set is in the format of benchmarks.proto: + +1. name is the benchmark dataset's name. +2. message_name is the benchmark's message type full name (including package and message name) +3. payload is the list of raw data. + +The schema for the datasets is described in `benchmarks.proto`. + +Benchmark likely want to run several benchmarks against each data set (parse, serialize, possibly JSON, possibly using different APIs, etc). We would like to add more data sets. In general we will favor data sets diff --git a/third_party/protobuf/benchmarks/__init__.py b/third_party/protobuf/benchmarks/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/third_party/protobuf/benchmarks/benchmark_messages_proto2.proto b/third_party/protobuf/benchmarks/benchmark_messages_proto2.proto deleted file mode 100644 index 01f67a1af3f2..000000000000 --- a/third_party/protobuf/benchmarks/benchmark_messages_proto2.proto +++ /dev/null @@ -1,141 +0,0 @@ -// Benchmark messages for proto2. - -syntax = "proto2"; - -package benchmarks.proto2; -option java_package = "com.google.protobuf.benchmarks"; - -// This is the default, but we specify it here explicitly. -option optimize_for = SPEED; - -message GoogleMessage1 { - required string field1 = 1; - optional string field9 = 9; - optional string field18 = 18; - optional bool field80 = 80 [default=false]; - optional bool field81 = 81 [default=true]; - required int32 field2 = 2; - required int32 field3 = 3; - optional int32 field280 = 280; - optional int32 field6 = 6 [default=0]; - optional int64 field22 = 22; - optional string field4 = 4; - repeated fixed64 field5 = 5; - optional bool field59 = 59 [default=false]; - optional string field7 = 7; - optional int32 field16 = 16; - optional int32 field130 = 130 [default=0]; - optional bool field12 = 12 [default=true]; - optional bool field17 = 17 [default=true]; - optional bool field13 = 13 [default=true]; - optional bool field14 = 14 [default=true]; - optional int32 field104 = 104 [default=0]; - optional int32 field100 = 100 [default=0]; - optional int32 field101 = 101 [default=0]; - optional string field102 = 102; - optional string field103 = 103; - optional int32 field29 = 29 [default=0]; - optional bool field30 = 30 [default=false]; - optional int32 field60 = 60 [default=-1]; - optional int32 field271 = 271 [default=-1]; - optional int32 field272 = 272 [default=-1]; - optional int32 field150 = 150; - optional int32 field23 = 23 [default=0]; - optional bool field24 = 24 [default=false]; - optional int32 field25 = 25 [default=0]; - optional GoogleMessage1SubMessage field15 = 15; - optional bool field78 = 78; - optional int32 field67 = 67 [default=0]; - optional int32 field68 = 68; - optional int32 field128 = 128 [default=0]; - optional string field129 = 129 [default="xxxxxxxxxxxxxxxxxxxxx"]; - optional int32 field131 = 131 [default=0]; -} - -message GoogleMessage1SubMessage { - optional int32 field1 = 1 [default=0]; - optional int32 field2 = 2 [default=0]; - optional int32 field3 = 3 [default=0]; - optional string field15 = 15; - optional bool field12 = 12 [default=true]; - optional int64 field13 = 13; - optional int64 field14 = 14; - optional int32 field16 = 16; - optional int32 field19 = 19 [default=2]; - optional bool field20 = 20 [default=true]; - optional bool field28 = 28 [default=true]; - optional fixed64 field21 = 21; - optional int32 field22 = 22; - optional bool field23 = 23 [ default=false ]; - optional bool field206 = 206 [default=false]; - optional fixed32 field203 = 203; - optional int32 field204 = 204; - optional string field205 = 205; - optional uint64 field207 = 207; - optional uint64 field300 = 300; -} - -message GoogleMessage2 { - optional string field1 = 1; - optional int64 field3 = 3; - optional int64 field4 = 4; - optional int64 field30 = 30; - optional bool field75 = 75 [default=false]; - optional string field6 = 6; - optional bytes field2 = 2; - optional int32 field21 = 21 [default=0]; - optional int32 field71 = 71; - optional float field25 = 25; - optional int32 field109 = 109 [default=0]; - optional int32 field210 = 210 [default=0]; - optional int32 field211 = 211 [default=0]; - optional int32 field212 = 212 [default=0]; - optional int32 field213 = 213 [default=0]; - optional int32 field216 = 216 [default=0]; - optional int32 field217 = 217 [default=0]; - optional int32 field218 = 218 [default=0]; - optional int32 field220 = 220 [default=0]; - optional int32 field221 = 221 [default=0]; - optional float field222 = 222 [default=0.0]; - optional int32 field63 = 63; - - repeated group Group1 = 10 { - required float field11 = 11; - optional float field26 = 26; - optional string field12 = 12; - optional string field13 = 13; - repeated string field14 = 14; - required uint64 field15 = 15; - optional int32 field5 = 5; - optional string field27 = 27; - optional int32 field28 = 28; - optional string field29 = 29; - optional string field16 = 16; - repeated string field22 = 22; - repeated int32 field73 = 73; - optional int32 field20 = 20 [default=0]; - optional string field24 = 24; - optional GoogleMessage2GroupedMessage field31 = 31; - } - repeated string field128 = 128; - optional int64 field131 = 131; - repeated string field127 = 127; - optional int32 field129 = 129; - repeated int64 field130 = 130; - optional bool field205 = 205 [default=false]; - optional bool field206 = 206 [default=false]; -} - -message GoogleMessage2GroupedMessage { - optional float field1 = 1; - optional float field2 = 2; - optional float field3 = 3 [default=0.0]; - optional bool field4 = 4; - optional bool field5 = 5; - optional bool field6 = 6 [default=true]; - optional bool field7 = 7 [default=false]; - optional float field8 = 8; - optional bool field9 = 9; - optional float field10 = 10; - optional int64 field11 = 11; -} diff --git a/third_party/protobuf/benchmarks/cpp/cpp_benchmark.cc b/third_party/protobuf/benchmarks/cpp/cpp_benchmark.cc new file mode 100644 index 000000000000..036d234fb741 --- /dev/null +++ b/third_party/protobuf/benchmarks/cpp/cpp_benchmark.cc @@ -0,0 +1,254 @@ +// 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 "benchmark/benchmark.h" +#include "benchmarks.pb.h" +#include "datasets/google_message1/proto2/benchmark_message1_proto2.pb.h" +#include "datasets/google_message1/proto3/benchmark_message1_proto3.pb.h" +#include "datasets/google_message2/benchmark_message2.pb.h" +#include "datasets/google_message3/benchmark_message3.pb.h" +#include "datasets/google_message4/benchmark_message4.pb.h" + + +#define PREFIX "dataset." +#define SUFFIX ".pb" + +using benchmarks::BenchmarkDataset; +using google::protobuf::Arena; +using google::protobuf::Descriptor; +using google::protobuf::DescriptorPool; +using google::protobuf::Message; +using google::protobuf::MessageFactory; + +class Fixture : public benchmark::Fixture { + public: + Fixture(const BenchmarkDataset& dataset, const std::string& suffix) { + for (int i = 0; i < dataset.payload_size(); i++) { + payloads_.push_back(dataset.payload(i)); + } + + const Descriptor* d = + DescriptorPool::generated_pool()->FindMessageTypeByName( + dataset.message_name()); + + if (!d) { + std::cerr << "Couldn't find message named '" << dataset.message_name() + << "\n"; + } + + prototype_ = MessageFactory::generated_factory()->GetPrototype(d); + SetName((dataset.name() + suffix).c_str()); + } + + protected: + std::vector payloads_; + const Message* prototype_; +}; + +class WrappingCounter { + public: + WrappingCounter(size_t limit) : value_(0), limit_(limit) {} + + size_t Next() { + size_t ret = value_; + if (++value_ == limit_) { + value_ = 0; + } + return ret; + } + + private: + size_t value_; + size_t limit_; +}; + +template +class ParseNewFixture : public Fixture { + public: + ParseNewFixture(const BenchmarkDataset& dataset) + : Fixture(dataset, "_parse_new") {} + + virtual void BenchmarkCase(benchmark::State& state) { + WrappingCounter i(payloads_.size()); + size_t total = 0; + + while (state.KeepRunning()) { + T m; + const std::string& payload = payloads_[i.Next()]; + total += payload.size(); + m.ParseFromString(payload); + } + + state.SetBytesProcessed(total); + } +}; + +template +class ParseNewArenaFixture : public Fixture { + public: + ParseNewArenaFixture(const BenchmarkDataset& dataset) + : Fixture(dataset, "_parse_newarena") {} + + virtual void BenchmarkCase(benchmark::State& state) { + WrappingCounter i(payloads_.size()); + size_t total = 0; + Arena arena; + + while (state.KeepRunning()) { + arena.Reset(); + Message* m = Arena::CreateMessage(&arena); + const std::string& payload = payloads_[i.Next()]; + total += payload.size(); + m->ParseFromString(payload); + } + + state.SetBytesProcessed(total); + } +}; + +template +class ParseReuseFixture : public Fixture { + public: + ParseReuseFixture(const BenchmarkDataset& dataset) + : Fixture(dataset, "_parse_reuse") {} + + virtual void BenchmarkCase(benchmark::State& state) { + T m; + WrappingCounter i(payloads_.size()); + size_t total = 0; + + while (state.KeepRunning()) { + const std::string& payload = payloads_[i.Next()]; + total += payload.size(); + m.ParseFromString(payload); + } + + state.SetBytesProcessed(total); + } +}; + +template +class SerializeFixture : public Fixture { + public: + SerializeFixture(const BenchmarkDataset& dataset) + : Fixture(dataset, "_serialize") { + for (size_t i = 0; i < payloads_.size(); i++) { + message_.push_back(new T); + message_.back()->ParseFromString(payloads_[i]); + } + } + + ~SerializeFixture() { + for (size_t i = 0; i < message_.size(); i++) { + delete message_[i]; + } + } + + virtual void BenchmarkCase(benchmark::State& state) { + size_t total = 0; + std::string str; + WrappingCounter i(payloads_.size()); + + while (state.KeepRunning()) { + str.clear(); + message_[i.Next()]->SerializeToString(&str); + total += str.size(); + } + + state.SetBytesProcessed(total); + } + + private: + std::vector message_; +}; + +std::string ReadFile(const std::string& name) { + std::ifstream file(name.c_str()); + GOOGLE_CHECK(file.is_open()) << "Couldn't find file '" << name << + "', please make sure you are running " + "this command from the benchmarks/ " + "directory.\n"; + return std::string((std::istreambuf_iterator(file)), + std::istreambuf_iterator()); +} + +template +void RegisterBenchmarksForType(const BenchmarkDataset& dataset) { + ::benchmark::internal::RegisterBenchmarkInternal( + new ParseNewFixture(dataset)); + ::benchmark::internal::RegisterBenchmarkInternal( + new ParseReuseFixture(dataset)); + ::benchmark::internal::RegisterBenchmarkInternal( + new ParseNewArenaFixture(dataset)); + ::benchmark::internal::RegisterBenchmarkInternal( + new SerializeFixture(dataset)); +} + +void RegisterBenchmarks(const std::string& dataset_bytes) { + BenchmarkDataset dataset; + GOOGLE_CHECK(dataset.ParseFromString(dataset_bytes)); + + if (dataset.message_name() == "benchmarks.proto3.GoogleMessage1") { + RegisterBenchmarksForType(dataset); + } else if (dataset.message_name() == "benchmarks.proto2.GoogleMessage1") { + RegisterBenchmarksForType(dataset); + } else if (dataset.message_name() == "benchmarks.proto2.GoogleMessage2") { + RegisterBenchmarksForType(dataset); + } else if (dataset.message_name() == + "benchmarks.google_message3.GoogleMessage3") { + RegisterBenchmarksForType + (dataset); + } else if (dataset.message_name() == + "benchmarks.google_message4.GoogleMessage4") { + RegisterBenchmarksForType + (dataset); + } else { + std::cerr << "Unknown message type: " << dataset.message_name(); + exit(1); + } +} + +int main(int argc, char *argv[]) { + ::benchmark::Initialize(&argc, argv); + if (argc == 1) { + std::cerr << "Usage: ./cpp-benchmark " << std::endl; + std::cerr << "input data is in the format of \"benchmarks.proto\"" + << std::endl; + return 1; + } else { + for (int i = 1; i < argc; i++) { + RegisterBenchmarks(ReadFile(argv[i])); + } + } + + ::benchmark::RunSpecifiedBenchmarks(); +} diff --git a/third_party/protobuf/benchmarks/datasets/google_message1/proto2/benchmark_message1_proto2.proto b/third_party/protobuf/benchmarks/datasets/google_message1/proto2/benchmark_message1_proto2.proto new file mode 100644 index 000000000000..21261905dafa --- /dev/null +++ b/third_party/protobuf/benchmarks/datasets/google_message1/proto2/benchmark_message1_proto2.proto @@ -0,0 +1,78 @@ +// Benchmark messages for proto2. + +syntax = "proto2"; + +package benchmarks.proto2; +option java_package = "com.google.protobuf.benchmarks"; + +// This is the default, but we specify it here explicitly. +option optimize_for = SPEED; + +option cc_enable_arenas = true; + +message GoogleMessage1 { + required string field1 = 1; + optional string field9 = 9; + optional string field18 = 18; + optional bool field80 = 80 [default = false]; + optional bool field81 = 81 [default = true]; + required int32 field2 = 2; + required int32 field3 = 3; + optional int32 field280 = 280; + optional int32 field6 = 6 [default = 0]; + optional int64 field22 = 22; + optional string field4 = 4; + repeated fixed64 field5 = 5; + optional bool field59 = 59 [default = false]; + optional string field7 = 7; + optional int32 field16 = 16; + optional int32 field130 = 130 [default = 0]; + optional bool field12 = 12 [default = true]; + optional bool field17 = 17 [default = true]; + optional bool field13 = 13 [default = true]; + optional bool field14 = 14 [default = true]; + optional int32 field104 = 104 [default = 0]; + optional int32 field100 = 100 [default = 0]; + optional int32 field101 = 101 [default = 0]; + optional string field102 = 102; + optional string field103 = 103; + optional int32 field29 = 29 [default = 0]; + optional bool field30 = 30 [default = false]; + optional int32 field60 = 60 [default = -1]; + optional int32 field271 = 271 [default = -1]; + optional int32 field272 = 272 [default = -1]; + optional int32 field150 = 150; + optional int32 field23 = 23 [default = 0]; + optional bool field24 = 24 [default = false]; + optional int32 field25 = 25 [default = 0]; + optional GoogleMessage1SubMessage field15 = 15; + optional bool field78 = 78; + optional int32 field67 = 67 [default = 0]; + optional int32 field68 = 68; + optional int32 field128 = 128 [default = 0]; + optional string field129 = 129 [default = "xxxxxxxxxxxxxxxxxxxxx"]; + optional int32 field131 = 131 [default = 0]; +} + +message GoogleMessage1SubMessage { + optional int32 field1 = 1 [default = 0]; + optional int32 field2 = 2 [default = 0]; + optional int32 field3 = 3 [default = 0]; + optional string field15 = 15; + optional bool field12 = 12 [default = true]; + optional int64 field13 = 13; + optional int64 field14 = 14; + optional int32 field16 = 16; + optional int32 field19 = 19 [default = 2]; + optional bool field20 = 20 [default = true]; + optional bool field28 = 28 [default = true]; + optional fixed64 field21 = 21; + optional int32 field22 = 22; + optional bool field23 = 23 [default = false]; + optional bool field206 = 206 [default = false]; + optional fixed32 field203 = 203; + optional int32 field204 = 204; + optional string field205 = 205; + optional uint64 field207 = 207; + optional uint64 field300 = 300; +} diff --git a/third_party/protobuf/benchmarks/google_message1.dat b/third_party/protobuf/benchmarks/datasets/google_message1/proto2/dataset.google_message1_proto2.pb similarity index 78% rename from third_party/protobuf/benchmarks/google_message1.dat rename to third_party/protobuf/benchmarks/datasets/google_message1/proto2/dataset.google_message1_proto2.pb index bc0f064cc2ebd108e4a8ee14d94c59d2207f0f19..f6fe7848cb889b65fb2c9465780c2e82b398639b 100644 GIT binary patch delta 68 zcmaFDxRA+~ODsJu8dj{HQ>|{A;GUn69Is(pqL3P_P+T4FX`ks_p6DLyqplTDYO0}D9&cq* zT^E(Wn88rMSQW`3DWFp2tYmK%5NQ(YW0Y)DTW4e)6B6bYUmh3j5Sfw*;%sf2nN*`y>=5MalvG+)6lk2Tk*(vmk}>4JGsitCF7*wJYC9MiI~W-z ZF>+Pg29~F#)+y&z&tU18n7DvV9sunQToM2P literal 0 HcmV?d00001 diff --git a/third_party/protobuf/benchmarks/datasets/google_message2/benchmark_message2.proto b/third_party/protobuf/benchmarks/datasets/google_message2/benchmark_message2.proto new file mode 100644 index 000000000000..820630e44d6c --- /dev/null +++ b/third_party/protobuf/benchmarks/datasets/google_message2/benchmark_message2.proto @@ -0,0 +1,76 @@ +// Benchmark messages for proto2. + +syntax = "proto2"; + +package benchmarks.proto2; +option java_package = "com.google.protobuf.benchmarks"; + +// This is the default, but we specify it here explicitly. +option optimize_for = SPEED; + +option cc_enable_arenas = true; + +message GoogleMessage2 { + optional string field1 = 1; + optional int64 field3 = 3; + optional int64 field4 = 4; + optional int64 field30 = 30; + optional bool field75 = 75 [default = false]; + optional string field6 = 6; + optional bytes field2 = 2; + optional int32 field21 = 21 [default = 0]; + optional int32 field71 = 71; + optional float field25 = 25; + optional int32 field109 = 109 [default = 0]; + optional int32 field210 = 210 [default = 0]; + optional int32 field211 = 211 [default = 0]; + optional int32 field212 = 212 [default = 0]; + optional int32 field213 = 213 [default = 0]; + optional int32 field216 = 216 [default = 0]; + optional int32 field217 = 217 [default = 0]; + optional int32 field218 = 218 [default = 0]; + optional int32 field220 = 220 [default = 0]; + optional int32 field221 = 221 [default = 0]; + optional float field222 = 222 [default = 0.0]; + optional int32 field63 = 63; + + repeated group Group1 = 10 { + required float field11 = 11; + optional float field26 = 26; + optional string field12 = 12; + optional string field13 = 13; + repeated string field14 = 14; + required uint64 field15 = 15; + optional int32 field5 = 5; + optional string field27 = 27; + optional int32 field28 = 28; + optional string field29 = 29; + optional string field16 = 16; + repeated string field22 = 22; + repeated int32 field73 = 73; + optional int32 field20 = 20 [default = 0]; + optional string field24 = 24; + optional GoogleMessage2GroupedMessage field31 = 31; + } + repeated string field128 = 128; + optional int64 field131 = 131; + repeated string field127 = 127; + optional int32 field129 = 129; + repeated int64 field130 = 130; + optional bool field205 = 205 [default = false]; + optional bool field206 = 206 [default = false]; +} + +message GoogleMessage2GroupedMessage { + optional float field1 = 1; + optional float field2 = 2; + optional float field3 = 3 [default = 0.0]; + optional bool field4 = 4; + optional bool field5 = 5; + optional bool field6 = 6 [default = true]; + optional bool field7 = 7 [default = false]; + optional float field8 = 8; + optional bool field9 = 9; + optional float field10 = 10; + optional int64 field11 = 11; +} diff --git a/third_party/protobuf/benchmarks/google_message2.dat b/third_party/protobuf/benchmarks/datasets/google_message2/dataset.google_message2.pb similarity index 99% rename from third_party/protobuf/benchmarks/google_message2.dat rename to third_party/protobuf/benchmarks/datasets/google_message2/dataset.google_message2.pb index 06c09441b9e1a3fc8577f6c36dbb583d85481b2c..3fa0e49e57db704a0f371d2b58a2d5b315acd554 100644 GIT binary patch delta 67 zcmcaLg>~XoR&y@?^!)tvoYeT-)Z*gA^i(4ug{0KHV5f};GAd?P(~uo7RW P3aMLDSR1x5MtK1MM35M+ delta 13 UcmbO@mG#yX)<*NK=8REZ04B5q=l}o! diff --git a/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3.proto b/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3.proto new file mode 100644 index 000000000000..d6f0d14e1b50 --- /dev/null +++ b/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3.proto @@ -0,0 +1,534 @@ +syntax = "proto2"; + +import "datasets/google_message3/benchmark_message3_1.proto"; +import "datasets/google_message3/benchmark_message3_2.proto"; +import "datasets/google_message3/benchmark_message3_3.proto"; +import "datasets/google_message3/benchmark_message3_4.proto"; +import "datasets/google_message3/benchmark_message3_5.proto"; +import "datasets/google_message3/benchmark_message3_7.proto"; +import "datasets/google_message3/benchmark_message3_8.proto"; +package benchmarks.google_message3; + +option cc_enable_arenas = true; +option java_package = "com.google.protobuf.benchmarks"; + +message GoogleMessage3 { + optional .benchmarks.google_message3.Message37487 field37519 = 2; + optional .benchmarks.google_message3.Message36876 field37520 = 3; + optional .benchmarks.google_message3.Message13062 field37521 = 4; + optional .benchmarks.google_message3.Message952 field37522 = 5; + optional .benchmarks.google_message3.UnusedEmptyMessage field37523 = 6; + optional .benchmarks.google_message3.UnusedEmptyMessage field37524 = 7; + optional .benchmarks.google_message3.UnusedEmptyMessage field37525 = 8; + optional .benchmarks.google_message3.UnusedEmptyMessage field37526 = 9; + optional .benchmarks.google_message3.UnusedEmptyMessage field37527 = 10; + optional .benchmarks.google_message3.UnusedEmptyMessage field37528 = 11; + optional .benchmarks.google_message3.UnusedEmptyMessage field37529 = 12; + optional .benchmarks.google_message3.UnusedEmptyMessage field37530 = 13; + optional .benchmarks.google_message3.UnusedEmptyMessage field37531 = 14; + optional .benchmarks.google_message3.UnusedEmptyMessage field37532 = 15; + optional .benchmarks.google_message3.UnusedEmptyMessage field37533 = 16; +} + +message Message1327 { + repeated .benchmarks.google_message3.UnusedEmptyMessage field1369 = 1; + repeated .benchmarks.google_message3.Message1328 field1370 = 3; + repeated .benchmarks.google_message3.UnusedEmptyMessage field1371 = 5; + repeated .benchmarks.google_message3.UnusedEmptyMessage field1372 = 6; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message1327 field1373 = 23104162; + } +} + +message Message3672 { + optional .benchmarks.google_message3.Enum3476 field3727 = 1; + optional int32 field3728 = 11; + optional int32 field3729 = 2; + repeated group Message3673 = 3 { + required .benchmarks.google_message3.Enum3476 field3738 = 4; + required int32 field3739 = 5; + } + repeated group Message3674 = 6 { + required .benchmarks.google_message3.Enum3476 field3740 = 7; + required int32 field3741 = 8; + } + optional bool field3732 = 9; + optional int32 field3733 = 10; + optional .benchmarks.google_message3.Enum3476 field3734 = 20; + optional int32 field3735 = 21; + optional .benchmarks.google_message3.UnusedEmptyMessage field3736 = 50; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message3672 field3737 = 3144435; + } +} + +message Message3804 { + required int64 field3818 = 1; + required bool field3819 = 2; + repeated .benchmarks.google_message3.Enum3805 field3820 = 4; + optional int32 field3821 = 5; + optional bool field3822 = 6; + optional int64 field3823 = 7; + optional .benchmarks.google_message3.Enum3783 field3824 = 8; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message3804 field3825 = 59241828; + } +} + +message Message6849 { + repeated .benchmarks.google_message3.Message6850 field6910 = 1; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message6849 field6911 = 107558455; + } +} + +message Message6866 { + repeated .benchmarks.google_message3.Message6863 field6973 = 1; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message6866 field6974 = 22259060; + } +} + +message Message6870 { + repeated .benchmarks.google_message3.Message6871 field6991 = 1; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message6870 field6992 = 90034652; + } +} + +message Message7651 { + optional string field7685 = 1; + optional int64 field7686 = 2; + optional int64 field7687 = 3; + optional int64 field7688 = 4; + optional int32 field7689 = 5; + optional int32 field7690 = 6; + optional int32 field7691 = 7; + optional int32 field7692 = 8; + optional int32 field7693 = 9; + optional int32 field7694 = 10; + optional int32 field7695 = 11; + optional int32 field7696 = 12; + optional int32 field7697 = 13; + optional int32 field7698 = 14; + optional int32 field7699 = 15; + optional int32 field7700 = 16; + optional int32 field7701 = 17; + optional int32 field7702 = 18; + optional bool field7703 = 19; + repeated int32 field7704 = 20; + repeated int32 field7705 = 21; + repeated string field7706 = 22; + repeated string field7707 = 23; + optional .benchmarks.google_message3.UnusedEmptyMessage field7708 = 24; + optional int32 field7709 = 25; + optional int32 field7710 = 26; + optional int32 field7711 = 27; + optional int32 field7712 = 43; + optional int32 field7713 = 28; + optional int32 field7714 = 29; + repeated .benchmarks.google_message3.Message7547 field7715 = 30; + repeated .benchmarks.google_message3.Message7547 field7716 = 31; + repeated .benchmarks.google_message3.UnusedEmptyMessage field7717 = 32; + repeated string field7718 = 33; + repeated string field7719 = 34; + repeated .benchmarks.google_message3.Message7648 field7720 = 35; + optional bool field7721 = 36; + optional bool field7722 = 37; + optional bool field7723 = 38; + optional bool field7724 = 39; + optional .benchmarks.google_message3.UnusedEmptyMessage field7725 = 40; + optional .benchmarks.google_message3.UnusedEnum field7726 = 41; + optional .benchmarks.google_message3.Enum7654 field7727 = 42; + optional string field7728 = 44; + optional .benchmarks.google_message3.UnusedEmptyMessage field7729 = 45; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message7651 field7730 = 55876009; + } +} + +message Message7864 { + optional string field7866 = 1; + optional string field7867 = 2; + repeated .benchmarks.google_message3.Message7865 field7868 = 5; + repeated .benchmarks.google_message3.Message7865 field7869 = 6; + repeated .benchmarks.google_message3.Message7865 field7870 = 7; + repeated .benchmarks.google_message3.UnusedEmptyMessage field7871 = 8; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message7864 field7872 = 44542730; + } +} + +message Message7929 { + optional int64 field7942 = 1; + optional int64 field7943 = 4; + optional int64 field7944 = 5; + optional int64 field7945 = 12; + optional int64 field7946 = 13; + optional int64 field7947 = 18; + optional int64 field7948 = 6; + optional int64 field7949 = 7; + repeated .benchmarks.google_message3.Message7919 field7950 = 8; + repeated .benchmarks.google_message3.UnusedEmptyMessage field7951 = 20; + repeated .benchmarks.google_message3.Message7920 field7952 = 14; + repeated .benchmarks.google_message3.Message7921 field7953 = 15; + repeated .benchmarks.google_message3.Message7928 field7954 = 17; + optional int64 field7955 = 19; + optional bool field7956 = 2; + optional int64 field7957 = 3; + optional int64 field7958 = 9; + repeated .benchmarks.google_message3.UnusedEmptyMessage field7959 = 10; + repeated bytes field7960 = 11; + optional int64 field7961 = 16; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message7929 field7962 = 53392238; + } +} + +message Message8508 { + repeated .benchmarks.google_message3.Message8511 field8517 = 8; + repeated .benchmarks.google_message3.Message8512 field8518 = 9; + repeated .benchmarks.google_message3.Message8513 field8519 = 11; + optional bool field8520 = 13; + optional .benchmarks.google_message3.Message8514 field8521 = 14; + repeated .benchmarks.google_message3.UnusedEmptyMessage field8522 = 15; + repeated .benchmarks.google_message3.Message8515 field8523 = 16; + repeated .benchmarks.google_message3.UnusedEmptyMessage field8524 = 17; + optional int64 field8525 = 1; + optional float field8526 = 2; + optional int64 field8527 = 3; + optional int64 field8528 = 4; + optional int32 field8529 = 5; + optional bytes field8530 = 6; + repeated bytes field8531 = 7; + optional bool field8532 = 10; + optional bytes field8533 = 12; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message8508 field8534 = 3811804; + } +} + +message Message9122 { + optional float field9132 = 1; + optional float field9133 = 2; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message9122 field9134 = 120398939; + } +} + +message Message10177 { + repeated .benchmarks.google_message3.Message10155 field10270 = 1; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message10177 field10271 = 26801105; + } +} + +message Message10278 { + repeated int32 field10286 = 1 [packed = true]; + repeated int32 field10287 = 2 [packed = true]; + optional int32 field10288 = 3; + extend .benchmarks.google_message3.Message10155 { + optional .benchmarks.google_message3.Message10278 field10289 = 29374161; + } +} + +message Message10323 { + repeated .benchmarks.google_message3.Message10320 field10360 = 1; + extend .benchmarks.google_message3.Message10155 { + optional .benchmarks.google_message3.Message10323 field10361 = 27922524; + } +} + +message Message10324 { + repeated .benchmarks.google_message3.Message10322 field10362 = 1; + optional .benchmarks.google_message3.Message10321 field10363 = 2; + extend .benchmarks.google_message3.Message10155 { + optional .benchmarks.google_message3.Message10324 field10364 = 27832297; + } +} + +message Message11990 { + repeated .benchmarks.google_message3.Message11988 field12030 = 1; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message11990 field12031 = 21265426; + } +} + +message Message12691 { + optional string field12713 = 1; + optional int32 field12714 = 2; + optional .benchmarks.google_message3.Message12668 field12715 = 3; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message12691 field12716 = 28426536; + } +} + +message Message12870 { + required int32 field12879 = 1; + optional int32 field12880 = 7; + required int32 field12881 = 2; + optional uint64 field12882 = 3; + optional string field12883 = 2001; + optional fixed64 field12884 = 4; + repeated fixed64 field12885 = 14; + optional int32 field12886 = 9; + optional int64 field12887 = 18; + repeated .benchmarks.google_message3.Message12870 field12888 = 8; + optional int32 field12889 = 5; + optional uint64 field12890 = 6; + optional int32 field12891 = 10; + optional int32 field12892 = 11; + optional double field12893 = 12; + optional .benchmarks.google_message3.Message12825 field12894 = 13; + optional double field12895 = 15; + optional string field12896 = 16; + optional .benchmarks.google_message3.Enum12871 field12897 = 17; + optional int32 field12898 = 19; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message12870 field12899 = 5447656; + } +} + +message Message13154 { + required float field13164 = 1; + required float field13165 = 2; + extend .benchmarks.google_message3.Message13145 { + optional .benchmarks.google_message3.Message13154 field13166 = 47301086; + } +} + +message Message16507 { + optional bool field16510 = 3; + optional bool field16511 = 4; + optional bool field16512 = 14; + repeated string field16513 = 5; + repeated string field16514 = 6; + optional string field16515 = 8; + repeated int32 field16516 = 9; + repeated int32 field16517 = 10; + optional int32 field16518 = 7; + optional string field16519 = 15; + repeated string field16520 = 11; + repeated .benchmarks.google_message3.UnusedEmptyMessage field16521 = 27; + repeated .benchmarks.google_message3.UnusedEmptyMessage field16522 = 22; + repeated .benchmarks.google_message3.UnusedEmptyMessage field16523 = 28; + optional string field16524 = 18; + optional int32 field16525 = 19; + optional int32 field16526 = 20; + optional .benchmarks.google_message3.UnusedEmptyMessage field16527 = 23; + optional bool field16528 = 24; + repeated string field16529 = 25; + optional double field16530 = 26; + optional .benchmarks.google_message3.Message16478 field16531 = 30; + optional bool field16532 = 31; + optional string field16533 = 32; + optional bool field16534 = 33; + optional bool field16535 = 35; + optional bool field16536 = 36; + optional bool field16537 = 37; + optional bool field16538 = 38; + optional bool field16539 = 39; + optional bool field16540 = 40; + repeated string field16541 = 41; + extensions 21 to 21; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message16507 field16542 = 5569941; + } +} + +message Message16564 { + repeated .benchmarks.google_message3.Message16552 field16568 = 1; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message16564 field16569 = 25830030; + } +} + +message Message16661 { + repeated .benchmarks.google_message3.Message16660 field16671 = 1; + repeated uint64 field16672 = 2; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message16661 field16673 = 31274398; + } +} + +message Message16746 { + repeated .benchmarks.google_message3.Message16727 field16806 = 1; + optional bool field16807 = 2; + optional bool field16808 = 3; + repeated .benchmarks.google_message3.Message16725 field16809 = 4; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message16746 field16810 = 28406765; + } +} + +message Message17786 { + repeated group Message17787 = 1 { + required int32 field18177 = 2; + required int32 field18178 = 3; + optional .benchmarks.google_message3.Message17783 field18179 = 4; + optional .benchmarks.google_message3.UnusedEmptyMessage field18180 = 5; + optional .benchmarks.google_message3.UnusedEmptyMessage field18181 = 6; + repeated .benchmarks.google_message3.UnusedEmptyMessage field18182 = 8; + optional .benchmarks.google_message3.UnusedEmptyMessage field18183 = 9; + optional .benchmarks.google_message3.Message17726 field18184 = 10; + optional .benchmarks.google_message3.UnusedEmptyMessage field18185 = 11; + optional .benchmarks.google_message3.Message16945 field18186 = 102; + optional .benchmarks.google_message3.UnusedEmptyMessage field18187 = 12; + optional .benchmarks.google_message3.UnusedEmptyMessage field18188 = 13; + optional .benchmarks.google_message3.UnusedEmptyMessage field18189 = 7; + optional .benchmarks.google_message3.UnusedEmptyMessage field18190 = 100; + optional .benchmarks.google_message3.UnusedEmptyMessage field18191 = 101; + optional .benchmarks.google_message3.UnusedEmptyMessage field18192 = 14; + optional .benchmarks.google_message3.UnusedEmptyMessage field18193 = 19; + optional .benchmarks.google_message3.UnusedEmptyMessage field18194 = 22; + optional .benchmarks.google_message3.UnusedEmptyMessage field18195 = 24; + optional .benchmarks.google_message3.Enum16925 field18196 = 21; + optional bool field18197 = 18; + repeated .benchmarks.google_message3.UnusedEnum field18198 = 23; + optional .benchmarks.google_message3.UnusedEmptyMessage field18199 = 15; + optional string field18200 = 16; + optional string field18201 = 17; + optional bool field18202 = 99; + } + repeated .benchmarks.google_message3.Message17782 field18175 = 20; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message17786 field18176 = 11823055; + } +} + +message Message22857 { + repeated .benchmarks.google_message3.Message22853 field22874 = 1; + extend .benchmarks.google_message3.Message10155 { + optional .benchmarks.google_message3.Message22857 field22875 = 67799715; + } +} + +message Message24404 { + repeated group Message24405 = 1 { + required int32 field24686 = 2; + required int32 field24687 = 3; + optional .benchmarks.google_message3.Message24317 field24688 = 4; + optional .benchmarks.google_message3.UnusedEmptyMessage field24689 = 5; + optional .benchmarks.google_message3.Message24376 field24690 = 6; + optional .benchmarks.google_message3.Message24345 field24691 = 7; + optional .benchmarks.google_message3.UnusedEmptyMessage field24692 = 8; + optional .benchmarks.google_message3.Message24379 field24693 = 9; + optional .benchmarks.google_message3.UnusedEmptyMessage field24694 = 10; + optional .benchmarks.google_message3.UnusedEmptyMessage field24695 = 11; + optional .benchmarks.google_message3.Message24391 field24696 = 12; + optional .benchmarks.google_message3.UnusedEmptyMessage field24697 = 13; + optional .benchmarks.google_message3.UnusedEmptyMessage field24698 = 14; + optional .benchmarks.google_message3.UnusedEmptyMessage field24699 = 22; + optional .benchmarks.google_message3.UnusedEmptyMessage field24700 = 23; + optional .benchmarks.google_message3.UnusedEmptyMessage field24701 = 25; + optional .benchmarks.google_message3.Enum16925 field24702 = 18; + optional float field24703 = 20; + optional bool field24704 = 19; + repeated .benchmarks.google_message3.Enum16891 field24705 = 24; + optional .benchmarks.google_message3.UnusedEmptyMessage field24706 = 15; + optional string field24707 = 16; + optional string field24708 = 17; + optional float field24709 = 21; + optional bool field24710 = 26; + optional .benchmarks.google_message3.UnusedEnum field24711 = 27; + optional bool field24712 = 28; + optional .benchmarks.google_message3.UnusedEnum field24713 = 29; + optional bool field24714 = 31; + optional bool field24715 = 99; + optional int64 field24716 = 32; + } + optional .benchmarks.google_message3.Message24403 field24684 = 30; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message24404 field24685 = 9129287; + } +} + +message Message27300 { + repeated .benchmarks.google_message3.UnusedEmptyMessage field27302 = 1; + optional string field27303 = 2; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message27300 field27304 = 24956467; + } +} + +message Message27453 { + optional string field27459 = 15; + repeated string field27460 = 1; + repeated float field27461 = 6; + repeated int32 field27462 = 27; + repeated int32 field27463 = 28; + repeated .benchmarks.google_message3.Message27454 field27464 = 24; + repeated string field27465 = 2; + repeated float field27466 = 7; + repeated string field27467 = 22; + repeated string field27468 = 23; + optional string field27469 = 26; + repeated .benchmarks.google_message3.Message27357 field27470 = 8; + optional .benchmarks.google_message3.Message27360 field27471 = 16; + optional string field27472 = 25; + optional string field27473 = 11; + optional bool field27474 = 13; + optional bool field27475 = 14; + optional bool field27476 = 17; + optional .benchmarks.google_message3.UnusedEmptyMessage field27477 = 12; + optional bool field27478 = 34268945; + optional bool field27479 = 20; + optional string field27480 = 21; + optional .benchmarks.google_message3.UnusedEmptyMessage field27481 = 10; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message27453 field27482 = 8086204; + } +} + +extend .benchmarks.google_message3.Message16945 { + optional string field17026 = 472; + repeated string field17027 = 818; + optional .benchmarks.google_message3.Message0 field17031 = 215; + repeated .benchmarks.google_message3.Message0 field17032 = 292; + repeated .benchmarks.google_message3.Message0 field17038 = 234; + repeated .benchmarks.google_message3.Message0 field17039 = 235; + optional .benchmarks.google_message3.Message0 field17042 = 246; + optional string field17043 = 224; + optional string field17044 = 225; + repeated string field17048 = 63; + repeated string field17049 = 64; + repeated .benchmarks.google_message3.Message0 field17052 = 233; + repeated .benchmarks.google_message3.Message0 field17053 = 66; + repeated string field17056 = 275; + optional string field17057 = 226; + repeated .benchmarks.google_message3.Message0 field17060 = 27; + repeated string field17073 = 75; + repeated .benchmarks.google_message3.Message0 field17076 = 77; + repeated string field17078 = 296; + repeated .benchmarks.google_message3.Message0 field17082 = 160; + repeated .benchmarks.google_message3.Message0 field17091 = 585; + repeated .benchmarks.google_message3.Message0 field17098 = 987; + repeated .benchmarks.google_message3.Message0 field17101 = 157; + repeated string field17102 = 158; + repeated string field17107 = 166; + repeated string field17133 = 567; + repeated string field17134 = 572; + repeated string field17160 = 49; + repeated string field17168 = 32; + repeated string field17170 = 34; + repeated .benchmarks.google_message3.Message0 field17172 = 509; + repeated string field17174 = 39; + repeated .benchmarks.google_message3.Message0 field17175 = 40; + repeated .benchmarks.google_message3.Message0 field17178 = 511; + repeated .benchmarks.google_message3.Message0 field17185 = 50; + repeated int32 field17207 = 1081; + repeated .benchmarks.google_message3.Message0 field17238 = 184; + repeated .benchmarks.google_message3.Message0 field17289 = 177; + repeated .benchmarks.google_message3.Message0 field17290 = 178; + repeated .benchmarks.google_message3.Message0 field17296 = 474; + repeated string field17298 = 44; + repeated .benchmarks.google_message3.Message0 field17301 = 47; + optional .benchmarks.google_message3.Message0 field17412 = 21; + repeated .benchmarks.google_message3.Message0 field17438 = 132; + repeated .benchmarks.google_message3.Message0 field17458 = 512; + repeated string field17460 = 560; + repeated string field17466 = 552; + repeated .benchmarks.google_message3.Message0 field17617 = 1080; + repeated int32 field17618 = 1084; +} + diff --git a/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_1.proto b/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_1.proto new file mode 100644 index 000000000000..3219553cc52f --- /dev/null +++ b/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_1.proto @@ -0,0 +1,1280 @@ +syntax = "proto2"; + +import "datasets/google_message3/benchmark_message3_2.proto"; +import "datasets/google_message3/benchmark_message3_3.proto"; +import "datasets/google_message3/benchmark_message3_5.proto"; +import "datasets/google_message3/benchmark_message3_7.proto"; +import "datasets/google_message3/benchmark_message3_8.proto"; +package benchmarks.google_message3; + +option cc_enable_arenas = true; +option java_package = "com.google.protobuf.benchmarks"; + +message Message34390 { + repeated .benchmarks.google_message3.Message34387 field34452 = 1; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message34390 field34453 = 92144610; + } +} + +message Message34624 { + optional .benchmarks.google_message3.Message34621 field34683 = 1; + optional .benchmarks.google_message3.Message34621 field34684 = 2; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message34624 field34685 = 18178548; + } +} + +message Message34791 { + optional fixed64 field34793 = 1; + repeated group Message34792 = 2 { + required string field34808 = 3; + optional string field34809 = 4; + } + optional int32 field34795 = 5; + optional int32 field34796 = 6; + optional int32 field34797 = 7; + optional int32 field34798 = 8; + optional int32 field34799 = 9; + optional int32 field34800 = 10; + optional bool field34801 = 11; + optional float field34802 = 12; + optional int32 field34803 = 13; + optional string field34804 = 14; + optional int64 field34805 = 15; + repeated fixed64 field34806 = 17 [packed = true]; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message34791 field34807 = 6330340; + } +} + +message Message35483 { + optional int32 field35499 = 1; + optional string field35500 = 2; + optional string field35501 = 3; + optional string field35502 = 4; + repeated .benchmarks.google_message3.Message35476 field35503 = 5; + optional .benchmarks.google_message3.UnusedEmptyMessage field35504 = 6; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message35483 field35505 = 7913554; + } +} + +message Message35807 { + optional int32 field35810 = 1; + optional int32 field35811 = 2; + optional int32 field35812 = 3; + optional int32 field35813 = 4; + optional int32 field35814 = 5; + optional int32 field35815 = 6; + optional int32 field35816 = 7; + optional int32 field35817 = 8; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message35807 field35818 = 3803299; + } +} + +message Message37487 { + optional bytes field37501 = 2; + optional bool field37502 = 3; +} + +message Message13062 { + optional int64 field13075 = 1; + optional string field13076 = 2; + optional int32 field13077 = 3; + optional string field13078 = 4; + optional int32 field13079 = 5; +} + +message Message952 { + repeated .benchmarks.google_message3.Message949 field963 = 1; +} + +message Message36876 { + optional .benchmarks.google_message3.Message2356 field36980 = 1; + repeated group Message36877 = 111 { + required string field37044 = 112; + optional int32 field37045 = 113; + optional bytes field37046 = 114; + optional int32 field37047 = 115; + optional int32 field37048 = 157; + } + repeated group Message36878 = 168 { + } + repeated group Message36879 = 55 { + required string field37050 = 56; + optional int32 field37051 = 69; + } + repeated .benchmarks.google_message3.UnusedEmptyMessage field36984 = 78; + optional group Message36880 = 137 { + } + optional uint64 field36986 = 59; + optional bytes field36987 = 121; + optional .benchmarks.google_message3.UnusedEmptyMessage field36988 = 2; + optional .benchmarks.google_message3.Message7029 field36989 = 118; + optional .benchmarks.google_message3.Message35573 field36990 = 11; + optional .benchmarks.google_message3.UnusedEmptyMessage field36991 = 21; + optional .benchmarks.google_message3.UnusedEmptyMessage field36992 = 22; + optional float field36993 = 13; + optional int32 field36994 = 20; + optional bool field36995 = 51; + optional bool field36996 = 57; + repeated .benchmarks.google_message3.UnusedEmptyMessage field36997 = 100; + optional int32 field36998 = 47; + optional int32 field36999 = 48; + optional .benchmarks.google_message3.UnusedEmptyMessage field37000 = 68; + repeated group Message36881 = 23 { + } + optional .benchmarks.google_message3.Message4144 field37002 = 125; + repeated group Message36882 = 35 { + } + optional .benchmarks.google_message3.UnusedEmptyMessage field37004 = 49; + optional .benchmarks.google_message3.Message18921 field37005 = 52; + optional .benchmarks.google_message3.Message36858 field37006 = 46; + optional .benchmarks.google_message3.Message18831 field37007 = 54; + optional .benchmarks.google_message3.UnusedEmptyMessage field37008 = 58; + optional .benchmarks.google_message3.Message18283 field37009 = 10; + optional string field37010 = 44; + optional string field37011 = 103; + optional .benchmarks.google_message3.Message0 field37012 = 43; + optional .benchmarks.google_message3.Message0 field37013 = 143; + optional .benchmarks.google_message3.UnusedEmptyMessage field37014 = 53; + optional .benchmarks.google_message3.Message36869 field37015 = 15; + optional group Message36883 = 3 { + } + repeated group Message36884 = 16 { + } + repeated group Message36885 = 27 { + } + optional group Message36886 = 32 { + } + repeated .benchmarks.google_message3.UnusedEnum field37020 = 71; + repeated int32 field37021 = 70; + optional .benchmarks.google_message3.UnusedEmptyMessage field37022 = 66; + optional .benchmarks.google_message3.Message13090 field37023 = 67; + optional group Message36887 = 62 { + } + repeated .benchmarks.google_message3.Message10155 field37025 = 50; + repeated .benchmarks.google_message3.Message11874 field37026 = 151; + optional string field37027 = 12; + optional int64 field37028 = 72; + optional .benchmarks.google_message3.UnusedEmptyMessage field37029 = 73; + optional .benchmarks.google_message3.Message35546 field37030 = 108; + optional group Message36888 = 74 { + optional uint64 field37089 = 75; + optional bool field37090 = 76; + optional uint64 field37091 = 165; + optional double field37092 = 166; + optional uint64 field37093 = 109; + optional bytes field37094 = 122; + } + repeated .benchmarks.google_message3.Message19255 field37032 = 104; + optional .benchmarks.google_message3.Message33968 field37033 = 105; + optional bool field37034 = 106; + repeated .benchmarks.google_message3.UnusedEmptyMessage field37035 = 107; + optional .benchmarks.google_message3.Message6644 field37036 = 110; + optional bytes field37037 = 133; + optional group Message36889 = 116 { + optional int64 field37095 = 117; + optional string field37096 = 145; + optional int32 field37097 = 123; + optional bool field37098 = 163; + optional int32 field37099 = 164; + optional int32 field37100 = 149; + optional .benchmarks.google_message3.UnusedEmptyMessage field37101 = 129; + optional .benchmarks.google_message3.Message13174 field37102 = 124; + optional .benchmarks.google_message3.Message13169 field37103 = 128; + optional uint64 field37104 = 132; + repeated .benchmarks.google_message3.Enum36890 field37105 = 131; + optional bool field37106 = 134; + optional bool field37107 = 140; + optional .benchmarks.google_message3.UnusedEmptyMessage field37108 = 135; + optional float field37109 = 136; + optional float field37110 = 156; + optional bool field37111 = 142; + optional int64 field37112 = 167; + optional .benchmarks.google_message3.UnusedEmptyMessage field37113 = 146; + optional bool field37114 = 148; + optional .benchmarks.google_message3.UnusedEmptyMessage field37115 = 154; + optional .benchmarks.google_message3.UnusedEnum field37116 = 158; + repeated .benchmarks.google_message3.UnusedEnum field37117 = 159; + optional int32 field37118 = 160; + repeated string field37119 = 161; + } + repeated group Message36910 = 119 { + } + optional group Message36911 = 126 { + optional .benchmarks.google_message3.UnusedEmptyMessage field37121 = 127; + optional .benchmarks.google_message3.Message35538 field37122 = 130; + optional .benchmarks.google_message3.Message35540 field37123 = 144; + optional .benchmarks.google_message3.Message35542 field37124 = 150; + } + optional group Message36912 = 152 { + optional .benchmarks.google_message3.Message3901 field37125 = 153; + optional .benchmarks.google_message3.Message3901 field37126 = 162; + } + optional .benchmarks.google_message3.UnusedEmptyMessage field37042 = 155; +} + +message Message1328 { +} + +message Message6850 { +} + +message Message6863 { + optional .benchmarks.google_message3.Enum6858 field6931 = 1; + optional .benchmarks.google_message3.Enum6858 field6932 = 2; + optional .benchmarks.google_message3.UnusedEnum field6933 = 36; + optional bool field6934 = 27; + optional .benchmarks.google_message3.Message6773 field6935 = 26; + optional int32 field6936 = 30; + optional int32 field6937 = 37; + optional .benchmarks.google_message3.Enum6815 field6938 = 31; + optional string field6939 = 3; + optional int32 field6940 = 4; + optional .benchmarks.google_message3.Enum6822 field6941 = 15; + optional bool field6942 = 10; + optional bool field6943 = 17; + optional float field6944 = 18; + optional float field6945 = 19; + optional int32 field6946 = 5; + optional int32 field6947 = 6; + optional bool field6948 = 7; + optional int32 field6949 = 12; + optional .benchmarks.google_message3.UnusedEmptyMessage field6950 = 8; + optional uint64 field6951 = 9; + optional string field6952 = 11; + optional bytes field6953 = 13; + optional int32 field6954 = 14; + optional .benchmarks.google_message3.UnusedEmptyMessage field6955 = 16; + optional .benchmarks.google_message3.UnusedEmptyMessage field6956 = 22; + optional .benchmarks.google_message3.Message3886 field6957 = 38; + optional string field6958 = 20; + optional uint32 field6959 = 21; + optional .benchmarks.google_message3.Message6743 field6960 = 23; + optional .benchmarks.google_message3.UnusedEmptyMessage field6961 = 29; + optional .benchmarks.google_message3.UnusedEmptyMessage field6962 = 33; + optional bool field6963 = 34; +} + +message Message6871 { +} + +message Message7547 { + required bytes field7549 = 1; + required int32 field7550 = 2; +} + +message Message7648 { + optional string field7669 = 1; + optional int32 field7670 = 2; + optional int32 field7671 = 3; + optional int32 field7672 = 4; + optional int32 field7673 = 5; + optional int32 field7674 = 6; + optional float field7675 = 7; + optional bool field7676 = 8; + optional bool field7677 = 9; + optional bool field7678 = 10; + optional bool field7679 = 11; + optional bool field7680 = 12; +} + +message Message7865 { +} + +message Message7928 { + optional string field7940 = 1; + optional int64 field7941 = 2; +} + +message Message7919 { + optional fixed64 field7931 = 1; + optional int64 field7932 = 2; + optional bytes field7933 = 3; +} + +message Message7920 { + optional int64 field7934 = 1; + optional int64 field7935 = 2; +} + +message Message7921 { + optional int32 field7936 = 1; + optional int64 field7937 = 2; + optional float field7938 = 3; + optional .benchmarks.google_message3.UnusedEnum field7939 = 4; +} + +message Message8511 { + optional .benchmarks.google_message3.Message8224 field8539 = 1; + optional string field8540 = 2; + optional bool field8541 = 3; + optional int64 field8542 = 4; + optional string field8543 = 5; +} + +message Message8512 { + optional .benchmarks.google_message3.Message8301 field8544 = 1; + optional .benchmarks.google_message3.Message8302 field8545 = 2; + optional string field8546 = 3; + optional bool field8547 = 4; + optional int64 field8548 = 5; + optional string field8549 = 6; +} + +message Message8513 { + repeated .benchmarks.google_message3.Message8392 field8550 = 1; + optional string field8551 = 2; + optional bool field8552 = 3; + optional string field8553 = 4; +} + +message Message8514 { + optional string field8554 = 1; + optional int64 field8555 = 2; + optional bool field8556 = 3; + repeated .benchmarks.google_message3.Message8130 field8557 = 4; + optional string field8558 = 5; +} + +message Message8515 { + optional .benchmarks.google_message3.Message8479 field8559 = 1; + optional .benchmarks.google_message3.Message8478 field8560 = 2; + optional string field8561 = 3; +} + +message Message10320 { + optional .benchmarks.google_message3.Enum10335 field10347 = 1; + repeated .benchmarks.google_message3.Message10319 field10348 = 2; + optional int32 field10349 = 3; + optional int32 field10350 = 4; + optional int32 field10351 = 5; + optional int32 field10352 = 6; + optional .benchmarks.google_message3.Enum10337 field10353 = 7; +} + +message Message10321 { + optional int32 field10354 = 1; + optional int32 field10355 = 2; + optional uint64 field10356 = 3; +} + +message Message10322 { + optional .benchmarks.google_message3.Message4016 field10357 = 1; + optional bool field10358 = 2; + optional bool field10359 = 3; +} + +message Message11988 { + optional string field12021 = 1; + optional string field12022 = 2; + optional .benchmarks.google_message3.UnusedEmptyMessage field12023 = 3; + optional .benchmarks.google_message3.Message10155 field12024 = 4; +} + +message Message12668 { + repeated .benchmarks.google_message3.Message12669 field12677 = 1; + optional int32 field12678 = 2; + optional int32 field12679 = 3; + optional int32 field12680 = 4; +} + +message Message12825 { + repeated .benchmarks.google_message3.Message12818 field12862 = 1; + optional int32 field12863 = 2; + optional .benchmarks.google_message3.Message12819 field12864 = 3; + optional .benchmarks.google_message3.Message12820 field12865 = 4; + optional int32 field12866 = 5; + repeated .benchmarks.google_message3.Message12821 field12867 = 6; + repeated .benchmarks.google_message3.UnusedEmptyMessage field12868 = 7; +} + +message Message16478 { + repeated .benchmarks.google_message3.Message16479 field16481 = 1; + optional bool field16482 = 3; + optional int32 field16483 = 2; +} + +message Message16552 { + optional fixed64 field16565 = 1; + optional int32 field16566 = 2; + optional .benchmarks.google_message3.Enum16553 field16567 = 3; +} + +message Message16660 { + optional string field16668 = 1; + optional string field16669 = 2; + optional int32 field16670 = 3; +} + +message Message16727 { + required .benchmarks.google_message3.Enum16728 field16782 = 1; + required string field16783 = 2; + optional string field16784 = 3; + optional int32 field16785 = 23; + required string field16786 = 4; + optional string field16787 = 5; + optional string field16788 = 6; + required .benchmarks.google_message3.Enum16732 field16789 = 7; + optional string field16790 = 8; + optional string field16791 = 9; + optional string field16792 = 10; + optional .benchmarks.google_message3.Enum16738 field16793 = 11; + optional int32 field16794 = 12; + repeated .benchmarks.google_message3.Message16722 field16795 = 13; + optional bool field16796 = 19; + optional bool field16797 = 24; + optional string field16798 = 14; + optional int64 field16799 = 15; + optional bool field16800 = 16; + optional string field16801 = 17; + optional .benchmarks.google_message3.Enum16698 field16802 = 18; + optional .benchmarks.google_message3.Message16724 field16803 = 20; + optional bool field16804 = 22; + optional .benchmarks.google_message3.UnusedEmptyMessage field16805 = 25; + extensions 1000 to 536870911; +} + +message Message16725 { + optional .benchmarks.google_message3.Enum16728 field16774 = 1; + repeated string field16775 = 2; +} + +message Message17726 { + optional string field17801 = 1; + repeated string field17802 = 2; + optional string field17803 = 3; + repeated string field17804 = 4; + optional string field17805 = 5; + repeated string field17806 = 6; + optional string field17807 = 7; + optional string field17808 = 8; + repeated string field17809 = 15; + repeated string field17810 = 16; + repeated string field17811 = 17; + repeated .benchmarks.google_message3.UnusedEmptyMessage field17812 = 18; + optional string field17813 = 9; + optional string field17814 = 10; + optional string field17815 = 11; + optional string field17816 = 12; + optional string field17817 = 13; + optional string field17818 = 14; + optional string field17819 = 19; + repeated .benchmarks.google_message3.Message17728 field17820 = 20; + repeated .benchmarks.google_message3.Message17728 field17821 = 21; + repeated .benchmarks.google_message3.UnusedEmptyMessage field17822 = 30; +} + +message Message17782 { + optional string field18153 = 1; + optional string field18154 = 2; +} + +message Message17783 { + optional string field18155 = 1; + optional string field18156 = 2; + optional string field18157 = 3; + repeated group Message17784 = 4 { + optional string field18162 = 5; + optional string field18163 = 6; + optional string field18164 = 7; + repeated string field18165 = 8; + optional string field18166 = 17; + optional string field18167 = 18; + } + repeated group Message17785 = 9 { + optional string field18168 = 10; + optional string field18169 = 11; + optional .benchmarks.google_message3.Message17783 field18170 = 12; + optional string field18171 = 13; + optional string field18172 = 14; + repeated string field18173 = 15; + } + repeated string field18160 = 16; +} + +message Message16945 { + optional string field16946 = 1; + optional string field16947 = 2; + optional string field16948 = 3; + optional string field16949 = 4; + optional string field16950 = 5; + optional .benchmarks.google_message3.UnusedEmptyMessage field16951 = 872; + repeated .benchmarks.google_message3.Message0 field16952 = 16; + repeated .benchmarks.google_message3.UnusedEmptyMessage field16953 = 54; + repeated .benchmarks.google_message3.Message0 field16954 = 55; + repeated string field16955 = 58; + repeated string field16956 = 59; + repeated string field16957 = 62; + repeated string field16958 = 37; + repeated string field16959 = 18; + repeated .benchmarks.google_message3.UnusedEmptyMessage field16960 = 38; + repeated .benchmarks.google_message3.Message0 field16961 = 67; + repeated .benchmarks.google_message3.Message0 field16962 = 130; + repeated .benchmarks.google_message3.UnusedEmptyMessage field16963 = 136; + repeated string field16964 = 138; + repeated .benchmarks.google_message3.UnusedEmptyMessage field16965 = 156; + repeated string field16966 = 139; + repeated .benchmarks.google_message3.UnusedEmptyMessage field16967 = 126; + repeated string field16968 = 152; + repeated .benchmarks.google_message3.Message0 field16969 = 183; + repeated string field16970 = 168; + repeated string field16971 = 212; + repeated string field16972 = 213; + repeated .benchmarks.google_message3.UnusedEmptyMessage field16973 = 189; + repeated .benchmarks.google_message3.UnusedEmptyMessage field16974 = 190; + repeated string field16975 = 191; + repeated string field16976 = 192; + repeated .benchmarks.google_message3.Message0 field16977 = 193; + repeated .benchmarks.google_message3.UnusedEmptyMessage field16978 = 194; + repeated .benchmarks.google_message3.UnusedEmptyMessage field16979 = 195; + repeated int32 field16980 = 196; + repeated .benchmarks.google_message3.UnusedEmptyMessage field16981 = 95; + repeated string field16982 = 96; + repeated .benchmarks.google_message3.UnusedEmptyMessage field16983 = 97; + repeated string field16984 = 1086; + repeated .benchmarks.google_message3.UnusedEmptyMessage field16985 = 98; + repeated string field16986 = 99; + repeated string field16987 = 100; + repeated string field16988 = 48; + optional string field16989 = 22; + repeated .benchmarks.google_message3.UnusedEmptyMessage field16990 = 51; + repeated string field16991 = 81; + repeated string field16992 = 85; + repeated string field16993 = 169; + optional .benchmarks.google_message3.UnusedEmptyMessage field16994 = 260; + optional int32 field16995 = 198; + optional int32 field16996 = 204; + optional string field16997 = 1087; + repeated string field16998 = 197; + repeated string field16999 = 206; + optional string field17000 = 211; + repeated string field17001 = 205; + repeated .benchmarks.google_message3.UnusedEmptyMessage field17002 = 68; + repeated .benchmarks.google_message3.UnusedEmptyMessage field17003 = 69; + repeated .benchmarks.google_message3.UnusedEmptyMessage field17004 = 70; + repeated .benchmarks.google_message3.UnusedEmptyMessage field17005 = 71; + repeated .benchmarks.google_message3.UnusedEmptyMessage field17006 = 72; + repeated .benchmarks.google_message3.UnusedEmptyMessage field17007 = 19; + repeated .benchmarks.google_message3.UnusedEmptyMessage field17008 = 24; + optional .benchmarks.google_message3.UnusedEmptyMessage field17009 = 23; + repeated .benchmarks.google_message3.Message0 field17010 = 131; + repeated string field17011 = 133; + repeated .benchmarks.google_message3.UnusedEmptyMessage field17012 = 142; + repeated string field17013 = 143; + repeated .benchmarks.google_message3.UnusedEmptyMessage field17014 = 153; + repeated .benchmarks.google_message3.Message0 field17015 = 170; + repeated string field17016 = 171; + repeated string field17017 = 172; + repeated string field17018 = 173; + repeated string field17019 = 174; + repeated string field17020 = 175; + repeated string field17021 = 186; + repeated string field17022 = 101; + repeated .benchmarks.google_message3.Message0 field17023 = 102; + repeated string field17024 = 274; + extensions 17 to 17; + extensions 21 to 21; + extensions 25 to 25; + extensions 27 to 27; + extensions 29 to 29; + extensions 30 to 30; + extensions 31 to 31; + extensions 32 to 32; + extensions 33 to 33; + extensions 34 to 34; + extensions 35 to 35; + extensions 36 to 36; + extensions 39 to 39; + extensions 40 to 40; + extensions 41 to 41; + extensions 42 to 42; + extensions 43 to 43; + extensions 44 to 44; + extensions 45 to 45; + extensions 46 to 46; + extensions 47 to 47; + extensions 49 to 49; + extensions 50 to 50; + extensions 52 to 52; + extensions 53 to 53; + extensions 56 to 56; + extensions 57 to 57; + extensions 60 to 60; + extensions 61 to 61; + extensions 63 to 63; + extensions 64 to 64; + extensions 65 to 65; + extensions 66 to 66; + extensions 73 to 73; + extensions 74 to 74; + extensions 75 to 75; + extensions 76 to 76; + extensions 77 to 77; + extensions 78 to 78; + extensions 79 to 79; + extensions 80 to 80; + extensions 82 to 82; + extensions 83 to 83; + extensions 84 to 84; + extensions 86 to 86; + extensions 87 to 87; + extensions 88 to 88; + extensions 89 to 89; + extensions 90 to 90; + extensions 91 to 91; + extensions 92 to 92; + extensions 93 to 93; + extensions 94 to 94; + extensions 103 to 103; + extensions 104 to 104; + extensions 105 to 105; + extensions 106 to 106; + extensions 107 to 107; + extensions 108 to 108; + extensions 109 to 109; + extensions 110 to 110; + extensions 111 to 111; + extensions 112 to 112; + extensions 113 to 113; + extensions 114 to 114; + extensions 115 to 115; + extensions 116 to 116; + extensions 117 to 117; + extensions 118 to 118; + extensions 119 to 119; + extensions 120 to 120; + extensions 121 to 121; + extensions 122 to 122; + extensions 123 to 123; + extensions 124 to 124; + extensions 125 to 125; + extensions 127 to 127; + extensions 128 to 128; + extensions 129 to 129; + extensions 132 to 132; + extensions 134 to 134; + extensions 135 to 135; + extensions 137 to 137; + extensions 140 to 140; + extensions 141 to 141; + extensions 144 to 144; + extensions 145 to 145; + extensions 146 to 146; + extensions 147 to 147; + extensions 148 to 148; + extensions 149 to 149; + extensions 150 to 150; + extensions 151 to 151; + extensions 154 to 154; + extensions 155 to 155; + extensions 157 to 157; + extensions 158 to 158; + extensions 159 to 159; + extensions 160 to 160; + extensions 161 to 161; + extensions 162 to 162; + extensions 163 to 163; + extensions 164 to 164; + extensions 165 to 165; + extensions 166 to 166; + extensions 167 to 167; + extensions 176 to 176; + extensions 177 to 177; + extensions 178 to 178; + extensions 179 to 179; + extensions 180 to 180; + extensions 181 to 181; + extensions 182 to 182; + extensions 184 to 184; + extensions 185 to 185; + extensions 187 to 187; + extensions 188 to 188; + extensions 199 to 199; + extensions 200 to 200; + extensions 201 to 201; + extensions 202 to 202; + extensions 203 to 203; + extensions 207 to 207; + extensions 208 to 208; + extensions 209 to 209; + extensions 210 to 210; + extensions 214 to 214; + extensions 215 to 215; + extensions 216 to 216; + extensions 217 to 217; + extensions 218 to 218; + extensions 219 to 219; + extensions 220 to 220; + extensions 221 to 221; + extensions 222 to 222; + extensions 223 to 223; + extensions 224 to 224; + extensions 225 to 225; + extensions 226 to 226; + extensions 227 to 227; + extensions 228 to 228; + extensions 229 to 229; + extensions 230 to 230; + extensions 231 to 231; + extensions 232 to 232; + extensions 233 to 233; + extensions 234 to 234; + extensions 235 to 235; + extensions 236 to 236; + extensions 237 to 237; + extensions 238 to 238; + extensions 239 to 239; + extensions 240 to 240; + extensions 241 to 241; + extensions 242 to 242; + extensions 243 to 243; + extensions 244 to 244; + extensions 245 to 245; + extensions 246 to 246; + extensions 247 to 247; + extensions 248 to 248; + extensions 249 to 249; + extensions 250 to 250; + extensions 251 to 251; + extensions 252 to 252; + extensions 253 to 253; + extensions 254 to 254; + extensions 255 to 255; + extensions 256 to 256; + extensions 257 to 257; + extensions 258 to 258; + extensions 259 to 259; + extensions 261 to 261; + extensions 262 to 262; + extensions 263 to 263; + extensions 264 to 264; + extensions 265 to 265; + extensions 266 to 266; + extensions 267 to 267; + extensions 268 to 268; + extensions 269 to 269; + extensions 270 to 270; + extensions 271 to 271; + extensions 272 to 272; + extensions 273 to 273; + extensions 275 to 275; + extensions 276 to 276; + extensions 277 to 277; + extensions 278 to 278; + extensions 279 to 279; + extensions 280 to 280; + extensions 281 to 281; + extensions 282 to 282; + extensions 283 to 283; + extensions 284 to 284; + extensions 285 to 285; + extensions 286 to 286; + extensions 290 to 290; + extensions 291 to 291; + extensions 292 to 292; + extensions 293 to 293; + extensions 294 to 294; + extensions 295 to 295; + extensions 296 to 296; + extensions 297 to 297; + extensions 298 to 298; + extensions 299 to 299; + extensions 300 to 300; + extensions 301 to 301; + extensions 302 to 302; + extensions 303 to 303; + extensions 304 to 304; + extensions 305 to 305; + extensions 306 to 306; + extensions 307 to 307; + extensions 308 to 308; + extensions 309 to 309; + extensions 310 to 310; + extensions 311 to 311; + extensions 312 to 312; + extensions 313 to 313; + extensions 314 to 314; + extensions 315 to 315; + extensions 316 to 316; + extensions 317 to 317; + extensions 318 to 318; + extensions 319 to 319; + extensions 320 to 320; + extensions 321 to 321; + extensions 322 to 322; + extensions 323 to 323; + extensions 324 to 324; + extensions 325 to 325; + extensions 326 to 326; + extensions 327 to 327; + extensions 328 to 328; + extensions 329 to 329; + extensions 330 to 330; + extensions 331 to 331; + extensions 332 to 332; + extensions 333 to 333; + extensions 334 to 334; + extensions 335 to 335; + extensions 336 to 336; + extensions 337 to 337; + extensions 338 to 338; + extensions 339 to 339; + extensions 340 to 340; + extensions 341 to 341; + extensions 342 to 342; + extensions 343 to 343; + extensions 344 to 344; + extensions 345 to 345; + extensions 346 to 346; + extensions 347 to 347; + extensions 348 to 348; + extensions 349 to 349; + extensions 350 to 350; + extensions 351 to 351; + extensions 352 to 352; + extensions 353 to 353; + extensions 354 to 354; + extensions 355 to 355; + extensions 356 to 356; + extensions 357 to 357; + extensions 358 to 358; + extensions 359 to 359; + extensions 360 to 360; + extensions 361 to 361; + extensions 362 to 362; + extensions 363 to 363; + extensions 364 to 364; + extensions 365 to 365; + extensions 366 to 366; + extensions 367 to 367; + extensions 368 to 368; + extensions 369 to 369; + extensions 370 to 370; + extensions 371 to 371; + extensions 372 to 372; + extensions 373 to 373; + extensions 374 to 374; + extensions 375 to 375; + extensions 376 to 376; + extensions 377 to 377; + extensions 378 to 378; + extensions 379 to 379; + extensions 380 to 380; + extensions 381 to 381; + extensions 382 to 382; + extensions 383 to 383; + extensions 384 to 384; + extensions 385 to 385; + extensions 386 to 386; + extensions 387 to 387; + extensions 388 to 388; + extensions 389 to 389; + extensions 390 to 390; + extensions 391 to 391; + extensions 392 to 392; + extensions 393 to 393; + extensions 394 to 394; + extensions 395 to 395; + extensions 396 to 396; + extensions 397 to 397; + extensions 398 to 398; + extensions 399 to 399; + extensions 400 to 400; + extensions 401 to 401; + extensions 402 to 402; + extensions 403 to 403; + extensions 404 to 404; + extensions 405 to 405; + extensions 406 to 406; + extensions 407 to 407; + extensions 408 to 408; + extensions 409 to 409; + extensions 410 to 410; + extensions 411 to 411; + extensions 412 to 412; + extensions 413 to 413; + extensions 414 to 414; + extensions 415 to 415; + extensions 416 to 416; + extensions 417 to 417; + extensions 418 to 418; + extensions 419 to 419; + extensions 420 to 420; + extensions 421 to 421; + extensions 422 to 422; + extensions 423 to 423; + extensions 424 to 424; + extensions 425 to 425; + extensions 426 to 426; + extensions 427 to 427; + extensions 428 to 428; + extensions 429 to 429; + extensions 430 to 430; + extensions 431 to 431; + extensions 432 to 432; + extensions 433 to 433; + extensions 434 to 434; + extensions 435 to 435; + extensions 436 to 436; + extensions 437 to 437; + extensions 438 to 438; + extensions 439 to 439; + extensions 440 to 440; + extensions 441 to 441; + extensions 442 to 442; + extensions 443 to 443; + extensions 444 to 444; + extensions 445 to 445; + extensions 446 to 446; + extensions 447 to 447; + extensions 448 to 448; + extensions 449 to 449; + extensions 450 to 450; + extensions 451 to 451; + extensions 452 to 452; + extensions 453 to 453; + extensions 454 to 454; + extensions 455 to 455; + extensions 456 to 456; + extensions 457 to 457; + extensions 458 to 458; + extensions 459 to 459; + extensions 460 to 460; + extensions 461 to 461; + extensions 462 to 462; + extensions 463 to 463; + extensions 464 to 464; + extensions 465 to 465; + extensions 466 to 466; + extensions 467 to 467; + extensions 468 to 468; + extensions 469 to 469; + extensions 470 to 470; + extensions 471 to 471; + extensions 472 to 472; + extensions 473 to 473; + extensions 474 to 474; + extensions 509 to 509; + extensions 511 to 511; + extensions 512 to 512; + extensions 513 to 513; + extensions 514 to 514; + extensions 515 to 515; + extensions 516 to 516; + extensions 517 to 517; + extensions 518 to 518; + extensions 519 to 519; + extensions 520 to 520; + extensions 521 to 521; + extensions 522 to 522; + extensions 523 to 523; + extensions 524 to 524; + extensions 525 to 525; + extensions 526 to 526; + extensions 527 to 527; + extensions 528 to 528; + extensions 529 to 529; + extensions 530 to 530; + extensions 531 to 531; + extensions 532 to 532; + extensions 533 to 533; + extensions 534 to 534; + extensions 535 to 535; + extensions 536 to 536; + extensions 537 to 537; + extensions 538 to 538; + extensions 539 to 539; + extensions 540 to 540; + extensions 541 to 541; + extensions 542 to 542; + extensions 543 to 543; + extensions 544 to 544; + extensions 545 to 545; + extensions 546 to 546; + extensions 547 to 547; + extensions 548 to 548; + extensions 549 to 549; + extensions 550 to 550; + extensions 551 to 551; + extensions 552 to 552; + extensions 553 to 553; + extensions 554 to 554; + extensions 555 to 555; + extensions 556 to 556; + extensions 557 to 557; + extensions 558 to 558; + extensions 559 to 559; + extensions 560 to 560; + extensions 561 to 561; + extensions 562 to 562; + extensions 563 to 563; + extensions 564 to 564; + extensions 565 to 565; + extensions 566 to 566; + extensions 567 to 567; + extensions 568 to 568; + extensions 569 to 569; + extensions 570 to 570; + extensions 571 to 571; + extensions 572 to 572; + extensions 573 to 573; + extensions 574 to 574; + extensions 575 to 575; + extensions 576 to 576; + extensions 577 to 577; + extensions 578 to 578; + extensions 579 to 579; + extensions 580 to 580; + extensions 581 to 581; + extensions 582 to 582; + extensions 583 to 583; + extensions 584 to 584; + extensions 585 to 585; + extensions 586 to 586; + extensions 587 to 587; + extensions 588 to 588; + extensions 589 to 589; + extensions 590 to 590; + extensions 604 to 604; + extensions 605 to 605; + extensions 606 to 606; + extensions 607 to 607; + extensions 608 to 608; + extensions 609 to 609; + extensions 610 to 610; + extensions 611 to 611; + extensions 612 to 612; + extensions 613 to 613; + extensions 614 to 614; + extensions 615 to 615; + extensions 616 to 616; + extensions 617 to 617; + extensions 618 to 618; + extensions 619 to 619; + extensions 620 to 620; + extensions 621 to 621; + extensions 622 to 622; + extensions 623 to 623; + extensions 624 to 624; + extensions 625 to 625; + extensions 626 to 626; + extensions 627 to 627; + extensions 628 to 628; + extensions 629 to 629; + extensions 813 to 813; + extensions 814 to 814; + extensions 815 to 815; + extensions 816 to 816; + extensions 817 to 817; + extensions 818 to 818; + extensions 819 to 819; + extensions 820 to 820; + extensions 821 to 821; + extensions 822 to 822; + extensions 823 to 823; + extensions 824 to 824; + extensions 827 to 827; + extensions 828 to 828; + extensions 829 to 829; + extensions 830 to 830; + extensions 831 to 831; + extensions 832 to 832; + extensions 833 to 833; + extensions 834 to 834; + extensions 835 to 835; + extensions 836 to 836; + extensions 837 to 837; + extensions 838 to 838; + extensions 839 to 839; + extensions 840 to 840; + extensions 841 to 841; + extensions 842 to 842; + extensions 843 to 843; + extensions 844 to 844; + extensions 845 to 845; + extensions 846 to 846; + extensions 847 to 847; + extensions 848 to 848; + extensions 849 to 849; + extensions 850 to 850; + extensions 851 to 851; + extensions 852 to 852; + extensions 853 to 853; + extensions 854 to 854; + extensions 855 to 855; + extensions 856 to 856; + extensions 857 to 857; + extensions 858 to 858; + extensions 859 to 859; + extensions 860 to 860; + extensions 861 to 861; + extensions 862 to 862; + extensions 863 to 863; + extensions 864 to 864; + extensions 865 to 865; + extensions 866 to 866; + extensions 867 to 867; + extensions 868 to 868; + extensions 869 to 869; + extensions 870 to 870; + extensions 871 to 871; + extensions 880 to 880; + extensions 881 to 881; + extensions 882 to 882; + extensions 883 to 883; + extensions 884 to 884; + extensions 885 to 885; + extensions 886 to 886; + extensions 887 to 887; + extensions 888 to 888; + extensions 890 to 890; + extensions 891 to 891; + extensions 892 to 892; + extensions 912 to 912; + extensions 914 to 914; + extensions 915 to 915; + extensions 916 to 916; + extensions 917 to 917; + extensions 918 to 918; + extensions 919 to 919; + extensions 920 to 920; + extensions 921 to 921; + extensions 922 to 922; + extensions 923 to 923; + extensions 924 to 924; + extensions 925 to 925; + extensions 926 to 926; + extensions 927 to 927; + extensions 928 to 928; + extensions 929 to 929; + extensions 930 to 930; + extensions 931 to 931; + extensions 932 to 932; + extensions 933 to 933; + extensions 934 to 934; + extensions 935 to 935; + extensions 936 to 936; + extensions 937 to 937; + extensions 938 to 938; + extensions 939 to 939; + extensions 940 to 940; + extensions 941 to 941; + extensions 942 to 942; + extensions 943 to 943; + extensions 944 to 944; + extensions 945 to 945; + extensions 946 to 946; + extensions 947 to 947; + extensions 949 to 949; + extensions 950 to 950; + extensions 951 to 951; + extensions 952 to 952; + extensions 954 to 954; + extensions 955 to 955; + extensions 956 to 956; + extensions 957 to 957; + extensions 958 to 958; + extensions 959 to 959; + extensions 960 to 960; + extensions 961 to 961; + extensions 962 to 962; + extensions 963 to 963; + extensions 964 to 964; + extensions 965 to 965; + extensions 966 to 966; + extensions 967 to 967; + extensions 968 to 968; + extensions 969 to 969; + extensions 970 to 970; + extensions 971 to 971; + extensions 972 to 972; + extensions 973 to 973; + extensions 974 to 974; + extensions 975 to 975; + extensions 976 to 976; + extensions 977 to 977; + extensions 978 to 978; + extensions 979 to 979; + extensions 980 to 980; + extensions 981 to 981; + extensions 982 to 982; + extensions 983 to 983; + extensions 984 to 984; + extensions 985 to 985; + extensions 987 to 987; + extensions 988 to 988; + extensions 1000 to 1000; + extensions 1001 to 1001; + extensions 1002 to 1002; + extensions 1003 to 1003; + extensions 1004 to 1004; + extensions 1005 to 1005; + extensions 1006 to 1006; + extensions 1007 to 1007; + extensions 1008 to 1008; + extensions 1009 to 1009; + extensions 1010 to 1010; + extensions 1011 to 1011; + extensions 1012 to 1012; + extensions 1013 to 1013; + extensions 1014 to 1014; + extensions 1015 to 1015; + extensions 1016 to 1016; + extensions 1017 to 1017; + extensions 1018 to 1018; + extensions 1019 to 1019; + extensions 1020 to 1020; + extensions 1021 to 1021; + extensions 1022 to 1022; + extensions 1023 to 1023; + extensions 1024 to 1024; + extensions 1025 to 1025; + extensions 1026 to 1026; + extensions 1027 to 1027; + extensions 1028 to 1028; + extensions 1029 to 1029; + extensions 1030 to 1030; + extensions 1031 to 1031; + extensions 1032 to 1032; + extensions 1033 to 1033; + extensions 1034 to 1034; + extensions 1035 to 1035; + extensions 1036 to 1036; + extensions 1037 to 1037; + extensions 1038 to 1038; + extensions 1039 to 1039; + extensions 1040 to 1040; + extensions 1041 to 1041; + extensions 1042 to 1042; + extensions 1043 to 1043; + extensions 1044 to 1044; + extensions 1045 to 1045; + extensions 1046 to 1046; + extensions 1047 to 1047; + extensions 1048 to 1048; + extensions 1049 to 1049; + extensions 1050 to 1050; + extensions 1051 to 1051; + extensions 1052 to 1052; + extensions 1053 to 1053; + extensions 1054 to 1054; + extensions 1055 to 1055; + extensions 1056 to 1056; + extensions 1057 to 1057; + extensions 1058 to 1058; + extensions 1079 to 1079; + extensions 1080 to 1080; + extensions 1081 to 1081; + extensions 1082 to 1082; + extensions 1083 to 1083; + extensions 1084 to 1084; + extensions 1085 to 1085; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message16945 field17025 = 22068132; + } +} + diff --git a/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_2.proto b/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_2.proto new file mode 100644 index 000000000000..7ab993ba5570 --- /dev/null +++ b/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_2.proto @@ -0,0 +1,499 @@ +syntax = "proto2"; + +import "datasets/google_message3/benchmark_message3_3.proto"; +import "datasets/google_message3/benchmark_message3_4.proto"; +import "datasets/google_message3/benchmark_message3_5.proto"; +import "datasets/google_message3/benchmark_message3_7.proto"; +import "datasets/google_message3/benchmark_message3_8.proto"; +package benchmarks.google_message3; + +option cc_enable_arenas = true; +option java_package = "com.google.protobuf.benchmarks"; + +message Message22853 { + optional .benchmarks.google_message3.Enum22854 field22869 = 1; + repeated uint32 field22870 = 2 [packed = true]; + repeated float field22871 = 3 [packed = true]; + repeated float field22872 = 5 [packed = true]; + optional .benchmarks.google_message3.UnusedEmptyMessage field22873 = 4; +} + +message Message24345 { + optional string field24533 = 1; + optional .benchmarks.google_message3.UnusedEnum field24534 = 22; + optional .benchmarks.google_message3.Message24346 field24535 = 2; + optional string field24536 = 3; + optional string field24537 = 4; + optional .benchmarks.google_message3.UnusedEnum field24538 = 23; + optional string field24539 = 5; + required string field24540 = 6; + optional string field24541 = 7; + optional string field24542 = 8; + optional .benchmarks.google_message3.Message24316 field24543 = 9; + optional .benchmarks.google_message3.Message24376 field24544 = 10; + optional string field24545 = 11; + optional string field24546 = 19; + optional string field24547 = 20; + optional string field24548 = 21; + optional .benchmarks.google_message3.UnusedEmptyMessage field24549 = 12; + optional .benchmarks.google_message3.UnusedEmptyMessage field24550 = 13; + repeated string field24551 = 14; + optional string field24552 = 15; + optional int32 field24553 = 18; + optional .benchmarks.google_message3.Message24379 field24554 = 16; + optional string field24555 = 17; + repeated .benchmarks.google_message3.Message24356 field24556 = 24; + repeated .benchmarks.google_message3.Message24366 field24557 = 25; +} + +message Message24403 { + optional .benchmarks.google_message3.Message24401 field24681 = 1; + optional .benchmarks.google_message3.Message24402 field24682 = 2; +} + +message Message24391 { + optional string field24631 = 1; + optional string field24632 = 2; + repeated string field24633 = 3; + optional string field24634 = 4; + repeated string field24635 = 5; + repeated string field24636 = 16; + optional string field24637 = 17; + optional .benchmarks.google_message3.UnusedEmptyMessage field24638 = 25; + optional string field24639 = 7; + optional string field24640 = 18; + optional string field24641 = 19; + optional string field24642 = 20; + optional int32 field24643 = 24; + optional .benchmarks.google_message3.Message24379 field24644 = 8; + repeated .benchmarks.google_message3.UnusedEmptyMessage field24645 = 9; + optional .benchmarks.google_message3.UnusedEmptyMessage field24646 = 10; + optional .benchmarks.google_message3.UnusedEmptyMessage field24647 = 11; + optional .benchmarks.google_message3.UnusedEmptyMessage field24648 = 12; + repeated .benchmarks.google_message3.UnusedEmptyMessage field24649 = 13; + optional .benchmarks.google_message3.UnusedEmptyMessage field24650 = 14; + optional string field24651 = 21; + optional int32 field24652 = 22; + optional int32 field24653 = 23; + repeated string field24654 = 15; + repeated string field24655 = 6; +} + +message Message27454 { +} + +message Message27357 { + optional string field27410 = 1; + optional float field27411 = 2; + optional string field27412 = 3; + optional bool field27413 = 4; + optional bool field27414 = 5; +} + +message Message27360 { + optional .benchmarks.google_message3.Message27358 field27426 = 1; + optional .benchmarks.google_message3.Enum27361 field27427 = 2; + optional .benchmarks.google_message3.Message27358 field27428 = 3; + repeated .benchmarks.google_message3.UnusedEmptyMessage field27429 = 4; +} + +message Message34387 { + optional string field34446 = 1; + repeated .benchmarks.google_message3.Message34381 field34447 = 2; + optional .benchmarks.google_message3.UnusedEnum field34448 = 3; + optional .benchmarks.google_message3.Enum34388 field34449 = 4; + optional int64 field34450 = 5; +} + +message Message34621 { + optional double field34651 = 1; + optional double field34652 = 2; + optional double field34653 = 3; + optional double field34654 = 4; + optional double field34655 = 11; + optional .benchmarks.google_message3.UnusedEmptyMessage field34656 = 13; + optional .benchmarks.google_message3.Message34619 field34657 = 14; + optional string field34658 = 5; + optional string field34659 = 9; + optional double field34660 = 12; + optional bytes field34661 = 19; + optional string field34662 = 15; + optional string field34663 = 16; + optional string field34664 = 17; + optional .benchmarks.google_message3.UnusedEmptyMessage field34665 = 18; + optional .benchmarks.google_message3.Message34621 field34666 = 20; + repeated .benchmarks.google_message3.UnusedEmptyMessage field34667 = 100; + optional .benchmarks.google_message3.UnusedEmptyMessage field34668 = 101; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message34621 field34669 = 17562023; + } +} + +message Message35476 { + optional string field35484 = 1; + optional string field35485 = 2; + optional string field35486 = 3; + optional .benchmarks.google_message3.Enum35477 field35487 = 4; + optional float field35488 = 5; + optional float field35489 = 6; + optional float field35490 = 7; + optional float field35491 = 8; + optional .benchmarks.google_message3.UnusedEmptyMessage field35492 = 9; + optional int32 field35493 = 10; + optional int32 field35494 = 11; + optional int32 field35495 = 12; + optional string field35496 = 13; + optional string field35497 = 14; +} + +message Message949 { + optional string field955 = 1; + optional int64 field956 = 2; + optional int64 field957 = 3; + optional .benchmarks.google_message3.Message730 field958 = 4; + repeated string field959 = 5; + optional string field960 = 6; + optional bool field961 = 7; +} + +message Message36869 { + optional int32 field36970 = 1; + optional int32 field36971 = 2; +} + +message Message33968 { + repeated group Message33969 = 1 { + } + repeated .benchmarks.google_message3.Message33958 field33989 = 3; + optional .benchmarks.google_message3.UnusedEmptyMessage field33990 = 106; + optional bool field33991 = 108; + optional .benchmarks.google_message3.UnusedEnum field33992 = 107; +} + +message Message6644 { + optional .benchmarks.google_message3.UnusedEmptyMessage field6701 = 8; + optional string field6702 = 1; + optional double field6703 = 2; + optional .benchmarks.google_message3.UnusedEmptyMessage field6704 = 9; + optional bytes field6705 = 3; + optional bytes field6706 = 19; + optional .benchmarks.google_message3.Message6637 field6707 = 4; + repeated .benchmarks.google_message3.Message6126 field6708 = 18; + optional bool field6709 = 6; + optional .benchmarks.google_message3.Message6643 field6710 = 10; + optional string field6711 = 12; + optional .benchmarks.google_message3.UnusedEmptyMessage field6712 = 14; + optional .benchmarks.google_message3.UnusedEmptyMessage field6713 = 15; + optional .benchmarks.google_message3.UnusedEmptyMessage field6714 = 16; + optional int32 field6715 = 17; + optional .benchmarks.google_message3.UnusedEmptyMessage field6716 = 20; +} + +message Message18831 { + repeated group Message18832 = 1 { + optional int32 field18836 = 2; + optional string field18837 = 5; + optional float field18838 = 3; + optional float field18839 = 9; + optional int32 field18840 = 11; + repeated uint64 field18841 = 4; + repeated group Message18833 = 6 { + required uint64 field18843 = 7; + optional string field18844 = 8; + optional float field18845 = 10; + optional int32 field18846 = 12; + optional bool field18847 = 13; + } + } +} + +message Message13090 { + optional .benchmarks.google_message3.Message13083 field13141 = 1; + optional .benchmarks.google_message3.Message13088 field13142 = 2; +} + +message Message11874 { + optional .benchmarks.google_message3.Message10391 field11888 = 3; + optional string field11889 = 4; + optional .benchmarks.google_message3.Message11873 field11890 = 6; + optional bool field11891 = 7; + extensions 1 to 1; + extensions 2 to 2; + extensions 5 to 5; +} + +message Message4144 { + repeated group Message4145 = 1 { + required .benchmarks.google_message3.Enum4146 field4165 = 2; + required int32 field4166 = 3; + optional .benchmarks.google_message3.Enum4160 field4167 = 9; + optional bytes field4168 = 4; + optional .benchmarks.google_message3.Enum4152 field4169 = 5; + optional string field4170 = 6; + } +} + +message Message35573 { + optional fixed64 field35695 = 16; + optional string field35696 = 1000; + optional string field35697 = 1004; + optional int32 field35698 = 1003; + repeated group Message35574 = 1012 { + } + optional int64 field35700 = 1011; + optional int64 field35701 = 1005; + optional int64 field35702 = 1006; + optional int64 field35703 = 1007; + optional int64 field35704 = 1008; + repeated group Message35575 = 1 { + optional int64 field35709 = 2; + optional string field35710 = 3; + optional string field35711 = 19; + optional int32 field35712 = 20; + optional int32 field35713 = 21; + optional int32 field35714 = 22; + optional bool field35715 = 23; + optional int32 field35716 = 47; + optional int32 field35717 = 48; + optional bool field35718 = 24; + optional fixed64 field35719 = 25; + optional bytes field35720 = 52; + optional int32 field35721 = 18; + optional fixed32 field35722 = 43; + optional bool field35723 = 26; + optional int32 field35724 = 27; + optional int32 field35725 = 17; + optional bool field35726 = 45; + repeated int32 field35727 = 33; + repeated int32 field35728 = 58; + optional float field35729 = 34; + optional float field35730 = 1009; + optional int32 field35731 = 28; + repeated fixed64 field35732 = 1001; + repeated fixed64 field35733 = 1002; + optional int32 field35734 = 44; + optional int32 field35735 = 50; + optional int32 field35736 = 36; + optional int32 field35737 = 40; + optional bool field35738 = 1016; + optional bool field35739 = 1010; + optional int32 field35740 = 37; + optional int32 field35741 = 38; + optional string field35742 = 46; + optional uint32 field35743 = 60; + repeated bytes field35744 = 56; + optional .benchmarks.google_message3.Message0 field35745 = 57; + required group Message35576 = 4 { + optional fixed64 field35747 = 5; + optional int32 field35748 = 6; + optional int32 field35749 = 49; + optional int32 field35750 = 7; + optional uint32 field35751 = 59; + optional int32 field35752 = 14; + optional int32 field35753 = 15; + optional int32 field35754 = 35; + optional bytes field35755 = 53; + optional int32 field35756 = 8; + optional string field35757 = 9; + optional fixed64 field35758 = 10; + optional int32 field35759 = 11; + optional int32 field35760 = 12; + optional int32 field35761 = 41; + optional int32 field35762 = 30; + optional int32 field35763 = 31; + optional int32 field35764 = 13; + optional bytes field35765 = 39; + optional string field35766 = 29; + optional int32 field35767 = 42; + repeated int32 field35768 = 32; + repeated int32 field35769 = 51; + optional int64 field35770 = 54; + optional .benchmarks.google_message3.Message0 field35771 = 55; + } + } +} + +message Message36858 { + repeated int32 field36956 = 1; + repeated string field36957 = 2; + repeated string field36958 = 12; + optional int32 field36959 = 3; + optional int32 field36960 = 4; + optional int32 field36961 = 14; + optional string field36962 = 11; + optional bool field36963 = 5; + optional bool field36964 = 13; + optional int64 field36965 = 6; + optional .benchmarks.google_message3.Message35506 field36966 = 7; + repeated group Message36859 = 8 { + required .benchmarks.google_message3.Enum36860 field36968 = 9; + optional float field36969 = 10; + } +} + +message Message13174 { + required int32 field13237 = 6; + optional int32 field13238 = 3; + required int32 field13239 = 4; + optional int32 field13240 = 8; + optional double field13241 = 5; + optional double field13242 = 7; + optional int32 field13243 = 17; + optional int32 field13244 = 19; + optional double field13245 = 20; + optional int32 field13246 = 9; + optional double field13247 = 10; + optional int32 field13248 = 11; + optional .benchmarks.google_message3.Message13151 field13249 = 21; + optional int32 field13250 = 1; + optional double field13251 = 2; + optional double field13252 = 15; + optional double field13253 = 16; + optional double field13254 = 12; + optional double field13255 = 13; + optional double field13256 = 14; + optional int32 field13257 = 18; +} + +message Message18283 { + optional .benchmarks.google_message3.UnusedEmptyMessage field18478 = 1; + optional int32 field18479 = 4; + optional int32 field18480 = 106; + optional int32 field18481 = 107; + optional int32 field18482 = 108; + optional int32 field18483 = 109; + optional int32 field18484 = 105; + optional int32 field18485 = 113; + optional int32 field18486 = 114; + optional int32 field18487 = 124; + optional int32 field18488 = 125; + optional int32 field18489 = 128; + optional int32 field18490 = 135; + optional bool field18491 = 166; + optional bool field18492 = 136; + optional int32 field18493 = 140; + optional int32 field18494 = 171; + optional int32 field18495 = 148; + optional int32 field18496 = 145; + optional float field18497 = 117; + optional int32 field18498 = 146; + optional string field18499 = 3; + optional .benchmarks.google_message3.UnusedEmptyMessage field18500 = 5; + optional .benchmarks.google_message3.UnusedEmptyMessage field18501 = 6; + optional .benchmarks.google_message3.UnusedEmptyMessage field18502 = 9; + optional .benchmarks.google_message3.Message18253 field18503 = 155; + optional .benchmarks.google_message3.UnusedEmptyMessage field18504 = 184; + optional .benchmarks.google_message3.UnusedEmptyMessage field18505 = 163; + optional .benchmarks.google_message3.UnusedEmptyMessage field18506 = 16; + repeated int32 field18507 = 20; + repeated int32 field18508 = 7; + repeated string field18509 = 194; + optional bytes field18510 = 30; + optional int32 field18511 = 31; + optional .benchmarks.google_message3.UnusedEmptyMessage field18512 = 178; + optional string field18513 = 8; + optional float field18514 = 2; + optional float field18515 = 100; + optional float field18516 = 101; + optional float field18517 = 102; + optional int32 field18518 = 103; + repeated .benchmarks.google_message3.UnusedEmptyMessage field18519 = 104; + optional int32 field18520 = 110; + optional int32 field18521 = 112; + optional .benchmarks.google_message3.UnusedEmptyMessage field18522 = 111; + optional .benchmarks.google_message3.UnusedEmptyMessage field18523 = 115; + optional .benchmarks.google_message3.UnusedEmptyMessage field18524 = 119; + optional .benchmarks.google_message3.UnusedEmptyMessage field18525 = 127; + optional .benchmarks.google_message3.UnusedEmptyMessage field18526 = 185; + optional int32 field18527 = 120; + optional int32 field18528 = 132; + optional .benchmarks.google_message3.UnusedEmptyMessage field18529 = 126; + optional .benchmarks.google_message3.UnusedEmptyMessage field18530 = 129; + optional .benchmarks.google_message3.UnusedEmptyMessage field18531 = 131; + optional fixed64 field18532 = 150; + optional int32 field18533 = 133; + optional int32 field18534 = 134; + optional int32 field18535 = 139; + optional fixed64 field18536 = 137; + optional fixed64 field18537 = 138; + optional .benchmarks.google_message3.UnusedEmptyMessage field18538 = 141; + optional int32 field18539 = 142; + optional int32 field18540 = 181; + optional .benchmarks.google_message3.Message16816 field18541 = 143; + optional .benchmarks.google_message3.Message16685 field18542 = 154; + optional int32 field18543 = 144; + optional int64 field18544 = 147; + optional int64 field18545 = 149; + optional int32 field18546 = 151; + optional int32 field18547 = 152; + optional int32 field18548 = 153; + optional float field18549 = 161; + optional .benchmarks.google_message3.Message0 field18550 = 123; + repeated int64 field18551 = 156; + optional int32 field18552 = 157; + repeated fixed64 field18553 = 188; + optional int32 field18554 = 158; + optional .benchmarks.google_message3.UnusedEmptyMessage field18555 = 159; + optional bool field18556 = 160; + optional uint64 field18557 = 162; + optional int32 field18558 = 164; + optional .benchmarks.google_message3.UnusedEmptyMessage field18559 = 10; + optional .benchmarks.google_message3.UnusedEmptyMessage field18560 = 167; + optional int32 field18561 = 168; + repeated fixed64 field18562 = 169; + repeated string field18563 = 170; + optional .benchmarks.google_message3.UnusedEmptyMessage field18564 = 172; + optional int64 field18565 = 173; + optional .benchmarks.google_message3.UnusedEmptyMessage field18566 = 174; + optional int64 field18567 = 175; + optional uint32 field18568 = 189; + optional .benchmarks.google_message3.UnusedEmptyMessage field18569 = 176; + optional .benchmarks.google_message3.UnusedEmptyMessage field18570 = 177; + optional uint32 field18571 = 179; + optional uint32 field18572 = 180; + optional .benchmarks.google_message3.UnusedEmptyMessage field18573 = 182; + optional .benchmarks.google_message3.UnusedEmptyMessage field18574 = 183; + optional .benchmarks.google_message3.UnusedEmptyMessage field18575 = 121; + optional .benchmarks.google_message3.UnusedEmptyMessage field18576 = 186; + optional .benchmarks.google_message3.UnusedEmptyMessage field18577 = 187; + optional .benchmarks.google_message3.UnusedEmptyMessage field18578 = 190; + optional int32 field18579 = 191; + optional float field18580 = 192; + optional bool field18581 = 193; + extensions 116 to 116; + extensions 118 to 118; + extensions 130 to 130; + extensions 165 to 165; +} + +message Message13169 { + repeated .benchmarks.google_message3.Message13168 field13223 = 1; + required .benchmarks.google_message3.Message13167 field13224 = 2; + optional string field13225 = 3; +} + +message Message19255 { + optional string field19257 = 1; +} + +message Message35542 { + optional bool field35543 = 1; + optional bool field35544 = 2; + optional bool field35545 = 3; +} + +message Message3901 { + optional int32 field3990 = 1; + optional int32 field3991 = 2; + optional int32 field3992 = 3; + optional int32 field3993 = 4; + optional int32 field3994 = 7; + optional int32 field3995 = 8; + optional int32 field3996 = 9; + optional int32 field3997 = 10; + optional int32 field3998 = 11; + optional int32 field3999 = 12; + optional .benchmarks.google_message3.UnusedEnum field4000 = 6; + optional int32 field4001 = 5; +} + diff --git a/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_3.proto b/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_3.proto new file mode 100644 index 000000000000..e71d26613645 --- /dev/null +++ b/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_3.proto @@ -0,0 +1,466 @@ +syntax = "proto2"; + +import "datasets/google_message3/benchmark_message3_4.proto"; +import "datasets/google_message3/benchmark_message3_5.proto"; +import "datasets/google_message3/benchmark_message3_7.proto"; +import "datasets/google_message3/benchmark_message3_8.proto"; +package benchmarks.google_message3; + +option cc_enable_arenas = true; +option java_package = "com.google.protobuf.benchmarks"; + +message Message35546 { + optional int64 field35556 = 1; + optional int32 field35557 = 2; + optional bool field35558 = 3; + optional int64 field35559 = 13; + optional group Message35547 = 4 { + required int32 field35569 = 5; + required int32 field35570 = 6; + } + optional group Message35548 = 10 { + required int64 field35571 = 11; + required int64 field35572 = 12; + } + optional bool field35562 = 14; + optional bool field35563 = 15; + optional int32 field35564 = 16; + optional bool field35565 = 17; + optional bool field35566 = 18; + optional string field35567 = 100; +} + +message Message2356 { + optional .benchmarks.google_message3.Message1374 field2368 = 121; + optional uint64 field2369 = 1; + optional int32 field2370 = 2; + optional int32 field2371 = 17; + required string field2372 = 3; + optional int32 field2373 = 7; + optional bytes field2374 = 8; + optional string field2375 = 4; + optional string field2376 = 101; + optional int32 field2377 = 102; + optional int32 field2378 = 103; + optional int32 field2379 = 104; + optional int32 field2380 = 113; + optional int32 field2381 = 114; + optional int32 field2382 = 115; + optional int32 field2383 = 117; + optional int32 field2384 = 118; + optional int32 field2385 = 119; + optional int32 field2386 = 105; + optional bytes field2387 = 5; + optional group Message2357 = 6 { + optional int64 field2399 = 9; + optional int32 field2400 = 10; + optional int32 field2401 = 11; + optional int32 field2402 = 12; + optional int32 field2403 = 13; + optional int32 field2404 = 116; + optional int32 field2405 = 106; + required bytes field2406 = 14; + optional int32 field2407 = 45; + optional int32 field2408 = 112; + optional bool field2409 = 122; + optional bytes field2410 = 124; + } + optional string field2389 = 120; + optional group Message2358 = 107 { + } + repeated group Message2359 = 40 { + optional string field2413 = 41; + optional string field2414 = 42; + optional string field2415 = 43; + optional string field2416 = 44; + optional int32 field2417 = 46; + optional string field2418 = 47; + optional float field2419 = 110; + optional float field2420 = 111; + } + optional int32 field2392 = 50; + optional .benchmarks.google_message3.UnusedEmptyMessage field2393 = 60; + optional .benchmarks.google_message3.UnusedEmptyMessage field2394 = 70; + optional .benchmarks.google_message3.UnusedEmptyMessage field2395 = 80; + optional .benchmarks.google_message3.UnusedEmptyMessage field2396 = 90; + optional string field2397 = 100; + optional string field2398 = 123; +} + +message Message7029 { + required int32 field7183 = 1; + optional int32 field7184 = 2; + optional int32 field7185 = 3; + optional int32 field7186 = 4; + optional int32 field7187 = 5; + optional int32 field7188 = 6; + optional int32 field7189 = 17; + optional int32 field7190 = 18; + optional int32 field7191 = 49; + optional int32 field7192 = 28; + optional int32 field7193 = 33; + optional int32 field7194 = 25; + optional int32 field7195 = 26; + optional int32 field7196 = 40; + optional int32 field7197 = 41; + optional int32 field7198 = 42; + optional int32 field7199 = 43; + optional int32 field7200 = 19; + optional int32 field7201 = 7; + optional int32 field7202 = 8; + optional int32 field7203 = 9; + optional int32 field7204 = 10; + optional int32 field7205 = 11; + optional int32 field7206 = 12; + repeated group Message7030 = 13 { + optional string field7226 = 14; + optional string field7227 = 15; + optional int64 field7228 = 16; + } + repeated group Message7031 = 21 { + optional string field7229 = 22; + optional int32 field7230 = 23; + optional int32 field7231 = 24; + optional int32 field7232 = 30; + optional int32 field7233 = 31; + optional int32 field7234 = 35; + } + optional int32 field7209 = 20; + optional float field7210 = 27; + optional int32 field7211 = 29; + optional int32 field7212 = 32; + optional string field7213 = 48; + optional bool field7214 = 34; + optional int32 field7215 = 36; + optional float field7216 = 37; + optional bool field7217 = 38; + optional bool field7218 = 39; + optional .benchmarks.google_message3.UnusedEmptyMessage field7219 = 44; + optional int32 field7220 = 45; + optional int32 field7221 = 46; + optional int32 field7222 = 47; + optional .benchmarks.google_message3.UnusedEmptyMessage field7223 = 50; + optional int32 field7224 = 51; +} + +message Message35538 { + required int64 field35539 = 1; +} + +message Message18921 { + optional string field18946 = 1; + optional fixed64 field18947 = 2; + optional int32 field18948 = 3; + optional double field18949 = 4; + optional bool field18950 = 17; + optional bool field18951 = 23; + optional .benchmarks.google_message3.UnusedEmptyMessage field18952 = 24; + repeated group Message18922 = 5 { + optional uint64 field18959 = 6; + optional string field18960 = 13; + optional bool field18961 = 21; + optional bool field18962 = 33; + optional int32 field18963 = 7; + optional int32 field18964 = 8; + optional string field18965 = 9; + optional .benchmarks.google_message3.Message18856 field18966 = 10; + optional uint64 field18967 = 34; + optional .benchmarks.google_message3.UnusedEmptyMessage field18968 = 11; + optional uint64 field18969 = 35; + optional float field18970 = 12; + repeated string field18971 = 14; + optional bool field18972 = 15; + optional bool field18973 = 16; + optional float field18974 = 22; + optional int32 field18975 = 18; + optional int32 field18976 = 19; + optional int32 field18977 = 20; + optional .benchmarks.google_message3.UnusedEmptyMessage field18978 = 25; + optional .benchmarks.google_message3.UnusedEnum field18979 = 26; + repeated string field18980 = 27; + optional float field18981 = 28; + } + repeated .benchmarks.google_message3.UnusedEmptyMessage field18954 = 29; + repeated .benchmarks.google_message3.Message18943 field18955 = 30; + repeated .benchmarks.google_message3.Message18944 field18956 = 31; + repeated .benchmarks.google_message3.UnusedEmptyMessage field18957 = 32; +} + +message Message35540 { + optional bool field35541 = 1; +} + +message Message3886 { + repeated group Message3887 = 1 { + required string field3932 = 2; + optional string field3933 = 9; + optional .benchmarks.google_message3.Message3850 field3934 = 3; + optional bytes field3935 = 8; + } +} + +message Message6743 { + optional .benchmarks.google_message3.Message6721 field6759 = 1; + optional .benchmarks.google_message3.Message6723 field6760 = 2; + optional .benchmarks.google_message3.Message6723 field6761 = 8; + optional .benchmarks.google_message3.Message6725 field6762 = 3; + optional .benchmarks.google_message3.Message6726 field6763 = 4; + optional .benchmarks.google_message3.Message6733 field6764 = 5; + optional .benchmarks.google_message3.Message6734 field6765 = 6; + optional .benchmarks.google_message3.Message6742 field6766 = 7; +} + +message Message6773 { + optional .benchmarks.google_message3.Enum6769 field6794 = 1; + optional int32 field6795 = 9; + optional .benchmarks.google_message3.UnusedEnum field6796 = 10; + optional int32 field6797 = 11; + optional int32 field6798 = 2; + optional .benchmarks.google_message3.Enum6774 field6799 = 3; + optional double field6800 = 5; + optional double field6801 = 7; + optional double field6802 = 8; + optional .benchmarks.google_message3.Enum6782 field6803 = 6; +} + +message Message8224 { + optional .benchmarks.google_message3.UnusedEmptyMessage field8255 = 1; + optional .benchmarks.google_message3.Message8184 field8256 = 2; + optional .benchmarks.google_message3.Message7966 field8257 = 3; + optional string field8258 = 4; + optional string field8259 = 5; + optional bool field8260 = 6; + optional int64 field8261 = 7; + optional string field8262 = 8; + optional int64 field8263 = 9; + optional double field8264 = 10; + optional int64 field8265 = 11; + repeated string field8266 = 12; + optional int64 field8267 = 13; + optional int32 field8268 = 14; + optional int32 field8269 = 15; + optional int64 field8270 = 16; + optional double field8271 = 17; + optional .benchmarks.google_message3.UnusedEmptyMessage field8272 = 18; + optional .benchmarks.google_message3.UnusedEmptyMessage field8273 = 19; + repeated .benchmarks.google_message3.UnusedEmptyMessage field8274 = 20; + optional bool field8275 = 21; + optional .benchmarks.google_message3.UnusedEmptyMessage field8276 = 22; + optional .benchmarks.google_message3.UnusedEmptyMessage field8277 = 23; + repeated .benchmarks.google_message3.UnusedEmptyMessage field8278 = 24; + optional .benchmarks.google_message3.UnusedEmptyMessage field8279 = 25; + optional bool field8280 = 26; + repeated .benchmarks.google_message3.UnusedEmptyMessage field8281 = 27; +} + +message Message8392 { + optional string field8395 = 1; + optional string field8396 = 2; + optional .benchmarks.google_message3.Message7966 field8397 = 3; + optional string field8398 = 4; + optional string field8399 = 5; + optional string field8400 = 6; + optional string field8401 = 7; + optional string field8402 = 8; + optional string field8403 = 9; +} + +message Message8130 { + optional string field8156 = 1; + optional string field8157 = 2; + optional string field8158 = 4; + optional .benchmarks.google_message3.UnusedEmptyMessage field8159 = 6; + repeated string field8160 = 7; + optional int64 field8161 = 8; + optional .benchmarks.google_message3.UnusedEmptyMessage field8162 = 9; + optional string field8163 = 10; + optional string field8164 = 11; + optional string field8165 = 12; + optional string field8166 = 13; + optional .benchmarks.google_message3.UnusedEmptyMessage field8167 = 14; + optional .benchmarks.google_message3.UnusedEmptyMessage field8168 = 15; + optional string field8169 = 16; + optional .benchmarks.google_message3.UnusedEnum field8170 = 17; + optional .benchmarks.google_message3.UnusedEnum field8171 = 18; + optional bool field8172 = 19; + optional bool field8173 = 20; + optional double field8174 = 21; + optional int32 field8175 = 22; + optional int32 field8176 = 23; + optional .benchmarks.google_message3.UnusedEmptyMessage field8177 = 24; + repeated .benchmarks.google_message3.UnusedEmptyMessage field8178 = 25; + repeated .benchmarks.google_message3.UnusedEmptyMessage field8179 = 26; +} + +message Message8478 { + optional string field8489 = 7; + optional .benchmarks.google_message3.Message7966 field8490 = 1; + optional .benchmarks.google_message3.Message8476 field8491 = 2; + optional int64 field8492 = 3; + optional .benchmarks.google_message3.Message8476 field8493 = 4; + repeated .benchmarks.google_message3.Message8477 field8494 = 5; + optional .benchmarks.google_message3.Message8454 field8495 = 6; + optional .benchmarks.google_message3.UnusedEmptyMessage field8496 = 8; +} + +message Message8479 { + optional .benchmarks.google_message3.Message8475 field8497 = 1; + optional .benchmarks.google_message3.Message7966 field8498 = 2; + optional .benchmarks.google_message3.Message8476 field8499 = 3; + optional .benchmarks.google_message3.Message8476 field8500 = 4; + optional string field8501 = 6; + optional string field8502 = 7; + optional .benchmarks.google_message3.Message7966 field8503 = 8; + optional .benchmarks.google_message3.Message8455 field8504 = 5; + optional .benchmarks.google_message3.UnusedEmptyMessage field8505 = 9; +} + +message Message10319 { + optional .benchmarks.google_message3.Enum10325 field10340 = 1; + optional int32 field10341 = 4; + optional int32 field10342 = 5; + optional bytes field10343 = 3; + optional string field10344 = 2; + optional string field10345 = 6; + optional string field10346 = 7; +} + +message Message4016 { + required int32 field4017 = 1; + required int32 field4018 = 2; + required int32 field4019 = 3; + required int32 field4020 = 4; +} + +message Message12669 { + optional .benchmarks.google_message3.Message12559 field12681 = 1; + optional float field12682 = 2; + optional bool field12683 = 3; + optional .benchmarks.google_message3.Enum12670 field12684 = 4; +} + +message Message12819 { + optional double field12834 = 1; + optional double field12835 = 2; + optional double field12836 = 3; + optional double field12837 = 4; + optional double field12838 = 5; + optional double field12839 = 6; +} + +message Message12820 { + optional int32 field12840 = 1; + optional int32 field12841 = 2; + optional int32 field12842 = 3; + optional int32 field12843 = 8; + optional int32 field12844 = 4; + optional int32 field12845 = 5; + optional int32 field12846 = 6; + optional int32 field12847 = 7; +} + +message Message12821 { + optional int32 field12848 = 1; + optional int32 field12849 = 2; + optional int32 field12850 = 3; + optional int32 field12851 = 4; + optional int32 field12852 = 5; +} + +message Message12818 { + optional uint64 field12829 = 1; + optional int32 field12830 = 2; + optional int32 field12831 = 3; + optional int32 field12832 = 5; + repeated .benchmarks.google_message3.Message12817 field12833 = 4; +} + +message Message16479 { + optional .benchmarks.google_message3.Message16480 field16484 = 1; + optional int32 field16485 = 5; + optional float field16486 = 2; + optional uint32 field16487 = 4; + optional bool field16488 = 3; + optional uint32 field16489 = 6; +} + +message Message16722 { + optional string field16752 = 1; + optional string field16753 = 2; + optional string field16754 = 3; + optional int32 field16755 = 5; + optional string field16756 = 4; +} + +message Message16724 { + optional int64 field16761 = 1; + optional float field16762 = 2; + optional int64 field16763 = 3; + optional int64 field16764 = 4; + optional bool field16765 = 5; + repeated string field16766 = 6; + repeated string field16767 = 7; + optional .benchmarks.google_message3.UnusedEmptyMessage field16768 = 8; + optional bool field16769 = 9; + optional uint32 field16770 = 10; + optional .benchmarks.google_message3.Enum16728 field16771 = 11; + repeated int32 field16772 = 12; + optional bool field16773 = 13; +} + +message Message17728 { +} + +message Message24356 { + optional string field24559 = 1; + optional string field24560 = 2; + optional int32 field24561 = 14; + optional string field24562 = 3; + optional string field24563 = 4; + optional string field24564 = 5; + optional .benchmarks.google_message3.UnusedEnum field24565 = 13; + optional string field24566 = 6; + optional .benchmarks.google_message3.Enum24361 field24567 = 12; + optional string field24568 = 7; + optional string field24569 = 8; + optional string field24570 = 9; + repeated .benchmarks.google_message3.UnusedEmptyMessage field24571 = 10; + repeated string field24572 = 11; + repeated string field24573 = 15; +} + +message Message24376 { + optional string field24589 = 1; + optional string field24590 = 2; + optional string field24591 = 3; + required .benchmarks.google_message3.Message24377 field24592 = 4; + optional .benchmarks.google_message3.Message24317 field24593 = 5; + optional string field24594 = 6; + optional .benchmarks.google_message3.Message24378 field24595 = 7; + repeated string field24596 = 8; + repeated .benchmarks.google_message3.UnusedEmptyMessage field24597 = 14; + repeated string field24598 = 9; + repeated string field24599 = 10; + repeated string field24600 = 11; + optional string field24601 = 12; + repeated string field24602 = 13; +} + +message Message24366 { + optional string field24574 = 1; + optional string field24575 = 2; + optional string field24576 = 3; + optional int32 field24577 = 10; + optional string field24578 = 13; + optional string field24579 = 4; + optional string field24580 = 5; + optional .benchmarks.google_message3.UnusedEnum field24581 = 9; + optional string field24582 = 14; + optional .benchmarks.google_message3.UnusedEnum field24583 = 15; + optional string field24584 = 6; + optional string field24585 = 12; + repeated .benchmarks.google_message3.UnusedEmptyMessage field24586 = 7; + repeated string field24587 = 8; + repeated string field24588 = 11; +} + diff --git a/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_4.proto b/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_4.proto new file mode 100644 index 000000000000..597cec6d1145 --- /dev/null +++ b/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_4.proto @@ -0,0 +1,491 @@ +syntax = "proto2"; + +import "datasets/google_message3/benchmark_message3_5.proto"; +import "datasets/google_message3/benchmark_message3_6.proto"; +import "datasets/google_message3/benchmark_message3_7.proto"; +import "datasets/google_message3/benchmark_message3_8.proto"; +package benchmarks.google_message3; + +option cc_enable_arenas = true; +option java_package = "com.google.protobuf.benchmarks"; + +message Message24346 { +} + +message Message24401 { + optional .benchmarks.google_message3.Message24400 field24679 = 1; +} + +message Message24402 { + optional .benchmarks.google_message3.Message24400 field24680 = 1; +} + +message Message24379 { + optional string field24603 = 1; + optional string field24604 = 2; + optional string field24605 = 3; + required .benchmarks.google_message3.Message24380 field24606 = 4; + optional .benchmarks.google_message3.UnusedEmptyMessage field24607 = 5; + optional string field24608 = 6; + optional .benchmarks.google_message3.Message24381 field24609 = 7; + repeated string field24610 = 8; + repeated .benchmarks.google_message3.UnusedEmptyMessage field24611 = 17; + repeated string field24612 = 9; + repeated string field24613 = 10; + repeated string field24614 = 11; + optional string field24615 = 14; + optional string field24616 = 12; + optional string field24617 = 16; + repeated .benchmarks.google_message3.UnusedEmptyMessage field24618 = 13; + repeated string field24619 = 15; + repeated string field24620 = 18; +} + +message Message27358 { + optional int32 field27415 = 1; + optional int32 field27416 = 2; +} + +message Message34381 { + optional string field34398 = 1; + optional .benchmarks.google_message3.UnusedEmptyMessage field34399 = 2; + optional .benchmarks.google_message3.UnusedEmptyMessage field34400 = 3; + optional .benchmarks.google_message3.UnusedEmptyMessage field34401 = 4; + optional .benchmarks.google_message3.UnusedEmptyMessage field34402 = 5; + optional bool field34403 = 6; + optional bool field34404 = 7; + optional .benchmarks.google_message3.UnusedEmptyMessage field34405 = 8; + optional bool field34406 = 9; + optional .benchmarks.google_message3.UnusedEmptyMessage field34407 = 10; +} + +message Message34619 { + optional double field34641 = 1; + optional double field34642 = 2; + optional double field34643 = 3; + optional double field34644 = 4; + optional double field34645 = 11; + optional double field34646 = 5; + optional .benchmarks.google_message3.UnusedEmptyMessage field34647 = 100; +} + +message Message730 { + optional string field897 = 19; + repeated string field898 = 27; + repeated string field899 = 28; + repeated string field900 = 21; + optional string field901 = 30; + repeated uint32 field902 = 20; + repeated uint32 field903 = 32; + repeated string field904 = 16; + repeated .benchmarks.google_message3.Message697 field905 = 6; + repeated .benchmarks.google_message3.Message704 field906 = 7; + repeated string field907 = 18; + repeated .benchmarks.google_message3.Message703 field908 = 8; + repeated string field909 = 9; + optional .benchmarks.google_message3.Message716 field910 = 10; + optional .benchmarks.google_message3.Message718 field911 = 11; + optional bool field912 = 14; + repeated .benchmarks.google_message3.Message715 field913 = 4; + repeated string field914 = 17; + repeated string field915 = 23; + repeated .benchmarks.google_message3.Message719 field916 = 24; + repeated .benchmarks.google_message3.Message728 field917 = 26; + repeated .benchmarks.google_message3.Message702 field918 = 35; + optional string field919 = 36; + repeated string field920 = 37; + optional int64 field921 = 38; + repeated .benchmarks.google_message3.UnusedEmptyMessage field922 = 39; + repeated .benchmarks.google_message3.UnusedEmptyMessage field923 = 1; + optional .benchmarks.google_message3.UnusedEmptyMessage field924 = 2; + optional .benchmarks.google_message3.UnusedEmptyMessage field925 = 3; + optional .benchmarks.google_message3.UnusedEmptyMessage field926 = 5; + optional .benchmarks.google_message3.UnusedEmptyMessage field927 = 13; + repeated string field928 = 22; + optional bytes field929 = 31; + extensions 25 to 25; + extensions 29 to 29; + extensions 34 to 34; + extensions 15 to 15; +} + +message Message33958 { + optional string field33977 = 1; + optional string field33978 = 9; + repeated group Message33959 = 2 { + required string field33982 = 3; + optional string field33983 = 4; + optional string field33984 = 5; + optional fixed64 field33985 = 8; + optional bool field33986 = 10; + optional .benchmarks.google_message3.Message0 field33987 = 6; + } + optional .benchmarks.google_message3.Enum33960 field33980 = 7; + extend .benchmarks.google_message3.Message0 { + optional .benchmarks.google_message3.Message33958 field33981 = 10747482; + } +} + +message Message6637 { + optional .benchmarks.google_message3.UnusedEmptyMessage field6670 = 2; + repeated .benchmarks.google_message3.UnusedEmptyMessage field6671 = 1; + optional int32 field6672 = 3; + repeated string field6673 = 4; + optional .benchmarks.google_message3.UnusedEmptyMessage field6674 = 5; +} + +message Message6643 { + optional .benchmarks.google_message3.UnusedEmptyMessage field6683 = 3; + optional .benchmarks.google_message3.UnusedEmptyMessage field6684 = 4; + optional double field6685 = 5; + optional double field6686 = 6; + optional int32 field6687 = 1; + optional int32 field6688 = 2; + optional double field6689 = 9; + optional bytes field6690 = 10; + optional int32 field6691 = 11; + optional bool field6692 = 12; + optional bool field6693 = 13; + optional .benchmarks.google_message3.Message6578 field6694 = 15; + optional .benchmarks.google_message3.UnusedEnum field6695 = 16; + optional int64 field6696 = 17; + repeated .benchmarks.google_message3.UnusedEmptyMessage field6697 = 22; + optional .benchmarks.google_message3.UnusedEmptyMessage field6698 = 19; + optional .benchmarks.google_message3.UnusedEmptyMessage field6699 = 20; + optional int32 field6700 = 21; +} + +message Message6126 { + required string field6152 = 1; + repeated .benchmarks.google_message3.UnusedEmptyMessage field6153 = 9; + optional int32 field6154 = 14; + optional bytes field6155 = 10; + optional .benchmarks.google_message3.Message6024 field6156 = 12; + optional int32 field6157 = 4; + optional string field6158 = 5; + optional int32 field6159 = 6; + repeated int32 field6160 = 2; + repeated int32 field6161 = 3; + repeated .benchmarks.google_message3.Message6052 field6162 = 7; + repeated .benchmarks.google_message3.UnusedEmptyMessage field6163 = 11; + optional .benchmarks.google_message3.Enum6065 field6164 = 15; + repeated .benchmarks.google_message3.UnusedEmptyMessage field6165 = 8; + optional bool field6166 = 13; + optional bool field6167 = 16; + optional bool field6168 = 18; + repeated .benchmarks.google_message3.Message6054 field6169 = 17; + optional int32 field6170 = 19; +} + +message Message13083 { + optional float field13096 = 1; + repeated group Message13084 = 2 { + required float field13107 = 3; + required int32 field13108 = 4; + optional float field13109 = 5; + repeated .benchmarks.google_message3.Enum13092 field13110 = 6; + } + optional float field13098 = 44; + optional float field13099 = 45; + optional uint64 field13100 = 46; + optional float field13101 = 47; + optional group Message13085 = 16 { + } + repeated group Message13086 = 23 { + } + repeated group Message13087 = 29 { + } + optional .benchmarks.google_message3.UnusedEmptyMessage field13105 = 43; +} + +message Message13088 { + repeated group Message13089 = 1 { + required string field13139 = 2; + optional float field13140 = 3; + } + optional int64 field13136 = 4; + optional bool field13137 = 5; +} + +message Message10391 { + optional .benchmarks.google_message3.Enum10392 field10411 = 1; + optional .benchmarks.google_message3.UnusedEnum field10412 = 2; + optional int64 field10413 = 3; + optional string field10414 = 4; + optional string field10415 = 5; + optional bytes field10416 = 6; + optional bool field10417 = 8; + optional .benchmarks.google_message3.UnusedEmptyMessage field10418 = 9; + optional bool field10419 = 10; +} + +message Message11873 { + optional string field11876 = 1; + optional string field11877 = 4; + optional .benchmarks.google_message3.Message10573 field11878 = 5; + optional .benchmarks.google_message3.Message10582 field11879 = 6; + optional .benchmarks.google_message3.Message10824 field11880 = 7; + optional .benchmarks.google_message3.Message10773 field11881 = 12; + optional .benchmarks.google_message3.Message11866 field11882 = 8; + optional .benchmarks.google_message3.Message10818 field11883 = 13; + optional .benchmarks.google_message3.UnusedEmptyMessage field11884 = 16; + optional .benchmarks.google_message3.Message10155 field11885 = 11; + optional .benchmarks.google_message3.Message10469 field11886 = 14; + optional .benchmarks.google_message3.UnusedEmptyMessage field11887 = 15; + extensions 9 to 9; + extensions 10 to 10; +} + +message Message35506 { + optional int32 field35524 = 1; + optional string field35525 = 2; + optional .benchmarks.google_message3.Enum35507 field35526 = 3; + repeated .benchmarks.google_message3.UnusedEmptyMessage field35527 = 4; +} + +message Message13151 { + repeated .benchmarks.google_message3.Message13145 field13158 = 1; +} + +message Message18253 { + repeated group Message18254 = 1 { + required fixed64 field18362 = 2; + required double field18363 = 3; + } +} + +message Message16685 { + repeated .benchmarks.google_message3.Message16686 field16694 = 2; +} + +message Message16816 { + optional float field16826 = 1; + optional .benchmarks.google_message3.Enum16819 field16827 = 2; + optional float field16828 = 3; + repeated group Message16817 = 4 { + } + optional bool field16830 = 7; + optional bool field16831 = 8; + repeated group Message16818 = 12 { + } + optional string field16833 = 10; + optional bool field16834 = 13; + optional bool field16835 = 14; +} + +message Message13168 { + required int32 field13212 = 1; + optional fixed64 field13213 = 7; + optional bool field13214 = 8; + optional fixed64 field13215 = 10; + optional bool field13216 = 11; + optional .benchmarks.google_message3.Message12796 field13217 = 9; + required double field13218 = 2; + required bool field13219 = 3; + optional int32 field13220 = 4; + required bool field13221 = 5; + optional int32 field13222 = 6; +} + +message Message13167 { + required int32 field13199 = 1; + optional int32 field13200 = 2; + optional int32 field13201 = 3; + optional bool field13202 = 8; + optional fixed64 field13203 = 12; + optional bool field13204 = 13; + optional .benchmarks.google_message3.Message12796 field13205 = 11; + optional fixed64 field13206 = 9; + optional bool field13207 = 10; + repeated int32 field13208 = 4; + optional int32 field13209 = 5; + optional int32 field13210 = 6; + optional int32 field13211 = 7; +} + +message Message1374 { + required string field1375 = 1; + optional string field1376 = 2; +} + +message Message18943 { +} + +message Message18944 { +} + +message Message18856 { + optional string field18857 = 1; + optional string field18858 = 2; + optional bool field18859 = 31; + optional string field18860 = 26; + optional string field18861 = 3; + optional string field18862 = 4; + optional string field18863 = 5; + optional string field18864 = 17; + optional string field18865 = 6; + optional string field18866 = 7; + optional string field18867 = 8; + optional string field18868 = 9; + optional string field18869 = 10; + optional string field18870 = 11; + optional string field18871 = 21; + optional string field18872 = 18; + optional string field18873 = 19; + optional string field18874 = 20; + optional string field18875 = 22; + optional string field18876 = 23; + optional string field18877 = 24; + optional string field18878 = 25; + optional string field18879 = 12; + optional string field18880 = 13; + optional string field18881 = 29; + optional string field18882 = 30; + optional string field18883 = 15; + optional string field18884 = 16; + repeated string field18885 = 14; + optional string field18886 = 27; + optional string field18887 = 28; +} + +message Message3850 { + optional .benchmarks.google_message3.Enum3851 field3924 = 2; + optional bool field3925 = 12; + optional int32 field3926 = 4; + optional bool field3927 = 10; + optional bool field3928 = 13; + optional bool field3929 = 14; +} + +message Message6721 { + optional .benchmarks.google_message3.Message6722 field6744 = 1; + optional bool field6745 = 2; + optional bool field6746 = 3; + optional bool field6747 = 4; +} + +message Message6742 { + optional bool field6758 = 1; +} + +message Message6726 { + optional int64 field6752 = 1; + repeated .benchmarks.google_message3.Message6727 field6753 = 2; +} + +message Message6733 { + optional int64 field6754 = 1; + optional int64 field6755 = 2; + optional bool field6756 = 3; +} + +message Message6723 { + optional int64 field6748 = 1; + repeated .benchmarks.google_message3.Message6724 field6749 = 2; +} + +message Message6725 { + optional int32 field6750 = 1; + optional int32 field6751 = 2; +} + +message Message6734 { + repeated .benchmarks.google_message3.Message6735 field6757 = 1; +} + +message Message8184 { + optional .benchmarks.google_message3.Message7966 field8228 = 1; + optional bool field8229 = 2; + repeated .benchmarks.google_message3.Message8183 field8230 = 3; +} + +message Message8477 { + optional .benchmarks.google_message3.Message7966 field8486 = 1; + optional int64 field8487 = 2; + optional string field8488 = 3; +} + +message Message8454 { + optional .benchmarks.google_message3.Message8449 field8465 = 1; + optional int64 field8466 = 3; + optional int32 field8467 = 4; + optional bool field8468 = 5; + extend .benchmarks.google_message3.Message8301 { + optional .benchmarks.google_message3.Message8454 field8469 = 66; + } +} + +message Message8476 { + optional string field8483 = 1; + optional string field8484 = 2; + optional string field8485 = 3; +} + +message Message8455 { + optional .benchmarks.google_message3.Message8449 field8470 = 1; + repeated .benchmarks.google_message3.Message8456 field8471 = 2; + optional .benchmarks.google_message3.Message8457 field8472 = 5; + optional .benchmarks.google_message3.UnusedEmptyMessage field8473 = 6; + extend .benchmarks.google_message3.Message8302 { + optional .benchmarks.google_message3.Message8455 field8474 = 66; + } +} + +message Message8475 { + optional string field8481 = 1; + optional int64 field8482 = 2; +} + +message Message12559 { +} + +message Message12817 { + optional int32 field12826 = 1; + optional int32 field12827 = 2; + optional int32 field12828 = 3; +} + +message Message16480 { + optional .benchmarks.google_message3.Message13358 field16490 = 1; + optional .benchmarks.google_message3.Enum16042 field16491 = 2; + optional .benchmarks.google_message3.Message13912 field16492 = 3; + optional string field16493 = 4; + optional string field16494 = 5; + optional string field16495 = 6; + optional string field16496 = 7; + optional .benchmarks.google_message3.Message13358 field16497 = 8; + optional fixed32 field16498 = 9; +} + +message Message24317 { + optional string field24446 = 1; + optional .benchmarks.google_message3.Message24312 field24447 = 2; + repeated .benchmarks.google_message3.Message24315 field24448 = 3; + repeated .benchmarks.google_message3.Message24313 field24449 = 4; + repeated .benchmarks.google_message3.Message24316 field24450 = 5; + repeated .benchmarks.google_message3.UnusedEmptyMessage field24451 = 6; + optional .benchmarks.google_message3.UnusedEmptyMessage field24452 = 7; + repeated string field24453 = 8; + repeated string field24454 = 9; + repeated string field24455 = 10; + repeated string field24456 = 28; + optional string field24457 = 11; + optional string field24458 = 12; + optional string field24459 = 13; + optional string field24460 = 14; + repeated string field24461 = 15; + optional string field24462 = 16; + repeated string field24463 = 17; + repeated string field24464 = 18; + repeated string field24465 = 19; + repeated string field24466 = 20; + repeated string field24467 = 21; + repeated string field24468 = 22; + repeated string field24469 = 23; + repeated string field24470 = 24; + optional string field24471 = 25; + optional string field24472 = 26; + repeated string field24473 = 27; + optional bool field24474 = 40; +} + diff --git a/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_5.proto b/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_5.proto new file mode 100644 index 000000000000..bc6cbc1c81d1 --- /dev/null +++ b/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_5.proto @@ -0,0 +1,473 @@ +syntax = "proto2"; + +import "datasets/google_message3/benchmark_message3_6.proto"; +import "datasets/google_message3/benchmark_message3_7.proto"; +import "datasets/google_message3/benchmark_message3_8.proto"; +package benchmarks.google_message3; + +option cc_enable_arenas = true; +option java_package = "com.google.protobuf.benchmarks"; + +message Message24377 { +} + +message Message24378 { +} + +message Message24400 { + optional int32 field24674 = 1; + optional int32 field24675 = 2; + optional int32 field24676 = 3; + optional int32 field24677 = 4; + optional int32 field24678 = 5; +} + +message Message24380 { +} + +message Message24381 { +} + +message Message719 { + repeated string field881 = 1; + repeated string field882 = 2; + repeated string field883 = 3; + optional .benchmarks.google_message3.Enum720 field884 = 4; +} + +message Message728 { + required string field887 = 1; + repeated string field888 = 2; + repeated .benchmarks.google_message3.Message703 field889 = 3; + repeated .benchmarks.google_message3.Message715 field890 = 4; + repeated string field891 = 5; + repeated string field892 = 6; + optional .benchmarks.google_message3.Message718 field893 = 7; + optional .benchmarks.google_message3.Message716 field894 = 8; + repeated string field895 = 9; + extensions 10 to 10; + extensions 11 to 11; + extensions 12 to 12; +} + +message Message704 { + optional string field800 = 1; + optional string field801 = 7; + optional string field802 = 2; + optional string field803 = 3; + optional string field804 = 4; + optional string field805 = 5; + optional .benchmarks.google_message3.UnusedEmptyMessage field806 = 6; +} + +message Message697 { + optional string field743 = 7; + repeated string field744 = 1; + repeated string field745 = 2; + repeated string field746 = 33; + repeated string field747 = 29; + repeated string field748 = 30; + repeated string field749 = 31; + repeated string field750 = 32; + repeated string field751 = 13; + repeated string field752 = 6; + repeated string field753 = 3; + repeated string field754 = 14; + repeated string field755 = 15; + repeated string field756 = 16; + repeated string field757 = 4; + repeated string field758 = 34; + repeated string field759 = 35; + repeated string field760 = 5; + repeated string field761 = 17; + repeated string field762 = 18; + repeated string field763 = 19; + optional bool field764 = 36; + repeated string field765 = 8; + repeated string field766 = 9; + optional string field767 = 27; + optional bool field768 = 25; + optional .benchmarks.google_message3.Message700 field769 = 10; + optional bool field770 = 11; + optional bool field771 = 24; + repeated string field772 = 12; + repeated string field773 = 20; + repeated string field774 = 21; + repeated string field775 = 22; + repeated .benchmarks.google_message3.Message699 field776 = 23; + repeated .benchmarks.google_message3.Message698 field777 = 37; + optional int64 field778 = 38; + extensions 28 to 28; + extensions 26 to 26; +} + +message Message0 { + option message_set_wire_format = true; + extensions 4 to 2147483646; +} + +message Message6578 { + optional .benchmarks.google_message3.Enum6579 field6632 = 1; + optional .benchmarks.google_message3.Enum6588 field6633 = 2; +} + +message Message6024 { + optional .benchmarks.google_message3.Enum6025 field6048 = 1; + optional string field6049 = 2; + optional .benchmarks.google_message3.UnusedEmptyMessage field6050 = 3; +} + +message Message6052 { + required string field6084 = 1; + required bytes field6085 = 2; +} + +message Message6054 { + required string field6089 = 1; + optional string field6090 = 2; +} + +message Message10573 { + repeated .benchmarks.google_message3.Message10576 field10580 = 1; + optional string field10581 = 2; + extensions 10000 to 536870911; +} + +message Message10824 { + required string field10825 = 1; + optional int32 field10826 = 2; +} + +message Message10582 { + required bool field10583 = 1; + required double field10584 = 2; + optional bool field10585 = 3; + optional double field10586 = 4; + optional double field10587 = 5; + optional bool field10588 = 6; +} + +message Message10155 { + required int32 field10195 = 1; + required int32 field10196 = 2; + optional .benchmarks.google_message3.Enum10157 field10197 = 59; + optional int32 field10198 = 18; + optional int32 field10199 = 19; + optional int32 field10200 = 21; + repeated group Message10156 = 50 { + optional .benchmarks.google_message3.Enum8862 field10266 = 51; + optional int32 field10267 = 52; + optional int32 field10268 = 53; + optional int32 field10269 = 54; + } + optional int32 field10202 = 3; + optional int32 field10203 = 4; + optional int32 field10204 = 5; + optional bool field10205 = 84; + optional bool field10206 = 33; + optional int32 field10207 = 75; + optional float field10208 = 26; + optional int32 field10209 = 27; + optional int32 field10210 = 49; + optional int32 field10211 = 10; + optional float field10212 = 78; + optional .benchmarks.google_message3.Message9151 field10213 = 91; + optional int32 field10214 = 11; + optional int32 field10215 = 12; + optional float field10216 = 41; + optional .benchmarks.google_message3.Message10154 field10217 = 61; + optional int32 field10218 = 23; + optional bytes field10219 = 24; + optional int32 field10220 = 65; + repeated bytes field10221 = 66; + optional int32 field10222 = 70; + optional bytes field10223 = 71; + repeated fixed64 field10224 = 73; + optional float field10225 = 29; + optional int32 field10226 = 30; + optional float field10227 = 31; + optional int32 field10228 = 32; + optional float field10229 = 34; + optional int32 field10230 = 35; + optional string field10231 = 22; + optional fixed64 field10232 = 13; + optional fixed64 field10233 = 20; + optional bool field10234 = 79; + repeated .benchmarks.google_message3.Enum10167 field10235 = 80 [packed = true]; + optional int32 field10236 = 14; + optional int32 field10237 = 15; + optional int32 field10238 = 28; + repeated string field10239 = 16; + optional .benchmarks.google_message3.Message9182 field10240 = 17; + optional int32 field10241 = 63; + optional float field10242 = 64; + optional float field10243 = 37; + repeated float field10244 = 43; + optional int32 field10245 = 44; + optional .benchmarks.google_message3.Message9242 field10246 = 45; + optional .benchmarks.google_message3.UnusedEmptyMessage field10247 = 46; + optional .benchmarks.google_message3.UnusedEmptyMessage field10248 = 62; + optional .benchmarks.google_message3.Message8944 field10249 = 48; + optional .benchmarks.google_message3.UnusedEmptyMessage field10250 = 87; + optional int32 field10251 = 58; + optional int32 field10252 = 92; + optional .benchmarks.google_message3.Message9123 field10253 = 93; + optional .benchmarks.google_message3.Message9160 field10254 = 60; + optional .benchmarks.google_message3.Message8890 field10255 = 67; + optional string field10256 = 69; + optional int64 field10257 = 74; + optional float field10258 = 82; + optional float field10259 = 85; + optional float field10260 = 86; + optional int64 field10261 = 83; + optional string field10262 = 77; + optional bool field10263 = 88; + repeated .benchmarks.google_message3.Message9628 field10264 = 94; + extensions 57 to 57; + extensions 1000 to 536870911; +} + +message Message11866 { + required .benchmarks.google_message3.Message11014 field11868 = 1; + optional bool field11869 = 2; + optional double field11870 = 3; + optional double field11871 = 4; + repeated .benchmarks.google_message3.UnusedEmptyMessage field11872 = 5; +} + +message Message10469 { + optional string field10473 = 1; + optional float field10474 = 2; + optional int32 field10475 = 3; + optional int32 field10476 = 4; + optional int32 field10477 = 5; + optional bool field10478 = 6; + optional bool field10479 = 7; + optional int32 field10480 = 8; + optional float field10481 = 9; +} + +message Message10818 { + optional .benchmarks.google_message3.Message10800 field10819 = 1; + optional .benchmarks.google_message3.Message10801 field10820 = 2; +} + +message Message10773 { + optional bool field10774 = 9; + optional bool field10775 = 1; + optional bool field10776 = 23; + optional bool field10777 = 2; + optional bool field10778 = 3; + optional int32 field10779 = 4; + optional int32 field10780 = 5; + optional int32 field10781 = 6; + optional int32 field10782 = 7; + optional int32 field10783 = 8; + optional int32 field10784 = 10; + optional .benchmarks.google_message3.Message10749 field10785 = 11; + repeated .benchmarks.google_message3.UnusedEmptyMessage field10786 = 12; + optional bool field10787 = 13; + optional bool field10788 = 15; + optional bool field10789 = 16; + optional int32 field10790 = 17; + optional int32 field10791 = 18; + optional bool field10792 = 19; + optional bool field10793 = 20; + optional bool field10794 = 21; + optional .benchmarks.google_message3.UnusedEnum field10795 = 14; + optional .benchmarks.google_message3.UnusedEnum field10796 = 22; +} + +message Message13145 { + required .benchmarks.google_message3.Enum13146 field13155 = 1; + optional float field13156 = 2; + optional float field13157 = 3; + extensions 1000 to 536870911; +} + +message Message16686 { +} + +message Message12796 { + repeated fixed64 field12800 = 1; + optional uint64 field12801 = 2; +} + +message Message6722 { +} + +message Message6727 { +} + +message Message6724 { +} + +message Message6735 { +} + +message Message8183 { + optional string field8226 = 1; + optional string field8227 = 2; +} + +message Message8301 { + optional string field8328 = 1; + optional .benchmarks.google_message3.Message7966 field8329 = 2; + optional string field8330 = 3; + optional string field8331 = 4; + repeated .benchmarks.google_message3.Message8290 field8332 = 5; + optional .benchmarks.google_message3.Message7966 field8333 = 6; + repeated .benchmarks.google_message3.Message8298 field8334 = 7; + optional .benchmarks.google_message3.Message8300 field8335 = 8; + optional int64 field8336 = 9; + optional .benchmarks.google_message3.UnusedEmptyMessage field8337 = 10; + optional .benchmarks.google_message3.Message7965 field8338 = 11; + extensions 64 to 536870911; +} + +message Message8456 { +} + +message Message8302 { + optional string field8339 = 1; + optional .benchmarks.google_message3.Message7966 field8340 = 2; + optional string field8341 = 3; + optional string field8342 = 4; + optional string field8343 = 5; + optional string field8344 = 6; + optional string field8345 = 7; + optional int64 field8346 = 8; + optional int64 field8347 = 9; + repeated .benchmarks.google_message3.Message8290 field8348 = 10; + optional string field8349 = 11; + optional .benchmarks.google_message3.UnusedEmptyMessage field8350 = 12; + optional .benchmarks.google_message3.Message8291 field8351 = 13; + optional int64 field8352 = 14; + optional .benchmarks.google_message3.Message8296 field8353 = 15; + optional string field8354 = 16; + optional .benchmarks.google_message3.UnusedEmptyMessage field8355 = 17; + repeated int32 field8356 = 18; + repeated int32 field8357 = 19; + repeated .benchmarks.google_message3.UnusedEmptyMessage field8358 = 20; + optional .benchmarks.google_message3.Message7965 field8359 = 21; + extensions 64 to 536870911; +} + +message Message8457 { +} + +message Message8449 { + optional string field8458 = 1; + optional bool field8459 = 2; + optional .benchmarks.google_message3.Enum8450 field8460 = 3; + repeated string field8461 = 4; + optional string field8462 = 5; + optional string field8463 = 6; + optional .benchmarks.google_message3.Message7966 field8464 = 7; +} + +message Message13358 { + required fixed64 field13359 = 1; + required fixed64 field13360 = 2; + optional .benchmarks.google_message3.UnusedEmptyMessage field13361 = 3; +} + +message Message13912 { + required fixed32 field13913 = 1; + required fixed32 field13914 = 2; + optional .benchmarks.google_message3.UnusedEmptyMessage field13915 = 500; + optional .benchmarks.google_message3.UnusedEmptyMessage field13916 = 15; +} + +message Message24316 { + repeated string field24443 = 1; + repeated string field24444 = 2; + repeated string field24445 = 3; +} + +message Message24312 { + optional string field24421 = 1; + optional string field24422 = 2; + repeated string field24423 = 3; + repeated string field24424 = 4; + repeated string field24425 = 5; + repeated string field24426 = 6; +} + +message Message24313 { + optional string field24427 = 1; + optional string field24428 = 2; + repeated string field24429 = 3; + optional string field24430 = 4; + optional string field24431 = 5; + optional string field24432 = 6; + optional string field24433 = 7; + repeated string field24434 = 8; + optional string field24435 = 9; + repeated string field24436 = 10; +} + +message Message24315 { + required string field24440 = 1; + repeated string field24441 = 2; + repeated string field24442 = 3; +} + +message Message716 { + required string field872 = 1; + required int32 field873 = 2; + optional bool field874 = 3; + optional .benchmarks.google_message3.Message717 field875 = 4; +} + +message Message718 { + repeated string field878 = 1; + repeated string field879 = 2; + optional string field880 = 3; +} + +message Message703 { + required string field795 = 1; + repeated string field796 = 2; + repeated string field797 = 3; + optional string field798 = 4; + repeated string field799 = 5; +} + +message Message715 { + required string field859 = 1; + optional string field860 = 7; + repeated .benchmarks.google_message3.Message707 field861 = 2; + repeated .benchmarks.google_message3.Message708 field862 = 3; + repeated .benchmarks.google_message3.Message711 field863 = 4; + repeated .benchmarks.google_message3.Message712 field864 = 5; + repeated .benchmarks.google_message3.Message713 field865 = 6; + repeated .benchmarks.google_message3.Message714 field866 = 8; + repeated .benchmarks.google_message3.Message710 field867 = 9; + repeated .benchmarks.google_message3.Message709 field868 = 10; + repeated .benchmarks.google_message3.Message705 field869 = 11; + repeated .benchmarks.google_message3.Message702 field870 = 12; + repeated .benchmarks.google_message3.Message706 field871 = 13; +} + +message Message700 { + repeated string field789 = 1; + repeated string field790 = 2; +} + +message Message699 { + required string field787 = 1; + repeated string field788 = 2; +} + +message Message698 { + optional string field779 = 1; + optional string field780 = 2; + optional string field781 = 3; + optional string field782 = 4; + optional uint64 field783 = 5; + optional uint32 field784 = 6; + optional int64 field785 = 7; + repeated string field786 = 8; +} + diff --git a/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_6.proto b/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_6.proto new file mode 100644 index 000000000000..98e1529e2419 --- /dev/null +++ b/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_6.proto @@ -0,0 +1,454 @@ +syntax = "proto2"; + +import "datasets/google_message3/benchmark_message3_7.proto"; +import "datasets/google_message3/benchmark_message3_8.proto"; +package benchmarks.google_message3; + +option cc_enable_arenas = true; +option java_package = "com.google.protobuf.benchmarks"; + +message Message10576 { +} + +message Message10154 { + optional bytes field10192 = 1; + optional int32 field10193 = 2; +} + +message Message8944 { + optional string field9045 = 2; + optional string field9046 = 3; + optional string field9047 = 23; + optional string field9048 = 52; + optional int32 field9049 = 53; + optional int32 field9050 = 54; + optional float field9051 = 55; + optional float field9052 = 56; + optional string field9053 = 57; + optional int64 field9054 = 1; + optional bool field9055 = 4; + optional int32 field9056 = 5; + optional int32 field9057 = 6; + optional int32 field9058 = 7; + optional float field9059 = 8; + optional float field9060 = 11; + optional float field9061 = 9; + optional float field9062 = 10; + optional float field9063 = 13; + optional bool field9064 = 14; + optional float field9065 = 70; + optional int32 field9066 = 71; + optional .benchmarks.google_message3.Enum8945 field9067 = 15; + optional int32 field9068 = 16; + optional int32 field9069 = 17; + optional float field9070 = 18; + optional float field9071 = 19; + optional int32 field9072 = 28; + optional int32 field9073 = 29; + optional float field9074 = 60; + optional float field9075 = 61; + optional int32 field9076 = 72; + optional int32 field9077 = 73; + optional .benchmarks.google_message3.Enum8951 field9078 = 62; + optional string field9079 = 20; + optional string field9080 = 21; + optional string field9081 = 22; + optional double field9082 = 31; + optional double field9083 = 32; + optional double field9084 = 33; + optional double field9085 = 36; + optional .benchmarks.google_message3.UnusedEnum field9086 = 37; + optional double field9087 = 38; + optional double field9088 = 39; + optional double field9089 = 63; + optional double field9090 = 64; + optional double field9091 = 65; + optional double field9092 = 34; + optional .benchmarks.google_message3.UnusedEnum field9093 = 35; + optional .benchmarks.google_message3.UnusedEnum field9094 = 66; + optional string field9095 = 40; + optional string field9096 = 41; + optional string field9097 = 42; + optional string field9098 = 43; + optional string field9099 = 44; + optional string field9100 = 45; + optional string field9101 = 46; + optional string field9102 = 47; + optional string field9103 = 48; + optional string field9104 = 49; + optional .benchmarks.google_message3.Message8939 field9105 = 100; + optional int64 field9106 = 101; +} + +message Message9182 { + optional string field9205 = 1; + optional string field9206 = 2; + optional float field9207 = 16; + optional int32 field9208 = 17; + optional int32 field9209 = 27; + optional int32 field9210 = 7; + optional int32 field9211 = 8; + optional float field9212 = 26; + optional float field9213 = 22; + optional bool field9214 = 28; + repeated .benchmarks.google_message3.UnusedEmptyMessage field9215 = 21; + repeated .benchmarks.google_message3.UnusedEmptyMessage field9216 = 25; + repeated .benchmarks.google_message3.Message9181 field9217 = 29; + optional bool field9218 = 18; + optional bool field9219 = 19; + optional bool field9220 = 20; + optional .benchmarks.google_message3.Message9164 field9221 = 30; + optional .benchmarks.google_message3.Message9165 field9222 = 31; + optional .benchmarks.google_message3.Message9166 field9223 = 32; + optional float field9224 = 33; + optional .benchmarks.google_message3.Message9151 field9225 = 34; + optional float field9226 = 35; + optional float field9227 = 36; + optional float field9228 = 37; + optional float field9229 = 38; + optional float field9230 = 39; + extensions 3 to 6; + extensions 9 to 15; + extensions 23 to 23; + extensions 24 to 24; + extensions 1000 to 536870911; +} + +message Message9160 { + optional int32 field9161 = 1; + optional bytes field9162 = 2; +} + +message Message9242 { + repeated .benchmarks.google_message3.Enum9243 field9327 = 1; +} + +message Message8890 { + repeated .benchmarks.google_message3.Message8888 field8916 = 1; +} + +message Message9123 { + optional float field9135 = 1; +} + +message Message9628 { + optional .benchmarks.google_message3.Message9627 field9673 = 1; + optional string field9674 = 2; + repeated int32 field9675 = 3; + optional int32 field9676 = 4; +} + +message Message11014 { + optional int32 field11780 = 40; + optional string field11781 = 46; + optional bool field11782 = 47; + optional .benchmarks.google_message3.Enum11107 field11783 = 1; + optional int32 field11784 = 2; + optional double field11785 = 4; + optional int32 field11786 = 5; + optional int32 field11787 = 6; + optional double field11788 = 7; + optional double field11789 = 8; + optional int64 field11790 = 9; + optional bool field11791 = 10; + optional int64 field11792 = 28; + optional bool field11793 = 37; + optional .benchmarks.google_message3.Enum11541 field11794 = 44; + optional double field11795 = 49; + optional double field11796 = 51; + optional int64 field11797 = 54; + optional int64 field11798 = 55; + optional .benchmarks.google_message3.UnusedEnum field11799 = 57; + optional .benchmarks.google_message3.Enum11468 field11800 = 58; + optional int32 field11801 = 59; + optional .benchmarks.google_message3.UnusedEnum field11802 = 60; + optional int32 field11803 = 61; + optional int32 field11804 = 62; + optional int32 field11805 = 69; + optional .benchmarks.google_message3.UnusedEmptyMessage field11806 = 68; + repeated .benchmarks.google_message3.Message11018 field11807 = 71; + optional bool field11808 = 50; + optional bool field11809 = 56; + optional bool field11810 = 66; + optional bool field11811 = 63; + optional bool field11812 = 64; + optional bool field11813 = 65; + optional bool field11814 = 67; + optional .benchmarks.google_message3.Enum11107 field11815 = 15; + optional int64 field11816 = 16; + optional double field11817 = 17; + optional int64 field11818 = 18; + optional int32 field11819 = 19; + optional int64 field11820 = 20; + optional int32 field11821 = 42; + optional int64 field11822 = 52; + optional int64 field11823 = 53; + optional int64 field11824 = 41; + optional double field11825 = 48; + repeated .benchmarks.google_message3.Message11020 field11826 = 70; + repeated .benchmarks.google_message3.UnusedEmptyMessage field11827 = 72; + optional double field11828 = 25; + optional string field11829 = 26; + optional int64 field11830 = 27; + optional int64 field11831 = 32; + optional uint64 field11832 = 33; + optional bool field11833 = 29; + optional bool field11834 = 34; + optional string field11835 = 30; + optional int32 field11836 = 3; + optional int32 field11837 = 31; + optional int32 field11838 = 73; + optional int32 field11839 = 35; + optional .benchmarks.google_message3.Enum11022 field11840 = 36; + optional .benchmarks.google_message3.Message11013 field11841 = 38; + optional double field11842 = 39; + optional int32 field11843 = 45; + optional bool field11844 = 74; +} + +message Message10801 { + optional .benchmarks.google_message3.Message10800 field10812 = 1; + repeated .benchmarks.google_message3.Message10802 field10813 = 2; + optional int32 field10814 = 3; +} + +message Message10749 { + repeated .benchmarks.google_message3.Message10748 field10754 = 1; +} + +message Message8298 { + optional .benchmarks.google_message3.Message7966 field8321 = 1; + optional int64 field8322 = 2; + optional string field8323 = 3; +} + +message Message8300 { + optional string field8326 = 1; + optional .benchmarks.google_message3.Message7966 field8327 = 2; +} + +message Message8291 { + optional string field8306 = 1; + optional int32 field8307 = 2; + optional string field8308 = 3; + optional string field8309 = 4; + optional .benchmarks.google_message3.Enum8292 field8310 = 5; +} + +message Message8296 { + optional .benchmarks.google_message3.Message7966 field8311 = 1; + optional string field8312 = 2; + optional .benchmarks.google_message3.Message7966 field8313 = 3; + optional int32 field8314 = 4; + optional int32 field8315 = 5; + optional string field8316 = 6; +} + +message Message7965 { + optional int32 field7967 = 1; + optional int32 field7968 = 2; +} + +message Message8290 { + optional string field8304 = 1; + optional string field8305 = 2; +} + +message Message717 { + repeated string field876 = 1; + optional double field877 = 2; +} + +message Message713 { + required .benchmarks.google_message3.Message708 field852 = 1; + repeated string field853 = 2; +} + +message Message705 { + required string field807 = 1; + optional string field808 = 2; + optional string field809 = 3; + optional bool field810 = 4; + optional string field811 = 5; + optional string field812 = 6; + repeated string field813 = 7; +} + +message Message709 { + repeated string field829 = 1; + repeated string field830 = 2; + repeated string field831 = 3; + repeated string field832 = 4; + repeated string field833 = 5; +} + +message Message702 { + optional string field793 = 1; + optional string field794 = 2; +} + +message Message714 { + optional string field854 = 1; + optional string field855 = 2; + optional string field856 = 3; + optional string field857 = 4; + optional uint32 field858 = 5; +} + +message Message710 { + repeated string field834 = 1; + optional string field835 = 2; + optional string field836 = 3; + repeated string field837 = 4; + repeated string field838 = 5; +} + +message Message706 { + repeated string field814 = 1; + optional string field815 = 2; + repeated string field816 = 3; + repeated string field817 = 4; +} + +message Message707 { + required string field818 = 1; + required string field819 = 2; + required string field820 = 3; + optional bool field821 = 4; + repeated string field822 = 5; +} + +message Message711 { + optional .benchmarks.google_message3.UnusedEmptyMessage field839 = 1; + repeated string field840 = 4; + repeated string field841 = 2; + repeated string field842 = 3; +} + +message Message712 { + repeated string field843 = 1; + required string field844 = 2; + optional string field845 = 3; + repeated string field846 = 4; + repeated string field847 = 5; + optional string field848 = 6; + repeated string field849 = 7; + optional string field850 = 8; + optional string field851 = 9; +} + +message Message8939 { + optional string field9010 = 1; + optional string field9011 = 2; + optional string field9012 = 3; + repeated string field9013 = 4; + optional string field9014 = 5; + repeated group Message8940 = 11 { + } + optional int64 field9016 = 21; + optional int64 field9017 = 22; + optional int64 field9018 = 23; + optional group Message8941 = 31 { + optional string field9033 = 32; + optional string field9034 = 33; + optional string field9035 = 34; + optional string field9036 = 35; + optional string field9037 = 36; + optional string field9038 = 37; + } + optional .benchmarks.google_message3.Message8942 field9020 = 38; + repeated .benchmarks.google_message3.UnusedEmptyMessage field9021 = 39; + repeated string field9022 = 41; + optional string field9023 = 42; + optional string field9024 = 43; + optional string field9025 = 44; + optional string field9026 = 45; + optional string field9027 = 46; + optional string field9028 = 47; + optional .benchmarks.google_message3.UnusedEnum field9029 = 48; + optional .benchmarks.google_message3.UnusedEnum field9030 = 49; + optional group Message8943 = 51 { + optional string field9039 = 1; + optional string field9040 = 2; + optional string field9041 = 3; + optional string field9042 = 4; + optional string field9043 = 5; + optional string field9044 = 6; + } +} + +message Message9181 { + optional string field9204 = 1; +} + +message Message9164 { + optional int32 field9168 = 1; + optional int32 field9169 = 2; + optional int32 field9170 = 3; +} + +message Message9165 { + optional float field9171 = 1; + optional float field9172 = 2; +} + +message Message9166 { + optional float field9173 = 1; + optional int32 field9174 = 2; +} + +message Message9151 { + optional double field9152 = 1; + optional double field9153 = 2; + optional float field9154 = 3; + optional float field9155 = 4; + optional float field9156 = 5; + optional float field9157 = 6; + optional float field9158 = 7; + optional float field9159 = 8; +} + +message Message8888 { + optional int32 field8908 = 1; + optional .benchmarks.google_message3.Enum8900 field8909 = 4; + repeated int32 field8910 = 2 [packed = true]; + optional bytes field8911 = 3; +} + +message Message9627 { + required int32 field9668 = 1; + required int32 field9669 = 2; + required int32 field9670 = 3; + required int32 field9671 = 4; + optional float field9672 = 5; +} + +message Message11020 { +} + +message Message11013 { + optional bytes field11757 = 19; + optional bytes field11758 = 1; + optional bytes field11759 = 2; + optional bytes field11760 = 3; + optional bytes field11761 = 4; + optional bytes field11762 = 5; + optional bytes field11763 = 6; + optional bytes field11764 = 7; + optional bytes field11765 = 8; + optional bytes field11766 = 9; + optional bytes field11767 = 10; + optional bytes field11768 = 11; + optional bytes field11769 = 12; + optional bytes field11770 = 13; + optional bytes field11771 = 14; + optional bytes field11772 = 15; + optional bytes field11773 = 16; + optional bytes field11774 = 17; + optional bytes field11775 = 18; + optional bytes field11776 = 20; + optional bytes field11777 = 21; + optional .benchmarks.google_message3.UnusedEmptyMessage field11778 = 23; + repeated .benchmarks.google_message3.Message11011 field11779 = 22; +} + diff --git a/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_7.proto b/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_7.proto new file mode 100644 index 000000000000..2497db5e297b --- /dev/null +++ b/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_7.proto @@ -0,0 +1,56 @@ +syntax = "proto2"; + +package benchmarks.google_message3; + +option cc_enable_arenas = true; +option java_package = "com.google.protobuf.benchmarks"; + +message Message11018 { +} + +message Message10800 { + optional string field10808 = 1; + optional int64 field10809 = 2; + optional bool field10810 = 3; + optional float field10811 = 4; +} + +message Message10802 { +} + +message Message10748 { + optional string field10750 = 1; + optional int32 field10751 = 2; + optional int32 field10752 = 3; + optional int32 field10753 = 4; +} + +message Message7966 { + optional string field7969 = 1; + optional bool field7970 = 2; +} + +message Message708 { + optional .benchmarks.google_message3.Message741 field823 = 1; + repeated string field824 = 6; + optional string field825 = 2; + optional string field826 = 3; + repeated string field827 = 4; + repeated string field828 = 5; +} + +message Message8942 { +} + +message Message11011 { + required bytes field11752 = 1; + required bytes field11753 = 2; +} + +message UnusedEmptyMessage { +} + +message Message741 { + repeated string field936 = 1; +} + diff --git a/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_8.proto b/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_8.proto new file mode 100644 index 000000000000..1d2b14723010 --- /dev/null +++ b/third_party/protobuf/benchmarks/datasets/google_message3/benchmark_message3_8.proto @@ -0,0 +1,1900 @@ +syntax = "proto2"; + +package benchmarks.google_message3; + +option cc_enable_arenas = true; +option java_package = "com.google.protobuf.benchmarks"; + +enum Enum720 { + ENUM_VALUE721 = 1; + ENUM_VALUE722 = 2; +} + +enum Enum3476 { + ENUM_VALUE3477 = 0; + ENUM_VALUE3478 = 1; + ENUM_VALUE3479 = 2; + ENUM_VALUE3480 = 3; + ENUM_VALUE3481 = 4; + ENUM_VALUE3482 = 5; + ENUM_VALUE3483 = 6; + ENUM_VALUE3484 = 7; + ENUM_VALUE3485 = 8; + ENUM_VALUE3486 = 9; + ENUM_VALUE3487 = 10; + ENUM_VALUE3488 = 11; + ENUM_VALUE3489 = 12; + ENUM_VALUE3490 = 13; + ENUM_VALUE3491 = 14; + ENUM_VALUE3492 = 15; + ENUM_VALUE3493 = 16; + ENUM_VALUE3494 = 17; + ENUM_VALUE3495 = 18; + ENUM_VALUE3496 = 19; + ENUM_VALUE3497 = 20; + ENUM_VALUE3498 = 21; + ENUM_VALUE3499 = 22; + ENUM_VALUE3500 = 23; + ENUM_VALUE3501 = 24; + ENUM_VALUE3502 = 25; + ENUM_VALUE3503 = 26; + ENUM_VALUE3504 = 27; + ENUM_VALUE3505 = 28; + ENUM_VALUE3506 = 29; + ENUM_VALUE3507 = 30; + ENUM_VALUE3508 = 31; + ENUM_VALUE3509 = 32; + ENUM_VALUE3510 = 33; + ENUM_VALUE3511 = 34; + ENUM_VALUE3512 = 35; + ENUM_VALUE3513 = 36; + ENUM_VALUE3514 = 37; + ENUM_VALUE3515 = 38; + ENUM_VALUE3516 = 39; + ENUM_VALUE3517 = 40; + ENUM_VALUE3518 = 41; + ENUM_VALUE3519 = 42; + ENUM_VALUE3520 = 43; + ENUM_VALUE3521 = 44; + ENUM_VALUE3522 = 45; + ENUM_VALUE3523 = 46; + ENUM_VALUE3524 = 47; + ENUM_VALUE3525 = 48; + ENUM_VALUE3526 = 49; + ENUM_VALUE3527 = 50; + ENUM_VALUE3528 = 51; + ENUM_VALUE3529 = 52; + ENUM_VALUE3530 = 53; + ENUM_VALUE3531 = 54; + ENUM_VALUE3532 = 55; + ENUM_VALUE3533 = 56; + ENUM_VALUE3534 = 57; + ENUM_VALUE3535 = 58; + ENUM_VALUE3536 = 59; + ENUM_VALUE3537 = 60; + ENUM_VALUE3538 = 61; + ENUM_VALUE3539 = 62; + ENUM_VALUE3540 = 63; + ENUM_VALUE3541 = 64; + ENUM_VALUE3542 = 65; + ENUM_VALUE3543 = 66; + ENUM_VALUE3544 = 67; + ENUM_VALUE3545 = 68; + ENUM_VALUE3546 = 69; + ENUM_VALUE3547 = 70; + ENUM_VALUE3548 = 71; + ENUM_VALUE3549 = 72; + ENUM_VALUE3550 = 73; + ENUM_VALUE3551 = 74; + ENUM_VALUE3552 = 75; + ENUM_VALUE3553 = 76; + ENUM_VALUE3554 = 77; + ENUM_VALUE3555 = 78; + ENUM_VALUE3556 = 79; + ENUM_VALUE3557 = 80; + ENUM_VALUE3558 = 81; + ENUM_VALUE3559 = 82; + ENUM_VALUE3560 = 83; + ENUM_VALUE3561 = 84; + ENUM_VALUE3562 = 85; + ENUM_VALUE3563 = 86; + ENUM_VALUE3564 = 87; + ENUM_VALUE3565 = 88; + ENUM_VALUE3566 = 89; + ENUM_VALUE3567 = 90; + ENUM_VALUE3568 = 91; + ENUM_VALUE3569 = 92; + ENUM_VALUE3570 = 93; + ENUM_VALUE3571 = 94; + ENUM_VALUE3572 = 95; + ENUM_VALUE3573 = 96; + ENUM_VALUE3574 = 97; + ENUM_VALUE3575 = 98; + ENUM_VALUE3576 = 99; + ENUM_VALUE3577 = 100; + ENUM_VALUE3578 = 101; + ENUM_VALUE3579 = 102; + ENUM_VALUE3580 = 103; + ENUM_VALUE3581 = 104; + ENUM_VALUE3582 = 105; + ENUM_VALUE3583 = 106; + ENUM_VALUE3584 = 107; + ENUM_VALUE3585 = 108; + ENUM_VALUE3586 = 109; + ENUM_VALUE3587 = 110; + ENUM_VALUE3588 = 111; + ENUM_VALUE3589 = 112; + ENUM_VALUE3590 = 113; + ENUM_VALUE3591 = 114; + ENUM_VALUE3592 = 115; + ENUM_VALUE3593 = 116; + ENUM_VALUE3594 = 117; + ENUM_VALUE3595 = 118; + ENUM_VALUE3596 = 119; + ENUM_VALUE3597 = 120; + ENUM_VALUE3598 = 121; + ENUM_VALUE3599 = 122; + ENUM_VALUE3600 = 123; + ENUM_VALUE3601 = 124; + ENUM_VALUE3602 = 125; + ENUM_VALUE3603 = 126; + ENUM_VALUE3604 = 127; + ENUM_VALUE3605 = 128; + ENUM_VALUE3606 = 129; + ENUM_VALUE3607 = 130; + ENUM_VALUE3608 = 131; + ENUM_VALUE3609 = 132; + ENUM_VALUE3610 = 133; + ENUM_VALUE3611 = 134; + ENUM_VALUE3612 = 135; + ENUM_VALUE3613 = 136; + ENUM_VALUE3614 = 137; + ENUM_VALUE3615 = 138; + ENUM_VALUE3616 = 139; + ENUM_VALUE3617 = 140; + ENUM_VALUE3618 = 141; + ENUM_VALUE3619 = 142; + ENUM_VALUE3620 = 143; + ENUM_VALUE3621 = 144; + ENUM_VALUE3622 = 145; + ENUM_VALUE3623 = 146; + ENUM_VALUE3624 = 147; + ENUM_VALUE3625 = 148; + ENUM_VALUE3626 = 149; + ENUM_VALUE3627 = 150; + ENUM_VALUE3628 = 151; + ENUM_VALUE3629 = 152; + ENUM_VALUE3630 = 153; + ENUM_VALUE3631 = 154; + ENUM_VALUE3632 = 155; + ENUM_VALUE3633 = 156; + ENUM_VALUE3634 = 157; + ENUM_VALUE3635 = 158; + ENUM_VALUE3636 = 159; + ENUM_VALUE3637 = 160; + ENUM_VALUE3638 = 161; + ENUM_VALUE3639 = 162; + ENUM_VALUE3640 = 163; + ENUM_VALUE3641 = 164; + ENUM_VALUE3642 = 165; + ENUM_VALUE3643 = 166; + ENUM_VALUE3644 = 167; + ENUM_VALUE3645 = 168; + ENUM_VALUE3646 = 169; + ENUM_VALUE3647 = 170; + ENUM_VALUE3648 = 171; + ENUM_VALUE3649 = 172; + ENUM_VALUE3650 = 173; + ENUM_VALUE3651 = 174; + ENUM_VALUE3652 = 175; + ENUM_VALUE3653 = 176; + ENUM_VALUE3654 = 177; + ENUM_VALUE3655 = 178; + ENUM_VALUE3656 = 179; + ENUM_VALUE3657 = 180; + ENUM_VALUE3658 = 181; + ENUM_VALUE3659 = 182; + ENUM_VALUE3660 = 183; +} + +enum Enum3805 { + ENUM_VALUE3806 = 0; + ENUM_VALUE3807 = 1; + ENUM_VALUE3808 = 2; + ENUM_VALUE3809 = 3; + ENUM_VALUE3810 = 4; + ENUM_VALUE3811 = 5; + ENUM_VALUE3812 = 6; + ENUM_VALUE3813 = 7; + ENUM_VALUE3814 = 8; + ENUM_VALUE3815 = 9; + ENUM_VALUE3816 = 11; + ENUM_VALUE3817 = 10; +} + +enum Enum3783 { + ENUM_VALUE3784 = 0; + ENUM_VALUE3785 = 1; + ENUM_VALUE3786 = 2; + ENUM_VALUE3787 = 3; + ENUM_VALUE3788 = 4; + ENUM_VALUE3789 = 5; + ENUM_VALUE3790 = 6; + ENUM_VALUE3791 = 7; + ENUM_VALUE3792 = 8; + ENUM_VALUE3793 = 9; + ENUM_VALUE3794 = 10; + ENUM_VALUE3795 = 11; + ENUM_VALUE3796 = 12; + ENUM_VALUE3797 = 13; + ENUM_VALUE3798 = 14; + ENUM_VALUE3799 = 15; + ENUM_VALUE3800 = 16; + ENUM_VALUE3801 = 20; + ENUM_VALUE3802 = 21; + ENUM_VALUE3803 = 50; +} + +enum Enum3851 { + ENUM_VALUE3852 = 0; + ENUM_VALUE3853 = 1; + ENUM_VALUE3854 = 2; + ENUM_VALUE3855 = 3; + ENUM_VALUE3856 = 4; + ENUM_VALUE3857 = 5; + ENUM_VALUE3858 = 6; + ENUM_VALUE3859 = 7; + ENUM_VALUE3860 = 8; + ENUM_VALUE3861 = 9; + ENUM_VALUE3862 = 10; + ENUM_VALUE3863 = 11; + ENUM_VALUE3864 = 12; + ENUM_VALUE3865 = 13; + ENUM_VALUE3866 = 14; + ENUM_VALUE3867 = 15; + ENUM_VALUE3868 = 16; + ENUM_VALUE3869 = 17; +} + +enum UnusedEnum { + UNUSED_ENUM_VALUE1 = 0; + UNUSED_ENUM_VALUE2 = 1; +} + +enum Enum4146 { + ENUM_VALUE4147 = 0; + ENUM_VALUE4148 = 1; + ENUM_VALUE4149 = 2; + ENUM_VALUE4150 = 3; + ENUM_VALUE4151 = 4; +} + +enum Enum4160 { + ENUM_VALUE4161 = 0; + ENUM_VALUE4162 = 1; +} + +enum Enum4152 { + ENUM_VALUE4153 = 0; + ENUM_VALUE4154 = 1; + ENUM_VALUE4155 = 2; + ENUM_VALUE4156 = 3; + ENUM_VALUE4157 = 4; + ENUM_VALUE4158 = 5; + ENUM_VALUE4159 = 6; +} + +enum Enum6025 { + ENUM_VALUE6026 = 0; + ENUM_VALUE6027 = 1; + ENUM_VALUE6028 = 2; + ENUM_VALUE6029 = 3; + ENUM_VALUE6030 = 4; + ENUM_VALUE6031 = 5; + ENUM_VALUE6032 = 6; + ENUM_VALUE6033 = 7; + ENUM_VALUE6034 = 8; + ENUM_VALUE6035 = 9; + ENUM_VALUE6036 = 10; + ENUM_VALUE6037 = 11; + ENUM_VALUE6038 = 12; + ENUM_VALUE6039 = 13; + ENUM_VALUE6040 = 14; + ENUM_VALUE6041 = 15; + ENUM_VALUE6042 = 16; + ENUM_VALUE6043 = 17; + ENUM_VALUE6044 = 18; + ENUM_VALUE6045 = 19; + ENUM_VALUE6046 = 20; + ENUM_VALUE6047 = 21; +} + +enum Enum6065 { + ENUM_VALUE6066 = 0; + ENUM_VALUE6067 = 1; + ENUM_VALUE6068 = 2; + ENUM_VALUE6069 = 3; + ENUM_VALUE6070 = 4; + ENUM_VALUE6071 = 5; + ENUM_VALUE6072 = 6; + ENUM_VALUE6073 = 7; + ENUM_VALUE6074 = 8; + ENUM_VALUE6075 = 9; + ENUM_VALUE6076 = 10; + ENUM_VALUE6077 = 11; + ENUM_VALUE6078 = 12; + ENUM_VALUE6079 = 13; + ENUM_VALUE6080 = 14; +} + +enum Enum6579 { + ENUM_VALUE6580 = 0; + ENUM_VALUE6581 = 2; + ENUM_VALUE6582 = 3; + ENUM_VALUE6583 = 5; + ENUM_VALUE6584 = 10; + ENUM_VALUE6585 = 15; + ENUM_VALUE6586 = 25; + ENUM_VALUE6587 = 30; +} + +enum Enum6588 { + ENUM_VALUE6589 = 0; + ENUM_VALUE6590 = 1; + ENUM_VALUE6591 = 2; + ENUM_VALUE6592 = 3; + ENUM_VALUE6593 = 4; + ENUM_VALUE6594 = 5; + ENUM_VALUE6595 = 6; + ENUM_VALUE6596 = 7; + ENUM_VALUE6597 = 8; + ENUM_VALUE6598 = 9; + ENUM_VALUE6599 = 10; + ENUM_VALUE6600 = 11; + ENUM_VALUE6601 = 12; + ENUM_VALUE6602 = 13; + ENUM_VALUE6603 = 14; + ENUM_VALUE6604 = 15; + ENUM_VALUE6605 = 16; + ENUM_VALUE6606 = 17; + ENUM_VALUE6607 = 19; + ENUM_VALUE6608 = 20; + ENUM_VALUE6609 = 21; + ENUM_VALUE6610 = 22; + ENUM_VALUE6611 = 23; + ENUM_VALUE6612 = 24; + ENUM_VALUE6613 = 25; + ENUM_VALUE6614 = 26; + ENUM_VALUE6615 = 27; + ENUM_VALUE6616 = 28; + ENUM_VALUE6617 = 29; + ENUM_VALUE6618 = 30; + ENUM_VALUE6619 = 31; + ENUM_VALUE6620 = 32; + ENUM_VALUE6621 = 33; + ENUM_VALUE6622 = 34; +} + +enum Enum6769 { + ENUM_VALUE6770 = 0; + ENUM_VALUE6771 = 1; + ENUM_VALUE6772 = 2; +} + +enum Enum6774 { + ENUM_VALUE6775 = 0; + ENUM_VALUE6776 = 1; + ENUM_VALUE6777 = 2; + ENUM_VALUE6778 = 3; + ENUM_VALUE6779 = 4; + ENUM_VALUE6780 = 5; + ENUM_VALUE6781 = 6; +} + +enum Enum6782 { + ENUM_VALUE6783 = 0; + ENUM_VALUE6784 = 1; + ENUM_VALUE6785 = 2; + ENUM_VALUE6786 = 3; + ENUM_VALUE6787 = 4; + ENUM_VALUE6788 = 5; +} + +enum Enum6858 { + ENUM_VALUE6859 = 1; + ENUM_VALUE6860 = 2; + ENUM_VALUE6861 = 3; + ENUM_VALUE6862 = 4; +} + +enum Enum6815 { + ENUM_VALUE6816 = 0; + ENUM_VALUE6817 = 1; + ENUM_VALUE6818 = 2; + ENUM_VALUE6819 = 3; + ENUM_VALUE6820 = 4; + ENUM_VALUE6821 = 5; +} + +enum Enum6822 { + ENUM_VALUE6823 = 0; + ENUM_VALUE6824 = 1; + ENUM_VALUE6825 = 2; + ENUM_VALUE6826 = 3; +} + +enum Enum7654 { + ENUM_VALUE7655 = 1; + ENUM_VALUE7656 = 2; + ENUM_VALUE7657 = 3; +} + +enum Enum8292 { + ENUM_VALUE8293 = 0; + ENUM_VALUE8294 = 1; + ENUM_VALUE8295 = 2; +} + +enum Enum8450 { + ENUM_VALUE8451 = 0; + ENUM_VALUE8452 = 1; + ENUM_VALUE8453 = 2; +} + +enum Enum8900 { + ENUM_VALUE8901 = 0; + ENUM_VALUE8902 = 1; + ENUM_VALUE8903 = 2; + ENUM_VALUE8904 = 3; + ENUM_VALUE8905 = 4; +} + +enum Enum8945 { + ENUM_VALUE8946 = 0; + ENUM_VALUE8947 = 1; + ENUM_VALUE8948 = 2; + ENUM_VALUE8949 = 3; + ENUM_VALUE8950 = 4; +} + +enum Enum8951 { + ENUM_VALUE8952 = 1; + ENUM_VALUE8953 = 2; + ENUM_VALUE8954 = 3; + ENUM_VALUE8955 = 4; + ENUM_VALUE8956 = 5; + ENUM_VALUE8957 = 6; + ENUM_VALUE8958 = 7; + ENUM_VALUE8959 = 8; +} + +enum Enum9243 { + ENUM_VALUE9244 = -1; + ENUM_VALUE9245 = 0; + ENUM_VALUE9246 = 1; + ENUM_VALUE9247 = 2; + ENUM_VALUE9248 = 3; + ENUM_VALUE9249 = 4; + ENUM_VALUE9250 = 5; + ENUM_VALUE9251 = 6; + ENUM_VALUE9252 = 7; + ENUM_VALUE9253 = 8; + ENUM_VALUE9254 = 9; + ENUM_VALUE9255 = 10; + ENUM_VALUE9256 = 11; + ENUM_VALUE9257 = 12; + ENUM_VALUE9258 = 13; + ENUM_VALUE9259 = 14; + ENUM_VALUE9260 = 15; + ENUM_VALUE9261 = 16; + ENUM_VALUE9262 = 17; + ENUM_VALUE9263 = 71; + ENUM_VALUE9264 = 72; + ENUM_VALUE9265 = 73; + ENUM_VALUE9266 = 74; + ENUM_VALUE9267 = 18; + ENUM_VALUE9268 = 20; + ENUM_VALUE9269 = 21; + ENUM_VALUE9270 = 22; + ENUM_VALUE9271 = 23; + ENUM_VALUE9272 = 61; + ENUM_VALUE9273 = 62; + ENUM_VALUE9274 = 63; + ENUM_VALUE9275 = 64; + ENUM_VALUE9276 = 66; + ENUM_VALUE9277 = 67; + ENUM_VALUE9278 = 24; + ENUM_VALUE9279 = 25; + ENUM_VALUE9280 = 26; + ENUM_VALUE9281 = 27; + ENUM_VALUE9282 = 28; + ENUM_VALUE9283 = 29; + ENUM_VALUE9284 = 30; + ENUM_VALUE9285 = 31; + ENUM_VALUE9286 = 32; + ENUM_VALUE9287 = 33; + ENUM_VALUE9288 = 34; + ENUM_VALUE9289 = 35; + ENUM_VALUE9290 = 36; + ENUM_VALUE9291 = 37; + ENUM_VALUE9292 = 38; + ENUM_VALUE9293 = 39; + ENUM_VALUE9294 = 40; + ENUM_VALUE9295 = 41; + ENUM_VALUE9296 = 42; + ENUM_VALUE9297 = 43; + ENUM_VALUE9298 = 44; + ENUM_VALUE9299 = 45; + ENUM_VALUE9300 = 46; + ENUM_VALUE9301 = 47; + ENUM_VALUE9302 = 48; + ENUM_VALUE9303 = 49; + ENUM_VALUE9304 = 50; + ENUM_VALUE9305 = 51; + ENUM_VALUE9306 = 52; + ENUM_VALUE9307 = 53; + ENUM_VALUE9308 = 54; + ENUM_VALUE9309 = 55; + ENUM_VALUE9310 = 56; + ENUM_VALUE9311 = 57; + ENUM_VALUE9312 = 58; + ENUM_VALUE9313 = 59; + ENUM_VALUE9314 = 60; + ENUM_VALUE9315 = 68; + ENUM_VALUE9316 = 69; + ENUM_VALUE9317 = 70; + ENUM_VALUE9318 = 1000; + ENUM_VALUE9319 = 1001; + ENUM_VALUE9320 = 1002; + ENUM_VALUE9321 = 1003; + ENUM_VALUE9322 = 1004; + ENUM_VALUE9323 = 1005; + ENUM_VALUE9324 = 1006; + ENUM_VALUE9325 = 1007; + ENUM_VALUE9326 = 65; +} + +enum Enum10157 { + ENUM_VALUE10158 = 0; + ENUM_VALUE10159 = 1; + ENUM_VALUE10160 = 2; + ENUM_VALUE10161 = 3; + ENUM_VALUE10162 = 4; + ENUM_VALUE10163 = 5; + ENUM_VALUE10164 = 6; + ENUM_VALUE10165 = 7; + ENUM_VALUE10166 = 8; +} + +enum Enum10167 { + ENUM_VALUE10168 = 0; + ENUM_VALUE10169 = 1; + ENUM_VALUE10170 = 2; + ENUM_VALUE10171 = 3; + ENUM_VALUE10172 = 4; + ENUM_VALUE10173 = 5; + ENUM_VALUE10174 = 6; + ENUM_VALUE10175 = 7; + ENUM_VALUE10176 = 8; +} + +enum Enum8862 { + ENUM_VALUE8863 = 0; + ENUM_VALUE8864 = 1; + ENUM_VALUE8865 = 2; + ENUM_VALUE8866 = 3; + ENUM_VALUE8867 = 4; + ENUM_VALUE8868 = 5; + ENUM_VALUE8869 = 6; + ENUM_VALUE8870 = 7; + ENUM_VALUE8871 = 13; + ENUM_VALUE8872 = 14; + ENUM_VALUE8873 = 8; + ENUM_VALUE8874 = 9; + ENUM_VALUE8875 = 10; + ENUM_VALUE8876 = 11; + ENUM_VALUE8877 = 12; + ENUM_VALUE8878 = 15; +} + +enum Enum10325 { + ENUM_VALUE10326 = 0; + ENUM_VALUE10327 = 1; + ENUM_VALUE10328 = 2; + ENUM_VALUE10329 = 3; + ENUM_VALUE10330 = 4; + ENUM_VALUE10331 = 5; + ENUM_VALUE10332 = 6; + ENUM_VALUE10333 = 7; + ENUM_VALUE10334 = 8; +} + +enum Enum10335 { + ENUM_VALUE10336 = 0; +} + +enum Enum10337 { + ENUM_VALUE10338 = 0; + ENUM_VALUE10339 = 1; +} + +enum Enum10392 { + ENUM_VALUE10393 = 0; + ENUM_VALUE10394 = 1; + ENUM_VALUE10395 = 2; + ENUM_VALUE10396 = 3; + ENUM_VALUE10397 = 4; + ENUM_VALUE10398 = 5; + ENUM_VALUE10399 = 6; + ENUM_VALUE10400 = 7; + ENUM_VALUE10401 = 8; + ENUM_VALUE10402 = 15; + ENUM_VALUE10403 = 9; + ENUM_VALUE10404 = 10; + ENUM_VALUE10405 = 11; + ENUM_VALUE10406 = 12; + ENUM_VALUE10407 = 13; + ENUM_VALUE10408 = 14; + ENUM_VALUE10409 = 101; + ENUM_VALUE10410 = 102; +} + +enum Enum11107 { + ENUM_VALUE11108 = 0; + ENUM_VALUE11109 = 1; + ENUM_VALUE11110 = 2; + ENUM_VALUE11111 = 3; + ENUM_VALUE11112 = 4; + ENUM_VALUE11113 = 5; + ENUM_VALUE11114 = 6; + ENUM_VALUE11115 = 7; + ENUM_VALUE11116 = 8; + ENUM_VALUE11117 = 9; + ENUM_VALUE11118 = 10; + ENUM_VALUE11119 = 11; + ENUM_VALUE11120 = 12; + ENUM_VALUE11121 = 13; + ENUM_VALUE11122 = 14; + ENUM_VALUE11123 = 15; + ENUM_VALUE11124 = 16; + ENUM_VALUE11125 = 17; + ENUM_VALUE11126 = 18; + ENUM_VALUE11127 = 19; + ENUM_VALUE11128 = 20; + ENUM_VALUE11129 = 21; + ENUM_VALUE11130 = 22; + ENUM_VALUE11131 = 23; + ENUM_VALUE11132 = 24; + ENUM_VALUE11133 = 25; + ENUM_VALUE11134 = 26; + ENUM_VALUE11135 = 27; + ENUM_VALUE11136 = 28; + ENUM_VALUE11137 = 29; + ENUM_VALUE11138 = 30; + ENUM_VALUE11139 = 31; + ENUM_VALUE11140 = 32; + ENUM_VALUE11141 = 33; + ENUM_VALUE11142 = 34; + ENUM_VALUE11143 = 35; + ENUM_VALUE11144 = 36; + ENUM_VALUE11145 = 37; + ENUM_VALUE11146 = 38; + ENUM_VALUE11147 = 39; + ENUM_VALUE11148 = 40; + ENUM_VALUE11149 = 41; + ENUM_VALUE11150 = 42; + ENUM_VALUE11151 = 43; + ENUM_VALUE11152 = 44; + ENUM_VALUE11153 = 45; + ENUM_VALUE11154 = 46; + ENUM_VALUE11155 = 47; + ENUM_VALUE11156 = 48; + ENUM_VALUE11157 = 49; + ENUM_VALUE11158 = 50; + ENUM_VALUE11159 = 51; + ENUM_VALUE11160 = 52; + ENUM_VALUE11161 = 53; + ENUM_VALUE11162 = 54; + ENUM_VALUE11163 = 55; + ENUM_VALUE11164 = 56; + ENUM_VALUE11165 = 57; + ENUM_VALUE11166 = 58; + ENUM_VALUE11167 = 59; + ENUM_VALUE11168 = 60; + ENUM_VALUE11169 = 61; + ENUM_VALUE11170 = 62; + ENUM_VALUE11171 = 63; + ENUM_VALUE11172 = 64; + ENUM_VALUE11173 = 65; + ENUM_VALUE11174 = 66; + ENUM_VALUE11175 = 67; + ENUM_VALUE11176 = 68; + ENUM_VALUE11177 = 69; + ENUM_VALUE11178 = 70; + ENUM_VALUE11179 = 71; + ENUM_VALUE11180 = 72; + ENUM_VALUE11181 = 73; + ENUM_VALUE11182 = 74; + ENUM_VALUE11183 = 75; + ENUM_VALUE11184 = 76; + ENUM_VALUE11185 = 77; + ENUM_VALUE11186 = 78; + ENUM_VALUE11187 = 79; + ENUM_VALUE11188 = 80; + ENUM_VALUE11189 = 81; + ENUM_VALUE11190 = 82; + ENUM_VALUE11191 = 83; + ENUM_VALUE11192 = 84; + ENUM_VALUE11193 = 85; + ENUM_VALUE11194 = 86; + ENUM_VALUE11195 = 87; + ENUM_VALUE11196 = 88; + ENUM_VALUE11197 = 89; + ENUM_VALUE11198 = 90; + ENUM_VALUE11199 = 91; + ENUM_VALUE11200 = 92; + ENUM_VALUE11201 = 93; + ENUM_VALUE11202 = 94; + ENUM_VALUE11203 = 95; + ENUM_VALUE11204 = 96; + ENUM_VALUE11205 = 97; + ENUM_VALUE11206 = 98; + ENUM_VALUE11207 = 99; + ENUM_VALUE11208 = 100; + ENUM_VALUE11209 = 101; + ENUM_VALUE11210 = 102; + ENUM_VALUE11211 = 103; + ENUM_VALUE11212 = 104; + ENUM_VALUE11213 = 105; + ENUM_VALUE11214 = 106; + ENUM_VALUE11215 = 107; + ENUM_VALUE11216 = 108; + ENUM_VALUE11217 = 109; + ENUM_VALUE11218 = 110; + ENUM_VALUE11219 = 111; + ENUM_VALUE11220 = 112; + ENUM_VALUE11221 = 113; + ENUM_VALUE11222 = 114; + ENUM_VALUE11223 = 115; + ENUM_VALUE11224 = 116; + ENUM_VALUE11225 = 117; + ENUM_VALUE11226 = 118; + ENUM_VALUE11227 = 119; + ENUM_VALUE11228 = 120; + ENUM_VALUE11229 = 121; + ENUM_VALUE11230 = 122; + ENUM_VALUE11231 = 123; + ENUM_VALUE11232 = 124; + ENUM_VALUE11233 = 125; + ENUM_VALUE11234 = 126; + ENUM_VALUE11235 = 127; + ENUM_VALUE11236 = 128; + ENUM_VALUE11237 = 129; + ENUM_VALUE11238 = 130; + ENUM_VALUE11239 = 131; + ENUM_VALUE11240 = 132; + ENUM_VALUE11241 = 133; + ENUM_VALUE11242 = 134; + ENUM_VALUE11243 = 135; + ENUM_VALUE11244 = 136; + ENUM_VALUE11245 = 137; + ENUM_VALUE11246 = 138; + ENUM_VALUE11247 = 139; + ENUM_VALUE11248 = 140; + ENUM_VALUE11249 = 141; + ENUM_VALUE11250 = 142; + ENUM_VALUE11251 = 143; + ENUM_VALUE11252 = 144; + ENUM_VALUE11253 = 145; + ENUM_VALUE11254 = 146; + ENUM_VALUE11255 = 147; + ENUM_VALUE11256 = 148; + ENUM_VALUE11257 = 149; + ENUM_VALUE11258 = 150; + ENUM_VALUE11259 = 151; + ENUM_VALUE11260 = 152; + ENUM_VALUE11261 = 153; + ENUM_VALUE11262 = 154; + ENUM_VALUE11263 = 155; + ENUM_VALUE11264 = 156; + ENUM_VALUE11265 = 157; + ENUM_VALUE11266 = 158; + ENUM_VALUE11267 = 159; + ENUM_VALUE11268 = 160; + ENUM_VALUE11269 = 161; + ENUM_VALUE11270 = 163; + ENUM_VALUE11271 = 164; + ENUM_VALUE11272 = 165; + ENUM_VALUE11273 = 166; + ENUM_VALUE11274 = 167; + ENUM_VALUE11275 = 168; + ENUM_VALUE11276 = 169; + ENUM_VALUE11277 = 170; + ENUM_VALUE11278 = 171; + ENUM_VALUE11279 = 172; + ENUM_VALUE11280 = 173; + ENUM_VALUE11281 = 174; + ENUM_VALUE11282 = 175; + ENUM_VALUE11283 = 176; + ENUM_VALUE11284 = 177; + ENUM_VALUE11285 = 178; + ENUM_VALUE11286 = 179; + ENUM_VALUE11287 = 180; + ENUM_VALUE11288 = 181; + ENUM_VALUE11289 = 182; + ENUM_VALUE11290 = 183; + ENUM_VALUE11291 = 184; + ENUM_VALUE11292 = 185; + ENUM_VALUE11293 = 187; + ENUM_VALUE11294 = 188; + ENUM_VALUE11295 = 189; + ENUM_VALUE11296 = 190; + ENUM_VALUE11297 = 191; + ENUM_VALUE11298 = 192; + ENUM_VALUE11299 = 193; + ENUM_VALUE11300 = 194; + ENUM_VALUE11301 = 195; + ENUM_VALUE11302 = 196; + ENUM_VALUE11303 = 197; + ENUM_VALUE11304 = 198; + ENUM_VALUE11305 = 65535; + ENUM_VALUE11306 = 65536; + ENUM_VALUE11307 = 65537; + ENUM_VALUE11308 = 65538; + ENUM_VALUE11309 = 65539; + ENUM_VALUE11310 = 65540; + ENUM_VALUE11311 = 65541; + ENUM_VALUE11312 = 65542; + ENUM_VALUE11313 = 65543; + ENUM_VALUE11314 = 65544; + ENUM_VALUE11315 = 65545; + ENUM_VALUE11316 = 65546; + ENUM_VALUE11317 = 65547; + ENUM_VALUE11318 = 65548; + ENUM_VALUE11319 = 65549; + ENUM_VALUE11320 = 65550; + ENUM_VALUE11321 = 65551; + ENUM_VALUE11322 = 65552; + ENUM_VALUE11323 = 65553; + ENUM_VALUE11324 = 65554; + ENUM_VALUE11325 = 65555; + ENUM_VALUE11326 = 65556; + ENUM_VALUE11327 = 65557; + ENUM_VALUE11328 = 65558; + ENUM_VALUE11329 = 65559; + ENUM_VALUE11330 = 65560; + ENUM_VALUE11331 = 65561; + ENUM_VALUE11332 = 65562; + ENUM_VALUE11333 = 65563; + ENUM_VALUE11334 = 69632; + ENUM_VALUE11335 = 69633; + ENUM_VALUE11336 = 69634; + ENUM_VALUE11337 = 69635; + ENUM_VALUE11338 = 69636; + ENUM_VALUE11339 = 69637; + ENUM_VALUE11340 = 69638; + ENUM_VALUE11341 = 69639; + ENUM_VALUE11342 = 69640; + ENUM_VALUE11343 = 69641; + ENUM_VALUE11344 = 69642; + ENUM_VALUE11345 = 69643; + ENUM_VALUE11346 = 69644; + ENUM_VALUE11347 = 69645; + ENUM_VALUE11348 = 69646; + ENUM_VALUE11349 = 69647; + ENUM_VALUE11350 = 69648; + ENUM_VALUE11351 = 69649; + ENUM_VALUE11352 = 69650; + ENUM_VALUE11353 = 69651; + ENUM_VALUE11354 = 69652; + ENUM_VALUE11355 = 69653; + ENUM_VALUE11356 = 69654; + ENUM_VALUE11357 = 69655; + ENUM_VALUE11358 = 69656; + ENUM_VALUE11359 = 69657; + ENUM_VALUE11360 = 69658; + ENUM_VALUE11361 = 69659; + ENUM_VALUE11362 = 69660; + ENUM_VALUE11363 = 69661; + ENUM_VALUE11364 = 69662; + ENUM_VALUE11365 = 73728; + ENUM_VALUE11366 = 73729; + ENUM_VALUE11367 = 77824; + ENUM_VALUE11368 = 77825; + ENUM_VALUE11369 = 81920; + ENUM_VALUE11370 = 81921; + ENUM_VALUE11371 = 81922; + ENUM_VALUE11372 = 81923; + ENUM_VALUE11373 = 86016; + ENUM_VALUE11374 = 86017; + ENUM_VALUE11375 = 86018; + ENUM_VALUE11376 = 86019; + ENUM_VALUE11377 = 86020; + ENUM_VALUE11378 = 86021; + ENUM_VALUE11379 = 86022; + ENUM_VALUE11380 = 86023; + ENUM_VALUE11381 = 86024; + ENUM_VALUE11382 = 86025; + ENUM_VALUE11383 = 86026; + ENUM_VALUE11384 = 86027; + ENUM_VALUE11385 = 86028; + ENUM_VALUE11386 = 86029; + ENUM_VALUE11387 = 86030; + ENUM_VALUE11388 = 86031; + ENUM_VALUE11389 = 86032; + ENUM_VALUE11390 = 86033; + ENUM_VALUE11391 = 86034; + ENUM_VALUE11392 = 86035; + ENUM_VALUE11393 = 86036; + ENUM_VALUE11394 = 86037; + ENUM_VALUE11395 = 86038; + ENUM_VALUE11396 = 86039; + ENUM_VALUE11397 = 86040; + ENUM_VALUE11398 = 86041; + ENUM_VALUE11399 = 86042; + ENUM_VALUE11400 = 86043; + ENUM_VALUE11401 = 86044; + ENUM_VALUE11402 = 86045; + ENUM_VALUE11403 = 86046; + ENUM_VALUE11404 = 86047; + ENUM_VALUE11405 = 86048; + ENUM_VALUE11406 = 86049; + ENUM_VALUE11407 = 86050; + ENUM_VALUE11408 = 86051; + ENUM_VALUE11409 = 86052; + ENUM_VALUE11410 = 86053; + ENUM_VALUE11411 = 86054; + ENUM_VALUE11412 = 86055; + ENUM_VALUE11413 = 86056; + ENUM_VALUE11414 = 86057; + ENUM_VALUE11415 = 86058; + ENUM_VALUE11416 = 86059; + ENUM_VALUE11417 = 86060; + ENUM_VALUE11418 = 86061; + ENUM_VALUE11419 = 86062; + ENUM_VALUE11420 = 86063; + ENUM_VALUE11421 = 86064; + ENUM_VALUE11422 = 86065; + ENUM_VALUE11423 = 86066; + ENUM_VALUE11424 = 86067; + ENUM_VALUE11425 = 86068; + ENUM_VALUE11426 = 86069; + ENUM_VALUE11427 = 86070; + ENUM_VALUE11428 = 86071; + ENUM_VALUE11429 = 86072; + ENUM_VALUE11430 = 86073; + ENUM_VALUE11431 = 86074; + ENUM_VALUE11432 = 86077; + ENUM_VALUE11433 = 86078; + ENUM_VALUE11434 = 86079; + ENUM_VALUE11435 = 86080; + ENUM_VALUE11436 = 86081; + ENUM_VALUE11437 = 86082; + ENUM_VALUE11438 = 86083; + ENUM_VALUE11439 = 86084; + ENUM_VALUE11440 = 90112; + ENUM_VALUE11441 = 94208; + ENUM_VALUE11442 = 94209; + ENUM_VALUE11443 = 94210; + ENUM_VALUE11444 = 94211; + ENUM_VALUE11445 = 94212; + ENUM_VALUE11446 = 94213; + ENUM_VALUE11447 = 94214; + ENUM_VALUE11448 = 94215; + ENUM_VALUE11449 = 94216; + ENUM_VALUE11450 = 94217; + ENUM_VALUE11451 = 94218; + ENUM_VALUE11452 = 94219; + ENUM_VALUE11453 = 94220; + ENUM_VALUE11454 = 94221; + ENUM_VALUE11455 = 94222; + ENUM_VALUE11456 = 94223; + ENUM_VALUE11457 = 94224; + ENUM_VALUE11458 = 98304; + ENUM_VALUE11459 = 98305; + ENUM_VALUE11460 = 98306; + ENUM_VALUE11461 = 98307; + ENUM_VALUE11462 = 98308; + ENUM_VALUE11463 = 102400; + ENUM_VALUE11464 = 131072; + ENUM_VALUE11465 = 131073; + ENUM_VALUE11466 = 135168; + ENUM_VALUE11467 = 9439507; +} + +enum Enum11541 { + ENUM_VALUE11542 = -1; + ENUM_VALUE11543 = 0; + ENUM_VALUE11544 = 1; + ENUM_VALUE11545 = 2; + ENUM_VALUE11546 = 3; + ENUM_VALUE11547 = 4; + ENUM_VALUE11548 = 5; + ENUM_VALUE11549 = 6; + ENUM_VALUE11550 = 7; + ENUM_VALUE11551 = 8; + ENUM_VALUE11552 = 9; + ENUM_VALUE11553 = 10; + ENUM_VALUE11554 = 11; + ENUM_VALUE11555 = 12; + ENUM_VALUE11556 = 13; + ENUM_VALUE11557 = 14; + ENUM_VALUE11558 = 15; + ENUM_VALUE11559 = 16; + ENUM_VALUE11560 = 17; + ENUM_VALUE11561 = 18; + ENUM_VALUE11562 = 19; + ENUM_VALUE11563 = 20; + ENUM_VALUE11564 = 21; + ENUM_VALUE11565 = 22; + ENUM_VALUE11566 = 23; + ENUM_VALUE11567 = 24; + ENUM_VALUE11568 = 25; + ENUM_VALUE11569 = 26; + ENUM_VALUE11570 = 27; + ENUM_VALUE11571 = 28; + ENUM_VALUE11572 = 29; + ENUM_VALUE11573 = 30; + ENUM_VALUE11574 = 31; + ENUM_VALUE11575 = 32; + ENUM_VALUE11576 = 33; + ENUM_VALUE11577 = 34; + ENUM_VALUE11578 = 35; + ENUM_VALUE11579 = 36; + ENUM_VALUE11580 = 37; + ENUM_VALUE11581 = 38; + ENUM_VALUE11582 = 39; + ENUM_VALUE11583 = 40; + ENUM_VALUE11584 = 41; + ENUM_VALUE11585 = 42; + ENUM_VALUE11586 = 43; + ENUM_VALUE11587 = 44; + ENUM_VALUE11588 = 45; + ENUM_VALUE11589 = 46; + ENUM_VALUE11590 = 47; + ENUM_VALUE11591 = 48; + ENUM_VALUE11592 = 49; + ENUM_VALUE11593 = 50; + ENUM_VALUE11594 = 51; + ENUM_VALUE11595 = 52; + ENUM_VALUE11596 = 53; + ENUM_VALUE11597 = 54; + ENUM_VALUE11598 = 55; + ENUM_VALUE11599 = 56; + ENUM_VALUE11600 = 57; + ENUM_VALUE11601 = 58; + ENUM_VALUE11602 = 59; + ENUM_VALUE11603 = 60; + ENUM_VALUE11604 = 61; + ENUM_VALUE11605 = 62; + ENUM_VALUE11606 = 63; + ENUM_VALUE11607 = 64; + ENUM_VALUE11608 = 65; + ENUM_VALUE11609 = 66; + ENUM_VALUE11610 = 67; + ENUM_VALUE11611 = 68; + ENUM_VALUE11612 = 69; + ENUM_VALUE11613 = 70; + ENUM_VALUE11614 = 71; + ENUM_VALUE11615 = 72; + ENUM_VALUE11616 = 73; + ENUM_VALUE11617 = 74; + ENUM_VALUE11618 = 75; + ENUM_VALUE11619 = 76; + ENUM_VALUE11620 = 77; + ENUM_VALUE11621 = 78; + ENUM_VALUE11622 = 79; + ENUM_VALUE11623 = 80; + ENUM_VALUE11624 = 81; + ENUM_VALUE11625 = 82; + ENUM_VALUE11626 = 83; + ENUM_VALUE11627 = 84; + ENUM_VALUE11628 = 85; + ENUM_VALUE11629 = 86; + ENUM_VALUE11630 = 87; + ENUM_VALUE11631 = 88; + ENUM_VALUE11632 = 89; + ENUM_VALUE11633 = 90; + ENUM_VALUE11634 = 91; + ENUM_VALUE11635 = 92; + ENUM_VALUE11636 = 93; + ENUM_VALUE11637 = 94; + ENUM_VALUE11638 = 95; + ENUM_VALUE11639 = 96; + ENUM_VALUE11640 = 97; + ENUM_VALUE11641 = 98; + ENUM_VALUE11642 = 99; + ENUM_VALUE11643 = 100; + ENUM_VALUE11644 = 101; + ENUM_VALUE11645 = 102; + ENUM_VALUE11646 = 103; + ENUM_VALUE11647 = 104; + ENUM_VALUE11648 = 105; + ENUM_VALUE11649 = 106; + ENUM_VALUE11650 = 107; + ENUM_VALUE11651 = 108; + ENUM_VALUE11652 = 109; + ENUM_VALUE11653 = 110; + ENUM_VALUE11654 = 111; + ENUM_VALUE11655 = 112; + ENUM_VALUE11656 = 113; + ENUM_VALUE11657 = 114; + ENUM_VALUE11658 = 115; + ENUM_VALUE11659 = 116; + ENUM_VALUE11660 = 117; + ENUM_VALUE11661 = 118; + ENUM_VALUE11662 = 119; + ENUM_VALUE11663 = 120; + ENUM_VALUE11664 = 121; + ENUM_VALUE11665 = 122; + ENUM_VALUE11666 = 123; + ENUM_VALUE11667 = 124; + ENUM_VALUE11668 = 125; + ENUM_VALUE11669 = 126; + ENUM_VALUE11670 = 127; + ENUM_VALUE11671 = 128; + ENUM_VALUE11672 = 129; + ENUM_VALUE11673 = 130; + ENUM_VALUE11674 = 131; + ENUM_VALUE11675 = 132; + ENUM_VALUE11676 = 133; + ENUM_VALUE11677 = 134; + ENUM_VALUE11678 = 135; + ENUM_VALUE11679 = 136; + ENUM_VALUE11680 = 137; + ENUM_VALUE11681 = 138; + ENUM_VALUE11682 = 139; + ENUM_VALUE11683 = 140; + ENUM_VALUE11684 = 141; + ENUM_VALUE11685 = 142; + ENUM_VALUE11686 = 143; + ENUM_VALUE11687 = 144; + ENUM_VALUE11688 = 145; + ENUM_VALUE11689 = 146; + ENUM_VALUE11690 = 147; + ENUM_VALUE11691 = 148; + ENUM_VALUE11692 = 149; + ENUM_VALUE11693 = 150; + ENUM_VALUE11694 = 151; + ENUM_VALUE11695 = 152; + ENUM_VALUE11696 = 153; + ENUM_VALUE11697 = 154; + ENUM_VALUE11698 = 155; + ENUM_VALUE11699 = 156; + ENUM_VALUE11700 = 157; + ENUM_VALUE11701 = 158; + ENUM_VALUE11702 = 159; + ENUM_VALUE11703 = 160; + ENUM_VALUE11704 = 161; + ENUM_VALUE11705 = 162; + ENUM_VALUE11706 = 163; + ENUM_VALUE11707 = 164; + ENUM_VALUE11708 = 165; + ENUM_VALUE11709 = 166; + ENUM_VALUE11710 = 167; + ENUM_VALUE11711 = 168; + ENUM_VALUE11712 = 169; + ENUM_VALUE11713 = 170; + ENUM_VALUE11714 = 171; + ENUM_VALUE11715 = 172; + ENUM_VALUE11716 = 173; + ENUM_VALUE11717 = 174; + ENUM_VALUE11718 = 175; + ENUM_VALUE11719 = 176; + ENUM_VALUE11720 = 177; + ENUM_VALUE11721 = 178; + ENUM_VALUE11722 = 179; + ENUM_VALUE11723 = 180; + ENUM_VALUE11724 = 181; + ENUM_VALUE11725 = 182; + ENUM_VALUE11726 = 183; + ENUM_VALUE11727 = 184; + ENUM_VALUE11728 = 185; + ENUM_VALUE11729 = 186; + ENUM_VALUE11730 = 187; + ENUM_VALUE11731 = 188; + ENUM_VALUE11732 = 16777215; +} + +enum Enum11468 { + ENUM_VALUE11469 = -99; + ENUM_VALUE11470 = 0; + ENUM_VALUE11471 = 1; + ENUM_VALUE11472 = 2; + ENUM_VALUE11473 = 3; + ENUM_VALUE11474 = 4; + ENUM_VALUE11475 = 28; + ENUM_VALUE11476 = 22; + ENUM_VALUE11477 = 38; + ENUM_VALUE11478 = 512; + ENUM_VALUE11479 = 2048; + ENUM_VALUE11480 = 66; + ENUM_VALUE11481 = 578; + ENUM_VALUE11482 = 77; + ENUM_VALUE11483 = 88; + ENUM_VALUE11484 = 100; + ENUM_VALUE11485 = 110; + ENUM_VALUE11486 = 2158; + ENUM_VALUE11487 = 122; + ENUM_VALUE11488 = 2170; + ENUM_VALUE11489 = 144; + ENUM_VALUE11490 = 244; + ENUM_VALUE11491 = 2292; + ENUM_VALUE11492 = 44; +} + +enum Enum11022 { + ENUM_VALUE11023 = 0; + ENUM_VALUE11024 = 1; + ENUM_VALUE11025 = 2; + ENUM_VALUE11026 = 3; + ENUM_VALUE11027 = 4; + ENUM_VALUE11028 = 5; + ENUM_VALUE11029 = 6; + ENUM_VALUE11030 = 7; + ENUM_VALUE11031 = 8; + ENUM_VALUE11032 = 9; + ENUM_VALUE11033 = 10; + ENUM_VALUE11034 = 11; + ENUM_VALUE11035 = 12; + ENUM_VALUE11036 = 13; + ENUM_VALUE11037 = 14; + ENUM_VALUE11038 = 15; + ENUM_VALUE11039 = 16; + ENUM_VALUE11040 = 17; + ENUM_VALUE11041 = 18; + ENUM_VALUE11042 = 19; + ENUM_VALUE11043 = 20; + ENUM_VALUE11044 = 21; + ENUM_VALUE11045 = 22; + ENUM_VALUE11046 = 23; + ENUM_VALUE11047 = 24; + ENUM_VALUE11048 = 25; + ENUM_VALUE11049 = 26; + ENUM_VALUE11050 = 27; + ENUM_VALUE11051 = 28; + ENUM_VALUE11052 = 29; + ENUM_VALUE11053 = 30; + ENUM_VALUE11054 = 31; + ENUM_VALUE11055 = 32; + ENUM_VALUE11056 = 33; + ENUM_VALUE11057 = 34; + ENUM_VALUE11058 = 35; + ENUM_VALUE11059 = 36; + ENUM_VALUE11060 = 37; + ENUM_VALUE11061 = 38; + ENUM_VALUE11062 = 39; + ENUM_VALUE11063 = 40; + ENUM_VALUE11064 = 41; + ENUM_VALUE11065 = 42; + ENUM_VALUE11066 = 43; + ENUM_VALUE11067 = 44; + ENUM_VALUE11068 = 45; + ENUM_VALUE11069 = 46; + ENUM_VALUE11070 = 47; + ENUM_VALUE11071 = 48; + ENUM_VALUE11072 = 49; + ENUM_VALUE11073 = 50; + ENUM_VALUE11074 = 51; + ENUM_VALUE11075 = 52; + ENUM_VALUE11076 = 53; + ENUM_VALUE11077 = 54; + ENUM_VALUE11078 = 55; + ENUM_VALUE11079 = 56; + ENUM_VALUE11080 = 57; + ENUM_VALUE11081 = 58; + ENUM_VALUE11082 = 59; + ENUM_VALUE11083 = 60; + ENUM_VALUE11084 = 61; + ENUM_VALUE11085 = 62; + ENUM_VALUE11086 = 63; + ENUM_VALUE11087 = 64; + ENUM_VALUE11088 = 65; + ENUM_VALUE11089 = 66; + ENUM_VALUE11090 = 67; + ENUM_VALUE11091 = 68; + ENUM_VALUE11092 = 69; + ENUM_VALUE11093 = 70; + ENUM_VALUE11094 = 71; + ENUM_VALUE11095 = 72; + ENUM_VALUE11096 = 73; + ENUM_VALUE11097 = 74; + ENUM_VALUE11098 = 75; + ENUM_VALUE11099 = 76; + ENUM_VALUE11100 = 77; + ENUM_VALUE11101 = 78; + ENUM_VALUE11102 = 79; + ENUM_VALUE11103 = 80; + ENUM_VALUE11104 = 81; + ENUM_VALUE11105 = 82; + ENUM_VALUE11106 = 83; +} + +enum Enum12670 { + ENUM_VALUE12671 = 0; + ENUM_VALUE12672 = 1; + ENUM_VALUE12673 = 2; +} + +enum Enum12871 { + ENUM_VALUE12872 = 1; + ENUM_VALUE12873 = 2; + ENUM_VALUE12874 = 3; + ENUM_VALUE12875 = 4; + ENUM_VALUE12876 = 5; + ENUM_VALUE12877 = 6; +} + +enum Enum13092 { + ENUM_VALUE13093 = 1; + ENUM_VALUE13094 = 2; + ENUM_VALUE13095 = 3; +} + +enum Enum13146 { + ENUM_VALUE13147 = 0; + ENUM_VALUE13148 = 1; + ENUM_VALUE13149 = 2; + ENUM_VALUE13150 = 3; +} + +enum Enum16042 { + ENUM_VALUE16043 = 0; + ENUM_VALUE16044 = 1; + ENUM_VALUE16045 = 17; + ENUM_VALUE16046 = 273; + ENUM_VALUE16047 = 274; + ENUM_VALUE16048 = 4385; + ENUM_VALUE16049 = 4386; + ENUM_VALUE16050 = 4387; + ENUM_VALUE16051 = 4388; + ENUM_VALUE16052 = 4389; + ENUM_VALUE16053 = 4390; + ENUM_VALUE16054 = 4391; + ENUM_VALUE16055 = 4392; + ENUM_VALUE16056 = 4393; + ENUM_VALUE16057 = 276; + ENUM_VALUE16058 = 277; + ENUM_VALUE16059 = 18; + ENUM_VALUE16060 = 289; + ENUM_VALUE16061 = 291; + ENUM_VALUE16062 = 4657; + ENUM_VALUE16063 = 74513; + ENUM_VALUE16064 = 4658; + ENUM_VALUE16065 = 4659; + ENUM_VALUE16066 = 4660; + ENUM_VALUE16067 = 4661; + ENUM_VALUE16068 = 4662; + ENUM_VALUE16069 = 4663; + ENUM_VALUE16070 = 4664; + ENUM_VALUE16071 = 292; + ENUM_VALUE16072 = 4673; + ENUM_VALUE16073 = 4674; + ENUM_VALUE16074 = 293; + ENUM_VALUE16075 = 19; + ENUM_VALUE16076 = 20; + ENUM_VALUE16077 = 321; + ENUM_VALUE16078 = 5137; + ENUM_VALUE16079 = 5138; + ENUM_VALUE16080 = 5139; + ENUM_VALUE16081 = 5140; + ENUM_VALUE16082 = 5141; + ENUM_VALUE16083 = 5142; + ENUM_VALUE16084 = 82273; + ENUM_VALUE16085 = 82274; + ENUM_VALUE16086 = 82275; + ENUM_VALUE16087 = 82276; + ENUM_VALUE16088 = 82277; + ENUM_VALUE16089 = 82278; + ENUM_VALUE16090 = 5143; + ENUM_VALUE16091 = 5144; + ENUM_VALUE16092 = 5145; + ENUM_VALUE16093 = 5146; + ENUM_VALUE16094 = 82337; + ENUM_VALUE16095 = 5147; + ENUM_VALUE16096 = 5148; + ENUM_VALUE16097 = 322; + ENUM_VALUE16098 = 323; + ENUM_VALUE16099 = 324; + ENUM_VALUE16100 = 325; + ENUM_VALUE16101 = 326; + ENUM_VALUE16102 = 327; + ENUM_VALUE16103 = 328; + ENUM_VALUE16104 = 21; + ENUM_VALUE16105 = 337; + ENUM_VALUE16106 = 22; + ENUM_VALUE16107 = 23; + ENUM_VALUE16108 = 24; + ENUM_VALUE16109 = 2; + ENUM_VALUE16110 = 33; + ENUM_VALUE16111 = 34; + ENUM_VALUE16112 = 545; + ENUM_VALUE16113 = 8721; + ENUM_VALUE16114 = 8723; + ENUM_VALUE16115 = 8724; + ENUM_VALUE16116 = 546; + ENUM_VALUE16117 = 8739; + ENUM_VALUE16118 = 8740; + ENUM_VALUE16119 = 547; + ENUM_VALUE16120 = 548; + ENUM_VALUE16121 = 549; + ENUM_VALUE16122 = 550; + ENUM_VALUE16123 = 551; + ENUM_VALUE16124 = 552; + ENUM_VALUE16125 = 553; + ENUM_VALUE16126 = 35; + ENUM_VALUE16127 = 36; + ENUM_VALUE16128 = 37; + ENUM_VALUE16129 = 593; + ENUM_VALUE16130 = 594; + ENUM_VALUE16131 = 595; + ENUM_VALUE16132 = 596; + ENUM_VALUE16133 = 597; + ENUM_VALUE16134 = 38; + ENUM_VALUE16135 = 609; + ENUM_VALUE16136 = 610; + ENUM_VALUE16137 = 617; + ENUM_VALUE16138 = 614; + ENUM_VALUE16139 = 615; + ENUM_VALUE16140 = 616; + ENUM_VALUE16141 = 618; + ENUM_VALUE16142 = 620; + ENUM_VALUE16143 = 9937; + ENUM_VALUE16144 = 9938; + ENUM_VALUE16145 = 9939; + ENUM_VALUE16146 = 9940; + ENUM_VALUE16147 = 9941; + ENUM_VALUE16148 = 39; + ENUM_VALUE16149 = 40; + ENUM_VALUE16150 = 41; + ENUM_VALUE16151 = 42; + ENUM_VALUE16152 = 43; + ENUM_VALUE16153 = 44; + ENUM_VALUE16154 = 45; + ENUM_VALUE16155 = 11793; + ENUM_VALUE16156 = 3; + ENUM_VALUE16157 = 49; + ENUM_VALUE16158 = 50; + ENUM_VALUE16159 = 51; + ENUM_VALUE16160 = 817; + ENUM_VALUE16161 = 818; + ENUM_VALUE16162 = 819; + ENUM_VALUE16163 = 52; + ENUM_VALUE16164 = 833; + ENUM_VALUE16165 = 53; + ENUM_VALUE16166 = 54; + ENUM_VALUE16167 = 4; + ENUM_VALUE16168 = 1041; + ENUM_VALUE16169 = 16657; + ENUM_VALUE16170 = 16658; + ENUM_VALUE16171 = 16659; + ENUM_VALUE16172 = 16660; + ENUM_VALUE16173 = 16661; + ENUM_VALUE16174 = 1042; + ENUM_VALUE16175 = 16673; + ENUM_VALUE16176 = 1043; + ENUM_VALUE16177 = 16689; + ENUM_VALUE16178 = 16690; + ENUM_VALUE16179 = 16691; + ENUM_VALUE16180 = 16692; + ENUM_VALUE16181 = 16693; + ENUM_VALUE16182 = 16694; + ENUM_VALUE16183 = 16695; + ENUM_VALUE16184 = 1044; + ENUM_VALUE16185 = 16705; + ENUM_VALUE16186 = 16706; + ENUM_VALUE16187 = 16707; + ENUM_VALUE16188 = 16708; + ENUM_VALUE16189 = 16709; + ENUM_VALUE16190 = 16710; + ENUM_VALUE16191 = 16711; + ENUM_VALUE16192 = 16712; + ENUM_VALUE16193 = 16713; + ENUM_VALUE16194 = 1046; + ENUM_VALUE16195 = 16737; + ENUM_VALUE16196 = 1047; + ENUM_VALUE16197 = 16753; + ENUM_VALUE16198 = 268049; + ENUM_VALUE16199 = 268050; + ENUM_VALUE16200 = 268051; + ENUM_VALUE16201 = 268052; + ENUM_VALUE16202 = 1048; + ENUM_VALUE16203 = 16769; + ENUM_VALUE16204 = 16770; + ENUM_VALUE16205 = 16771; + ENUM_VALUE16206 = 16772; + ENUM_VALUE16207 = 16773; + ENUM_VALUE16208 = 1049; + ENUM_VALUE16209 = 1056; + ENUM_VALUE16210 = 1058; + ENUM_VALUE16211 = 1059; + ENUM_VALUE16212 = 1060; + ENUM_VALUE16213 = 1061; + ENUM_VALUE16214 = 5; + ENUM_VALUE16215 = 6; + ENUM_VALUE16216 = 97; + ENUM_VALUE16217 = 98; + ENUM_VALUE16218 = 99; + ENUM_VALUE16219 = 100; + ENUM_VALUE16220 = 101; + ENUM_VALUE16221 = 102; + ENUM_VALUE16222 = 103; + ENUM_VALUE16223 = 104; + ENUM_VALUE16224 = 105; + ENUM_VALUE16225 = 106; + ENUM_VALUE16226 = 108; + ENUM_VALUE16227 = 1729; + ENUM_VALUE16228 = 1730; + ENUM_VALUE16229 = 1731; + ENUM_VALUE16230 = 7; + ENUM_VALUE16231 = 8; + ENUM_VALUE16232 = 9; + ENUM_VALUE16233 = 10; + ENUM_VALUE16234 = 161; + ENUM_VALUE16235 = 2577; + ENUM_VALUE16236 = 41233; + ENUM_VALUE16237 = 41234; + ENUM_VALUE16238 = 2578; + ENUM_VALUE16239 = 2579; + ENUM_VALUE16240 = 41265; + ENUM_VALUE16241 = 2580; + ENUM_VALUE16242 = 2581; + ENUM_VALUE16243 = 41297; + ENUM_VALUE16244 = 41298; + ENUM_VALUE16245 = 41299; + ENUM_VALUE16246 = 41300; + ENUM_VALUE16247 = 2582; + ENUM_VALUE16248 = 2583; + ENUM_VALUE16249 = 2584; + ENUM_VALUE16250 = 162; + ENUM_VALUE16251 = 2593; + ENUM_VALUE16252 = 41489; + ENUM_VALUE16253 = 663825; + ENUM_VALUE16254 = 663826; + ENUM_VALUE16255 = 41490; + ENUM_VALUE16256 = 41491; + ENUM_VALUE16257 = 41492; + ENUM_VALUE16258 = 663873; + ENUM_VALUE16259 = 2594; + ENUM_VALUE16260 = 41505; + ENUM_VALUE16261 = 41506; + ENUM_VALUE16262 = 41507; + ENUM_VALUE16263 = 2595; + ENUM_VALUE16264 = 41521; + ENUM_VALUE16265 = 41522; + ENUM_VALUE16266 = 41523; + ENUM_VALUE16267 = 41524; + ENUM_VALUE16268 = 41525; + ENUM_VALUE16269 = 664401; + ENUM_VALUE16270 = 664402; + ENUM_VALUE16271 = 41526; + ENUM_VALUE16272 = 41527; + ENUM_VALUE16273 = 2596; + ENUM_VALUE16274 = 2597; + ENUM_VALUE16275 = 2598; + ENUM_VALUE16276 = 41569; + ENUM_VALUE16277 = 41570; + ENUM_VALUE16278 = 41571; + ENUM_VALUE16279 = 41572; + ENUM_VALUE16280 = 41573; + ENUM_VALUE16281 = 665169; + ENUM_VALUE16282 = 665170; + ENUM_VALUE16283 = 665171; + ENUM_VALUE16284 = 665172; + ENUM_VALUE16285 = 2599; + ENUM_VALUE16286 = 2600; + ENUM_VALUE16287 = 2601; + ENUM_VALUE16288 = 2603; + ENUM_VALUE16289 = 2604; + ENUM_VALUE16290 = 163; + ENUM_VALUE16291 = 2608; + ENUM_VALUE16292 = 2609; + ENUM_VALUE16293 = 2610; + ENUM_VALUE16294 = 2611; + ENUM_VALUE16295 = 2612; + ENUM_VALUE16296 = 164; + ENUM_VALUE16297 = 2625; + ENUM_VALUE16298 = 2626; + ENUM_VALUE16299 = 42017; + ENUM_VALUE16300 = 42018; + ENUM_VALUE16301 = 42019; + ENUM_VALUE16302 = 2627; + ENUM_VALUE16303 = 2628; + ENUM_VALUE16304 = 165; + ENUM_VALUE16305 = 2641; + ENUM_VALUE16306 = 42257; + ENUM_VALUE16307 = 42258; + ENUM_VALUE16308 = 2642; + ENUM_VALUE16309 = 2643; + ENUM_VALUE16310 = 2644; + ENUM_VALUE16311 = 2646; + ENUM_VALUE16312 = 2647; + ENUM_VALUE16313 = 42353; + ENUM_VALUE16314 = 2648; + ENUM_VALUE16315 = 2649; + ENUM_VALUE16316 = 2650; + ENUM_VALUE16317 = 2651; + ENUM_VALUE16318 = 2652; + ENUM_VALUE16319 = 2653; + ENUM_VALUE16320 = 2654; + ENUM_VALUE16321 = 42481; + ENUM_VALUE16322 = 42482; + ENUM_VALUE16323 = 42483; + ENUM_VALUE16324 = 166; + ENUM_VALUE16325 = 2657; + ENUM_VALUE16326 = 2658; + ENUM_VALUE16327 = 42529; + ENUM_VALUE16328 = 2659; + ENUM_VALUE16329 = 2660; + ENUM_VALUE16330 = 2661; + ENUM_VALUE16331 = 2662; + ENUM_VALUE16332 = 2663; + ENUM_VALUE16333 = 42609; + ENUM_VALUE16334 = 2664; + ENUM_VALUE16335 = 2665; + ENUM_VALUE16336 = 42753; + ENUM_VALUE16337 = 42754; + ENUM_VALUE16338 = 42755; + ENUM_VALUE16339 = 11; + ENUM_VALUE16340 = 177; + ENUM_VALUE16341 = 2833; + ENUM_VALUE16342 = 179; + ENUM_VALUE16343 = 180; + ENUM_VALUE16344 = 2881; + ENUM_VALUE16345 = 182; + ENUM_VALUE16346 = 183; + ENUM_VALUE16347 = 12; + ENUM_VALUE16348 = 3089; + ENUM_VALUE16349 = 194; + ENUM_VALUE16350 = 195; + ENUM_VALUE16351 = 196; + ENUM_VALUE16352 = 198; + ENUM_VALUE16353 = 3169; + ENUM_VALUE16354 = 199; + ENUM_VALUE16355 = 200; + ENUM_VALUE16356 = 208; + ENUM_VALUE16357 = 3329; + ENUM_VALUE16358 = 3330; + ENUM_VALUE16359 = 3331; + ENUM_VALUE16360 = 209; + ENUM_VALUE16361 = 210; + ENUM_VALUE16362 = 211; + ENUM_VALUE16363 = 3377; + ENUM_VALUE16364 = 3378; + ENUM_VALUE16365 = 3379; + ENUM_VALUE16366 = 3380; + ENUM_VALUE16367 = 3381; + ENUM_VALUE16368 = 865809; + ENUM_VALUE16369 = 865810; + ENUM_VALUE16370 = 865811; + ENUM_VALUE16371 = 865812; + ENUM_VALUE16372 = 865813; + ENUM_VALUE16373 = 865814; + ENUM_VALUE16374 = 865815; + ENUM_VALUE16375 = 865816; + ENUM_VALUE16376 = 865817; + ENUM_VALUE16377 = 865818; + ENUM_VALUE16378 = 865819; + ENUM_VALUE16379 = 865820; + ENUM_VALUE16380 = 865821; + ENUM_VALUE16381 = 865822; + ENUM_VALUE16382 = 865823; + ENUM_VALUE16383 = 865824; + ENUM_VALUE16384 = 865825; + ENUM_VALUE16385 = 865826; + ENUM_VALUE16386 = 865827; + ENUM_VALUE16387 = 865828; + ENUM_VALUE16388 = 865829; + ENUM_VALUE16389 = 212; + ENUM_VALUE16390 = 3393; + ENUM_VALUE16391 = 3394; + ENUM_VALUE16392 = 3395; + ENUM_VALUE16393 = 213; + ENUM_VALUE16394 = 214; + ENUM_VALUE16395 = 215; + ENUM_VALUE16396 = 3441; + ENUM_VALUE16397 = 3442; + ENUM_VALUE16398 = 216; + ENUM_VALUE16399 = 217; + ENUM_VALUE16400 = 3473; + ENUM_VALUE16401 = 3474; + ENUM_VALUE16402 = 3475; + ENUM_VALUE16403 = 254; + ENUM_VALUE16404 = 255; +} + +enum Enum16553 { + ENUM_VALUE16554 = 0; + ENUM_VALUE16555 = 1; + ENUM_VALUE16556 = 2; + ENUM_VALUE16557 = 3; + ENUM_VALUE16558 = 4; + ENUM_VALUE16559 = 5; + ENUM_VALUE16560 = 6; + ENUM_VALUE16561 = 7; + ENUM_VALUE16562 = 8; + ENUM_VALUE16563 = 9; +} + +enum Enum16728 { + ENUM_VALUE16729 = 1; + ENUM_VALUE16730 = 2; + ENUM_VALUE16731 = 3; +} + +enum Enum16732 { + ENUM_VALUE16733 = 1; + ENUM_VALUE16734 = 2; + ENUM_VALUE16735 = 3; + ENUM_VALUE16736 = 4; + ENUM_VALUE16737 = 5; +} + +enum Enum16738 { + ENUM_VALUE16739 = 1; + ENUM_VALUE16740 = 2; + ENUM_VALUE16741 = 3; + ENUM_VALUE16742 = 4; + ENUM_VALUE16743 = 5; + ENUM_VALUE16744 = 6; + ENUM_VALUE16745 = 7; +} + +enum Enum16698 { + ENUM_VALUE16699 = -1; + ENUM_VALUE16700 = 100; + ENUM_VALUE16701 = 2; + ENUM_VALUE16702 = 0; + ENUM_VALUE16703 = 1; + ENUM_VALUE16704 = 4; + ENUM_VALUE16705 = 11; + ENUM_VALUE16706 = 12; + ENUM_VALUE16707 = 3; + ENUM_VALUE16708 = 5; + ENUM_VALUE16709 = 6; + ENUM_VALUE16710 = 7; + ENUM_VALUE16711 = 8; + ENUM_VALUE16712 = 9; + ENUM_VALUE16713 = 10; + ENUM_VALUE16714 = 13; + ENUM_VALUE16715 = 14; + ENUM_VALUE16716 = 15; + ENUM_VALUE16717 = 16; + ENUM_VALUE16718 = 18; + ENUM_VALUE16719 = 17; + ENUM_VALUE16720 = 19; + ENUM_VALUE16721 = 20; +} + +enum Enum16819 { + ENUM_VALUE16820 = 0; + ENUM_VALUE16821 = 1; + ENUM_VALUE16822 = 2; + ENUM_VALUE16823 = 3; + ENUM_VALUE16824 = 4; + ENUM_VALUE16825 = 5; +} + +enum Enum16925 { + ENUM_VALUE16926 = 0; + ENUM_VALUE16927 = 1; + ENUM_VALUE16928 = 2; + ENUM_VALUE16929 = 3; + ENUM_VALUE16930 = 4; + ENUM_VALUE16931 = 5; + ENUM_VALUE16932 = 6; + ENUM_VALUE16933 = 7; + ENUM_VALUE16934 = 8; + ENUM_VALUE16935 = 9; + ENUM_VALUE16936 = 10; + ENUM_VALUE16937 = 11; + ENUM_VALUE16938 = 12; + ENUM_VALUE16939 = 13; +} + +enum Enum22854 { + ENUM_VALUE22855 = 0; + ENUM_VALUE22856 = 1; +} + +enum Enum24361 { + ENUM_VALUE24362 = 0; + ENUM_VALUE24363 = 1; + ENUM_VALUE24364 = 2; + ENUM_VALUE24365 = 3; +} + +enum Enum16891 { + ENUM_VALUE16892 = 0; + ENUM_VALUE16893 = 1; + ENUM_VALUE16894 = 2; + ENUM_VALUE16895 = 3; + ENUM_VALUE16896 = 4; + ENUM_VALUE16897 = 5; + ENUM_VALUE16898 = 6; + ENUM_VALUE16899 = 7; + ENUM_VALUE16900 = 8; + ENUM_VALUE16901 = 9; + ENUM_VALUE16902 = 10; + ENUM_VALUE16903 = 11; + ENUM_VALUE16904 = 12; + ENUM_VALUE16905 = 13; + ENUM_VALUE16906 = 14; + ENUM_VALUE16907 = 15; + ENUM_VALUE16908 = 16; + ENUM_VALUE16909 = 17; + ENUM_VALUE16910 = 18; + ENUM_VALUE16911 = 19; + ENUM_VALUE16912 = 20; + ENUM_VALUE16913 = 21; + ENUM_VALUE16914 = 22; + ENUM_VALUE16915 = 23; + ENUM_VALUE16916 = 24; + ENUM_VALUE16917 = 25; + ENUM_VALUE16918 = 26; + ENUM_VALUE16919 = 27; + ENUM_VALUE16920 = 28; + ENUM_VALUE16921 = 29; + ENUM_VALUE16922 = 30; + ENUM_VALUE16923 = 31; +} + +enum Enum27361 { + ENUM_VALUE27362 = 0; + ENUM_VALUE27363 = 1; + ENUM_VALUE27364 = 2; + ENUM_VALUE27365 = 3; + ENUM_VALUE27366 = 4; +} + +enum Enum33960 { + ENUM_VALUE33961 = 0; + ENUM_VALUE33962 = 1; + ENUM_VALUE33963 = 2; + ENUM_VALUE33964 = 3; + ENUM_VALUE33965 = 4; + ENUM_VALUE33966 = 5; + ENUM_VALUE33967 = 6; +} + +enum Enum34388 { + ENUM_VALUE34389 = 1; +} + +enum Enum35477 { + ENUM_VALUE35478 = 4; + ENUM_VALUE35479 = 3; + ENUM_VALUE35480 = 2; + ENUM_VALUE35481 = 1; + ENUM_VALUE35482 = 0; +} + +enum Enum35507 { + ENUM_VALUE35508 = 0; + ENUM_VALUE35509 = 1; + ENUM_VALUE35510 = 2; + ENUM_VALUE35511 = 3; + ENUM_VALUE35512 = 4; + ENUM_VALUE35513 = 5; + ENUM_VALUE35514 = 6; + ENUM_VALUE35515 = 7; + ENUM_VALUE35516 = 8; + ENUM_VALUE35517 = 9; +} + +enum Enum36860 { + ENUM_VALUE36861 = 0; + ENUM_VALUE36862 = 1; + ENUM_VALUE36863 = 2; + ENUM_VALUE36864 = 3; + ENUM_VALUE36865 = 4; + ENUM_VALUE36866 = 5; + ENUM_VALUE36867 = 6; + ENUM_VALUE36868 = 7; +} + +enum Enum36890 { + ENUM_VALUE36891 = 0; + ENUM_VALUE36892 = 1; +} + diff --git a/third_party/protobuf/benchmarks/datasets/google_message4/benchmark_message4.proto b/third_party/protobuf/benchmarks/datasets/google_message4/benchmark_message4.proto new file mode 100644 index 000000000000..2161393918d7 --- /dev/null +++ b/third_party/protobuf/benchmarks/datasets/google_message4/benchmark_message4.proto @@ -0,0 +1,454 @@ +syntax = "proto2"; + +import "datasets/google_message4/benchmark_message4_1.proto"; +import "datasets/google_message4/benchmark_message4_2.proto"; +import "datasets/google_message4/benchmark_message4_3.proto"; +package benchmarks.google_message4; + +option cc_enable_arenas = true; +option java_package = "com.google.protobuf.benchmarks"; + +message GoogleMessage4 { + optional int32 field37503 = 1; + optional .benchmarks.google_message4.UnusedEmptyMessage field37504 = 2; + optional .benchmarks.google_message4.UnusedEmptyMessage field37505 = 3; + optional .benchmarks.google_message4.UnusedEmptyMessage field37506 = 4; + optional .benchmarks.google_message4.UnusedEmptyMessage field37507 = 5; + optional .benchmarks.google_message4.Message37489 field37508 = 6; + optional .benchmarks.google_message4.UnusedEmptyMessage field37509 = 7; + optional .benchmarks.google_message4.UnusedEmptyMessage field37510 = 8; + optional .benchmarks.google_message4.UnusedEmptyMessage field37511 = 9; + optional .benchmarks.google_message4.UnusedEmptyMessage field37512 = 10; + optional .benchmarks.google_message4.UnusedEmptyMessage field37513 = 11; + optional .benchmarks.google_message4.UnusedEmptyMessage field37514 = 12; + optional .benchmarks.google_message4.UnusedEmptyMessage field37515 = 13; + optional .benchmarks.google_message4.UnusedEmptyMessage field37516 = 14; + optional .benchmarks.google_message4.UnusedEmptyMessage field37517 = 15; + optional .benchmarks.google_message4.UnusedEmptyMessage field37518 = 16; +} + +message Message37489 { + optional .benchmarks.google_message4.Message2517 field37534 = 3; + optional .benchmarks.google_message4.Message7330 field37535 = 4; + optional .benchmarks.google_message4.Message8815 field37536 = 6; + optional .benchmarks.google_message4.Message8817 field37537 = 7; + optional .benchmarks.google_message4.Message8835 field37538 = 8; + optional .benchmarks.google_message4.Message8848 field37539 = 9; + optional .benchmarks.google_message4.Message8856 field37540 = 11; + optional .benchmarks.google_message4.Message12717 field37541 = 15; + optional .benchmarks.google_message4.Message12748 field37542 = 20; + optional .benchmarks.google_message4.Message7319 field37543 = 22; + optional .benchmarks.google_message4.Message12908 field37544 = 24; + optional .benchmarks.google_message4.Message12910 field37545 = 25; + optional .benchmarks.google_message4.Message12960 field37546 = 30; + optional .benchmarks.google_message4.Message176 field37547 = 33; + optional .benchmarks.google_message4.Message13000 field37548 = 34; + optional .benchmarks.google_message4.Message13035 field37549 = 35; + optional .benchmarks.google_message4.Message37331 field37550 = 36; + optional .benchmarks.google_message4.Message37329 field37551 = 37; + optional .benchmarks.google_message4.Message37327 field37552 = 38; + optional .benchmarks.google_message4.Message37333 field37553 = 39; + optional .benchmarks.google_message4.Message37335 field37554 = 40; +} + +message Message7319 { + optional .benchmarks.google_message4.UnusedEmptyMessage field7321 = 1; + optional .benchmarks.google_message4.UnusedEmptyMessage field7322 = 7; +} + +message Message12717 { + optional .benchmarks.google_message4.UnusedEmptyMessage field12719 = 1; + optional string field12720 = 2; + optional uint32 field12721 = 3; + optional .benchmarks.google_message4.Message11976 field12722 = 4; + repeated .benchmarks.google_message4.Message11948 field12723 = 5; + optional .benchmarks.google_message4.Message11947 field12724 = 6; + optional .benchmarks.google_message4.Message12687 field12725 = 7; + repeated .benchmarks.google_message4.Message11948 field12726 = 8; + optional int64 field12727 = 9; +} + +message Message37331 { + optional .benchmarks.google_message4.UnusedEmptyMessage field37367 = 4; + required .benchmarks.google_message4.Message37326 field37368 = 1; + required int64 field37369 = 2; + required bytes field37370 = 3; +} + +message Message8815 { + optional .benchmarks.google_message4.UnusedEmptyMessage field8819 = 1; + repeated .benchmarks.google_message4.Message8768 field8820 = 2; + optional bool field8821 = 3; +} + +message Message7330 { + optional .benchmarks.google_message4.UnusedEmptyMessage field7332 = 1; + optional .benchmarks.google_message4.Message3069 field7333 = 2; + optional .benchmarks.google_message4.Message7320 field7334 = 3; + optional .benchmarks.google_message4.UnusedEmptyMessage field7335 = 4; + optional bool field7336 = 5; + optional int64 field7337 = 6; +} + +message Message12960 { + optional .benchmarks.google_message4.UnusedEmptyMessage field12962 = 1; + optional .benchmarks.google_message4.Message12948 field12963 = 2; +} + +message Message176 { + required string field408 = 1; + optional int32 field409 = 4; + optional string field410 = 50; + optional int32 field411 = 2; + optional uint64 field412 = 47; + optional string field413 = 56; + optional int32 field414 = 24; + optional string field415 = 21; + optional bytes field416 = 3; + optional string field417 = 57; + optional int32 field418 = 51; + optional float field419 = 7; + optional bool field420 = 5; + optional bool field421 = 28; + optional int32 field422 = 6; + repeated int32 field423 = 40; + optional .benchmarks.google_message4.UnusedEmptyMessage field424 = 41; + optional bool field425 = 25; + optional uint64 field426 = 26; + optional int32 field427 = 38; + optional bytes field428 = 15; + optional bytes field429 = 55; + optional bytes field430 = 16; + optional bytes field431 = 23; + optional bool field432 = 33; + optional bytes field433 = 31; + optional bytes field434 = 32; + optional int32 field435 = 36; + optional uint64 field436 = 17; + optional int32 field437 = 45; + optional uint64 field438 = 18; + optional string field439 = 46; + optional .benchmarks.google_message4.UnusedEmptyMessage field440 = 64; + optional int32 field441 = 39; + optional uint64 field442 = 48; + optional bytes field443 = 19; + optional bytes field444 = 42; + optional bytes field445 = 43; + optional string field446 = 44; + optional string field447 = 49; + optional int64 field448 = 20; + optional bool field449 = 53; + optional .benchmarks.google_message4.UnusedEmptyMessage field450 = 54; + repeated .benchmarks.google_message4.UnusedEmptyMessage field451 = 22; + optional .benchmarks.google_message4.UnusedEnum field452 = 27; + optional int32 field453 = 29; + optional int32 field454 = 30; + optional .benchmarks.google_message4.UnusedEnum field455 = 37; + optional .benchmarks.google_message4.UnusedEnum field456 = 34; + optional int32 field457 = 35; + repeated group Message178 = 101 { + } + optional bool field459 = 52; + optional uint64 field460 = 58; + optional uint64 field461 = 59; + optional .benchmarks.google_message4.UnusedEmptyMessage field462 = 60; + optional .benchmarks.google_message4.UnusedEmptyMessage field463 = 61; + optional .benchmarks.google_message4.UnusedEnum field464 = 62; + repeated string field465 = 63; + optional .benchmarks.google_message4.UnusedEmptyMessage field466 = 65; +} + +message Message8817 { + optional .benchmarks.google_message4.UnusedEmptyMessage field8825 = 1; + repeated .benchmarks.google_message4.Message8768 field8826 = 2; + optional string field8827 = 3; +} + +message Message8835 { + optional .benchmarks.google_message4.UnusedEmptyMessage field8837 = 1; + repeated string field8838 = 2; + optional .benchmarks.google_message4.UnusedEnum field8839 = 3; +} + +message Message37333 { + optional .benchmarks.google_message4.UnusedEmptyMessage field37372 = 3; + required .benchmarks.google_message4.Message37326 field37373 = 1; + optional uint64 field37374 = 2; +} + +message Message13000 { + optional int64 field13015 = 1; + repeated .benchmarks.google_message4.Message12979 field13016 = 2; +} + +message Message37335 { + optional .benchmarks.google_message4.UnusedEmptyMessage field37376 = 4; + required .benchmarks.google_message4.Message37326 field37377 = 1; + required .benchmarks.google_message4.Message37173 field37378 = 2; + optional uint64 field37379 = 3; +} + +message Message8848 { + optional .benchmarks.google_message4.UnusedEmptyMessage field8850 = 1; + optional string field8851 = 2; + optional bytes field8852 = 3; +} + +message Message13035 { + optional int64 field13058 = 1; + repeated int64 field13059 = 2; +} + +message Message8856 { + optional .benchmarks.google_message4.UnusedEmptyMessage field8858 = 1; + optional string field8859 = 2; +} + +message Message12908 { + optional .benchmarks.google_message4.UnusedEmptyMessage field12912 = 1; + optional string field12913 = 2; + optional .benchmarks.google_message4.Message12799 field12914 = 3; + optional int64 field12915 = 4; + optional .benchmarks.google_message4.Message3804 field12916 = 5; + optional .benchmarks.google_message4.Message12870 field12917 = 6; +} + +message Message12910 { + optional .benchmarks.google_message4.UnusedEmptyMessage field12920 = 1; + optional .benchmarks.google_message4.Message12818 field12921 = 2; + repeated .benchmarks.google_message4.Message12903 field12922 = 3; +} + +message Message37327 { + optional .benchmarks.google_message4.UnusedEmptyMessage field37347 = 11; + required .benchmarks.google_message4.Message37326 field37348 = 1; + optional bool field37349 = 2; + optional bool field37350 = 3; + optional bool field37351 = 4; + optional bool field37352 = 5; + optional bool field37353 = 6; + optional .benchmarks.google_message4.UnusedEmptyMessage field37354 = 7; + optional uint64 field37355 = 8; + optional bool field37356 = 9; + optional bool field37357 = 10; +} + +message Message37329 { + optional .benchmarks.google_message4.UnusedEmptyMessage field37359 = 6; + required .benchmarks.google_message4.Message37326 field37360 = 1; + required int64 field37361 = 2; + required int64 field37362 = 3; + optional bool field37363 = 4; +} + +message Message2517 { + optional .benchmarks.google_message4.UnusedEmptyMessage field2519 = 1; + optional .benchmarks.google_message4.Message2356 field2520 = 2; + optional .benchmarks.google_message4.Message0 field2521 = 3; + optional .benchmarks.google_message4.Message2463 field2522 = 4; + repeated .benchmarks.google_message4.Message971 field2523 = 5; +} + +message Message12748 { + optional .benchmarks.google_message4.UnusedEmptyMessage field12754 = 1; + optional string field12755 = 2; + optional string field12756 = 3; + optional .benchmarks.google_message4.Enum12735 field12757 = 4; +} + +message Message12687 { + repeated .benchmarks.google_message4.Message12686 field12701 = 1; +} + +message Message11948 { + optional string field11954 = 1; + repeated .benchmarks.google_message4.Message11949 field11955 = 2; + optional bool field11956 = 3; +} + +message Message11976 { + repeated .benchmarks.google_message4.Message11975 field12002 = 1; +} + +message Message7320 { + optional .benchmarks.google_message4.UnusedEmptyMessage field7323 = 1; + optional .benchmarks.google_message4.Message7287 field7324 = 8; +} + +message Message3069 { + optional .benchmarks.google_message4.Message3061 field3374 = 1; + optional bytes field3375 = 2; + repeated group Message3070 = 3 { + required .benchmarks.google_message4.Enum3071 field3378 = 4; + required bytes field3379 = 5; + } + extensions 10000 to 536870911; +} + +message Message12948 { + repeated .benchmarks.google_message4.Message12949 field12958 = 1; +} + +message Message8768 { + optional string field8782 = 1; + optional .benchmarks.google_message4.Message8572 field8783 = 2; + optional bool field8784 = 3; + repeated .benchmarks.google_message4.Message8774 field8785 = 4; + optional int64 field8786 = 5; + optional .benchmarks.google_message4.UnusedEmptyMessage field8787 = 6; + optional string field8788 = 7; +} + +message Message12979 { + required bytes field12981 = 1; + repeated string field12982 = 2; + optional .benchmarks.google_message4.UnusedEmptyMessage field12983 = 3; + optional int64 field12984 = 4; + optional string field12985 = 5; + optional int32 field12986 = 6; + optional .benchmarks.google_message4.UnusedEmptyMessage field12987 = 7; +} + +message Message37173 { + optional string field37252 = 1; + optional int64 field37253 = 2; + optional .benchmarks.google_message4.UnusedEnum field37254 = 4; + optional bool field37255 = 5; + optional bool field37256 = 6; + optional bool field37257 = 7; + optional string field37258 = 8; + optional string field37259 = 9; + optional uint32 field37260 = 10; + optional fixed32 field37261 = 11; + optional string field37262 = 12; + optional string field37263 = 13; + optional string field37264 = 14; + optional int32 field37265 = 15; + optional int64 field37266 = 16; + optional int64 field37267 = 17; + optional int32 field37268 = 18; + optional int32 field37269 = 19; + optional .benchmarks.google_message4.UnusedEmptyMessage field37270 = 20; + optional .benchmarks.google_message4.UnusedEmptyMessage field37271 = 21; + optional .benchmarks.google_message4.UnusedEmptyMessage field37272 = 22; + optional .benchmarks.google_message4.UnusedEmptyMessage field37273 = 23; + optional .benchmarks.google_message4.UnusedEmptyMessage field37274 = 24; + optional string field37275 = 25; + optional bool field37276 = 26; +} + +message Message12799 { + required string field12809 = 1; + repeated fixed64 field12810 = 2; + repeated .benchmarks.google_message4.Message12776 field12811 = 8; + repeated int32 field12812 = 4; + repeated .benchmarks.google_message4.Message12798 field12813 = 5; + required int32 field12814 = 3; + optional int32 field12815 = 6; + optional .benchmarks.google_message4.Message12797 field12816 = 7; +} + +message Message12870 { + required int32 field12879 = 1; + optional int32 field12880 = 7; + required int32 field12881 = 2; + optional uint64 field12882 = 3; + optional string field12883 = 2001; + optional fixed64 field12884 = 4; + repeated fixed64 field12885 = 14; + optional int32 field12886 = 9; + optional int64 field12887 = 18; + repeated .benchmarks.google_message4.Message12870 field12888 = 8; + optional int32 field12889 = 5; + optional uint64 field12890 = 6; + optional int32 field12891 = 10; + optional int32 field12892 = 11; + optional double field12893 = 12; + optional .benchmarks.google_message4.Message12825 field12894 = 13; + optional double field12895 = 15; + optional string field12896 = 16; + optional .benchmarks.google_message4.Enum12871 field12897 = 17; + optional int32 field12898 = 19; +} + +message Message3804 { + required int64 field3818 = 1; + required bool field3819 = 2; + repeated .benchmarks.google_message4.Enum3805 field3820 = 4; + optional int32 field3821 = 5; + optional bool field3822 = 6; + optional int64 field3823 = 7; + optional .benchmarks.google_message4.Enum3783 field3824 = 8; +} + +message Message12903 { + optional string field12905 = 1; + optional .benchmarks.google_message4.Message8587 field12906 = 2; + repeated .benchmarks.google_message4.Message8590 field12907 = 3; +} + +message Message37326 { + required string field37345 = 1; + optional string field37346 = 2; +} + +message Message2356 { + optional .benchmarks.google_message4.Message1374 field2368 = 121; + optional uint64 field2369 = 1; + optional int32 field2370 = 2; + optional int32 field2371 = 17; + required string field2372 = 3; + optional int32 field2373 = 7; + optional bytes field2374 = 8; + optional string field2375 = 4; + optional string field2376 = 101; + optional int32 field2377 = 102; + optional int32 field2378 = 103; + optional int32 field2379 = 104; + optional int32 field2380 = 113; + optional int32 field2381 = 114; + optional int32 field2382 = 115; + optional int32 field2383 = 117; + optional int32 field2384 = 118; + optional int32 field2385 = 119; + optional int32 field2386 = 105; + optional bytes field2387 = 5; + optional group Message2357 = 6 { + optional int64 field2399 = 9; + optional int32 field2400 = 10; + optional int32 field2401 = 11; + optional int32 field2402 = 12; + optional int32 field2403 = 13; + optional int32 field2404 = 116; + optional int32 field2405 = 106; + required bytes field2406 = 14; + optional int32 field2407 = 45; + optional int32 field2408 = 112; + optional bool field2409 = 122; + optional bytes field2410 = 124; + } + optional string field2389 = 120; + optional group Message2358 = 107 { + } + repeated group Message2359 = 40 { + } + optional int32 field2392 = 50; + optional .benchmarks.google_message4.UnusedEmptyMessage field2393 = 60; + optional .benchmarks.google_message4.UnusedEmptyMessage field2394 = 70; + optional .benchmarks.google_message4.UnusedEmptyMessage field2395 = 80; + optional .benchmarks.google_message4.UnusedEmptyMessage field2396 = 90; + optional string field2397 = 100; + optional string field2398 = 123; +} + +message Message0 { + option message_set_wire_format = true; + extensions 4 to 2147483646; +} + +message Message971 { + optional string field972 = 1; + optional int32 field973 = 2; + optional bool field974 = 3; +} + diff --git a/third_party/protobuf/benchmarks/datasets/google_message4/benchmark_message4_1.proto b/third_party/protobuf/benchmarks/datasets/google_message4/benchmark_message4_1.proto new file mode 100644 index 000000000000..e7697480524f --- /dev/null +++ b/third_party/protobuf/benchmarks/datasets/google_message4/benchmark_message4_1.proto @@ -0,0 +1,474 @@ +syntax = "proto2"; + +import "datasets/google_message4/benchmark_message4_2.proto"; +import "datasets/google_message4/benchmark_message4_3.proto"; +package benchmarks.google_message4; + +option cc_enable_arenas = true; +option java_package = "com.google.protobuf.benchmarks"; + +message Message2463 { + repeated .benchmarks.google_message4.Message2462 field2498 = 1; +} + +message Message12686 { + optional string field12699 = 1; + optional .benchmarks.google_message4.Message12685 field12700 = 2; +} + +message Message11949 { +} + +message Message11975 { + optional string field11992 = 1; + optional int32 field11993 = 2; + repeated .benchmarks.google_message4.Message10320 field11994 = 3; + optional .benchmarks.google_message4.Message11947 field11995 = 4; + optional .benchmarks.google_message4.Message11920 field11996 = 5; + optional bool field11997 = 6; + repeated string field11998 = 7; + optional float field11999 = 8; + repeated .benchmarks.google_message4.UnusedEnum field12000 = 9; + optional int32 field12001 = 11; +} + +message Message7287 { + optional .benchmarks.google_message4.Message6133 field7311 = 1; + optional .benchmarks.google_message4.UnusedEmptyMessage field7312 = 8; + optional string field7313 = 3; + optional .benchmarks.google_message4.Message6643 field7314 = 4; + optional .benchmarks.google_message4.Enum7288 field7315 = 5; + optional bytes field7316 = 6; + optional .benchmarks.google_message4.UnusedEmptyMessage field7317 = 7; + optional .benchmarks.google_message4.UnusedEmptyMessage field7318 = 9; +} + +message Message3061 { + optional string field3286 = 2; + optional int32 field3287 = 77; + optional string field3288 = 49; + required .benchmarks.google_message4.Message3046 field3289 = 3; + optional .benchmarks.google_message4.Message3046 field3290 = 58; + optional group Message3062 = 4 { + required int32 field3335 = 5; + optional int32 field3336 = 6; + optional int32 field3337 = 7; + } + optional .benchmarks.google_message4.Message3060 field3292 = 104; + optional int64 field3293 = 32; + optional int32 field3294 = 41; + optional group Message3063 = 13 { + required int32 field3338 = 14; + optional .benchmarks.google_message4.Enum2851 field3339 = 18; + optional int64 field3340 = 15; + optional int64 field3341 = 23; + } + optional .benchmarks.google_message4.Enum2834 field3296 = 94; + optional bool field3297 = 25; + optional bool field3298 = 50; + optional string field3299 = 89; + optional string field3300 = 91; + optional string field3301 = 105; + optional .benchmarks.google_message4.Message3050 field3302 = 53; + optional fixed64 field3303 = 51; + optional fixed64 field3304 = 106; + optional int32 field3305 = 60; + optional string field3306 = 44; + optional bytes field3307 = 81; + optional string field3308 = 70; + optional bytes field3309 = 45; + optional .benchmarks.google_message4.Enum2806 field3310 = 71; + optional int32 field3311 = 72; + optional bytes field3312 = 78; + optional int32 field3313 = 20; + repeated group Message3064 = 8 { + required .benchmarks.google_message4.Enum2602 field3342 = 9; + optional int32 field3343 = 92; + optional string field3344 = 10; + optional bytes field3345 = 11; + optional int32 field3346 = 12; + optional .benchmarks.google_message4.Message3060 field3347 = 98; + optional .benchmarks.google_message4.UnusedEmptyMessage field3348 = 82; + optional .benchmarks.google_message4.Message3050 field3349 = 80; + optional fixed64 field3350 = 52; + optional int32 field3351 = 33; + optional string field3352 = 42; + optional string field3353 = 69; + optional bytes field3354 = 43; + optional .benchmarks.google_message4.Enum2806 field3355 = 73; + optional int32 field3356 = 74; + optional int32 field3357 = 90; + optional bytes field3358 = 79; + optional int32 field3359 = 19; + optional .benchmarks.google_message4.Enum2834 field3360 = 95; + } + optional .benchmarks.google_message4.UnusedEmptyMessage field3315 = 39; + optional int32 field3316 = 76; + optional group Message3065 = 63 { + } + optional .benchmarks.google_message4.Enum2806 field3318 = 54; + optional int32 field3319 = 46; + repeated string field3320 = 24; + optional fixed32 field3321 = 38; + optional bytes field3322 = 99; + optional fixed64 field3323 = 1; + optional fixed64 field3324 = 97; + repeated .benchmarks.google_message4.Message3040 field3325 = 16; + repeated .benchmarks.google_message4.Message3041 field3326 = 61; + optional group Message3066 = 21 { + optional int32 field3366 = 22; + optional int32 field3367 = 55; + optional int32 field3368 = 88; + optional int32 field3369 = 56; + optional int32 field3370 = 75; + optional int32 field3371 = 57; + optional .benchmarks.google_message4.UnusedEmptyMessage field3372 = 85; + optional .benchmarks.google_message4.UnusedEmptyMessage field3373 = 96; + } + optional .benchmarks.google_message4.UnusedEmptyMessage field3328 = 47; + optional .benchmarks.google_message4.UnusedEmptyMessage field3329 = 48; + optional fixed64 field3330 = 40; + optional .benchmarks.google_message4.UnusedEmptyMessage field3331 = 86; + optional .benchmarks.google_message4.UnusedEmptyMessage field3332 = 59; + optional int32 field3333 = 17; +} + +message Message12949 { +} + +message Message8572 { + optional bytes field8647 = 1; + optional bytes field8648 = 3; + optional .benchmarks.google_message4.Message3886 field8649 = 4; + optional .benchmarks.google_message4.Message3919 field8650 = 57; + optional bool field8651 = 5; + optional int32 field8652 = 6; + optional int32 field8653 = 49; + optional .benchmarks.google_message4.Message7905 field8654 = 7; + optional int32 field8655 = 10; + optional .benchmarks.google_message4.UnusedEmptyMessage field8656 = 11; + optional bool field8657 = 35; + optional bytes field8658 = 12; + optional string field8659 = 14; + optional .benchmarks.google_message4.UnusedEmptyMessage field8660 = 13; + optional bytes field8661 = 15; + optional .benchmarks.google_message4.UnusedEmptyMessage field8662 = 17; + optional int32 field8663 = 18; + optional int32 field8664 = 19; + optional bool field8665 = 20; + optional .benchmarks.google_message4.Enum3476 field8666 = 31; + optional bool field8667 = 36; + optional .benchmarks.google_message4.UnusedEmptyMessage field8668 = 39; + optional bytes field8669 = 22; + optional int32 field8670 = 24; + optional .benchmarks.google_message4.Message3052 field8671 = 25; + optional bytes field8672 = 26; + optional bytes field8673 = 28; + optional int32 field8674 = 29; + optional bytes field8675 = 30; + optional bytes field8676 = 32; + optional string field8677 = 33; + optional int32 field8678 = 34; + optional int32 field8679 = 37; + optional double field8680 = 38; + optional double field8681 = 42; + optional .benchmarks.google_message4.Message3922 field8682 = 40; + optional .benchmarks.google_message4.UnusedEmptyMessage field8683 = 43; + optional int64 field8684 = 44; + optional .benchmarks.google_message4.Message7929 field8685 = 45; + optional uint64 field8686 = 46; + optional uint32 field8687 = 48; + optional .benchmarks.google_message4.Message7843 field8688 = 47; + optional .benchmarks.google_message4.Message7864 field8689 = 50; + optional .benchmarks.google_message4.UnusedEmptyMessage field8690 = 52; + optional bool field8691 = 58; + optional bool field8692 = 54; + optional string field8693 = 55; + optional .benchmarks.google_message4.UnusedEmptyMessage field8694 = 41; + optional .benchmarks.google_message4.UnusedEmptyMessage field8695 = 53; + optional .benchmarks.google_message4.Message8575 field8696 = 61; +} + +message Message8774 { + optional string field8810 = 1; + optional string field8811 = 2; + optional string field8812 = 3; + optional string field8813 = 4; + optional string field8814 = 5; +} + +message Message12776 { + optional string field12786 = 1; + optional fixed64 field12787 = 11; + optional int32 field12788 = 6; + optional int32 field12789 = 13; + optional int32 field12790 = 14; + optional int32 field12791 = 15; + optional int32 field12792 = 16; + optional .benchmarks.google_message4.UnusedEmptyMessage field12793 = 8; + optional .benchmarks.google_message4.Message12774 field12794 = 10; + optional .benchmarks.google_message4.UnusedEmptyMessage field12795 = 12; + extensions 2 to 2; + extensions 3 to 3; + extensions 4 to 4; + extensions 5 to 5; + extensions 7 to 7; + extensions 9 to 9; +} + +message Message12798 { + optional int32 field12805 = 1; + optional int32 field12806 = 2; + optional .benchmarks.google_message4.Message12774 field12807 = 6; + optional bool field12808 = 7; +} + +message Message12797 { + optional .benchmarks.google_message4.Message12796 field12802 = 1; + repeated .benchmarks.google_message4.Message12796 field12803 = 2; + optional string field12804 = 3; +} + +message Message12825 { + repeated .benchmarks.google_message4.Message12818 field12862 = 1; + optional int32 field12863 = 2; + optional .benchmarks.google_message4.Message12819 field12864 = 3; + optional .benchmarks.google_message4.Message12820 field12865 = 4; + optional int32 field12866 = 5; + repeated .benchmarks.google_message4.Message12821 field12867 = 6; + repeated .benchmarks.google_message4.UnusedEmptyMessage field12868 = 7; +} + +message Message8590 { +} + +message Message8587 { +} + +message Message1374 { + required string field1375 = 1; + optional string field1376 = 2; +} + +message Message2462 { + required bytes field2496 = 1; + required double field2497 = 2; +} + +message Message12685 { + repeated string field12692 = 1; + repeated string field12693 = 2; + optional int64 field12694 = 3; + optional uint32 field12695 = 4; + repeated string field12696 = 5; + optional string field12697 = 6; + optional string field12698 = 7; +} + +message Message10320 { + optional .benchmarks.google_message4.Enum10335 field10347 = 1; + repeated .benchmarks.google_message4.Message10319 field10348 = 2; + optional int32 field10349 = 3; + optional int32 field10350 = 4; + optional int32 field10351 = 5; + optional int32 field10352 = 6; + optional .benchmarks.google_message4.Enum10337 field10353 = 7; +} + +message Message11947 { + optional uint32 field11951 = 1; + optional bool field11952 = 2; + optional int32 field11953 = 3; +} + +message Message11920 { + optional .benchmarks.google_message4.Enum11901 field11945 = 1; + optional .benchmarks.google_message4.UnusedEnum field11946 = 2; +} + +message Message6643 { + optional .benchmarks.google_message4.UnusedEmptyMessage field6683 = 3; + optional .benchmarks.google_message4.UnusedEmptyMessage field6684 = 4; + optional double field6685 = 5; + optional double field6686 = 6; + optional int32 field6687 = 1; + optional int32 field6688 = 2; + optional double field6689 = 9; + optional bytes field6690 = 10; + optional int32 field6691 = 11; + optional bool field6692 = 12; + optional bool field6693 = 13; + optional .benchmarks.google_message4.Message6578 field6694 = 15; + optional .benchmarks.google_message4.UnusedEnum field6695 = 16; + optional int64 field6696 = 17; + repeated .benchmarks.google_message4.UnusedEmptyMessage field6697 = 22; + optional .benchmarks.google_message4.UnusedEmptyMessage field6698 = 19; + optional .benchmarks.google_message4.UnusedEmptyMessage field6699 = 20; + optional int32 field6700 = 21; +} + +message Message6133 { + optional .benchmarks.google_message4.Message4016 field6173 = 12; + optional double field6174 = 16; + required string field6175 = 1; + required string field6176 = 2; + required string field6177 = 3; + optional string field6178 = 4; + optional string field6179 = 8; + repeated .benchmarks.google_message4.Message6109 field6180 = 5; + repeated .benchmarks.google_message4.Message5908 field6181 = 13; + repeated .benchmarks.google_message4.Message6107 field6182 = 7; + repeated .benchmarks.google_message4.Message6126 field6183 = 9; + repeated .benchmarks.google_message4.Message6129 field6184 = 15; + optional int32 field6185 = 10; + optional int32 field6186 = 11; + optional .benchmarks.google_message4.Message4016 field6187 = 17; + optional double field6188 = 14; + optional double field6189 = 18; + optional string field6190 = 19; + optional string field6191 = 20; + repeated .benchmarks.google_message4.Message5881 field6192 = 21; +} + +message Message6109 { + optional string field6140 = 1; + required .benchmarks.google_message4.Enum6111 field6141 = 2; + optional int32 field6142 = 9; + optional string field6143 = 3; + repeated .benchmarks.google_message4.Message6110 field6144 = 4; + repeated int32 field6145 = 7; + repeated int32 field6146 = 8; + optional .benchmarks.google_message4.Message6133 field6147 = 10; + repeated int32 field6148 = 11; + optional string field6149 = 12; + optional string field6150 = 13; + optional bool field6151 = 14; + extensions 1000 to 536870911; +} + +message Message3046 { + required .benchmarks.google_message4.Enum2593 field3222 = 1; + optional int32 field3223 = 4; +} + +message Message3060 { + optional int64 field3283 = 1; + optional int64 field3284 = 2; + optional int64 field3285 = 3; +} + +message Message3041 { + optional string field3214 = 1; + optional int32 field3215 = 2; +} + +message Message3040 { + required fixed64 field3209 = 1; + repeated fixed64 field3210 = 4; + optional int32 field3211 = 5; + optional fixed64 field3212 = 2; + required string field3213 = 3; +} + +message Message3050 { + optional bytes field3245 = 5; + optional int32 field3246 = 2; + optional bytes field3247 = 6; + optional int32 field3248 = 4; + optional fixed32 field3249 = 1; + optional fixed32 field3250 = 3; +} + +message Message7905 { + optional int32 field7911 = 1; + optional bool field7912 = 2; + optional bytes field7913 = 3; + optional int32 field7914 = 4; + optional int32 field7915 = 5; + optional bytes field7916 = 6; + optional int32 field7917 = 7; +} + +message Message3886 { + repeated group Message3887 = 1 { + required string field3932 = 2; + optional string field3933 = 9; + optional .benchmarks.google_message4.Message3850 field3934 = 3; + optional bytes field3935 = 8; + } +} + +message Message7864 { + optional string field7866 = 1; + optional string field7867 = 2; + repeated .benchmarks.google_message4.Message7865 field7868 = 5; + repeated .benchmarks.google_message4.Message7865 field7869 = 6; + repeated .benchmarks.google_message4.Message7865 field7870 = 7; + repeated .benchmarks.google_message4.UnusedEmptyMessage field7871 = 8; +} + +message Message3922 { + optional uint64 field4012 = 1; +} + +message Message3052 { + repeated string field3254 = 1; + repeated string field3255 = 2; + repeated bytes field3256 = 3; + repeated string field3257 = 4; + optional bool field3258 = 5; + optional int32 field3259 = 6; + optional int32 field3260 = 7; + optional string field3261 = 8; + optional string field3262 = 9; +} + +message Message8575 { +} + +message Message7843 { + optional bool field7844 = 5; + optional int32 field7845 = 1; + optional .benchmarks.google_message4.UnusedEmptyMessage field7846 = 22; + repeated int32 field7847 = 3; + repeated string field7848 = 11; + optional .benchmarks.google_message4.UnusedEnum field7849 = 15; + optional .benchmarks.google_message4.UnusedEmptyMessage field7850 = 6; + optional .benchmarks.google_message4.UnusedEmptyMessage field7851 = 14; + optional .benchmarks.google_message4.UnusedEmptyMessage field7852 = 10; + optional .benchmarks.google_message4.Message7511 field7853 = 13; + optional .benchmarks.google_message4.UnusedEmptyMessage field7854 = 16; + optional .benchmarks.google_message4.UnusedEmptyMessage field7855 = 17; + optional .benchmarks.google_message4.UnusedEmptyMessage field7856 = 19; + optional .benchmarks.google_message4.UnusedEmptyMessage field7857 = 18; + optional .benchmarks.google_message4.UnusedEnum field7858 = 20; + optional int32 field7859 = 2; +} + +message Message3919 { + repeated .benchmarks.google_message4.Message3920 field4009 = 1; +} + +message Message7929 { + optional int64 field7942 = 1; + optional int64 field7943 = 4; + optional int64 field7944 = 5; + optional int64 field7945 = 12; + optional int64 field7946 = 13; + optional int64 field7947 = 18; + optional int64 field7948 = 6; + optional int64 field7949 = 7; + repeated .benchmarks.google_message4.Message7919 field7950 = 8; + repeated .benchmarks.google_message4.UnusedEmptyMessage field7951 = 20; + repeated .benchmarks.google_message4.Message7920 field7952 = 14; + repeated .benchmarks.google_message4.Message7921 field7953 = 15; + repeated .benchmarks.google_message4.Message7928 field7954 = 17; + optional int64 field7955 = 19; + optional bool field7956 = 2; + optional int64 field7957 = 3; + optional int64 field7958 = 9; + repeated .benchmarks.google_message4.UnusedEmptyMessage field7959 = 10; + repeated bytes field7960 = 11; + optional int64 field7961 = 16; +} + diff --git a/third_party/protobuf/benchmarks/datasets/google_message4/benchmark_message4_2.proto b/third_party/protobuf/benchmarks/datasets/google_message4/benchmark_message4_2.proto new file mode 100644 index 000000000000..d5e9da5aa973 --- /dev/null +++ b/third_party/protobuf/benchmarks/datasets/google_message4/benchmark_message4_2.proto @@ -0,0 +1,292 @@ +syntax = "proto2"; + +import "datasets/google_message4/benchmark_message4_3.proto"; +package benchmarks.google_message4; + +option cc_enable_arenas = true; +option java_package = "com.google.protobuf.benchmarks"; + +message Message12774 { + optional uint32 field12777 = 1; + optional uint32 field12778 = 2; + optional uint32 field12779 = 3; + optional uint32 field12780 = 4; + optional uint32 field12781 = 5; + optional bool field12782 = 6; +} + +message Message12796 { + repeated fixed64 field12800 = 1; + optional uint64 field12801 = 2; +} + +message Message12821 { + optional int32 field12848 = 1; + optional int32 field12849 = 2; + optional int32 field12850 = 3; + optional int32 field12851 = 4; + optional int32 field12852 = 5; +} + +message Message12820 { + optional int32 field12840 = 1; + optional int32 field12841 = 2; + optional int32 field12842 = 3; + optional int32 field12843 = 8; + optional int32 field12844 = 4; + optional int32 field12845 = 5; + optional int32 field12846 = 6; + optional int32 field12847 = 7; +} + +message Message12819 { + optional double field12834 = 1; + optional double field12835 = 2; + optional double field12836 = 3; + optional double field12837 = 4; + optional double field12838 = 5; + optional double field12839 = 6; +} + +message Message12818 { + optional uint64 field12829 = 1; + optional int32 field12830 = 2; + optional int32 field12831 = 3; + optional int32 field12832 = 5; + repeated .benchmarks.google_message4.Message12817 field12833 = 4; +} + +message Message10319 { + optional .benchmarks.google_message4.Enum10325 field10340 = 1; + optional int32 field10341 = 4; + optional int32 field10342 = 5; + optional bytes field10343 = 3; + optional string field10344 = 2; + optional string field10345 = 6; + optional string field10346 = 7; +} + +message Message6578 { + optional .benchmarks.google_message4.Enum6579 field6632 = 1; + optional .benchmarks.google_message4.Enum6588 field6633 = 2; +} + +message Message6126 { + required string field6152 = 1; + repeated .benchmarks.google_message4.Message6127 field6153 = 9; + optional int32 field6154 = 14; + optional bytes field6155 = 10; + optional .benchmarks.google_message4.Message6024 field6156 = 12; + optional int32 field6157 = 4; + optional string field6158 = 5; + optional int32 field6159 = 6; + repeated int32 field6160 = 2; + repeated int32 field6161 = 3; + repeated .benchmarks.google_message4.Message6052 field6162 = 7; + repeated .benchmarks.google_message4.UnusedEmptyMessage field6163 = 11; + optional .benchmarks.google_message4.Enum6065 field6164 = 15; + repeated .benchmarks.google_message4.Message6127 field6165 = 8; + optional bool field6166 = 13; + optional bool field6167 = 16; + optional bool field6168 = 18; + repeated .benchmarks.google_message4.Message6054 field6169 = 17; + optional int32 field6170 = 19; +} + +message Message5881 { + required double field5897 = 1; + optional string field5898 = 5; + optional .benchmarks.google_message4.Message5861 field5899 = 2; + optional .benchmarks.google_message4.UnusedEmptyMessage field5900 = 3; + optional .benchmarks.google_message4.Message5867 field5901 = 4; + optional .benchmarks.google_message4.Message5880 field5902 = 6; +} + +message Message6110 { +} + +message Message6107 { + optional .benchmarks.google_message4.Message4016 field6134 = 1; + optional int32 field6135 = 2; + optional string field6136 = 3; + repeated int32 field6137 = 4; + optional int32 field6138 = 5; + repeated .benchmarks.google_message4.Message6108 field6139 = 6; +} + +message Message6129 { + required .benchmarks.google_message4.Enum6130 field6171 = 1; + required string field6172 = 2; +} + +message Message5908 { + optional string field5971 = 1; + optional int32 field5972 = 2; + optional int32 field5973 = 3; + optional .benchmarks.google_message4.Enum5909 field5974 = 45; + optional .benchmarks.google_message4.Enum5912 field5975 = 4; + optional fixed32 field5976 = 50; + optional fixed32 field5977 = 5; + optional fixed32 field5978 = 6; + optional string field5979 = 7; + optional .benchmarks.google_message4.Enum5915 field5980 = 8; + optional .benchmarks.google_message4.Message5903 field5981 = 9; + optional .benchmarks.google_message4.Message5903 field5982 = 10; + optional .benchmarks.google_message4.Enum5920 field5983 = 11; + optional .benchmarks.google_message4.Enum5923 field5984 = 40; + optional .benchmarks.google_message4.Message5903 field5985 = 41; + optional .benchmarks.google_message4.Message5903 field5986 = 42; + optional .benchmarks.google_message4.Enum5928 field5987 = 47; + optional bool field5988 = 48; + repeated fixed32 field5989 = 49; + optional string field5990 = 12; + optional .benchmarks.google_message4.Message5903 field5991 = 13; + optional .benchmarks.google_message4.Message5903 field5992 = 14; + optional .benchmarks.google_message4.Message5903 field5993 = 15; + optional .benchmarks.google_message4.Message5903 field5994 = 16; + optional .benchmarks.google_message4.Message5903 field5995 = 32; + optional .benchmarks.google_message4.Message5903 field5996 = 33; + optional .benchmarks.google_message4.Message5903 field5997 = 34; + optional .benchmarks.google_message4.Message5903 field5998 = 35; + optional .benchmarks.google_message4.Enum5931 field5999 = 17; + optional .benchmarks.google_message4.Enum5935 field6000 = 18; + optional .benchmarks.google_message4.Enum5939 field6001 = 36; + optional .benchmarks.google_message4.Enum5939 field6002 = 37; + repeated int32 field6003 = 19; + optional uint32 field6004 = 20; + optional uint32 field6005 = 21; + optional uint32 field6006 = 22; + optional uint32 field6007 = 23; + optional .benchmarks.google_message4.Enum5946 field6008 = 24; + optional .benchmarks.google_message4.Enum5946 field6009 = 25; + optional .benchmarks.google_message4.Enum5946 field6010 = 26; + optional .benchmarks.google_message4.Enum5946 field6011 = 27; + optional fixed32 field6012 = 28; + optional fixed32 field6013 = 29; + optional fixed32 field6014 = 30; + optional fixed32 field6015 = 31; + optional int32 field6016 = 38; + optional float field6017 = 39; + optional .benchmarks.google_message4.Enum5957 field6018 = 43; + optional .benchmarks.google_message4.Message5907 field6019 = 44; + optional .benchmarks.google_message4.Enum5962 field6020 = 46; +} + +message Message3850 { + optional .benchmarks.google_message4.Enum3851 field3924 = 2; + optional bool field3925 = 12; + optional int32 field3926 = 4; + optional bool field3927 = 10; + optional bool field3928 = 13; + optional bool field3929 = 14; +} + +message Message7865 { +} + +message Message7511 { + optional bool field7523 = 1; + optional .benchmarks.google_message4.Enum7512 field7524 = 2; + optional int32 field7525 = 3; + optional int32 field7526 = 4; + optional bool field7527 = 5; + optional int32 field7528 = 6; + optional int32 field7529 = 7; +} + +message Message3920 { +} + +message Message7928 { + optional string field7940 = 1; + optional int64 field7941 = 2; +} + +message Message7921 { + optional int32 field7936 = 1; + optional int64 field7937 = 2; + optional float field7938 = 3; + optional .benchmarks.google_message4.Enum7922 field7939 = 4; +} + +message Message7920 { + optional int64 field7934 = 1; + optional int64 field7935 = 2; +} + +message Message7919 { + optional fixed64 field7931 = 1; + optional int64 field7932 = 2; + optional bytes field7933 = 3; +} + +message Message12817 { + optional int32 field12826 = 1; + optional int32 field12827 = 2; + optional int32 field12828 = 3; +} + +message Message6054 { + required string field6089 = 1; + optional string field6090 = 2; +} + +message Message6127 { +} + +message Message6052 { + required string field6084 = 1; + required bytes field6085 = 2; +} + +message Message6024 { + optional .benchmarks.google_message4.Enum6025 field6048 = 1; + optional string field6049 = 2; + optional .benchmarks.google_message4.UnusedEmptyMessage field6050 = 3; +} + +message Message5861 { + required .benchmarks.google_message4.Enum5862 field5882 = 1; + required string field5883 = 2; + optional bool field5884 = 3; + optional string field5885 = 4; +} + +message Message5880 { + optional string field5896 = 1; +} + +message Message5867 { + optional .benchmarks.google_message4.Enum5868 field5890 = 1; + optional string field5891 = 2; + optional .benchmarks.google_message4.Enum5873 field5892 = 3; + optional int32 field5893 = 4; + optional .benchmarks.google_message4.UnusedEnum field5894 = 5; + optional bool field5895 = 6; +} + +message Message4016 { + required int32 field4017 = 1; + required int32 field4018 = 2; + required int32 field4019 = 3; + required int32 field4020 = 4; +} + +message Message6108 { +} + +message Message5907 { + optional .benchmarks.google_message4.Message5903 field5967 = 1; + optional .benchmarks.google_message4.Message5903 field5968 = 2; + optional .benchmarks.google_message4.Message5903 field5969 = 3; + optional .benchmarks.google_message4.Message5903 field5970 = 4; +} + +message UnusedEmptyMessage { +} + +message Message5903 { + required int32 field5965 = 1; + optional .benchmarks.google_message4.Enum5904 field5966 = 2; +} + diff --git a/third_party/protobuf/benchmarks/datasets/google_message4/benchmark_message4_3.proto b/third_party/protobuf/benchmarks/datasets/google_message4/benchmark_message4_3.proto new file mode 100644 index 000000000000..544fad202aee --- /dev/null +++ b/third_party/protobuf/benchmarks/datasets/google_message4/benchmark_message4_3.proto @@ -0,0 +1,751 @@ +syntax = "proto2"; + +package benchmarks.google_message4; + +option cc_enable_arenas = true; +option java_package = "com.google.protobuf.benchmarks"; + +enum UnusedEnum { + UNUSED_ENUM_VALUE1 = 0; + UNUSED_ENUM_VALUE2 = 1; +} + +enum Enum2593 { + ENUM_VALUE2594 = 0; + ENUM_VALUE2595 = 1; + ENUM_VALUE2596 = 2; + ENUM_VALUE2597 = 3; + ENUM_VALUE2598 = 4; + ENUM_VALUE2599 = 5; + ENUM_VALUE2600 = 6; + ENUM_VALUE2601 = 7; +} + +enum Enum2834 { + ENUM_VALUE2835 = 0; + ENUM_VALUE2836 = 1; + ENUM_VALUE2837 = 2; +} + +enum Enum2806 { + ENUM_VALUE2807 = 0; + ENUM_VALUE2808 = 1; + ENUM_VALUE2809 = 2; + ENUM_VALUE2810 = 3; + ENUM_VALUE2811 = 4; + ENUM_VALUE2812 = 5; + ENUM_VALUE2813 = 6; + ENUM_VALUE2814 = 7; + ENUM_VALUE2815 = 8; + ENUM_VALUE2816 = 9; + ENUM_VALUE2817 = 10; + ENUM_VALUE2818 = 11; + ENUM_VALUE2819 = 12; + ENUM_VALUE2820 = 13; + ENUM_VALUE2821 = 14; +} + +enum Enum2851 { + option allow_alias = true; + ENUM_VALUE2852 = 0; + ENUM_VALUE2853 = 0; + ENUM_VALUE2854 = 1; + ENUM_VALUE2855 = 2; + ENUM_VALUE2856 = 3; + ENUM_VALUE2857 = 4; + ENUM_VALUE2858 = 5; + ENUM_VALUE2859 = 6; + ENUM_VALUE2860 = 7; + ENUM_VALUE2861 = 8; + ENUM_VALUE2862 = 9; + ENUM_VALUE2863 = 10; + ENUM_VALUE2864 = 11; + ENUM_VALUE2865 = 12; + ENUM_VALUE2866 = 13; + ENUM_VALUE2867 = 14; + ENUM_VALUE2868 = 15; + ENUM_VALUE2869 = 16; + ENUM_VALUE2870 = 17; + ENUM_VALUE2871 = 18; + ENUM_VALUE2872 = 19; + ENUM_VALUE2873 = 20; + ENUM_VALUE2874 = 21; + ENUM_VALUE2875 = 22; + ENUM_VALUE2876 = 23; + ENUM_VALUE2877 = 24; + ENUM_VALUE2878 = 25; + ENUM_VALUE2879 = 26; + ENUM_VALUE2880 = 27; + ENUM_VALUE2881 = 28; + ENUM_VALUE2882 = 29; + ENUM_VALUE2883 = 30; + ENUM_VALUE2884 = 31; + ENUM_VALUE2885 = 32; + ENUM_VALUE2886 = 33; + ENUM_VALUE2887 = 34; + ENUM_VALUE2888 = 35; + ENUM_VALUE2889 = 36; + ENUM_VALUE2890 = 37; + ENUM_VALUE2891 = 38; + ENUM_VALUE2892 = 39; + ENUM_VALUE2893 = 40; + ENUM_VALUE2894 = 41; + ENUM_VALUE2895 = 42; + ENUM_VALUE2896 = 43; + ENUM_VALUE2897 = 44; + ENUM_VALUE2898 = 45; + ENUM_VALUE2899 = 46; + ENUM_VALUE2900 = 47; + ENUM_VALUE2901 = 48; + ENUM_VALUE2902 = 49; + ENUM_VALUE2903 = 50; + ENUM_VALUE2904 = 51; + ENUM_VALUE2905 = 52; + ENUM_VALUE2906 = 53; + ENUM_VALUE2907 = 54; + ENUM_VALUE2908 = 55; + ENUM_VALUE2909 = 56; + ENUM_VALUE2910 = 57; + ENUM_VALUE2911 = 58; + ENUM_VALUE2912 = 59; + ENUM_VALUE2913 = 60; + ENUM_VALUE2914 = 61; + ENUM_VALUE2915 = 62; + ENUM_VALUE2916 = 63; + ENUM_VALUE2917 = 64; + ENUM_VALUE2918 = 65; + ENUM_VALUE2919 = 66; + ENUM_VALUE2920 = 67; + ENUM_VALUE2921 = 68; + ENUM_VALUE2922 = 69; + ENUM_VALUE2923 = 70; + ENUM_VALUE2924 = 71; + ENUM_VALUE2925 = 72; + ENUM_VALUE2926 = 73; + ENUM_VALUE2927 = 74; + ENUM_VALUE2928 = 75; + ENUM_VALUE2929 = 76; + ENUM_VALUE2930 = 77; + ENUM_VALUE2931 = 78; + ENUM_VALUE2932 = 79; + ENUM_VALUE2933 = 80; + ENUM_VALUE2934 = 81; + ENUM_VALUE2935 = 82; + ENUM_VALUE2936 = 83; + ENUM_VALUE2937 = 84; + ENUM_VALUE2938 = 85; + ENUM_VALUE2939 = 86; + ENUM_VALUE2940 = 87; + ENUM_VALUE2941 = 88; + ENUM_VALUE2942 = 89; + ENUM_VALUE2943 = 90; + ENUM_VALUE2944 = 91; + ENUM_VALUE2945 = 92; + ENUM_VALUE2946 = 93; + ENUM_VALUE2947 = 94; + ENUM_VALUE2948 = 95; + ENUM_VALUE2949 = 96; + ENUM_VALUE2950 = 97; + ENUM_VALUE2951 = 98; + ENUM_VALUE2952 = 99; + ENUM_VALUE2953 = 100; + ENUM_VALUE2954 = 101; + ENUM_VALUE2955 = 102; + ENUM_VALUE2956 = 103; + ENUM_VALUE2957 = 104; + ENUM_VALUE2958 = 105; + ENUM_VALUE2959 = 106; + ENUM_VALUE2960 = 107; + ENUM_VALUE2961 = 108; + ENUM_VALUE2962 = 109; + ENUM_VALUE2963 = 110; + ENUM_VALUE2964 = 111; + ENUM_VALUE2965 = 112; + ENUM_VALUE2966 = 113; + ENUM_VALUE2967 = 114; + ENUM_VALUE2968 = 115; + ENUM_VALUE2969 = 116; + ENUM_VALUE2970 = 117; + ENUM_VALUE2971 = 118; + ENUM_VALUE2972 = 119; +} + +enum Enum2602 { + ENUM_VALUE2603 = 0; + ENUM_VALUE2604 = 1; + ENUM_VALUE2605 = 2; + ENUM_VALUE2606 = 3; + ENUM_VALUE2607 = 4; + ENUM_VALUE2608 = 5; + ENUM_VALUE2609 = 6; + ENUM_VALUE2610 = 7; + ENUM_VALUE2611 = 8; + ENUM_VALUE2612 = 9; + ENUM_VALUE2613 = 10; + ENUM_VALUE2614 = 11; +} + +enum Enum3071 { + ENUM_VALUE3072 = 1; + ENUM_VALUE3073 = 2; + ENUM_VALUE3074 = 3; + ENUM_VALUE3075 = 4; + ENUM_VALUE3076 = 5; + ENUM_VALUE3077 = 6; + ENUM_VALUE3078 = 7; + ENUM_VALUE3079 = 8; + ENUM_VALUE3080 = 9; + ENUM_VALUE3081 = 10; + ENUM_VALUE3082 = 11; + ENUM_VALUE3083 = 12; + ENUM_VALUE3084 = 13; + ENUM_VALUE3085 = 14; + ENUM_VALUE3086 = 15; + ENUM_VALUE3087 = 16; + ENUM_VALUE3088 = 17; + ENUM_VALUE3089 = 18; + ENUM_VALUE3090 = 19; + ENUM_VALUE3091 = 20; + ENUM_VALUE3092 = 21; + ENUM_VALUE3093 = 22; + ENUM_VALUE3094 = 23; + ENUM_VALUE3095 = 24; + ENUM_VALUE3096 = 25; + ENUM_VALUE3097 = 26; + ENUM_VALUE3098 = 27; + ENUM_VALUE3099 = 28; +} + +enum Enum3805 { + ENUM_VALUE3806 = 0; + ENUM_VALUE3807 = 1; + ENUM_VALUE3808 = 2; + ENUM_VALUE3809 = 3; + ENUM_VALUE3810 = 4; + ENUM_VALUE3811 = 5; + ENUM_VALUE3812 = 6; + ENUM_VALUE3813 = 7; + ENUM_VALUE3814 = 8; + ENUM_VALUE3815 = 9; + ENUM_VALUE3816 = 11; + ENUM_VALUE3817 = 10; +} + +enum Enum3783 { + ENUM_VALUE3784 = 0; + ENUM_VALUE3785 = 1; + ENUM_VALUE3786 = 2; + ENUM_VALUE3787 = 3; + ENUM_VALUE3788 = 4; + ENUM_VALUE3789 = 5; + ENUM_VALUE3790 = 6; + ENUM_VALUE3791 = 7; + ENUM_VALUE3792 = 8; + ENUM_VALUE3793 = 9; + ENUM_VALUE3794 = 10; + ENUM_VALUE3795 = 11; + ENUM_VALUE3796 = 12; + ENUM_VALUE3797 = 13; + ENUM_VALUE3798 = 14; + ENUM_VALUE3799 = 15; + ENUM_VALUE3800 = 16; + ENUM_VALUE3801 = 20; + ENUM_VALUE3802 = 21; + ENUM_VALUE3803 = 50; +} + +enum Enum3851 { + ENUM_VALUE3852 = 0; + ENUM_VALUE3853 = 1; + ENUM_VALUE3854 = 2; + ENUM_VALUE3855 = 3; + ENUM_VALUE3856 = 4; + ENUM_VALUE3857 = 5; + ENUM_VALUE3858 = 6; + ENUM_VALUE3859 = 7; + ENUM_VALUE3860 = 8; + ENUM_VALUE3861 = 9; + ENUM_VALUE3862 = 10; + ENUM_VALUE3863 = 11; + ENUM_VALUE3864 = 12; + ENUM_VALUE3865 = 13; + ENUM_VALUE3866 = 14; + ENUM_VALUE3867 = 15; + ENUM_VALUE3868 = 16; + ENUM_VALUE3869 = 17; +} + +enum Enum5862 { + ENUM_VALUE5863 = 1; + ENUM_VALUE5864 = 2; + ENUM_VALUE5865 = 3; +} + +enum Enum5868 { + ENUM_VALUE5869 = 0; + ENUM_VALUE5870 = 1; + ENUM_VALUE5871 = 2; + ENUM_VALUE5872 = 3; +} + +enum Enum5873 { + ENUM_VALUE5874 = 0; + ENUM_VALUE5875 = 1; + ENUM_VALUE5876 = 2; +} + +enum Enum5904 { + ENUM_VALUE5905 = 0; + ENUM_VALUE5906 = 1; +} + +enum Enum5909 { + ENUM_VALUE5910 = 0; + ENUM_VALUE5911 = 1; +} + +enum Enum5912 { + ENUM_VALUE5913 = 0; + ENUM_VALUE5914 = 1; +} + +enum Enum5915 { + ENUM_VALUE5916 = 0; + ENUM_VALUE5917 = 1; + ENUM_VALUE5918 = 2; + ENUM_VALUE5919 = 3; +} + +enum Enum5920 { + ENUM_VALUE5921 = 0; + ENUM_VALUE5922 = 1; +} + +enum Enum5923 { + ENUM_VALUE5924 = 0; + ENUM_VALUE5925 = 1; + ENUM_VALUE5926 = 2; + ENUM_VALUE5927 = 3; +} + +enum Enum5928 { + ENUM_VALUE5929 = 0; + ENUM_VALUE5930 = 1; +} + +enum Enum5931 { + ENUM_VALUE5932 = 0; + ENUM_VALUE5933 = 1; + ENUM_VALUE5934 = 2; +} + +enum Enum5935 { + ENUM_VALUE5936 = 0; + ENUM_VALUE5937 = 1; + ENUM_VALUE5938 = 2; +} + +enum Enum5939 { + ENUM_VALUE5940 = 0; + ENUM_VALUE5941 = 1; + ENUM_VALUE5942 = 2; + ENUM_VALUE5943 = 3; + ENUM_VALUE5944 = 4; + ENUM_VALUE5945 = 5; +} + +enum Enum5946 { + ENUM_VALUE5947 = 0; + ENUM_VALUE5948 = 1; + ENUM_VALUE5949 = 2; + ENUM_VALUE5950 = 3; + ENUM_VALUE5951 = 4; + ENUM_VALUE5952 = 5; + ENUM_VALUE5953 = 6; + ENUM_VALUE5954 = 7; + ENUM_VALUE5955 = 8; + ENUM_VALUE5956 = 9; +} + +enum Enum5957 { + ENUM_VALUE5958 = 0; + ENUM_VALUE5959 = 1; + ENUM_VALUE5960 = 2; + ENUM_VALUE5961 = 3; +} + +enum Enum5962 { + ENUM_VALUE5963 = 0; + ENUM_VALUE5964 = 1; +} + +enum Enum6025 { + ENUM_VALUE6026 = 0; + ENUM_VALUE6027 = 1; + ENUM_VALUE6028 = 2; + ENUM_VALUE6029 = 3; + ENUM_VALUE6030 = 4; + ENUM_VALUE6031 = 5; + ENUM_VALUE6032 = 6; + ENUM_VALUE6033 = 7; + ENUM_VALUE6034 = 8; + ENUM_VALUE6035 = 9; + ENUM_VALUE6036 = 10; + ENUM_VALUE6037 = 11; + ENUM_VALUE6038 = 12; + ENUM_VALUE6039 = 13; + ENUM_VALUE6040 = 14; + ENUM_VALUE6041 = 15; + ENUM_VALUE6042 = 16; + ENUM_VALUE6043 = 17; + ENUM_VALUE6044 = 18; + ENUM_VALUE6045 = 19; + ENUM_VALUE6046 = 20; + ENUM_VALUE6047 = 21; +} + +enum Enum6111 { + ENUM_VALUE6112 = 1; + ENUM_VALUE6113 = 2; + ENUM_VALUE6114 = 3; + ENUM_VALUE6115 = 4; + ENUM_VALUE6116 = 5; + ENUM_VALUE6117 = 6; + ENUM_VALUE6118 = 7; + ENUM_VALUE6119 = 8; + ENUM_VALUE6120 = 9; + ENUM_VALUE6121 = 10; + ENUM_VALUE6122 = 11; + ENUM_VALUE6123 = 12; + ENUM_VALUE6124 = 13; + ENUM_VALUE6125 = 14; +} + +enum Enum6065 { + ENUM_VALUE6066 = 0; + ENUM_VALUE6067 = 1; + ENUM_VALUE6068 = 2; + ENUM_VALUE6069 = 3; + ENUM_VALUE6070 = 4; + ENUM_VALUE6071 = 5; + ENUM_VALUE6072 = 6; + ENUM_VALUE6073 = 7; + ENUM_VALUE6074 = 8; + ENUM_VALUE6075 = 9; + ENUM_VALUE6076 = 10; + ENUM_VALUE6077 = 11; + ENUM_VALUE6078 = 12; + ENUM_VALUE6079 = 13; + ENUM_VALUE6080 = 14; +} + +enum Enum6130 { + ENUM_VALUE6131 = 0; + ENUM_VALUE6132 = 1; +} + +enum Enum6579 { + ENUM_VALUE6580 = 0; + ENUM_VALUE6581 = 2; + ENUM_VALUE6582 = 3; + ENUM_VALUE6583 = 5; + ENUM_VALUE6584 = 10; + ENUM_VALUE6585 = 15; + ENUM_VALUE6586 = 25; + ENUM_VALUE6587 = 30; +} + +enum Enum6588 { + ENUM_VALUE6589 = 0; + ENUM_VALUE6590 = 1; + ENUM_VALUE6591 = 2; + ENUM_VALUE6592 = 3; + ENUM_VALUE6593 = 4; + ENUM_VALUE6594 = 5; + ENUM_VALUE6595 = 6; + ENUM_VALUE6596 = 7; + ENUM_VALUE6597 = 8; + ENUM_VALUE6598 = 9; + ENUM_VALUE6599 = 10; + ENUM_VALUE6600 = 11; + ENUM_VALUE6601 = 12; + ENUM_VALUE6602 = 13; + ENUM_VALUE6603 = 14; + ENUM_VALUE6604 = 15; + ENUM_VALUE6605 = 16; + ENUM_VALUE6606 = 17; + ENUM_VALUE6607 = 19; + ENUM_VALUE6608 = 20; + ENUM_VALUE6609 = 21; + ENUM_VALUE6610 = 22; + ENUM_VALUE6611 = 23; + ENUM_VALUE6612 = 24; + ENUM_VALUE6613 = 25; + ENUM_VALUE6614 = 26; + ENUM_VALUE6615 = 27; + ENUM_VALUE6616 = 28; + ENUM_VALUE6617 = 29; + ENUM_VALUE6618 = 30; + ENUM_VALUE6619 = 31; + ENUM_VALUE6620 = 32; + ENUM_VALUE6621 = 33; + ENUM_VALUE6622 = 34; +} + +enum Enum7288 { + ENUM_VALUE7289 = 0; + ENUM_VALUE7290 = 1; + ENUM_VALUE7291 = 2; + ENUM_VALUE7292 = 3; +} + +enum Enum7512 { + ENUM_VALUE7513 = 0; + ENUM_VALUE7514 = 1; + ENUM_VALUE7515 = 2; + ENUM_VALUE7516 = 3; + ENUM_VALUE7517 = 4; + ENUM_VALUE7518 = 5; + ENUM_VALUE7519 = 6; + ENUM_VALUE7520 = 7; +} + +enum Enum7922 { + ENUM_VALUE7923 = 1; + ENUM_VALUE7924 = 2; + ENUM_VALUE7925 = 3; + ENUM_VALUE7926 = 4; + ENUM_VALUE7927 = 5; +} + +enum Enum3476 { + ENUM_VALUE3477 = 0; + ENUM_VALUE3478 = 1; + ENUM_VALUE3479 = 2; + ENUM_VALUE3480 = 3; + ENUM_VALUE3481 = 4; + ENUM_VALUE3482 = 5; + ENUM_VALUE3483 = 6; + ENUM_VALUE3484 = 7; + ENUM_VALUE3485 = 8; + ENUM_VALUE3486 = 9; + ENUM_VALUE3487 = 10; + ENUM_VALUE3488 = 11; + ENUM_VALUE3489 = 12; + ENUM_VALUE3490 = 13; + ENUM_VALUE3491 = 14; + ENUM_VALUE3492 = 15; + ENUM_VALUE3493 = 16; + ENUM_VALUE3494 = 17; + ENUM_VALUE3495 = 18; + ENUM_VALUE3496 = 19; + ENUM_VALUE3497 = 20; + ENUM_VALUE3498 = 21; + ENUM_VALUE3499 = 22; + ENUM_VALUE3500 = 23; + ENUM_VALUE3501 = 24; + ENUM_VALUE3502 = 25; + ENUM_VALUE3503 = 26; + ENUM_VALUE3504 = 27; + ENUM_VALUE3505 = 28; + ENUM_VALUE3506 = 29; + ENUM_VALUE3507 = 30; + ENUM_VALUE3508 = 31; + ENUM_VALUE3509 = 32; + ENUM_VALUE3510 = 33; + ENUM_VALUE3511 = 34; + ENUM_VALUE3512 = 35; + ENUM_VALUE3513 = 36; + ENUM_VALUE3514 = 37; + ENUM_VALUE3515 = 38; + ENUM_VALUE3516 = 39; + ENUM_VALUE3517 = 40; + ENUM_VALUE3518 = 41; + ENUM_VALUE3519 = 42; + ENUM_VALUE3520 = 43; + ENUM_VALUE3521 = 44; + ENUM_VALUE3522 = 45; + ENUM_VALUE3523 = 46; + ENUM_VALUE3524 = 47; + ENUM_VALUE3525 = 48; + ENUM_VALUE3526 = 49; + ENUM_VALUE3527 = 50; + ENUM_VALUE3528 = 51; + ENUM_VALUE3529 = 52; + ENUM_VALUE3530 = 53; + ENUM_VALUE3531 = 54; + ENUM_VALUE3532 = 55; + ENUM_VALUE3533 = 56; + ENUM_VALUE3534 = 57; + ENUM_VALUE3535 = 58; + ENUM_VALUE3536 = 59; + ENUM_VALUE3537 = 60; + ENUM_VALUE3538 = 61; + ENUM_VALUE3539 = 62; + ENUM_VALUE3540 = 63; + ENUM_VALUE3541 = 64; + ENUM_VALUE3542 = 65; + ENUM_VALUE3543 = 66; + ENUM_VALUE3544 = 67; + ENUM_VALUE3545 = 68; + ENUM_VALUE3546 = 69; + ENUM_VALUE3547 = 70; + ENUM_VALUE3548 = 71; + ENUM_VALUE3549 = 72; + ENUM_VALUE3550 = 73; + ENUM_VALUE3551 = 74; + ENUM_VALUE3552 = 75; + ENUM_VALUE3553 = 76; + ENUM_VALUE3554 = 77; + ENUM_VALUE3555 = 78; + ENUM_VALUE3556 = 79; + ENUM_VALUE3557 = 80; + ENUM_VALUE3558 = 81; + ENUM_VALUE3559 = 82; + ENUM_VALUE3560 = 83; + ENUM_VALUE3561 = 84; + ENUM_VALUE3562 = 85; + ENUM_VALUE3563 = 86; + ENUM_VALUE3564 = 87; + ENUM_VALUE3565 = 88; + ENUM_VALUE3566 = 89; + ENUM_VALUE3567 = 90; + ENUM_VALUE3568 = 91; + ENUM_VALUE3569 = 92; + ENUM_VALUE3570 = 93; + ENUM_VALUE3571 = 94; + ENUM_VALUE3572 = 95; + ENUM_VALUE3573 = 96; + ENUM_VALUE3574 = 97; + ENUM_VALUE3575 = 98; + ENUM_VALUE3576 = 99; + ENUM_VALUE3577 = 100; + ENUM_VALUE3578 = 101; + ENUM_VALUE3579 = 102; + ENUM_VALUE3580 = 103; + ENUM_VALUE3581 = 104; + ENUM_VALUE3582 = 105; + ENUM_VALUE3583 = 106; + ENUM_VALUE3584 = 107; + ENUM_VALUE3585 = 108; + ENUM_VALUE3586 = 109; + ENUM_VALUE3587 = 110; + ENUM_VALUE3588 = 111; + ENUM_VALUE3589 = 112; + ENUM_VALUE3590 = 113; + ENUM_VALUE3591 = 114; + ENUM_VALUE3592 = 115; + ENUM_VALUE3593 = 116; + ENUM_VALUE3594 = 117; + ENUM_VALUE3595 = 118; + ENUM_VALUE3596 = 119; + ENUM_VALUE3597 = 120; + ENUM_VALUE3598 = 121; + ENUM_VALUE3599 = 122; + ENUM_VALUE3600 = 123; + ENUM_VALUE3601 = 124; + ENUM_VALUE3602 = 125; + ENUM_VALUE3603 = 126; + ENUM_VALUE3604 = 127; + ENUM_VALUE3605 = 128; + ENUM_VALUE3606 = 129; + ENUM_VALUE3607 = 130; + ENUM_VALUE3608 = 131; + ENUM_VALUE3609 = 132; + ENUM_VALUE3610 = 133; + ENUM_VALUE3611 = 134; + ENUM_VALUE3612 = 135; + ENUM_VALUE3613 = 136; + ENUM_VALUE3614 = 137; + ENUM_VALUE3615 = 138; + ENUM_VALUE3616 = 139; + ENUM_VALUE3617 = 140; + ENUM_VALUE3618 = 141; + ENUM_VALUE3619 = 142; + ENUM_VALUE3620 = 143; + ENUM_VALUE3621 = 144; + ENUM_VALUE3622 = 145; + ENUM_VALUE3623 = 146; + ENUM_VALUE3624 = 147; + ENUM_VALUE3625 = 148; + ENUM_VALUE3626 = 149; + ENUM_VALUE3627 = 150; + ENUM_VALUE3628 = 151; + ENUM_VALUE3629 = 152; + ENUM_VALUE3630 = 153; + ENUM_VALUE3631 = 154; + ENUM_VALUE3632 = 155; + ENUM_VALUE3633 = 156; + ENUM_VALUE3634 = 157; + ENUM_VALUE3635 = 158; + ENUM_VALUE3636 = 159; + ENUM_VALUE3637 = 160; + ENUM_VALUE3638 = 161; + ENUM_VALUE3639 = 162; + ENUM_VALUE3640 = 163; + ENUM_VALUE3641 = 164; + ENUM_VALUE3642 = 165; + ENUM_VALUE3643 = 166; + ENUM_VALUE3644 = 167; + ENUM_VALUE3645 = 168; + ENUM_VALUE3646 = 169; + ENUM_VALUE3647 = 170; + ENUM_VALUE3648 = 171; + ENUM_VALUE3649 = 172; + ENUM_VALUE3650 = 173; + ENUM_VALUE3651 = 174; + ENUM_VALUE3652 = 175; + ENUM_VALUE3653 = 176; + ENUM_VALUE3654 = 177; + ENUM_VALUE3655 = 178; + ENUM_VALUE3656 = 179; + ENUM_VALUE3657 = 180; + ENUM_VALUE3658 = 181; + ENUM_VALUE3659 = 182; + ENUM_VALUE3660 = 183; +} + +enum Enum10325 { + ENUM_VALUE10326 = 0; + ENUM_VALUE10327 = 1; + ENUM_VALUE10328 = 2; + ENUM_VALUE10329 = 3; + ENUM_VALUE10330 = 4; + ENUM_VALUE10331 = 5; + ENUM_VALUE10332 = 6; + ENUM_VALUE10333 = 7; + ENUM_VALUE10334 = 8; +} + +enum Enum10335 { + ENUM_VALUE10336 = 0; +} + +enum Enum10337 { + ENUM_VALUE10338 = 0; + ENUM_VALUE10339 = 1; +} + +enum Enum11901 { + ENUM_VALUE11902 = 0; + ENUM_VALUE11903 = 1; + ENUM_VALUE11904 = 2; + ENUM_VALUE11905 = 3; +} + +enum Enum12735 { + ENUM_VALUE12736 = 0; + ENUM_VALUE12737 = 1; + ENUM_VALUE12738 = 2; + ENUM_VALUE12739 = 3; +} + +enum Enum12871 { + ENUM_VALUE12872 = 1; + ENUM_VALUE12873 = 2; + ENUM_VALUE12874 = 3; + ENUM_VALUE12875 = 4; + ENUM_VALUE12876 = 5; + ENUM_VALUE12877 = 6; +} + diff --git a/third_party/protobuf/benchmarks/download_data.sh b/third_party/protobuf/benchmarks/download_data.sh new file mode 100755 index 000000000000..fa0729e9a336 --- /dev/null +++ b/third_party/protobuf/benchmarks/download_data.sh @@ -0,0 +1,5 @@ +#! /bin/sh + +curl -O https://storage.googleapis.com/protobuf_opensource_benchmark_data/datasets.tar.gz +tar -zvxf datasets.tar.gz + diff --git a/third_party/protobuf/benchmarks/generate_datasets.cc b/third_party/protobuf/benchmarks/generate_datasets.cc deleted file mode 100644 index 61e7adf1ba3f..000000000000 --- a/third_party/protobuf/benchmarks/generate_datasets.cc +++ /dev/null @@ -1,117 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include -#include -#include "benchmarks.pb.h" - -using benchmarks::BenchmarkDataset; -using google::protobuf::Descriptor; -using google::protobuf::DescriptorPool; -using google::protobuf::Message; -using google::protobuf::MessageFactory; - -std::set names; - -const char *file_prefix = "dataset."; -const char *file_suffix = ".pb"; - -void WriteFileWithPayloads(const std::string& name, - const std::string& message_name, - const std::vector& payload) { - if (!names.insert(name).second) { - std::cerr << "Duplicate test name: " << name << "\n"; - abort(); - } - - // First verify that this message name exists in our set of benchmark messages - // and that these payloads are valid for the given message. - const Descriptor* d = - DescriptorPool::generated_pool()->FindMessageTypeByName(message_name); - - if (!d) { - std::cerr << "For dataset " << name << ", no such message: " - << message_name << "\n"; - abort(); - } - - Message* m = MessageFactory::generated_factory()->GetPrototype(d)->New(); - - for (size_t i = 0; i < payload.size(); i++) { - if (!m->ParseFromString(payload[i])) { - std::cerr << "For dataset " << name << ", payload[" << i << "] fails " - << "to parse\n"; - abort(); - } - } - - BenchmarkDataset dataset; - dataset.set_name(name); - dataset.set_message_name(message_name); - for (size_t i = 0; i < payload.size(); i++) { - dataset.add_payload()->assign(payload[i]); - } - - std::ofstream writer; - std::string fname = file_prefix + name + file_suffix; - writer.open(fname.c_str()); - dataset.SerializeToOstream(&writer); - writer.close(); - - std::cerr << "Wrote dataset: " << fname << "\n"; -} - -void WriteFile(const std::string& name, const std::string& message_name, - const std::string& payload) { - std::vector payloads; - payloads.push_back(payload); - WriteFileWithPayloads(name, message_name, payloads); -} - -std::string ReadFile(const std::string& name) { - std::ifstream file(name.c_str()); - GOOGLE_CHECK(file.is_open()) << "Couldn't find file '" << name << - "', please make sure you are running " - "this command from the benchmarks/ " - "directory.\n"; - return std::string((std::istreambuf_iterator(file)), - std::istreambuf_iterator()); -} - -int main() { - WriteFile("google_message1_proto3", "benchmarks.proto3.GoogleMessage1", - ReadFile("google_message1.dat")); - WriteFile("google_message1_proto2", "benchmarks.proto2.GoogleMessage1", - ReadFile("google_message1.dat")); - - // Not in proto3 because it has a group, which is not supported. - WriteFile("google_message2", "benchmarks.proto2.GoogleMessage2", - ReadFile("google_message2.dat")); -} diff --git a/third_party/protobuf/benchmarks/go/go_benchmark_test.go b/third_party/protobuf/benchmarks/go/go_benchmark_test.go new file mode 100644 index 000000000000..8c741b710649 --- /dev/null +++ b/third_party/protobuf/benchmarks/go/go_benchmark_test.go @@ -0,0 +1,124 @@ +package main + +import ( + benchmarkWrapper "../tmp" + googleMessage1Proto2 "../tmp/datasets/google_message1/proto2" + googleMessage1Proto3 "../tmp/datasets/google_message1/proto3" + googleMessage2 "../tmp/datasets/google_message2" + googleMessage3 "../tmp/datasets/google_message3" + googleMessage4 "../tmp/datasets/google_message4" + "flag" + "github.com/golang/protobuf/proto" + "io/ioutil" + "testing" +) + +// Data is returned by the Load function. +type Dataset struct { + name string + newMessage func() proto.Message + marshaled [][]byte + unmarshaled []proto.Message +} + +var datasets []Dataset + +// This is used to getDefaultInstance for a message type. +func generateNewMessageFunction(dataset benchmarkWrapper.BenchmarkDataset) func() proto.Message { + switch dataset.MessageName { + case "benchmarks.proto3.GoogleMessage1": + return func() proto.Message { return new(googleMessage1Proto3.GoogleMessage1) } + case "benchmarks.proto2.GoogleMessage1": + return func() proto.Message { return new(googleMessage1Proto2.GoogleMessage1) } + case "benchmarks.proto2.GoogleMessage2": + return func() proto.Message { return new(googleMessage2.GoogleMessage2) } + case "benchmarks.google_message3.GoogleMessage3": + return func() proto.Message { return new(googleMessage3.GoogleMessage3) } + case "benchmarks.google_message4.GoogleMessage4": + return func() proto.Message { return new(googleMessage4.GoogleMessage4) } + default: + panic("Unknown message type: " + dataset.MessageName) + } +} + +func init() { + flag.Parse() + for _, f := range flag.Args() { + // Load the benchmark. + b, err := ioutil.ReadFile(f) + if err != nil { + panic(err) + } + + // Parse the benchmark. + var dm benchmarkWrapper.BenchmarkDataset + if err := proto.Unmarshal(b, &dm); err != nil { + panic(err) + } + + // Determine the concrete protobuf message type to use. + var ds Dataset + ds.newMessage = generateNewMessageFunction(dm) + + // Unmarshal each test message. + for _, payload := range dm.Payload { + ds.marshaled = append(ds.marshaled, payload) + m := ds.newMessage() + if err := proto.Unmarshal(payload, m); err != nil { + panic(err) + } + ds.unmarshaled = append(ds.unmarshaled, m) + } + ds.name = f + + datasets = append(datasets, ds) + } +} + +func Benchmark(b *testing.B) { + for _, ds := range datasets { + b.Run(ds.name, func(b *testing.B) { + b.Run("Unmarshal", func(b *testing.B) { + for i := 0; i < b.N; i++ { + for j, payload := range ds.marshaled { + out := ds.newMessage() + if err := proto.Unmarshal(payload, out); err != nil { + b.Fatalf("can't unmarshal message %d %v", j, err) + } + } + } + }) + b.Run("Marshal", func(b *testing.B) { + for i := 0; i < b.N; i++ { + for j, m := range ds.unmarshaled { + if _, err := proto.Marshal(m); err != nil { + b.Fatalf("can't marshal message %d %+v: %v", j, m, err) + } + } + } + }) + b.Run("Size", func(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, m := range ds.unmarshaled { + proto.Size(m) + } + } + }) + b.Run("Clone", func(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, m := range ds.unmarshaled { + proto.Clone(m) + } + } + }) + b.Run("Merge", func(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, m := range ds.unmarshaled { + out := ds.newMessage() + proto.Merge(out, m) + } + } + }) + }) + } +} diff --git a/third_party/protobuf/benchmarks/java/pom.xml b/third_party/protobuf/benchmarks/java/pom.xml new file mode 100644 index 000000000000..570bd6644fd7 --- /dev/null +++ b/third_party/protobuf/benchmarks/java/pom.xml @@ -0,0 +1,98 @@ + + + + 4.0.0 + protobuf-java-benchmark + com.google.protobuf + 1.0.0 + Protocol Buffers [Benchmark] + The benchmark tools for Protobuf Java. + + + + com.google.protobuf + protobuf-java + ${protobuf.version} + jar + system + ${project.basedir}/lib/protobuf-java.jar + + + com.google.caliper + caliper + 1.0-beta-2 + + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.4.1 + + + + jar-with-dependencies + + + + + com.mkyong.core.utils.App + + + + + + make-assembly + + package + + single + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-jar-plugin + 2.5 + + + + true + com.google.protocolbuffers.ProtoBench + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.4 + + + attach-sources + + jar-no-fork + + + + + + + + + diff --git a/third_party/protobuf/benchmarks/java/src/main/java/com/google/protobuf/ProtoCaliperBenchmark.java b/third_party/protobuf/benchmarks/java/src/main/java/com/google/protobuf/ProtoCaliperBenchmark.java new file mode 100644 index 000000000000..a4402481b0a0 --- /dev/null +++ b/third_party/protobuf/benchmarks/java/src/main/java/com/google/protobuf/ProtoCaliperBenchmark.java @@ -0,0 +1,214 @@ + +package com.google.protobuf; + +import com.google.caliper.BeforeExperiment; +import com.google.caliper.AfterExperiment; +import com.google.caliper.Benchmark; +import com.google.caliper.Param; +import com.google.caliper.api.VmOptions; +import com.google.protobuf.ByteString; +import com.google.protobuf.CodedOutputStream; +import com.google.protobuf.ExtensionRegistry; +import com.google.protobuf.Message; +import com.google.protobuf.benchmarks.Benchmarks.BenchmarkDataset; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.util.ArrayList; +import java.util.List; + +// Caliper set CICompilerCount to 1 for making sure compilation doesn't run in parallel with itself, +// This makes TieredCompilation not working. We just disable TieredCompilation by default. In master +// branch this has been disabled by default in caliper: +// https://github.com/google/caliper/blob/master/caliper-runner/src/main/java/com/google/caliper/runner/target/Jvm.java#L38:14 +// But this haven't been added into most recent release. +@VmOptions("-XX:-TieredCompilation") +public class ProtoCaliperBenchmark { + public enum BenchmarkMessageType { + GOOGLE_MESSAGE1_PROTO3 { + @Override ExtensionRegistry getExtensionRegistry() { return ExtensionRegistry.newInstance(); } + @Override + Message getDefaultInstance() { + return com.google.protobuf.benchmarks.BenchmarkMessage1Proto3.GoogleMessage1 + .getDefaultInstance(); + } + }, + GOOGLE_MESSAGE1_PROTO2 { + @Override ExtensionRegistry getExtensionRegistry() { return ExtensionRegistry.newInstance(); } + @Override + Message getDefaultInstance() { + return com.google.protobuf.benchmarks.BenchmarkMessage1Proto2.GoogleMessage1 + .getDefaultInstance(); + } + }, + GOOGLE_MESSAGE2 { + @Override ExtensionRegistry getExtensionRegistry() { return ExtensionRegistry.newInstance(); } + @Override + Message getDefaultInstance() { + return com.google.protobuf.benchmarks.BenchmarkMessage2.GoogleMessage2.getDefaultInstance(); + } + }, + GOOGLE_MESSAGE3 { + @Override + ExtensionRegistry getExtensionRegistry() { + ExtensionRegistry extensions = ExtensionRegistry.newInstance(); + com.google.protobuf.benchmarks.BenchmarkMessage38.registerAllExtensions(extensions); + com.google.protobuf.benchmarks.BenchmarkMessage37.registerAllExtensions(extensions); + com.google.protobuf.benchmarks.BenchmarkMessage36.registerAllExtensions(extensions); + com.google.protobuf.benchmarks.BenchmarkMessage35.registerAllExtensions(extensions); + com.google.protobuf.benchmarks.BenchmarkMessage34.registerAllExtensions(extensions); + com.google.protobuf.benchmarks.BenchmarkMessage33.registerAllExtensions(extensions); + com.google.protobuf.benchmarks.BenchmarkMessage32.registerAllExtensions(extensions); + com.google.protobuf.benchmarks.BenchmarkMessage31.registerAllExtensions(extensions); + com.google.protobuf.benchmarks.BenchmarkMessage3.registerAllExtensions(extensions); + return extensions; + } + @Override + Message getDefaultInstance() { + return com.google.protobuf.benchmarks.BenchmarkMessage3.GoogleMessage3.getDefaultInstance(); + } + }, + GOOGLE_MESSAGE4 { + @Override + ExtensionRegistry getExtensionRegistry() { + ExtensionRegistry extensions = ExtensionRegistry.newInstance(); + com.google.protobuf.benchmarks.BenchmarkMessage43.registerAllExtensions(extensions); + com.google.protobuf.benchmarks.BenchmarkMessage42.registerAllExtensions(extensions); + com.google.protobuf.benchmarks.BenchmarkMessage41.registerAllExtensions(extensions); + com.google.protobuf.benchmarks.BenchmarkMessage4.registerAllExtensions(extensions); + return extensions; + } + @Override + Message getDefaultInstance() { + return com.google.protobuf.benchmarks.BenchmarkMessage4.GoogleMessage4.getDefaultInstance(); + } + }; + + abstract ExtensionRegistry getExtensionRegistry(); + abstract Message getDefaultInstance(); + } + + private BenchmarkMessageType benchmarkMessageType; + @Param("") + private String dataFile; + + private byte[] inputData; + private BenchmarkDataset benchmarkDataset; + private Message defaultMessage; + private ExtensionRegistry extensions; + private List inputDataList; + private List inputStreamList; + private List inputStringList; + private List sampleMessageList; + + private BenchmarkMessageType getMessageType() throws IOException { + if (benchmarkDataset.getMessageName().equals("benchmarks.proto3.GoogleMessage1")) { + return BenchmarkMessageType.GOOGLE_MESSAGE1_PROTO3; + } else if (benchmarkDataset.getMessageName().equals("benchmarks.proto2.GoogleMessage1")) { + return BenchmarkMessageType.GOOGLE_MESSAGE1_PROTO2; + } else if (benchmarkDataset.getMessageName().equals("benchmarks.proto2.GoogleMessage2")) { + return BenchmarkMessageType.GOOGLE_MESSAGE2; + } else if (benchmarkDataset.getMessageName(). + equals("benchmarks.google_message3.GoogleMessage3")) { + return BenchmarkMessageType.GOOGLE_MESSAGE3; + } else if (benchmarkDataset.getMessageName(). + equals("benchmarks.google_message4.GoogleMessage4")) { + return BenchmarkMessageType.GOOGLE_MESSAGE4; + } else { + throw new IllegalStateException("Invalid DataFile! There's no testing message named " + + benchmarkDataset.getMessageName()); + } + } + + @BeforeExperiment + void setUp() throws IOException { + if (!dataFile.equals("")) { + RandomAccessFile file = new RandomAccessFile(new File(dataFile), "r"); + inputData = new byte[(int) file.length()]; + file.readFully(inputData); + benchmarkDataset = BenchmarkDataset.parseFrom(inputData); + benchmarkMessageType = getMessageType(); + } else { + inputData = new byte[0]; + benchmarkDataset = BenchmarkDataset.parseFrom(inputData); + benchmarkMessageType = BenchmarkMessageType.GOOGLE_MESSAGE2; + } + defaultMessage = benchmarkMessageType.getDefaultInstance(); + extensions = benchmarkMessageType.getExtensionRegistry(); + inputDataList = new ArrayList(); + inputStreamList = new ArrayList(); + inputStringList = new ArrayList(); + sampleMessageList = new ArrayList(); + + for (int i = 0; i < benchmarkDataset.getPayloadCount(); i++) { + byte[] singleInputData = benchmarkDataset.getPayload(i).toByteArray(); + inputDataList.add(benchmarkDataset.getPayload(i).toByteArray()); + inputStreamList.add(new ByteArrayInputStream( + benchmarkDataset.getPayload(i).toByteArray())); + inputStringList.add(benchmarkDataset.getPayload(i)); + sampleMessageList.add( + defaultMessage.newBuilderForType().mergeFrom(singleInputData, extensions).build()); + } + } + + + @Benchmark + void serializeToByteArray(int reps) throws IOException { + if (sampleMessageList.size() == 0) { + return; + } + for (int i = 0; i < reps; i++) { + for (int j = 0; j < sampleMessageList.size(); j++) { + sampleMessageList.get(j).toByteArray(); + } + } + } + + @Benchmark + void serializeToMemoryStream(int reps) throws IOException { + if (sampleMessageList.size() == 0) { + return; + } + for (int i = 0; i < reps; i++) { + for (int j = 0; j < sampleMessageList.size(); j++) { + ByteArrayOutputStream output = new ByteArrayOutputStream(); + sampleMessageList.get(j).writeTo(output); + } + } + } + + @Benchmark + void deserializeFromByteArray(int reps) throws IOException { + if (inputDataList.size() == 0) { + return; + } + for (int i = 0; i < reps; i++) { + for (int j = 0; j < inputDataList.size(); j++) { + benchmarkMessageType.getDefaultInstance().getParserForType().parseFrom( + inputDataList.get(j), extensions); + } + } + } + + @Benchmark + void deserializeFromMemoryStream(int reps) throws IOException { + if (inputStreamList.size() == 0) { + return; + } + for (int i = 0; i < reps; i++) { + for (int j = 0; j < inputStreamList.size(); j++) { + benchmarkMessageType.getDefaultInstance().getParserForType().parseFrom( + inputStreamList.get(j), extensions); + inputStreamList.get(j).reset(); + } + } + } +} + + diff --git a/third_party/protobuf/benchmarks/js/benchmark_suite.js b/third_party/protobuf/benchmarks/js/benchmark_suite.js new file mode 100644 index 000000000000..c5c3e5105a48 --- /dev/null +++ b/third_party/protobuf/benchmarks/js/benchmark_suite.js @@ -0,0 +1,33 @@ +var benchmark = require("benchmark"); + +function newBenchmark(messageName, filename, language) { + var benches = []; + return { + suite: new benchmark.Suite(messageName + filename + language ) + .on("add", function(event) { + benches.push(event.target); + }) + .on("start", function() { + process.stdout.write( + "benchmarking message " + messageName + + " of dataset file " + filename + + "'s performance ..." + "\n\n"); + }) + .on("cycle", function(event) { + process.stdout.write(String(event.target) + "\n"); + }) + .on("complete", function() { + var getHz = function(bench) { + return 1 / (bench.stats.mean + bench.stats.moe); + } + benches.forEach(function(val, index) { + benches[index] = getHz(val); + }); + }), + benches: benches + } +} + +module.exports = { + newBenchmark: newBenchmark +} diff --git a/third_party/protobuf/benchmarks/js/js_benchmark.js b/third_party/protobuf/benchmarks/js/js_benchmark.js new file mode 100644 index 000000000000..c44fee01c39c --- /dev/null +++ b/third_party/protobuf/benchmarks/js/js_benchmark.js @@ -0,0 +1,82 @@ +require('./datasets/google_message1/proto2/benchmark_message1_proto2_pb.js'); +require('./datasets/google_message1/proto3/benchmark_message1_proto3_pb.js'); +require('./datasets/google_message2/benchmark_message2_pb.js'); +require('./datasets/google_message3/benchmark_message3_pb.js'); +require('./datasets/google_message4/benchmark_message4_pb.js'); +require('./benchmarks_pb.js'); + +var fs = require('fs'); +var benchmarkSuite = require("./benchmark_suite.js"); + + +function getNewPrototype(name) { + var message = eval("proto." + name); + if (typeof(message) == "undefined") { + throw "type " + name + " is undefined"; + } + return message; +} + +var results = []; +var json_file = ""; + +console.log("#####################################################"); +console.log("Js Benchmark: "); +process.argv.forEach(function(filename, index) { + if (index < 2) { + return; + } + if (filename.indexOf("--json_output") != -1) { + json_file = filename.replace(/^--json_output=/, ''); + return; + } + + var benchmarkDataset = + proto.benchmarks.BenchmarkDataset.deserializeBinary(fs.readFileSync(filename)); + var messageList = []; + var totalBytes = 0; + benchmarkDataset.getPayloadList().forEach(function(onePayload) { + var message = getNewPrototype(benchmarkDataset.getMessageName()); + messageList.push(message.deserializeBinary(onePayload)); + totalBytes += onePayload.length; + }); + + var senarios = benchmarkSuite.newBenchmark( + benchmarkDataset.getMessageName(), filename, "js"); + senarios.suite + .add("js deserialize", function() { + benchmarkDataset.getPayloadList().forEach(function(onePayload) { + var protoType = getNewPrototype(benchmarkDataset.getMessageName()); + protoType.deserializeBinary(onePayload); + }); + }) + .add("js serialize", function() { + var protoType = getNewPrototype(benchmarkDataset.getMessageName()); + messageList.forEach(function(message) { + message.serializeBinary(); + }); + }) + .run({"Async": false}); + + results.push({ + filename: filename, + benchmarks: { + protobufjs_decoding: senarios.benches[0] * totalBytes / 1024 / 1024, + protobufjs_encoding: senarios.benches[1] * totalBytes / 1024 / 1024 + } + }) + + console.log("Throughput for deserialize: " + + senarios.benches[0] * totalBytes / 1024 / 1024 + "MB/s" ); + console.log("Throughput for serialize: " + + senarios.benches[1] * totalBytes / 1024 / 1024 + "MB/s" ); + console.log(""); +}); +console.log("#####################################################"); + +if (json_file != "") { + fs.writeFile(json_file, JSON.stringify(results), (err) => { + if (err) throw err; + }); +} + diff --git a/third_party/protobuf/benchmarks/php/PhpBenchmark.php b/third_party/protobuf/benchmarks/php/PhpBenchmark.php new file mode 100644 index 000000000000..d3db61d248da --- /dev/null +++ b/third_party/protobuf/benchmarks/php/PhpBenchmark.php @@ -0,0 +1,170 @@ +getPayload(); + for ($i = $payloads->count() - 1; $i >= 0; $i--) { + (new $args[1]())->mergeFromString($payloads->offsetGet($i)); + } + } + + // $args: array of message + static function serialize(&$args) { + foreach ($args as &$temp_message) { + $temp_message->serializeToString(); + } + } +} + +class Benchmark +{ + private $benchmark_name; + private $args; + private $benchmark_time; + private $total_bytes; + private $coefficient; + + public function __construct($benchmark_name, $args, $total_bytes, + $benchmark_time = 5.0) { + $this->args = $args; + $this->benchmark_name = $benchmark_name; + $this->benchmark_time = $benchmark_time; + $this->total_bytes = $total_bytes; + $this->coefficient = pow (10, 0) / pow(2, 20); + } + + public function runBenchmark() { + $t = $this->runBenchmarkWithTimes(1); + $times = ceil($this->benchmark_time / $t); + return $this->total_bytes * $times / + ($times == 1 ? $t : $this->runBenchmarkWithTimes($times)) * + $this->coefficient; + } + + private function runBenchmarkWithTimes($times) { + $st = microtime(true); + for ($i = 0; $i < $times; $i++) { + call_user_func_array($this->benchmark_name, array(&$this->args)); + } + $en = microtime(true); + return $en - $st; + } +} + +function getMessageName(&$dataset) { + switch ($dataset->getMessageName()) { + case "benchmarks.proto3.GoogleMessage1": + return "\Benchmarks\Proto3\GoogleMessage1"; + case "benchmarks.proto2.GoogleMessage1": + return "\Benchmarks\Proto2\GoogleMessage1"; + case "benchmarks.proto2.GoogleMessage2": + return "\Benchmarks\Proto2\GoogleMessage2"; + case "benchmarks.google_message3.GoogleMessage3": + return "\Benchmarks\Google_message3\GoogleMessage3"; + case "benchmarks.google_message4.GoogleMessage4": + return "\Benchmarks\Google_message4\GoogleMessage4"; + default: + exit("Message " . $dataset->getMessageName() . " not found !"); + } +} + +function runBenchmark($file, $behavior_prefix) { + $datafile = fopen($file, "r") or die("Unable to open file " . $file); + $bytes = fread($datafile, filesize($file)); + $dataset = new BenchmarkDataset(NULL); + $dataset->mergeFromString($bytes); + $message_name = getMessageName($dataset); + $message_list = array(); + $total_bytes = 0; + $payloads = $dataset->getPayload(); + for ($i = $payloads->count() - 1; $i >= 0; $i--) { + $new_message = new $message_name(); + $new_message->mergeFromString($payloads->offsetGet($i)); + array_push($message_list, $new_message); + $total_bytes += strlen($payloads->offsetGet($i)); + } + + $parse_benchmark = new Benchmark( + "\Google\Protobuf\Benchmark\BenchmarkMethod::parse", + array($dataset, $message_name), $total_bytes); + $serialize_benchmark = new Benchmark( + "\Google\Protobuf\Benchmark\BenchmarkMethod::serialize", + $message_list, $total_bytes); + + return array( + "filename" => $file, + "benchmarks" => array( + $behavior_prefix . "_parse" => $parse_benchmark->runBenchmark(), + $behavior_prefix . "_serailize" => $serialize_benchmark->runBenchmark() + ), + "message_name" => $dataset->getMessageName() + ); +} + +// main +$json_output = false; +$results = array(); +$behavior_prefix = ""; + +foreach ($argv as $index => $arg) { + if ($index == 0) { + continue; + } + if ($arg == "--json") { + $json_output = true; + } else if (strpos($arg, "--behavior_prefix") == 0) { + $behavior_prefix = str_replace("--behavior_prefix=", "", $arg); + } +} + +foreach ($argv as $index => $arg) { + if ($index == 0) { + continue; + } + if (substr($arg, 0, 2) == "--") { + continue; + } else { + array_push($results, runBenchmark($arg, $behavior_prefix)); + } +} + +if ($json_output) { + print json_encode($results); +} else { + print "PHP protobuf benchmark result:\n\n"; + foreach ($results as $result) { + printf("result for test data file: %s\n", $result["filename"]); + foreach ($result["benchmarks"] as $benchmark => $throughput) { + printf(" Throughput for benchmark %s: %.2f MB/s\n", + $benchmark, $throughput); + } + } +} + +?> diff --git a/third_party/protobuf/benchmarks/php/autoload.php b/third_party/protobuf/benchmarks/php/autoload.php new file mode 100644 index 000000000000..52a8741f80f0 --- /dev/null +++ b/third_party/protobuf/benchmarks/php/autoload.php @@ -0,0 +1,25 @@ + 6 && arg.substring(arg.length - 6) == ".proto") { + protoFiles.push(arg); + } else if (arg.length > 15 && arg.substring(0, 15) == "--include_path=") { + prefix = arg.substring(15); + } else if (index >= 2) { + argv.push(arg); + } +}); +protoFiles.forEach(function(val) { + argv.push(prefix + "/" + val); +}); + +pbjs.main(argv, function(err, output){ + if (err) { + console.log(err); + } +}); + diff --git a/third_party/protobuf/benchmarks/protobuf.js/protobufjs_benchmark.js b/third_party/protobuf/benchmarks/protobuf.js/protobufjs_benchmark.js new file mode 100644 index 000000000000..19e54972b86d --- /dev/null +++ b/third_party/protobuf/benchmarks/protobuf.js/protobufjs_benchmark.js @@ -0,0 +1,66 @@ +var root = require("./generated_bundle_code.js"); +var fs = require('fs'); +var benchmark = require("./node_modules/benchmark"); +var benchmarkSuite = require("./benchmark_suite.js"); + + +function getNewPrototype(name) { + var message = eval("root." + name); + if (typeof(message) == "undefined") { + throw "type " + name + " is undefined"; + } + return message; +} + + +var results = []; + +console.log("#####################################################"); +console.log("ProtobufJs Benchmark: "); +process.argv.forEach(function(filename, index) { + if (index < 2) { + return; + } + var benchmarkDataset = + root.benchmarks.BenchmarkDataset.decode(fs.readFileSync(filename)); + var messageList = []; + var totalBytes = 0; + benchmarkDataset.payload.forEach(function(onePayload) { + var message = getNewPrototype(benchmarkDataset.messageName); + messageList.push(message.decode(onePayload)); + totalBytes += onePayload.length; + }); + + var senarios = benchmarkSuite.newBenchmark( + benchmarkDataset.messageName, filename, "protobufjs"); + senarios.suite + .add("protobuf.js static decoding", function() { + benchmarkDataset.payload.forEach(function(onePayload) { + var protoType = getNewPrototype(benchmarkDataset.messageName); + protoType.decode(onePayload); + }); + }) + .add("protobuf.js static encoding", function() { + var protoType = getNewPrototype(benchmarkDataset.messageName); + messageList.forEach(function(message) { + protoType.encode(message).finish(); + }); + }) + .run({"Async": false}); + + results.push({ + filename: filename, + benchmarks: { + protobufjs_decoding: senarios.benches[0] * totalBytes, + protobufjs_encoding: senarios.benches[1] * totalBytes + } + }) + + console.log("Throughput for decoding: " + + senarios.benches[0] * totalBytes / 1024 / 1024 + "MB/s" ); + console.log("Throughput for encoding: " + + senarios.benches[1] * totalBytes / 1024 / 1024 + "MB/s" ); + console.log(""); +}); +console.log("#####################################################"); + diff --git a/third_party/protobuf/benchmarks/python/__init__.py b/third_party/protobuf/benchmarks/python/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/third_party/protobuf/benchmarks/python/py_benchmark.py b/third_party/protobuf/benchmarks/python/py_benchmark.py new file mode 100755 index 000000000000..60e377e4b8cc --- /dev/null +++ b/third_party/protobuf/benchmarks/python/py_benchmark.py @@ -0,0 +1,161 @@ +from __future__ import print_function +import sys +import os +import timeit +import math +import argparse +import fnmatch +import json + +parser = argparse.ArgumentParser(description="Python protobuf benchmark") +parser.add_argument("data_files", metavar="dataFile", nargs="+", + help="testing data files.") +parser.add_argument("--json", action="store_const", dest="json", + const="yes", default="no", + help="Whether to output json results") +parser.add_argument("--behavior_prefix", dest="behavior_prefix", + help="The output json format's behavior's name's prefix", + default="") +# BEGIN CPP GENERATED MESSAGE +parser.add_argument("--cpp_generated", action="store_const", + dest="cpp_generated", const="yes", default="no", + help="Whether to link generated code library") +# END CPP GENERATED MESSAGE +args = parser.parse_args() +# BEGIN CPP GENERATED MESSAGE +# CPP generated code must be linked before importing the generated Python code +# for the descriptor can be found in the pool +if args.cpp_generated != "no": + sys.path.append( os.path.dirname( os.path.dirname( os.path.abspath(__file__) ) ) + "/.libs" ) + import libbenchmark_messages + sys.path.append( os.path.dirname( os.path.dirname( os.path.abspath(__file__) ) ) + "/tmp" ) +# END CPP GENERATED MESSAGE + + +import datasets.google_message1.proto2.benchmark_message1_proto2_pb2 as benchmark_message1_proto2_pb2 +import datasets.google_message1.proto3.benchmark_message1_proto3_pb2 as benchmark_message1_proto3_pb2 +import datasets.google_message2.benchmark_message2_pb2 as benchmark_message2_pb2 +import datasets.google_message3.benchmark_message3_pb2 as benchmark_message3_pb2 +import datasets.google_message4.benchmark_message4_pb2 as benchmark_message4_pb2 +import benchmarks_pb2 as benchmarks_pb2 + + +def run_one_test(filename): + data = open(filename, "rb").read() + benchmark_dataset = benchmarks_pb2.BenchmarkDataset() + benchmark_dataset.ParseFromString(data) + total_bytes = 0 + for payload in benchmark_dataset.payload: + total_bytes += len(payload) + benchmark_util = Benchmark(full_iteration=len(benchmark_dataset.payload), + module="py_benchmark", + setup_method="init", + total_bytes=total_bytes) + result={} + result["filename"] = filename + result["message_name"] = benchmark_dataset.message_name + result["benchmarks"] = {} + benchmark_util.set_test_method("parse_from_benchmark") + result["benchmarks"][args.behavior_prefix + "_parse_from_benchmark"] = \ + benchmark_util.run_benchmark(setup_method_args='"%s"' % (filename)) + benchmark_util.set_test_method("serialize_to_benchmark") + result["benchmarks"][args.behavior_prefix + "_serialize_to_benchmark"] = \ + benchmark_util.run_benchmark(setup_method_args='"%s"' % (filename)) + return result + + +def init(filename): + global benchmark_dataset, message_class, message_list, counter, total_bytes + message_list=[] + counter = 0 + total_bytes = 0 + data = open(filename, "rb").read() + benchmark_dataset = benchmarks_pb2.BenchmarkDataset() + benchmark_dataset.ParseFromString(data) + + if benchmark_dataset.message_name == "benchmarks.proto3.GoogleMessage1": + message_class = benchmark_message1_proto3_pb2.GoogleMessage1 + elif benchmark_dataset.message_name == "benchmarks.proto2.GoogleMessage1": + message_class = benchmark_message1_proto2_pb2.GoogleMessage1 + elif benchmark_dataset.message_name == "benchmarks.proto2.GoogleMessage2": + message_class = benchmark_message2_pb2.GoogleMessage2 + elif benchmark_dataset.message_name == "benchmarks.google_message3.GoogleMessage3": + message_class = benchmark_message3_pb2.GoogleMessage3 + elif benchmark_dataset.message_name == "benchmarks.google_message4.GoogleMessage4": + message_class = benchmark_message4_pb2.GoogleMessage4 + else: + raise IOError("Message %s not found!" % (benchmark_dataset.message_name)) + + for one_payload in benchmark_dataset.payload: + temp = message_class() + temp.ParseFromString(one_payload) + message_list.append(temp) + total_bytes += len(one_payload) + + +def parse_from_benchmark(): + global counter, message_class, benchmark_dataset + m = message_class().ParseFromString(benchmark_dataset.payload[counter % len(benchmark_dataset.payload)]) + counter = counter + 1 + + +def serialize_to_benchmark(): + global counter, message_list, message_class + s = message_list[counter % len(benchmark_dataset.payload)].SerializeToString() + counter = counter + 1 + + +class Benchmark: + def __init__(self, module=None, test_method=None, + setup_method=None, total_bytes=None, full_iteration = 1): + self.full_iteration = full_iteration + self.module = module + self.test_method = test_method + self.setup_method = setup_method + self.total_bytes = total_bytes + + def set_test_method(self, test_method): + self.test_method = test_method + + def full_setup_code(self, setup_method_args=''): + setup_code = "" + setup_code += "from %s import %s\n" % (self.module, self.test_method) + setup_code += "from %s import %s\n" % (self.module, self.setup_method) + setup_code += "%s(%s)\n" % (self.setup_method, setup_method_args) + return setup_code + + def dry_run(self, test_method_args='', setup_method_args=''): + return timeit.timeit(stmt="%s(%s)" % (self.test_method, test_method_args), + setup=self.full_setup_code(setup_method_args), + number=self.full_iteration); + + def run_benchmark(self, test_method_args='', setup_method_args=''): + reps = self.full_iteration; + t = self.dry_run(test_method_args, setup_method_args); + if t < 3 : + reps = int(math.ceil(3 / t)) * self.full_iteration + if reps != self.full_iteration: + t = timeit.timeit(stmt="%s(%s)" % (self.test_method, test_method_args), + setup=self.full_setup_code(setup_method_args), + number=reps); + return self.total_bytes * 1.0 / 2 ** 20 / (1.0 * t / reps * self.full_iteration) + + +if __name__ == "__main__": + results = [] + for file in args.data_files: + results.append(run_one_test(file)) + + if args.json != "no": + print(json.dumps(results)) + else: + for result in results: + print("Message %s of dataset file %s" % \ + (result["message_name"], result["filename"])) + print("Average throughput for parse_from_benchmark: %.2f MB/s" % \ + (result["benchmarks"][ \ + args.behavior_prefix + "_parse_from_benchmark"])) + print("Average throughput for serialize_to_benchmark: %.2f MB/s" % \ + (result["benchmarks"][ \ + args.behavior_prefix + "_serialize_to_benchmark"])) + print("") diff --git a/third_party/protobuf/benchmarks/python/python_benchmark_messages.cc b/third_party/protobuf/benchmarks/python/python_benchmark_messages.cc new file mode 100644 index 000000000000..ded16fe96e95 --- /dev/null +++ b/third_party/protobuf/benchmarks/python/python_benchmark_messages.cc @@ -0,0 +1,29 @@ +#include + +#include "benchmarks.pb.h" +#include "datasets/google_message1/proto2/benchmark_message1_proto2.pb.h" +#include "datasets/google_message1/proto3/benchmark_message1_proto3.pb.h" +#include "datasets/google_message2/benchmark_message2.pb.h" +#include "datasets/google_message3/benchmark_message3.pb.h" +#include "datasets/google_message4/benchmark_message4.pb.h" + +static PyMethodDef python_benchmark_methods[] = { + {NULL, NULL, 0, NULL} /* Sentinel */ +}; + + +PyMODINIT_FUNC +initlibbenchmark_messages() { + benchmarks::BenchmarkDataset().descriptor(); + benchmarks::proto3::GoogleMessage1().descriptor(); + benchmarks::proto2::GoogleMessage1().descriptor(); + benchmarks::proto2::GoogleMessage2().descriptor(); + benchmarks::google_message3::GoogleMessage3().descriptor(); + benchmarks::google_message4::GoogleMessage4().descriptor(); + + PyObject *m; + + m = Py_InitModule("libbenchmark_messages", python_benchmark_methods); + if (m == NULL) + return; +} diff --git a/third_party/protobuf/benchmarks/readme.txt b/third_party/protobuf/benchmarks/readme.txt deleted file mode 100644 index 2c836d0a1cfb..000000000000 --- a/third_party/protobuf/benchmarks/readme.txt +++ /dev/null @@ -1,50 +0,0 @@ -Contents --------- - -This folder contains three kinds of file: - -- Code, such as ProtoBench.java, to build the benchmarking framework. -- Protocol buffer definitions (.proto files) -- Sample data files - -If we end up with a lot of different benchmarks it may be worth -separating these out info different directories, but while there are -so few they might as well all be together. - -Running a benchmark (Java) --------------------------- - -1) Build protoc and the Java protocol buffer library. The examples - below assume a jar file (protobuf.jar) has been built and copied - into this directory. - -2) Build ProtoBench: - $ javac -d tmp -cp protobuf.jar ProtoBench.java - -3) Generate code for the relevant benchmark protocol buffer, e.g. - $ protoc --java_out=tmp google_size.proto google_speed.proto - -4) Build the generated code, e.g. - $ cd tmp - $ javac -d . -cp ../protobuf.jar benchmarks/*.java - -5) Run the test. Arguments are given in pairs - the first argument - is the descriptor type; the second is the filename. For example: - $ java -cp .;../protobuf.jar com.google.protocolbuffers.ProtoBench - benchmarks.GoogleSize$SizeMessage1 ../google_message1.dat - benchmarks.GoogleSpeed$SpeedMessage1 ../google_message1.dat - benchmarks.GoogleSize$SizeMessage2 ../google_message2.dat - benchmarks.GoogleSpeed$SpeedMessage2 ../google_message2.dat - -6) Wait! Each test runs for around 30 seconds, and there are 6 tests - per class/data combination. The above command would therefore take - about 12 minutes to run. - - -Benchmarks available --------------------- - -From Google: -google_size.proto and google_speed.proto, messages -google_message1.dat and google_message2.dat. The proto files are -equivalent, but optimized differently. diff --git a/third_party/protobuf/benchmarks/util/__init__.py b/third_party/protobuf/benchmarks/util/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/third_party/protobuf/benchmarks/util/big_query_utils.py b/third_party/protobuf/benchmarks/util/big_query_utils.py new file mode 100755 index 000000000000..aea55bbd8963 --- /dev/null +++ b/third_party/protobuf/benchmarks/util/big_query_utils.py @@ -0,0 +1,189 @@ +#!/usr/bin/env python2.7 + +from __future__ import print_function +import argparse +import json +import uuid +import httplib2 + +from apiclient import discovery +from apiclient.errors import HttpError +from oauth2client.client import GoogleCredentials + +# 30 days in milliseconds +_EXPIRATION_MS = 30 * 24 * 60 * 60 * 1000 +NUM_RETRIES = 3 + + +def create_big_query(): + """Authenticates with cloud platform and gets a BiqQuery service object + """ + creds = GoogleCredentials.get_application_default() + return discovery.build( + 'bigquery', 'v2', credentials=creds, cache_discovery=False) + + +def create_dataset(biq_query, project_id, dataset_id): + is_success = True + body = { + 'datasetReference': { + 'projectId': project_id, + 'datasetId': dataset_id + } + } + + try: + dataset_req = biq_query.datasets().insert( + projectId=project_id, body=body) + dataset_req.execute(num_retries=NUM_RETRIES) + except HttpError as http_error: + if http_error.resp.status == 409: + print('Warning: The dataset %s already exists' % dataset_id) + else: + # Note: For more debugging info, print "http_error.content" + print('Error in creating dataset: %s. Err: %s' % (dataset_id, + http_error)) + is_success = False + return is_success + + +def create_table(big_query, project_id, dataset_id, table_id, table_schema, + description): + fields = [{ + 'name': field_name, + 'type': field_type, + 'description': field_description + } for (field_name, field_type, field_description) in table_schema] + return create_table2(big_query, project_id, dataset_id, table_id, fields, + description) + + +def create_partitioned_table(big_query, + project_id, + dataset_id, + table_id, + table_schema, + description, + partition_type='DAY', + expiration_ms=_EXPIRATION_MS): + """Creates a partitioned table. By default, a date-paritioned table is created with + each partition lasting 30 days after it was last modified. + """ + fields = [{ + 'name': field_name, + 'type': field_type, + 'description': field_description + } for (field_name, field_type, field_description) in table_schema] + return create_table2(big_query, project_id, dataset_id, table_id, fields, + description, partition_type, expiration_ms) + + +def create_table2(big_query, + project_id, + dataset_id, + table_id, + fields_schema, + description, + partition_type=None, + expiration_ms=None): + is_success = True + + body = { + 'description': description, + 'schema': { + 'fields': fields_schema + }, + 'tableReference': { + 'datasetId': dataset_id, + 'projectId': project_id, + 'tableId': table_id + } + } + + if partition_type and expiration_ms: + body["timePartitioning"] = { + "type": partition_type, + "expirationMs": expiration_ms + } + + try: + table_req = big_query.tables().insert( + projectId=project_id, datasetId=dataset_id, body=body) + res = table_req.execute(num_retries=NUM_RETRIES) + print('Successfully created %s "%s"' % (res['kind'], res['id'])) + except HttpError as http_error: + if http_error.resp.status == 409: + print('Warning: Table %s already exists' % table_id) + else: + print('Error in creating table: %s. Err: %s' % (table_id, + http_error)) + is_success = False + return is_success + + +def patch_table(big_query, project_id, dataset_id, table_id, fields_schema): + is_success = True + + body = { + 'schema': { + 'fields': fields_schema + }, + 'tableReference': { + 'datasetId': dataset_id, + 'projectId': project_id, + 'tableId': table_id + } + } + + try: + table_req = big_query.tables().patch( + projectId=project_id, + datasetId=dataset_id, + tableId=table_id, + body=body) + res = table_req.execute(num_retries=NUM_RETRIES) + print('Successfully patched %s "%s"' % (res['kind'], res['id'])) + except HttpError as http_error: + print('Error in creating table: %s. Err: %s' % (table_id, http_error)) + is_success = False + return is_success + + +def insert_rows(big_query, project_id, dataset_id, table_id, rows_list): + is_success = True + body = {'rows': rows_list} + try: + insert_req = big_query.tabledata().insertAll( + projectId=project_id, + datasetId=dataset_id, + tableId=table_id, + body=body) + res = insert_req.execute(num_retries=NUM_RETRIES) + if res.get('insertErrors', None): + print('Error inserting rows! Response: %s' % res) + is_success = False + except HttpError as http_error: + print('Error inserting rows to the table %s' % table_id) + is_success = False + + return is_success + + +def sync_query_job(big_query, project_id, query, timeout=5000): + query_data = {'query': query, 'timeoutMs': timeout} + query_job = None + try: + query_job = big_query.jobs().query( + projectId=project_id, + body=query_data).execute(num_retries=NUM_RETRIES) + except HttpError as http_error: + print('Query execute job failed with error: %s' % http_error) + print(http_error.content) + return query_job + + + # List of (column name, column type, description) tuples +def make_row(unique_row_id, row_values_dict): + """row_values_dict is a dictionary of column name and column value. + """ + return {'insertId': unique_row_id, 'json': row_values_dict} diff --git a/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h b/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h new file mode 100644 index 000000000000..5eea850900ae --- /dev/null +++ b/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h @@ -0,0 +1,64 @@ +#ifndef PROTOBUF_BENCHMARKS_UTIL_DATA_PROTO2_TO_PROTO3_UTIL_H_ +#define PROTOBUF_BENCHMARKS_UTIL_DATA_PROTO2_TO_PROTO3_UTIL_H_ + +#include "google/protobuf/message.h" +#include "google/protobuf/descriptor.h" + +using google::protobuf::FieldDescriptor; +using google::protobuf::Message; +using google::protobuf::Reflection; + +namespace google { +namespace protobuf { +namespace util { + +class DataStripper { + public: + void StripMessage(Message *message) { + std::vector set_fields; + const Reflection* reflection = message->GetReflection(); + reflection->ListFields(*message, &set_fields); + + for (size_t i = 0; i < set_fields.size(); i++) { + const FieldDescriptor* field = set_fields[i]; + if (ShouldBeClear(field)) { + reflection->ClearField(message, field); + continue; + } + if (field->type() == FieldDescriptor::TYPE_MESSAGE) { + if (field->is_repeated()) { + for (int j = 0; j < reflection->FieldSize(*message, field); j++) { + StripMessage(reflection->MutableRepeatedMessage(message, field, j)); + } + } else { + StripMessage(reflection->MutableMessage(message, field)); + } + } + } + + reflection->MutableUnknownFields(message)->Clear(); + } + private: + virtual bool ShouldBeClear(const FieldDescriptor *field) = 0; +}; + +class GogoDataStripper : public DataStripper { + private: + virtual bool ShouldBeClear(const FieldDescriptor *field) { + return field->type() == FieldDescriptor::TYPE_GROUP; + } +}; + +class Proto3DataStripper : public DataStripper { + private: + virtual bool ShouldBeClear(const FieldDescriptor *field) { + return field->type() == FieldDescriptor::TYPE_GROUP || + field->is_extension(); + } +}; + +} // namespace util +} // namespace protobuf +} // namespace google + +#endif // PROTOBUF_BENCHMARKS_UTIL_DATA_PROTO2_TO_PROTO3_UTIL_H_ diff --git a/third_party/protobuf/benchmarks/util/gogo_data_scrubber.cc b/third_party/protobuf/benchmarks/util/gogo_data_scrubber.cc new file mode 100644 index 000000000000..9ef57b0da041 --- /dev/null +++ b/third_party/protobuf/benchmarks/util/gogo_data_scrubber.cc @@ -0,0 +1,74 @@ +#include "benchmarks.pb.h" +#include "datasets/google_message1/proto2/benchmark_message1_proto2.pb.h" +#include "datasets/google_message1/proto3/benchmark_message1_proto3.pb.h" +#include "datasets/google_message2/benchmark_message2.pb.h" +#include "datasets/google_message3/benchmark_message3.pb.h" +#include "datasets/google_message4/benchmark_message4.pb.h" +#include "data_proto2_to_proto3_util.h" + +#include + +using google::protobuf::util::GogoDataStripper; + +std::string ReadFile(const std::string& name) { + std::ifstream file(name.c_str()); + GOOGLE_CHECK(file.is_open()) << "Couldn't find file '" + << name + << "', please make sure you are running this command from the benchmarks" + << " directory.\n"; + return std::string((std::istreambuf_iterator(file)), + std::istreambuf_iterator()); +} + +int main(int argc, char *argv[]) { + if (argc % 2 == 0 || argc == 1) { + std::cerr << "Usage: [input_files] [output_file_names] where " << + "input_files are one to one mapping to output_file_names." << + std::endl; + return 1; + } + + for (int i = argc / 2; i > 0; i--) { + const std::string &input_file = argv[i]; + const std::string &output_file = argv[i + argc / 2]; + + std::cerr << "Generating " << input_file + << " to " << output_file << std::endl; + benchmarks::BenchmarkDataset dataset; + Message* message; + std::string dataset_payload = ReadFile(input_file); + GOOGLE_CHECK(dataset.ParseFromString(dataset_payload)) + << "Can' t parse data file " << input_file; + + if (dataset.message_name() == "benchmarks.proto3.GoogleMessage1") { + message = new benchmarks::proto3::GoogleMessage1; + } else if (dataset.message_name() == "benchmarks.proto2.GoogleMessage1") { + message = new benchmarks::proto2::GoogleMessage1; + } else if (dataset.message_name() == "benchmarks.proto2.GoogleMessage2") { + message = new benchmarks::proto2::GoogleMessage2; + } else if (dataset.message_name() == + "benchmarks.google_message3.GoogleMessage3") { + message = new benchmarks::google_message3::GoogleMessage3; + } else if (dataset.message_name() == + "benchmarks.google_message4.GoogleMessage4") { + message = new benchmarks::google_message4::GoogleMessage4; + } else { + std::cerr << "Unknown message type: " << dataset.message_name(); + exit(1); + } + + for (int i = 0; i < dataset.payload_size(); i++) { + message->ParseFromString(dataset.payload(i)); + GogoDataStripper stripper; + stripper.StripMessage(message); + dataset.set_payload(i, message->SerializeAsString()); + } + + std::ofstream ofs(output_file); + ofs << dataset.SerializeAsString(); + ofs.close(); + } + + + return 0; +} diff --git a/third_party/protobuf/benchmarks/util/proto3_data_stripper.cc b/third_party/protobuf/benchmarks/util/proto3_data_stripper.cc new file mode 100644 index 000000000000..3096c4c115dc --- /dev/null +++ b/third_party/protobuf/benchmarks/util/proto3_data_stripper.cc @@ -0,0 +1,74 @@ +#include "benchmarks.pb.h" +#include "datasets/google_message1/proto2/benchmark_message1_proto2.pb.h" +#include "datasets/google_message1/proto3/benchmark_message1_proto3.pb.h" +#include "datasets/google_message2/benchmark_message2.pb.h" +#include "datasets/google_message3/benchmark_message3.pb.h" +#include "datasets/google_message4/benchmark_message4.pb.h" +#include "data_proto2_to_proto3_util.h" + +#include + +using google::protobuf::util::Proto3DataStripper; + +std::string ReadFile(const std::string& name) { + std::ifstream file(name.c_str()); + GOOGLE_CHECK(file.is_open()) << "Couldn't find file '" + << name + << "', please make sure you are running this command from the benchmarks" + << " directory.\n"; + return std::string((std::istreambuf_iterator(file)), + std::istreambuf_iterator()); +} + +int main(int argc, char *argv[]) { + if (argc % 2 == 0 || argc == 1) { + std::cerr << "Usage: [input_files] [output_file_names] where " << + "input_files are one to one mapping to output_file_names." << + std::endl; + return 1; + } + + for (int i = argc / 2; i > 0; i--) { + const std::string &input_file = argv[i]; + const std::string &output_file = argv[i + argc / 2]; + + std::cerr << "Generating " << input_file + << " to " << output_file << std::endl; + benchmarks::BenchmarkDataset dataset; + Message* message; + std::string dataset_payload = ReadFile(input_file); + GOOGLE_CHECK(dataset.ParseFromString(dataset_payload)) + << "Can' t parse data file " << input_file; + + if (dataset.message_name() == "benchmarks.proto3.GoogleMessage1") { + message = new benchmarks::proto3::GoogleMessage1; + } else if (dataset.message_name() == "benchmarks.proto2.GoogleMessage1") { + message = new benchmarks::proto2::GoogleMessage1; + } else if (dataset.message_name() == "benchmarks.proto2.GoogleMessage2") { + message = new benchmarks::proto2::GoogleMessage2; + } else if (dataset.message_name() == + "benchmarks.google_message3.GoogleMessage3") { + message = new benchmarks::google_message3::GoogleMessage3; + } else if (dataset.message_name() == + "benchmarks.google_message4.GoogleMessage4") { + message = new benchmarks::google_message4::GoogleMessage4; + } else { + std::cerr << "Unknown message type: " << dataset.message_name(); + exit(1); + } + + for (int i = 0; i < dataset.payload_size(); i++) { + message->ParseFromString(dataset.payload(i)); + Proto3DataStripper stripper; + stripper.StripMessage(message); + dataset.set_payload(i, message->SerializeAsString()); + } + + std::ofstream ofs(output_file); + ofs << dataset.SerializeAsString(); + ofs.close(); + } + + + return 0; +} diff --git a/third_party/protobuf/benchmarks/util/protoc-gen-gogoproto.cc b/third_party/protobuf/benchmarks/util/protoc-gen-gogoproto.cc new file mode 100644 index 000000000000..9c1b3d04e8ef --- /dev/null +++ b/third_party/protobuf/benchmarks/util/protoc-gen-gogoproto.cc @@ -0,0 +1,103 @@ +#include "google/protobuf/compiler/code_generator.h" +#include "google/protobuf/io/zero_copy_stream.h" +#include "google/protobuf/io/printer.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/descriptor.pb.h" +#include "schema_proto2_to_proto3_util.h" + +#include "google/protobuf/compiler/plugin.h" + +using google::protobuf::FileDescriptorProto; +using google::protobuf::FileDescriptor; +using google::protobuf::DescriptorPool; +using google::protobuf::io::Printer; +using google::protobuf::util::SchemaGroupStripper; +using google::protobuf::util::EnumScrubber; + +namespace google { +namespace protobuf { +namespace compiler { + +namespace { + +string StripProto(string filename) { + if (filename.substr(filename.size() - 11) == ".protodevel") { + // .protodevel + return filename.substr(0, filename.size() - 11); + } else { + // .proto + return filename.substr(0, filename.size() - 6); + } +} + +DescriptorPool new_pool_; + +} // namespace + +class GoGoProtoGenerator : public CodeGenerator { + public: + virtual bool GenerateAll(const std::vector& files, + const string& parameter, + GeneratorContext* context, + string* error) const { + for (int i = 0; i < files.size(); i++) { + for (auto file : files) { + bool can_generate = + (new_pool_.FindFileByName(file->name()) == nullptr); + for (int j = 0; j < file->dependency_count(); j++) { + can_generate &= (new_pool_.FindFileByName( + file->dependency(j)->name()) != nullptr); + } + for (int j = 0; j < file->public_dependency_count(); j++) { + can_generate &= (new_pool_.FindFileByName( + file->public_dependency(j)->name()) != nullptr); + } + for (int j = 0; j < file->weak_dependency_count(); j++) { + can_generate &= (new_pool_.FindFileByName( + file->weak_dependency(j)->name()) != nullptr); + } + if (can_generate) { + Generate(file, parameter, context, error); + break; + } + } + } + + return true; + } + + virtual bool Generate(const FileDescriptor* file, + const string& parameter, + GeneratorContext* context, + string* error) const { + FileDescriptorProto new_file; + file->CopyTo(&new_file); + SchemaGroupStripper::StripFile(file, &new_file); + + EnumScrubber enum_scrubber; + enum_scrubber.ScrubFile(&new_file); + + string filename = file->name(); + string basename = StripProto(filename); + + std::vector> option_pairs; + ParseGeneratorParameter(parameter, &option_pairs); + + std::unique_ptr output( + context->Open(basename + ".proto")); + string content = new_pool_.BuildFile(new_file)->DebugString(); + Printer printer(output.get(), '$'); + printer.WriteRaw(content.c_str(), content.size()); + + return true; + } +}; + +} // namespace compiler +} // namespace protobuf +} // namespace google + +int main(int argc, char* argv[]) { + google::protobuf::compiler::GoGoProtoGenerator generator; + return google::protobuf::compiler::PluginMain(argc, argv, &generator); +} diff --git a/third_party/protobuf/benchmarks/util/protoc-gen-proto2_to_proto3.cc b/third_party/protobuf/benchmarks/util/protoc-gen-proto2_to_proto3.cc new file mode 100644 index 000000000000..d0a890234751 --- /dev/null +++ b/third_party/protobuf/benchmarks/util/protoc-gen-proto2_to_proto3.cc @@ -0,0 +1,115 @@ +#include "google/protobuf/compiler/code_generator.h" +#include "google/protobuf/io/zero_copy_stream.h" +#include "google/protobuf/io/printer.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/descriptor.pb.h" +#include "schema_proto2_to_proto3_util.h" + +#include "google/protobuf/compiler/plugin.h" + +using google::protobuf::FileDescriptorProto; +using google::protobuf::FileDescriptor; +using google::protobuf::DescriptorPool; +using google::protobuf::io::Printer; +using google::protobuf::util::SchemaGroupStripper; +using google::protobuf::util::EnumScrubber; +using google::protobuf::util::ExtensionStripper; +using google::protobuf::util::FieldScrubber; + +namespace google { +namespace protobuf { +namespace compiler { + +namespace { + +string StripProto(string filename) { + return filename.substr(0, filename.rfind(".proto")); +} + +DescriptorPool* GetPool() { + static DescriptorPool *pool = new DescriptorPool(); + return pool; +} + +} // namespace + +class Proto2ToProto3Generator final : public CodeGenerator { + public: + bool GenerateAll(const std::vector& files, + const string& parameter, + GeneratorContext* context, + string* error) const { + for (int i = 0; i < files.size(); i++) { + for (auto file : files) { + if (CanGenerate(file)) { + Generate(file, parameter, context, error); + break; + } + } + } + + return true; + } + + bool Generate(const FileDescriptor* file, + const string& parameter, + GeneratorContext* context, + string* error) const { + FileDescriptorProto new_file; + file->CopyTo(&new_file); + SchemaGroupStripper::StripFile(file, &new_file); + + EnumScrubber enum_scrubber; + enum_scrubber.ScrubFile(&new_file); + ExtensionStripper::StripFile(&new_file); + FieldScrubber::ScrubFile(&new_file); + new_file.set_syntax("proto3"); + + string filename = file->name(); + string basename = StripProto(filename); + + std::vector> option_pairs; + ParseGeneratorParameter(parameter, &option_pairs); + + std::unique_ptr output( + context->Open(basename + ".proto")); + string content = GetPool()->BuildFile(new_file)->DebugString(); + Printer printer(output.get(), '$'); + printer.WriteRaw(content.c_str(), content.size()); + + return true; + } + private: + bool CanGenerate(const FileDescriptor* file) const { + if (GetPool()->FindFileByName(file->name()) != nullptr) { + return false; + } + for (int j = 0; j < file->dependency_count(); j++) { + if (GetPool()->FindFileByName(file->dependency(j)->name()) == nullptr) { + return false; + } + } + for (int j = 0; j < file->public_dependency_count(); j++) { + if (GetPool()->FindFileByName( + file->public_dependency(j)->name()) == nullptr) { + return false; + } + } + for (int j = 0; j < file->weak_dependency_count(); j++) { + if (GetPool()->FindFileByName( + file->weak_dependency(j)->name()) == nullptr) { + return false; + } + } + return true; + } +}; + +} // namespace compiler +} // namespace protobuf +} // namespace google + +int main(int argc, char* argv[]) { + google::protobuf::compiler::Proto2ToProto3Generator generator; + return google::protobuf::compiler::PluginMain(argc, argv, &generator); +} diff --git a/third_party/protobuf/benchmarks/util/result_parser.py b/third_party/protobuf/benchmarks/util/result_parser.py new file mode 100755 index 000000000000..b09f387a6b07 --- /dev/null +++ b/third_party/protobuf/benchmarks/util/result_parser.py @@ -0,0 +1,300 @@ +# This import depends on the automake rule protoc_middleman, please make sure +# protoc_middleman has been built before run this file. +import json +import re +import os.path +# BEGIN OPENSOURCE +import sys +sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)) +# END OPENSOURCE +import tmp.benchmarks_pb2 as benchmarks_pb2 + +__file_size_map = {} + +def __get_data_size(filename): + if filename[0] != '/': + filename = os.path.dirname(os.path.abspath(__file__)) + "/../" + filename + if filename in __file_size_map: + return __file_size_map[filename] + benchmark_dataset = benchmarks_pb2.BenchmarkDataset() + benchmark_dataset.ParseFromString( + open(filename, "rb").read()) + size = 0 + count = 0 + for payload in benchmark_dataset.payload: + size += len(payload) + count += 1 + __file_size_map[filename] = (size, 1.0 * size / count) + return size, 1.0 * size / count + + +def __extract_file_name(file_name): + name_list = re.split(r"[/\.]", file_name) + short_file_name = "" + for name in name_list: + if name[:14] == "google_message": + short_file_name = name + return short_file_name + + +__results = [] + + +# CPP results example: +# [ +# "benchmarks": [ +# { +# "bytes_per_second": int, +# "cpu_time_ns": double, +# "iterations": int, +# "name: string, +# "real_time_ns: double, +# ... +# }, +# ... +# ], +# ... +# ] +def __parse_cpp_result(filename): + if filename == "": + return + if filename[0] != '/': + filename = os.path.dirname(os.path.abspath(__file__)) + '/' + filename + with open(filename, "rb") as f: + results = json.loads(f.read()) + for benchmark in results["benchmarks"]: + data_filename = "".join( + re.split("(_parse_|_serialize)", benchmark["name"])[0]) + behavior = benchmark["name"][len(data_filename) + 1:] + if data_filename[:2] == "BM": + data_filename = data_filename[3:] + __results.append({ + "language": "cpp", + "dataFilename": data_filename, + "behavior": behavior, + "throughput": benchmark["bytes_per_second"] / 2.0 ** 20 + }) + + +# Synthetic benchmark results example: +# [ +# "benchmarks": [ +# { +# "cpu_time_ns": double, +# "iterations": int, +# "name: string, +# "real_time_ns: double, +# ... +# }, +# ... +# ], +# ... +# ] +def __parse_synthetic_result(filename): + if filename == "": + return + if filename[0] != "/": + filename = os.path.dirname(os.path.abspath(__file__)) + "/" + filename + with open(filename, "rb") as f: + results = json.loads(f.read()) + for benchmark in results["benchmarks"]: + __results.append({ + "language": "cpp", + "dataFilename": "", + "behavior": "synthetic", + "throughput": 10.0**9 / benchmark["cpu_time_ns"] + }) + + +# Python results example: +# [ +# [ +# { +# "filename": string, +# "benchmarks": { +# behavior: results, +# ... +# }, +# }, +# ... +# ], #pure-python +# ... +# ] +def __parse_python_result(filename): + if filename == "": + return + if filename[0] != '/': + filename = os.path.dirname(os.path.abspath(__file__)) + '/' + filename + with open(filename, "rb") as f: + results_list = json.loads(f.read()) + for results in results_list: + for result in results: + _, avg_size = __get_data_size(result["filename"]) + for behavior in result["benchmarks"]: + __results.append({ + "language": "python", + "dataFilename": __extract_file_name(result["filename"]), + "behavior": behavior, + "throughput": result["benchmarks"][behavior] + }) + + +# Java results example: +# [ +# { +# "id": string, +# "instrumentSpec": {...}, +# "measurements": [ +# { +# "weight": float, +# "value": { +# "magnitude": float, +# "unit": string +# }, +# ... +# }, +# ... +# ], +# "run": {...}, +# "scenario": { +# "benchmarkSpec": { +# "methodName": string, +# "parameters": { +# defined parameters in the benchmark: parameters value +# }, +# ... +# }, +# ... +# } +# +# }, +# ... +# ] +def __parse_java_result(filename): + if filename == "": + return + if filename[0] != '/': + filename = os.path.dirname(os.path.abspath(__file__)) + '/' + filename + with open(filename, "rb") as f: + results = json.loads(f.read()) + for result in results: + total_weight = 0 + total_value = 0 + for measurement in result["measurements"]: + total_weight += measurement["weight"] + total_value += measurement["value"]["magnitude"] + avg_time = total_value * 1.0 / total_weight + total_size, _ = __get_data_size( + result["scenario"]["benchmarkSpec"]["parameters"]["dataFile"]) + __results.append({ + "language": "java", + "throughput": total_size / avg_time * 1e9 / 2 ** 20, + "behavior": result["scenario"]["benchmarkSpec"]["methodName"], + "dataFilename": __extract_file_name( + result["scenario"]["benchmarkSpec"]["parameters"]["dataFile"]) + }) + + +# Go benchmark results: +# +# goos: linux +# goarch: amd64 +# Benchmark/.././datasets/google_message2/dataset.google_message2.pb/Unmarshal-12 3000 705784 ns/op +# Benchmark/.././datasets/google_message2/dataset.google_message2.pb/Marshal-12 2000 634648 ns/op +# Benchmark/.././datasets/google_message2/dataset.google_message2.pb/Size-12 5000 244174 ns/op +# Benchmark/.././datasets/google_message2/dataset.google_message2.pb/Clone-12 300 4120954 ns/op +# Benchmark/.././datasets/google_message2/dataset.google_message2.pb/Merge-12 300 4108632 ns/op +# PASS +# ok _/usr/local/google/home/yilunchong/mygit/protobuf/benchmarks 124.173s +def __parse_go_result(filename): + if filename == "": + return + if filename[0] != '/': + filename = os.path.dirname(os.path.abspath(__file__)) + '/' + filename + with open(filename, "rb") as f: + for line in f: + result_list = re.split(r"[\ \t]+", line) + if result_list[0][:9] != "Benchmark": + continue + first_slash_index = result_list[0].find('/') + last_slash_index = result_list[0].rfind('/') + full_filename = result_list[0][first_slash_index+1:last_slash_index] + total_bytes, _ = __get_data_size(full_filename) + behavior_with_suffix = result_list[0][last_slash_index+1:] + last_dash = behavior_with_suffix.rfind("-") + if last_dash == -1: + behavior = behavior_with_suffix + else: + behavior = behavior_with_suffix[:last_dash] + __results.append({ + "dataFilename": __extract_file_name(full_filename), + "throughput": total_bytes / float(result_list[2]) * 1e9 / 2 ** 20, + "behavior": behavior, + "language": "go" + }) + + +# Self built json results example: +# +# [ +# { +# "filename": string, +# "benchmarks": { +# behavior: results, +# ... +# }, +# }, +# ... +# ] +def __parse_custom_result(filename, language): + if filename == "": + return + if filename[0] != '/': + filename = os.path.dirname(os.path.abspath(__file__)) + '/' + filename + with open(filename, "rb") as f: + results = json.loads(f.read()) + for result in results: + _, avg_size = __get_data_size(result["filename"]) + for behavior in result["benchmarks"]: + __results.append({ + "language": language, + "dataFilename": __extract_file_name(result["filename"]), + "behavior": behavior, + "throughput": result["benchmarks"][behavior] + }) + + +def __parse_js_result(filename, language): + return __parse_custom_result(filename, language) + +def __parse_php_result(filename, language): + return __parse_custom_result(filename, language) + + +def get_result_from_file(cpp_file="", + java_file="", + python_file="", + go_file="", + synthetic_file="", + node_file="", + php_c_file="", + php_file=""): + results = {} + if cpp_file != "": + __parse_cpp_result(cpp_file) + if java_file != "": + __parse_java_result(java_file) + if python_file != "": + __parse_python_result(python_file) + if go_file != "": + __parse_go_result(go_file) + if synthetic_file != "": + __parse_synthetic_result(synthetic_file) + if node_file != "": + __parse_js_result(node_file, "node") + if php_file != "": + __parse_php_result(php_file, "php") + if php_c_file != "": + __parse_php_result(php_c_file, "php") + + return __results diff --git a/third_party/protobuf/benchmarks/util/result_uploader.py b/third_party/protobuf/benchmarks/util/result_uploader.py new file mode 100755 index 000000000000..2a35d9694d16 --- /dev/null +++ b/third_party/protobuf/benchmarks/util/result_uploader.py @@ -0,0 +1,107 @@ +from __future__ import print_function +from __future__ import absolute_import +import argparse +import os +import re +import copy +import uuid +import calendar +import time +import datetime + +from util import big_query_utils +from util import result_parser + +_PROJECT_ID = 'grpc-testing' +_DATASET = 'protobuf_benchmark_result' +_TABLE = 'opensource_result_v2' +_NOW = "%d%02d%02d" % (datetime.datetime.now().year, + datetime.datetime.now().month, + datetime.datetime.now().day) + +_INITIAL_TIME = calendar.timegm(time.gmtime()) + +def get_metadata(): + build_number = os.getenv('BUILD_NUMBER') + build_url = os.getenv('BUILD_URL') + job_name = os.getenv('JOB_NAME') + git_commit = os.getenv('GIT_COMMIT') + # actual commit is the actual head of PR that is getting tested + git_actual_commit = os.getenv('ghprbActualCommit') + + utc_timestamp = str(calendar.timegm(time.gmtime())) + metadata = {'created': utc_timestamp} + + if build_number: + metadata['buildNumber'] = build_number + if build_url: + metadata['buildUrl'] = build_url + if job_name: + metadata['jobName'] = job_name + if git_commit: + metadata['gitCommit'] = git_commit + if git_actual_commit: + metadata['gitActualCommit'] = git_actual_commit + + return metadata + + +def upload_result(result_list, metadata): + for result in result_list: + new_result = {} + new_result["metric"] = "throughput" + new_result["value"] = result["throughput"] + new_result["unit"] = "MB/s" + new_result["test"] = "protobuf_benchmark" + new_result["product_name"] = "protobuf" + labels_string = "" + for key in result: + labels_string += ",|%s:%s|" % (key, result[key]) + new_result["labels"] = labels_string[1:] + new_result["timestamp"] = _INITIAL_TIME + print(labels_string) + + bq = big_query_utils.create_big_query() + row = big_query_utils.make_row(str(uuid.uuid4()), new_result) + if not big_query_utils.insert_rows(bq, _PROJECT_ID, _DATASET, + _TABLE + "$" + _NOW, + [row]): + print('Error when uploading result', new_result) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("-cpp", "--cpp_input_file", + help="The CPP benchmark result file's name", + default="") + parser.add_argument("-java", "--java_input_file", + help="The Java benchmark result file's name", + default="") + parser.add_argument("-python", "--python_input_file", + help="The Python benchmark result file's name", + default="") + parser.add_argument("-go", "--go_input_file", + help="The golang benchmark result file's name", + default="") + parser.add_argument("-node", "--node_input_file", + help="The node.js benchmark result file's name", + default="") + parser.add_argument("-php", "--php_input_file", + help="The pure php benchmark result file's name", + default="") + parser.add_argument("-php_c", "--php_c_input_file", + help="The php with c ext benchmark result file's name", + default="") + args = parser.parse_args() + + metadata = get_metadata() + print("uploading results...") + upload_result(result_parser.get_result_from_file( + cpp_file=args.cpp_input_file, + java_file=args.java_input_file, + python_file=args.python_input_file, + go_file=args.go_input_file, + node_file=args.node_input_file, + php_file=args.php_input_file, + php_c_file=args.php_c_input_file, + ), metadata) diff --git a/third_party/protobuf/benchmarks/util/schema_proto2_to_proto3_util.h b/third_party/protobuf/benchmarks/util/schema_proto2_to_proto3_util.h new file mode 100644 index 000000000000..0079f6f1452e --- /dev/null +++ b/third_party/protobuf/benchmarks/util/schema_proto2_to_proto3_util.h @@ -0,0 +1,194 @@ +#ifndef PROTOBUF_BENCHMARKS_UTIL_SCHEMA_PROTO2_TO_PROTO3_UTIL_H_ +#define PROTOBUF_BENCHMARKS_UTIL_SCHEMA_PROTO2_TO_PROTO3_UTIL_H_ + +#include "google/protobuf/message.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/descriptor.pb.h" + +#include +#include + +using google::protobuf::Descriptor; +using google::protobuf::DescriptorProto; +using google::protobuf::FileDescriptorProto; +using google::protobuf::FieldDescriptorProto; +using google::protobuf::Message; +using google::protobuf::EnumValueDescriptorProto; + +namespace google { +namespace protobuf { +namespace util { + +class SchemaGroupStripper { + + public: + static void StripFile(const FileDescriptor* old_file, + FileDescriptorProto *file) { + for (int i = file->mutable_message_type()->size() - 1; i >= 0; i--) { + if (IsMessageSet(old_file->message_type(i))) { + file->mutable_message_type()->DeleteSubrange(i, 1); + continue; + } + StripMessage(old_file->message_type(i), file->mutable_message_type(i)); + } + for (int i = file->mutable_extension()->size() - 1; i >= 0; i--) { + auto field = old_file->extension(i); + if (field->type() == FieldDescriptor::TYPE_GROUP || + IsMessageSet(field->message_type()) || + IsMessageSet(field->containing_type())) { + file->mutable_extension()->DeleteSubrange(i, 1); + } + } + } + + private: + static bool IsMessageSet(const Descriptor *descriptor) { + if (descriptor != nullptr + && descriptor->options().message_set_wire_format()) { + return true; + } + return false; + } + + static void StripMessage(const Descriptor *old_message, + DescriptorProto *new_message) { + for (int i = new_message->mutable_field()->size() - 1; i >= 0; i--) { + if (old_message->field(i)->type() == FieldDescriptor::TYPE_GROUP || + IsMessageSet(old_message->field(i)->message_type())) { + new_message->mutable_field()->DeleteSubrange(i, 1); + } + } + for (int i = new_message->mutable_extension()->size() - 1; i >= 0; i--) { + auto field_type_name = new_message->mutable_extension(i)->type_name(); + if (old_message->extension(i)->type() == FieldDescriptor::TYPE_GROUP || + IsMessageSet(old_message->extension(i)->containing_type()) || + IsMessageSet(old_message->extension(i)->message_type())) { + new_message->mutable_extension()->DeleteSubrange(i, 1); + } + } + for (int i = 0; i < new_message->mutable_nested_type()->size(); i++) { + StripMessage(old_message->nested_type(i), + new_message->mutable_nested_type(i)); + } + } + +}; + +class EnumScrubber { + + public: + EnumScrubber() + : total_added_(0) { + } + + void ScrubFile(FileDescriptorProto *file) { + for (int i = 0; i < file->enum_type_size(); i++) { + ScrubEnum(file->mutable_enum_type(i)); + } + for (int i = 0; i < file->mutable_message_type()->size(); i++) { + ScrubMessage(file->mutable_message_type(i)); + } + } + + private: + void ScrubEnum(EnumDescriptorProto *enum_type) { + if (enum_type->value(0).number() != 0) { + bool has_zero = false; + for (int j = 0; j < enum_type->value().size(); j++) { + if (enum_type->value(j).number() == 0) { + EnumValueDescriptorProto temp_enum_value; + temp_enum_value.CopyFrom(enum_type->value(j)); + enum_type->mutable_value(j)->CopyFrom(enum_type->value(0)); + enum_type->mutable_value(0)->CopyFrom(temp_enum_value); + has_zero = true; + break; + } + } + if (!has_zero) { + enum_type->mutable_value()->Add(); + for (int i = enum_type->mutable_value()->size() - 1; i > 0; i--) { + enum_type->mutable_value(i)->CopyFrom( + *enum_type->mutable_value(i - 1)); + } + enum_type->mutable_value(0)->set_number(0); + enum_type->mutable_value(0)->set_name("ADDED_ZERO_VALUE_" + + std::to_string(total_added_++)); + } + } + + } + + void ScrubMessage(DescriptorProto *message_type) { + for (int i = 0; i < message_type->mutable_enum_type()->size(); i++) { + ScrubEnum(message_type->mutable_enum_type(i)); + } + for (int i = 0; i < message_type->mutable_nested_type()->size(); i++) { + ScrubMessage(message_type->mutable_nested_type(i)); + } + } + + int total_added_; +}; + +class ExtensionStripper { + public: + static void StripFile(FileDescriptorProto *file) { + for (int i = 0; i < file->mutable_message_type()->size(); i++) { + StripMessage(file->mutable_message_type(i)); + } + file->mutable_extension()->Clear(); + } + private: + static void StripMessage(DescriptorProto *message_type) { + message_type->mutable_extension()->Clear(); + message_type->clear_extension_range(); + for (int i = 0; i < message_type->mutable_nested_type()->size(); i++) { + StripMessage(message_type->mutable_nested_type(i)); + } + } +}; + + +class FieldScrubber { + public: + static void ScrubFile(FileDescriptorProto *file) { + for (int i = 0; i < file->mutable_message_type()->size(); i++) { + ScrubMessage(file->mutable_message_type(i)); + } + for (int i = 0; i < file->mutable_extension()->size(); i++) { + file->mutable_extension(i)->clear_default_value(); + if (ShouldClearLabel(file->mutable_extension(i))) { + file->mutable_extension(i)->clear_label(); + } + } + } + private: + static bool ShouldClearLabel(const FieldDescriptorProto *field) { + return field->label() == FieldDescriptorProto::LABEL_REQUIRED; + } + + static void ScrubMessage(DescriptorProto *message_type) { + message_type->mutable_extension()->Clear(); + for (int i = 0; i < message_type->mutable_extension()->size(); i++) { + message_type->mutable_extension(i)->clear_default_value(); + if (ShouldClearLabel(message_type->mutable_extension(i))) { + message_type->mutable_extension(i)->clear_label(); + } + } + for (int i = 0; i < message_type->mutable_field()->size(); i++) { + message_type->mutable_field(i)->clear_default_value(); + if (ShouldClearLabel(message_type->mutable_field(i))) { + message_type->mutable_field(i)->clear_label(); + } + } + for (int i = 0; i < message_type->mutable_nested_type()->size(); i++) { + ScrubMessage(message_type->mutable_nested_type(i)); + } + } +}; + +} // namespace util +} // namespace protobuf +} // namespace google + +#endif // PROTOBUF_BENCHMARKS_UTIL_SCHEMA_PROTO2_TO_PROTO3_UTIL_H_ diff --git a/third_party/protobuf/cmake/CMakeLists.txt b/third_party/protobuf/cmake/CMakeLists.txt index f32a0e4e65e5..71a0f37aaf10 100644 --- a/third_party/protobuf/cmake/CMakeLists.txt +++ b/third_party/protobuf/cmake/CMakeLists.txt @@ -1,30 +1,54 @@ # Minimum CMake required -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.1.3) -# Project -project(protobuf C CXX) +if(protobuf_VERBOSE) + message(STATUS "Protocol Buffers Configuring...") +endif() # CMake policies cmake_policy(SET CMP0022 NEW) +# On MacOS use @rpath/ for target's install name prefix path +if (POLICY CMP0042) + cmake_policy(SET CMP0042 NEW) +endif () +# Clear VERSION variables when no VERSION is given to project() +if(POLICY CMP0048) + cmake_policy(SET CMP0048 NEW) +endif() + +# Project +project(protobuf C CXX) + +# Add c++11 flags +if (CYGWIN) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") +else() + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) +endif() # Options -option(protobuf_VERBOSE "Enable for verbose output" OFF) option(protobuf_BUILD_TESTS "Build tests" ON) +option(protobuf_BUILD_CONFORMANCE "Build conformance tests" OFF) +option(protobuf_BUILD_EXAMPLES "Build examples" OFF) +option(protobuf_BUILD_PROTOC_BINARIES "Build libprotoc and protoc compiler" ON) if (BUILD_SHARED_LIBS) set(protobuf_BUILD_SHARED_LIBS_DEFAULT ON) else (BUILD_SHARED_LIBS) set(protobuf_BUILD_SHARED_LIBS_DEFAULT OFF) endif (BUILD_SHARED_LIBS) option(protobuf_BUILD_SHARED_LIBS "Build Shared Libraries" ${protobuf_BUILD_SHARED_LIBS_DEFAULT}) -option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON) -if (MSVC) - set(protobuf_WITH_ZLIB_DEFAULT OFF) -else (MSVC) - set(protobuf_WITH_ZLIB_DEFAULT ON) -endif (MSVC) +include(CMakeDependentOption) +cmake_dependent_option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON + "NOT protobuf_BUILD_SHARED_LIBS" OFF) +set(protobuf_WITH_ZLIB_DEFAULT ON) option(protobuf_WITH_ZLIB "Build with zlib support" ${protobuf_WITH_ZLIB_DEFAULT}) set(protobuf_DEBUG_POSTFIX "d" CACHE STRING "Default debug postfix") +mark_as_advanced(protobuf_DEBUG_POSTFIX) +# User options +include(protobuf-options.cmake) # Path to main configure script set(protobuf_CONFIGURE_SCRIPT "../configure.ac") @@ -44,17 +68,29 @@ string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\2" string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\3" protobuf_CONTACT "${protobuf_AC_INIT_LINE}") # Parse version tweaks -set(protobuf_VERSION_REGEX "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$") +set(protobuf_VERSION_REGEX "^([0-9]+)\\.([0-9]+)\\.([0-9]+)([-]rc[-]|\\.)?([0-9]*)$") string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\1" protobuf_VERSION_MAJOR "${protobuf_VERSION_STRING}") string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\2" protobuf_VERSION_MINOR "${protobuf_VERSION_STRING}") string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\3" protobuf_VERSION_PATCH "${protobuf_VERSION_STRING}") +string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\5" + protobuf_VERSION_PRERELEASE "${protobuf_VERSION_STRING}") + +message(STATUS "${protobuf_VERSION_PRERELEASE}") + # Package version set(protobuf_VERSION "${protobuf_VERSION_MAJOR}.${protobuf_VERSION_MINOR}.${protobuf_VERSION_PATCH}") +if(protobuf_VERSION_PRERELEASE) + set(protobuf_VERSION "${protobuf_VERSION}.${protobuf_VERSION_PRERELEASE}") +else() + set(protobuf_VERSION "${protobuf_VERSION}.0") +endif() +message(STATUS "${protobuf_VERSION}") + if(protobuf_VERBOSE) message(STATUS "Configuration script parsing status [") message(STATUS " Description : ${protobuf_DESCRIPTION}") @@ -70,6 +106,7 @@ if (CMAKE_USE_PTHREADS_INIT) add_definitions(-DHAVE_PTHREAD) endif (CMAKE_USE_PTHREADS_INIT) +set(_protobuf_FIND_ZLIB) if (protobuf_WITH_ZLIB) find_package(ZLIB) if (ZLIB_FOUND) @@ -80,6 +117,7 @@ if (protobuf_WITH_ZLIB) # Using imported target if exists if (TARGET ZLIB::ZLIB) set(ZLIB_LIBRARIES ZLIB::ZLIB) + set(_protobuf_FIND_ZLIB "if(NOT ZLIB_FOUND)\n find_package(ZLIB)\nendif()") endif (TARGET ZLIB::ZLIB) else (ZLIB_FOUND) set(HAVE_ZLIB 0) @@ -117,14 +155,44 @@ endif (protobuf_BUILD_SHARED_LIBS) if (MSVC) # Build with multiple processes add_definitions(/MP) - add_definitions(/wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305) + # MSVC warning suppressions + add_definitions( + /wd4018 # 'expression' : signed/unsigned mismatch + /wd4065 # switch statement contains 'default' but no 'case' labels + /wd4146 # unary minus operator applied to unsigned type, result still unsigned + /wd4244 # 'conversion' conversion from 'type1' to 'type2', possible loss of data + /wd4251 # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' + /wd4267 # 'var' : conversion from 'size_t' to 'type', possible loss of data + /wd4305 # 'identifier' : truncation from 'type1' to 'type2' + /wd4307 # 'operator' : integral constant overflow + /wd4309 # 'conversion' : truncation of constant value + /wd4334 # 'operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) + /wd4355 # 'this' : used in base member initializer list + /wd4506 # no definition for inline function 'function' + /wd4800 # 'type' : forcing value to bool 'true' or 'false' (performance warning) + /wd4996 # The compiler encountered a deprecated declaration. + ) # Allow big object add_definitions(/bigobj) string(REPLACE "/" "\\" PROTOBUF_SOURCE_WIN32_PATH ${protobuf_SOURCE_DIR}) string(REPLACE "/" "\\" PROTOBUF_BINARY_WIN32_PATH ${protobuf_BINARY_DIR}) + string(REPLACE "." "," protobuf_RC_FILEVERSION "${protobuf_VERSION}") configure_file(extract_includes.bat.in extract_includes.bat) + + # Suppress linker warnings about files with no symbols defined. + set(CMAKE_STATIC_LINKER_FLAGS /ignore:4221) + + # Configure Resource Compiler + enable_language(RC) + # use English language (0x409) in resource compiler + set(rc_flags "/l0x409") + # fix rc.exe invocations because of usage of add_definitions() + set(CMAKE_RC_COMPILE_OBJECT " ${rc_flags} /fo ") + + configure_file(version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY) endif (MSVC) + get_filename_component(protobuf_source_dir ${protobuf_SOURCE_DIR} PATH) include_directories( @@ -141,13 +209,31 @@ else (MSVC) set(LIB_PREFIX) endif (MSVC) +if (protobuf_UNICODE) + add_definitions(-DUNICODE -D_UNICODE) +endif (protobuf_UNICODE) + include(libprotobuf-lite.cmake) include(libprotobuf.cmake) -include(libprotoc.cmake) -include(protoc.cmake) +if (protobuf_BUILD_PROTOC_BINARIES) + include(libprotoc.cmake) + include(protoc.cmake) +endif (protobuf_BUILD_PROTOC_BINARIES) if (protobuf_BUILD_TESTS) include(tests.cmake) endif (protobuf_BUILD_TESTS) +if (protobuf_BUILD_CONFORMANCE) + include(conformance.cmake) +endif (protobuf_BUILD_CONFORMANCE) + include(install.cmake) + +if (protobuf_BUILD_EXAMPLES) + include(examples.cmake) +endif (protobuf_BUILD_EXAMPLES) + +if(protobuf_VERBOSE) + message(STATUS "Protocol Buffers Configuring done") +endif() diff --git a/third_party/protobuf/cmake/README.md b/third_party/protobuf/cmake/README.md index 1e7410d82854..96aaf4f97dc4 100644 --- a/third_party/protobuf/cmake/README.md +++ b/third_party/protobuf/cmake/README.md @@ -41,11 +41,18 @@ Good. Now you are ready to continue. Getting Sources =============== -You can get the latest stable source packages from the -[releases](https://github.com/google/protobuf/releases) page. -Or you can type: +You can get the latest stable source packages from the release page: - C:\Path\to> git clone -b [release_tag] https://github.com/google/protobuf.git + https://github.com/protocolbuffers/protobuf/releases/latest + +For example: if you only need C++, download `protobuf-cpp-[VERSION].tar.gz`; if +you need C++ and Java, download `protobuf-java-[VERSION].tar.gz` (every package +contains C++ source already); if you need C++ and multiple other languages, +download `protobuf-all-[VERSION].tar.gz`. + +Or you can use git to clone from protobuf git repository. + + C:\Path\to> git clone -b [release_tag] https://github.com/protocolbuffers/protobuf.git Where *[release_tag]* is a git tag like *v3.0.0-beta-1* or a branch name like *master* if you want to get the latest code. @@ -55,26 +62,16 @@ Go to the project folder: C:\Path\to>cd protobuf C:\Path\to\protobuf> -Protobuf unit-tests require gmock to build. If you download protobuf source code -from the *releases* page, the *gmock* directory should already be there. If you checkout -the code via `git clone`, this *gmock* directory won't exist and you will have to -download it manually or skip building protobuf unit-tests. - -You can download gmock as follows: +Remember to update any submodules if you are using git clone (you can skip this +step if you are using a release .tar.gz or .zip package): - C:\Path\to\protobuf>git clone -b release-1.7.0 https://github.com/google/googlemock.git gmock - -Then go to *gmock* folder and download gtest: - - C:\Path\to\protobuf>cd gmock - C:\Path\to\protobuf\gmock>git clone -b release-1.7.0 https://github.com/google/googletest.git gtest - -If you absolutely don't want to build and run protobuf unit-tests, skip -this steps and use protobuf at your own risk. +```console +C:\Path\to> git submodule update --init --recursive +``` Now go to *cmake* folder in protobuf sources: - C:\Path\to\protobuf\gmock>cd ..\cmake + C:\Path\to\protobuf>cd cmake C:\Path\to\protobuf\cmake> Good. Now you are ready to *CMake* configuration. @@ -124,7 +121,7 @@ It will generate *nmake* *Makefile* in current directory. To create *Visual Studio* solution file: C:\Path\to\protobuf\cmake\build>mkdir solution & cd solution - C:\Path\to\protobuf\cmake\build\solution>cmake -G "Visual Studio 12 2013 Win64" ^ + C:\Path\to\protobuf\cmake\build\solution>cmake -G "Visual Studio 14 2015 Win64" ^ -DCMAKE_INSTALL_PREFIX=../../../../install ^ ../.. @@ -133,6 +130,13 @@ It will generate *Visual Studio* solution file *protobuf.sln* in current directo If the *gmock* directory does not exist, and you do not want to build protobuf unit tests, you need to add *cmake* command argument `-Dprotobuf_BUILD_TESTS=OFF` to disable testing. +To make a *Visual Studio* file for Visual Studio 15 2017, create the *Visual Studio* +solution file above and edit the CmakeCache file. + + C:Path\to\protobuf\cmake\build\solution\CMakeCache + +Then create the *Visual Studio* solution file again + Compiling ========= @@ -173,9 +177,9 @@ You should see output similar to: Running main() from gmock_main.cc [==========] Running 1546 tests from 165 test cases. - + ... - + [==========] 1546 tests from 165 test cases ran. (2529 ms total) [ PASSED ] 1546 tests. @@ -194,7 +198,7 @@ To run specific tests: [ RUN ] AnyTest.TestIs [ OK ] AnyTest.TestIs (0 ms) [----------] 3 tests from AnyTest (1 ms total) - + [----------] Global test environment tear-down [==========] 3 tests from 1 test case ran. (2 ms total) [ PASSED ] 3 tests. @@ -302,6 +306,11 @@ further disable the option `-Dprotobuf_MSVC_STATIC_RUNTIME=OFF`. If it reports NOTFOUND for zlib_include or zlib_lib, you might haven't put the headers or the .lib file in the right directory. +If you already have ZLIB library and headers at some other location on your system then alternatively you can define following configuration flags to locate them: + + -DZLIB_INCLUDE_DIR= + -DZLIB_LIB= + Build and testing protobuf as usual. Notes on Compiler Warnings diff --git a/third_party/protobuf/cmake/conformance.cmake b/third_party/protobuf/cmake/conformance.cmake new file mode 100644 index 000000000000..82b4cf580a7d --- /dev/null +++ b/third_party/protobuf/cmake/conformance.cmake @@ -0,0 +1,50 @@ + +add_custom_command( + OUTPUT ${protobuf_source_dir}/conformance/conformance.pb.cc + DEPENDS protoc ${protobuf_source_dir}/conformance/conformance.proto + COMMAND protoc ${protobuf_source_dir}/conformance/conformance.proto + --proto_path=${protobuf_source_dir}/conformance + --cpp_out=${protobuf_source_dir}/conformance +) + +add_custom_command( + OUTPUT ${protobuf_source_dir}/src/google/protobuf/test_messages_proto3.pb.cc + ${protobuf_source_dir}/src/google/protobuf/test_messages_proto2.pb.cc + DEPENDS protoc ${protobuf_source_dir}/src/google/protobuf/test_messages_proto3.proto + protoc ${protobuf_source_dir}/src/google/protobuf/test_messages_proto2.proto + COMMAND protoc ${protobuf_source_dir}/src/google/protobuf/test_messages_proto3.proto + ${protobuf_source_dir}/src/google/protobuf/test_messages_proto2.proto + --proto_path=${protobuf_source_dir}/src + --cpp_out=${protobuf_source_dir}/src +) + +add_executable(conformance_test_runner + ${protobuf_source_dir}/conformance/conformance.pb.cc + ${protobuf_source_dir}/conformance/conformance_test.cc + ${protobuf_source_dir}/conformance/binary_json_conformance_main.cc + ${protobuf_source_dir}/conformance/binary_json_conformance_suite.cc + ${protobuf_source_dir}/conformance/binary_json_conformance_suite.h + ${protobuf_source_dir}/conformance/conformance_test_runner.cc + ${protobuf_source_dir}/conformance/third_party/jsoncpp/json.h + ${protobuf_source_dir}/conformance/third_party/jsoncpp/jsoncpp.cpp + ${protobuf_source_dir}/src/google/protobuf/test_messages_proto3.pb.cc + ${protobuf_source_dir}/src/google/protobuf/test_messages_proto2.pb.cc +) + +add_executable(conformance_cpp + ${protobuf_source_dir}/conformance/conformance.pb.cc + ${protobuf_source_dir}/conformance/conformance_cpp.cc + ${protobuf_source_dir}/src/google/protobuf/test_messages_proto3.pb.cc + ${protobuf_source_dir}/src/google/protobuf/test_messages_proto2.pb.cc +) + +target_include_directories( + conformance_test_runner + PUBLIC ${protobuf_source_dir}/conformance) + +target_include_directories( + conformance_cpp + PUBLIC ${protobuf_source_dir}/conformance) + +target_link_libraries(conformance_test_runner libprotobuf) +target_link_libraries(conformance_cpp libprotobuf) diff --git a/third_party/protobuf/cmake/examples.cmake b/third_party/protobuf/cmake/examples.cmake new file mode 100644 index 000000000000..e5cad63f6765 --- /dev/null +++ b/third_party/protobuf/cmake/examples.cmake @@ -0,0 +1,57 @@ +if(protobuf_VERBOSE) + message(STATUS "Protocol Buffers Examples Configuring...") +endif() + +get_filename_component(examples_dir "../examples" ABSOLUTE) + +if(protobuf_VERBOSE) + message(STATUS "Protocol Buffers Examples Configuring done") +endif() +include(ExternalProject) + +# Internal utility function: Create a custom target representing a build of examples with custom options. +function(add_examples_build NAME) + + ExternalProject_Add(${NAME} + PREFIX ${NAME} + SOURCE_DIR "${examples_dir}" + BINARY_DIR ${NAME} + STAMP_DIR ${NAME}/logs + INSTALL_COMMAND "" #Skip + LOG_CONFIGURE 1 + CMAKE_CACHE_ARGS "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}" + "-Dprotobuf_VERBOSE:BOOL=${protobuf_VERBOSE}" + ${ARGN} + ) + set_property(TARGET ${NAME} PROPERTY FOLDER "Examples") + set_property(TARGET ${NAME} PROPERTY EXCLUDE_FROM_ALL TRUE) +endfunction() + +# Add examples as an external project. +# sub_directory cannot be used because the find_package(protobuf) call would cause failures with redefined targets. +add_examples_build(examples "-Dprotobuf_DIR:PATH=${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}") +add_dependencies(examples libprotobuf protoc) + +option(protobuf_BUILD_EXAMPLES_MULTITEST "Build Examples in multiple configurations. Useful for testing." OFF) +mark_as_advanced(protobuf_BUILD_EXAMPLES_MULTITEST) +if(protobuf_BUILD_EXAMPLES_MULTITEST) + set_property(GLOBAL PROPERTY USE_FOLDERS ON) + + #Build using the legacy compatibility module. + add_examples_build(examples-legacy + "-Dprotobuf_DIR:PATH=${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}" + "-Dprotobuf_MODULE_COMPATIBLE:BOOL=TRUE" + ) + add_dependencies(examples-legacy libprotobuf protoc) + + #Build using the installed library. + add_examples_build(examples-installed + "-Dprotobuf_DIR:PATH=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_CMAKEDIR}" + ) + + #Build using the installed library in legacy compatibility mode. + add_examples_build(examples-installed-legacy + "-Dprotobuf_DIR:PATH=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_CMAKEDIR}" + "-Dprotobuf_MODULE_COMPATIBLE:BOOL=TRUE" + ) +endif() diff --git a/third_party/protobuf/cmake/extract_includes.bat.in b/third_party/protobuf/cmake/extract_includes.bat.in index b593e0c9ccee..7c97f20c4f1d 100644 --- a/third_party/protobuf/cmake/extract_includes.bat.in +++ b/third_party/protobuf/cmake/extract_includes.bat.in @@ -5,120 +5,126 @@ mkdir include\google\protobuf\compiler mkdir include\google\protobuf\compiler\cpp mkdir include\google\protobuf\compiler\csharp mkdir include\google\protobuf\compiler\java -mkdir include\google\protobuf\compiler\javanano mkdir include\google\protobuf\compiler\js mkdir include\google\protobuf\compiler\objectivec +mkdir include\google\protobuf\compiler\php mkdir include\google\protobuf\compiler\python mkdir include\google\protobuf\compiler\ruby mkdir include\google\protobuf\io mkdir include\google\protobuf\stubs mkdir include\google\protobuf\util -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\any.h include\google\protobuf\any.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\any.pb.h include\google\protobuf\any.pb.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\api.pb.h include\google\protobuf\api.pb.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arena.h include\google\protobuf\arena.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arenastring.h include\google\protobuf\arenastring.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\code_generator.h include\google\protobuf\compiler\code_generator.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\command_line_interface.h include\google\protobuf\compiler\command_line_interface.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\cpp\cpp_generator.h include\google\protobuf\compiler\cpp\cpp_generator.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_generator.h include\google\protobuf\compiler\csharp\csharp_generator.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_names.h include\google\protobuf\compiler\csharp\csharp_names.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\importer.h include\google\protobuf\compiler\importer.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_generator.h include\google\protobuf\compiler\java\java_generator.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_names.h include\google\protobuf\compiler\java\java_names.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\javanano\javanano_generator.h include\google\protobuf\compiler\javanano\javanano_generator.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\js\js_generator.h include\google\protobuf\compiler\js\js_generator.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_generator.h include\google\protobuf\compiler\objectivec\objectivec_generator.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_helpers.h include\google\protobuf\compiler\objectivec\objectivec_helpers.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\parser.h include\google\protobuf\compiler\parser.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.h include\google\protobuf\compiler\plugin.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.pb.h include\google\protobuf\compiler\plugin.pb.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\python\python_generator.h include\google\protobuf\compiler\python\python_generator.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\ruby\ruby_generator.h include\google\protobuf\compiler\ruby\ruby_generator.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.h include\google\protobuf\descriptor.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.pb.h include\google\protobuf\descriptor.pb.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor_database.h include\google\protobuf\descriptor_database.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\duration.pb.h include\google\protobuf\duration.pb.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\dynamic_message.h include\google\protobuf\dynamic_message.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\empty.pb.h include\google\protobuf\empty.pb.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\extension_set.h include\google\protobuf\extension_set.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\field_mask.pb.h include\google\protobuf\field_mask.pb.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_reflection.h include\google\protobuf\generated_enum_reflection.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_util.h include\google\protobuf\generated_enum_util.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_reflection.h include\google\protobuf\generated_message_reflection.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_util.h include\google\protobuf\generated_message_util.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\coded_stream.h include\google\protobuf\io\coded_stream.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\gzip_stream.h include\google\protobuf\io\gzip_stream.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\printer.h include\google\protobuf\io\printer.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\strtod.h include\google\protobuf\io\strtod.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\tokenizer.h include\google\protobuf\io\tokenizer.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream.h include\google\protobuf\io\zero_copy_stream.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream_impl.h include\google\protobuf\io\zero_copy_stream_impl.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream_impl_lite.h include\google\protobuf\io\zero_copy_stream_impl_lite.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map.h include\google\protobuf\map.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_entry.h include\google\protobuf\map_entry.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_entry_lite.h include\google\protobuf\map_entry_lite.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field.h include\google\protobuf\map_field.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field_inl.h include\google\protobuf\map_field_inl.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field_lite.h include\google\protobuf\map_field_lite.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_type_handler.h include\google\protobuf\map_type_handler.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\message.h include\google\protobuf\message.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\message_lite.h include\google\protobuf\message_lite.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\metadata.h include\google\protobuf\metadata.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\reflection.h include\google\protobuf\reflection.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\reflection_ops.h include\google\protobuf\reflection_ops.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\repeated_field.h include\google\protobuf\repeated_field.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\repeated_field_reflection.h include\google\protobuf\repeated_field_reflection.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\service.h include\google\protobuf\service.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\source_context.pb.h include\google\protobuf\source_context.pb.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\struct.pb.h include\google\protobuf\struct.pb.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomic_sequence_num.h include\google\protobuf\stubs\atomic_sequence_num.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops.h include\google\protobuf\stubs\atomicops.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm64_gcc.h include\google\protobuf\stubs\atomicops_internals_arm64_gcc.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm_gcc.h include\google\protobuf\stubs\atomicops_internals_arm_gcc.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm_qnx.h include\google\protobuf\stubs\atomicops_internals_arm_qnx.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_atomicword_compat.h include\google\protobuf\stubs\atomicops_internals_atomicword_compat.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_generic_gcc.h include\google\protobuf\stubs\atomicops_internals_generic_gcc.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_macosx.h include\google\protobuf\stubs\atomicops_internals_macosx.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_mips_gcc.h include\google\protobuf\stubs\atomicops_internals_mips_gcc.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_pnacl.h include\google\protobuf\stubs\atomicops_internals_pnacl.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_power.h include\google\protobuf\stubs\atomicops_internals_power.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_solaris.h include\google\protobuf\stubs\atomicops_internals_solaris.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_tsan.h include\google\protobuf\stubs\atomicops_internals_tsan.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_x86_gcc.h include\google\protobuf\stubs\atomicops_internals_x86_gcc.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_x86_msvc.h include\google\protobuf\stubs\atomicops_internals_x86_msvc.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\bytestream.h include\google\protobuf\stubs\bytestream.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\callback.h include\google\protobuf\stubs\callback.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\casts.h include\google\protobuf\stubs\casts.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\common.h include\google\protobuf\stubs\common.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\fastmem.h include\google\protobuf\stubs\fastmem.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\hash.h include\google\protobuf\stubs\hash.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\logging.h include\google\protobuf\stubs\logging.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\macros.h include\google\protobuf\stubs\macros.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\mutex.h include\google\protobuf\stubs\mutex.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\once.h include\google\protobuf\stubs\once.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\platform_macros.h include\google\protobuf\stubs\platform_macros.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\port.h include\google\protobuf\stubs\port.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\scoped_ptr.h include\google\protobuf\stubs\scoped_ptr.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\shared_ptr.h include\google\protobuf\stubs\shared_ptr.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\singleton.h include\google\protobuf\stubs\singleton.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\status.h include\google\protobuf\stubs\status.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\stl_util.h include\google\protobuf\stubs\stl_util.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\stringpiece.h include\google\protobuf\stubs\stringpiece.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\template_util.h include\google\protobuf\stubs\template_util.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\type_traits.h include\google\protobuf\stubs\type_traits.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\text_format.h include\google\protobuf\text_format.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\timestamp.pb.h include\google\protobuf\timestamp.pb.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\type.pb.h include\google\protobuf\type.pb.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\unknown_field_set.h include\google\protobuf\unknown_field_set.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\field_comparator.h include\google\protobuf\util\field_comparator.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\field_mask_util.h include\google\protobuf\util\field_mask_util.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\json_util.h include\google\protobuf\util\json_util.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\message_differencer.h include\google\protobuf\util\message_differencer.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\time_util.h include\google\protobuf\util\time_util.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\type_resolver.h include\google\protobuf\util\type_resolver.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\type_resolver_util.h include\google\protobuf\util\type_resolver_util.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format.h include\google\protobuf\wire_format.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format_lite.h include\google\protobuf\wire_format_lite.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format_lite_inl.h include\google\protobuf\wire_format_lite_inl.h -copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wrappers.pb.h include\google\protobuf\wrappers.pb.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\any.h" include\google\protobuf\any.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\any.pb.h" include\google\protobuf\any.pb.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\api.pb.h" include\google\protobuf\api.pb.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arena.h" include\google\protobuf\arena.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arena_impl.h" include\google\protobuf\arena_impl.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arenastring.h" include\google\protobuf\arenastring.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\code_generator.h" include\google\protobuf\compiler\code_generator.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\command_line_interface.h" include\google\protobuf\compiler\command_line_interface.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\cpp\cpp_generator.h" include\google\protobuf\compiler\cpp\cpp_generator.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_generator.h" include\google\protobuf\compiler\csharp\csharp_generator.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_names.h" include\google\protobuf\compiler\csharp\csharp_names.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\importer.h" include\google\protobuf\compiler\importer.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_generator.h" include\google\protobuf\compiler\java\java_generator.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_names.h" include\google\protobuf\compiler\java\java_names.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\js\js_generator.h" include\google\protobuf\compiler\js\js_generator.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\js\well_known_types_embed.h" include\google\protobuf\compiler\js\well_known_types_embed.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_generator.h" include\google\protobuf\compiler\objectivec\objectivec_generator.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_helpers.h" include\google\protobuf\compiler\objectivec\objectivec_helpers.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\parser.h" include\google\protobuf\compiler\parser.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\php\php_generator.h" include\google\protobuf\compiler\php\php_generator.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.h" include\google\protobuf\compiler\plugin.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.pb.h" include\google\protobuf\compiler\plugin.pb.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\python\python_generator.h" include\google\protobuf\compiler\python\python_generator.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\ruby\ruby_generator.h" include\google\protobuf\compiler\ruby\ruby_generator.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.h" include\google\protobuf\descriptor.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.pb.h" include\google\protobuf\descriptor.pb.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor_database.h" include\google\protobuf\descriptor_database.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\duration.pb.h" include\google\protobuf\duration.pb.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\dynamic_message.h" include\google\protobuf\dynamic_message.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\empty.pb.h" include\google\protobuf\empty.pb.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\extension_set.h" include\google\protobuf\extension_set.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\extension_set_inl.h" include\google\protobuf\extension_set_inl.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\field_mask.pb.h" include\google\protobuf\field_mask.pb.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_reflection.h" include\google\protobuf\generated_enum_reflection.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_util.h" include\google\protobuf\generated_enum_util.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_reflection.h" include\google\protobuf\generated_message_reflection.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_table_driven.h" include\google\protobuf\generated_message_table_driven.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_util.h" include\google\protobuf\generated_message_util.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\has_bits.h" include\google\protobuf\has_bits.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\implicit_weak_message.h" include\google\protobuf\implicit_weak_message.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\inlined_string_field.h" include\google\protobuf\inlined_string_field.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\coded_stream.h" include\google\protobuf\io\coded_stream.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\gzip_stream.h" include\google\protobuf\io\gzip_stream.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\io_win32.h" include\google\protobuf\io\io_win32.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\printer.h" include\google\protobuf\io\printer.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\strtod.h" include\google\protobuf\io\strtod.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\tokenizer.h" include\google\protobuf\io\tokenizer.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream.h" include\google\protobuf\io\zero_copy_stream.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream_impl.h" include\google\protobuf\io\zero_copy_stream_impl.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream_impl_lite.h" include\google\protobuf\io\zero_copy_stream_impl_lite.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map.h" include\google\protobuf\map.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_entry.h" include\google\protobuf\map_entry.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_entry_lite.h" include\google\protobuf\map_entry_lite.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field.h" include\google\protobuf\map_field.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field_inl.h" include\google\protobuf\map_field_inl.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field_lite.h" include\google\protobuf\map_field_lite.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_type_handler.h" include\google\protobuf\map_type_handler.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\message.h" include\google\protobuf\message.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\message_lite.h" include\google\protobuf\message_lite.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\metadata.h" include\google\protobuf\metadata.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\metadata_lite.h" include\google\protobuf\metadata_lite.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\parse_context.h" include\google\protobuf\parse_context.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\port.h" include\google\protobuf\port.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\port_def.inc" include\google\protobuf\port_def.inc +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\port_undef.inc" include\google\protobuf\port_undef.inc +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\reflection.h" include\google\protobuf\reflection.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\reflection_ops.h" include\google\protobuf\reflection_ops.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\repeated_field.h" include\google\protobuf\repeated_field.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\service.h" include\google\protobuf\service.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\source_context.pb.h" include\google\protobuf\source_context.pb.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\struct.pb.h" include\google\protobuf\struct.pb.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\bytestream.h" include\google\protobuf\stubs\bytestream.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\callback.h" include\google\protobuf\stubs\callback.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\casts.h" include\google\protobuf\stubs\casts.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\common.h" include\google\protobuf\stubs\common.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\fastmem.h" include\google\protobuf\stubs\fastmem.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\hash.h" include\google\protobuf\stubs\hash.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\logging.h" include\google\protobuf\stubs\logging.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\macros.h" include\google\protobuf\stubs\macros.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\mutex.h" include\google\protobuf\stubs\mutex.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\once.h" include\google\protobuf\stubs\once.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\platform_macros.h" include\google\protobuf\stubs\platform_macros.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\port.h" include\google\protobuf\stubs\port.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\status.h" include\google\protobuf\stubs\status.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\stl_util.h" include\google\protobuf\stubs\stl_util.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\stringpiece.h" include\google\protobuf\stubs\stringpiece.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\strutil.h" include\google\protobuf\stubs\strutil.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\template_util.h" include\google\protobuf\stubs\template_util.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\text_format.h" include\google\protobuf\text_format.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\timestamp.pb.h" include\google\protobuf\timestamp.pb.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\type.pb.h" include\google\protobuf\type.pb.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\unknown_field_set.h" include\google\protobuf\unknown_field_set.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\delimited_message_util.h" include\google\protobuf\util\delimited_message_util.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\field_comparator.h" include\google\protobuf\util\field_comparator.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\field_mask_util.h" include\google\protobuf\util\field_mask_util.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\json_util.h" include\google\protobuf\util\json_util.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\message_differencer.h" include\google\protobuf\util\message_differencer.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\time_util.h" include\google\protobuf\util\time_util.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\type_resolver.h" include\google\protobuf\util\type_resolver.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\type_resolver_util.h" include\google\protobuf\util\type_resolver_util.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format.h" include\google\protobuf\wire_format.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format_lite.h" include\google\protobuf\wire_format_lite.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wrappers.pb.h" include\google\protobuf\wrappers.pb.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\any.proto" include\google\protobuf\any.proto +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\api.proto" include\google\protobuf\api.proto +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.proto" include\google\protobuf\compiler\plugin.proto +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.proto" include\google\protobuf\descriptor.proto +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\duration.proto" include\google\protobuf\duration.proto +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\empty.proto" include\google\protobuf\empty.proto +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\field_mask.proto" include\google\protobuf\field_mask.proto +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\source_context.proto" include\google\protobuf\source_context.proto +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\struct.proto" include\google\protobuf\struct.proto +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\timestamp.proto" include\google\protobuf\timestamp.proto +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\type.proto" include\google\protobuf\type.proto +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wrappers.proto" include\google\protobuf\wrappers.proto diff --git a/third_party/protobuf/cmake/install.cmake b/third_party/protobuf/cmake/install.cmake index dbb4265d4502..be47c54a1e21 100644 --- a/third_party/protobuf/cmake/install.cmake +++ b/third_party/protobuf/cmake/install.cmake @@ -1,49 +1,67 @@ include(GNUInstallDirs) -foreach(_library - libprotobuf-lite - libprotobuf - libprotoc) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/protobuf.pc.cmake + ${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc @ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/protobuf-lite.pc.cmake + ${CMAKE_CURRENT_BINARY_DIR}/protobuf-lite.pc @ONLY) + +set(_protobuf_libraries libprotobuf-lite libprotobuf) +if (protobuf_BUILD_PROTOC_BINARIES) + list(APPEND _protobuf_libraries libprotoc) +endif (protobuf_BUILD_PROTOC_BINARIES) + +foreach(_library ${_protobuf_libraries}) set_property(TARGET ${_library} PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ $) + if (UNIX AND NOT APPLE) + set_property(TARGET ${_library} + PROPERTY INSTALL_RPATH "$ORIGIN") + elseif (APPLE) + set_property(TARGET ${_library} + PROPERTY INSTALL_RPATH "@loader_path") + endif() install(TARGETS ${_library} EXPORT protobuf-targets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${_library} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${_library} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${_library}) endforeach() -install(TARGETS protoc EXPORT protobuf-targets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc) +if (protobuf_BUILD_PROTOC_BINARIES) + install(TARGETS protoc EXPORT protobuf-targets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc) + if (UNIX AND NOT APPLE) + set_property(TARGET protoc + PROPERTY INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") + elseif (APPLE) + set_property(TARGET protoc + PROPERTY INSTALL_RPATH "@loader_path/../lib") + endif() +endif (protobuf_BUILD_PROTOC_BINARIES) -if(TRUE) - file(STRINGS extract_includes.bat.in _extract_strings - REGEX "^copy") - foreach(_extract_string ${_extract_strings}) - string(REPLACE "copy \${PROTOBUF_SOURCE_WIN32_PATH}\\" "" - _extract_string ${_extract_string}) - string(REPLACE "\\" "/" _extract_string ${_extract_string}) - string(REGEX MATCH "^[^ ]+" - _extract_from ${_extract_string}) - string(REGEX REPLACE "^${_extract_from} ([^$]+)" "\\1" - _extract_to ${_extract_string}) - get_filename_component(_extract_from "${protobuf_SOURCE_DIR}/${_extract_from}" ABSOLUTE) - get_filename_component(_extract_name ${_extract_to} NAME) - get_filename_component(_extract_to ${_extract_to} PATH) - string(REPLACE "include/" "${CMAKE_INSTALL_INCLUDEDIR}/" - _extract_to "${_extract_to}") - if(EXISTS "${_extract_from}") - install(FILES "${_extract_from}" - DESTINATION "${_extract_to}" - COMPONENT protobuf-headers - RENAME "${_extract_name}") - else() - message(AUTHOR_WARNING "The file \"${_extract_from}\" is listed in " - "\"${protobuf_SOURCE_DIR}/cmake/extract_includes.bat.in\" " - "but there not exists. The file will not be installed.") - endif() - endforeach() -endif() +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc ${CMAKE_CURRENT_BINARY_DIR}/protobuf-lite.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + +file(STRINGS extract_includes.bat.in _extract_strings + REGEX "^copy") +foreach(_extract_string ${_extract_strings}) + string(REGEX REPLACE "^.* .+ include\\\\(.+)$" "\\1" + _header ${_extract_string}) + string(REPLACE "\\" "/" _header ${_header}) + get_filename_component(_extract_from "${protobuf_SOURCE_DIR}/../src/${_header}" ABSOLUTE) + get_filename_component(_extract_name ${_header} NAME) + get_filename_component(_extract_to "${CMAKE_INSTALL_INCLUDEDIR}/${_header}" PATH) + if(EXISTS "${_extract_from}") + install(FILES "${_extract_from}" + DESTINATION "${_extract_to}" + COMPONENT protobuf-headers + RENAME "${_extract_name}") + else() + message(AUTHOR_WARNING "The file \"${_extract_from}\" is listed in " + "\"${protobuf_SOURCE_DIR}/cmake/extract_includes.bat.in\" " + "but there not exists. The file will not be installed.") + endif() +endforeach() # Internal function for parsing auto tools scripts function(_protobuf_auto_list FILE_NAME VARIABLE) @@ -82,22 +100,51 @@ foreach(_file ${nobase_dist_proto_DATA}) endif() endforeach() -# Export configuration - -install(EXPORT protobuf-targets - DESTINATION "lib/cmake/protobuf" - COMPONENT protobuf-export) +# Install configuration +set(_cmakedir_desc "Directory relative to CMAKE_INSTALL to install the cmake configuration files") +if(NOT MSVC) + set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/protobuf" CACHE STRING "${_cmakedir_desc}") +else() + set(CMAKE_INSTALL_CMAKEDIR "cmake" CACHE STRING "${_cmakedir_desc}") +endif() +mark_as_advanced(CMAKE_INSTALL_CMAKEDIR) configure_file(protobuf-config.cmake.in - protobuf-config.cmake @ONLY) + ${CMAKE_INSTALL_CMAKEDIR}/protobuf-config.cmake @ONLY) configure_file(protobuf-config-version.cmake.in - protobuf-config-version.cmake @ONLY) + ${CMAKE_INSTALL_CMAKEDIR}/protobuf-config-version.cmake @ONLY) configure_file(protobuf-module.cmake.in - protobuf-module.cmake @ONLY) + ${CMAKE_INSTALL_CMAKEDIR}/protobuf-module.cmake @ONLY) +configure_file(protobuf-options.cmake + ${CMAKE_INSTALL_CMAKEDIR}/protobuf-options.cmake @ONLY) + +# Allows the build directory to be used as a find directory. -install(FILES - "${protobuf_BINARY_DIR}/protobuf-config.cmake" - "${protobuf_BINARY_DIR}/protobuf-config-version.cmake" - "${protobuf_BINARY_DIR}/protobuf-module.cmake" - DESTINATION "lib/cmake/protobuf" +if (protobuf_BUILD_PROTOC_BINARIES) + export(TARGETS libprotobuf-lite libprotobuf libprotoc protoc + NAMESPACE protobuf:: + FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake + ) +else (protobuf_BUILD_PROTOC_BINARIES) + export(TARGETS libprotobuf-lite libprotobuf + NAMESPACE protobuf:: + FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake + ) +endif (protobuf_BUILD_PROTOC_BINARIES) + +install(EXPORT protobuf-targets + DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" + NAMESPACE protobuf:: COMPONENT protobuf-export) + +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}/ + DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" + COMPONENT protobuf-export + PATTERN protobuf-targets.cmake EXCLUDE +) + +option(protobuf_INSTALL_EXAMPLES "Install the examples folder" OFF) +if(protobuf_INSTALL_EXAMPLES) + install(DIRECTORY ../examples/ DESTINATION examples + COMPONENT protobuf-examples) +endif() diff --git a/third_party/protobuf/cmake/libprotobuf-lite.cmake b/third_party/protobuf/cmake/libprotobuf-lite.cmake index 036b051707db..c06cf9658cb4 100644 --- a/third_party/protobuf/cmake/libprotobuf-lite.cmake +++ b/third_party/protobuf/cmake/libprotobuf-lite.cmake @@ -1,19 +1,23 @@ set(libprotobuf_lite_files + ${protobuf_source_dir}/src/google/protobuf/any_lite.cc ${protobuf_source_dir}/src/google/protobuf/arena.cc - ${protobuf_source_dir}/src/google/protobuf/arenastring.cc ${protobuf_source_dir}/src/google/protobuf/extension_set.cc + ${protobuf_source_dir}/src/google/protobuf/generated_enum_util.cc + ${protobuf_source_dir}/src/google/protobuf/generated_message_table_driven_lite.cc ${protobuf_source_dir}/src/google/protobuf/generated_message_util.cc + ${protobuf_source_dir}/src/google/protobuf/implicit_weak_message.cc ${protobuf_source_dir}/src/google/protobuf/io/coded_stream.cc + ${protobuf_source_dir}/src/google/protobuf/io/io_win32.cc + ${protobuf_source_dir}/src/google/protobuf/io/strtod.cc ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.cc + ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl.cc ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc ${protobuf_source_dir}/src/google/protobuf/message_lite.cc + ${protobuf_source_dir}/src/google/protobuf/parse_context.cc ${protobuf_source_dir}/src/google/protobuf/repeated_field.cc - ${protobuf_source_dir}/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc - ${protobuf_source_dir}/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc ${protobuf_source_dir}/src/google/protobuf/stubs/bytestream.cc ${protobuf_source_dir}/src/google/protobuf/stubs/common.cc ${protobuf_source_dir}/src/google/protobuf/stubs/int128.cc - ${protobuf_source_dir}/src/google/protobuf/stubs/once.cc ${protobuf_source_dir}/src/google/protobuf/stubs/status.cc ${protobuf_source_dir}/src/google/protobuf/stubs/statusor.cc ${protobuf_source_dir}/src/google/protobuf/stubs/stringpiece.cc @@ -24,8 +28,41 @@ set(libprotobuf_lite_files ${protobuf_source_dir}/src/google/protobuf/wire_format_lite.cc ) +set(libprotobuf_lite_includes + ${protobuf_source_dir}/src/google/protobuf/arena.h + ${protobuf_source_dir}/src/google/protobuf/arenastring.h + ${protobuf_source_dir}/src/google/protobuf/extension_set.h + ${protobuf_source_dir}/src/google/protobuf/generated_message_util.h + ${protobuf_source_dir}/src/google/protobuf/implicit_weak_message.h + ${protobuf_source_dir}/src/google/protobuf/parse_context.h + ${protobuf_source_dir}/src/google/protobuf/io/coded_stream.h + ${protobuf_source_dir}/src/google/protobuf/io/strtod.h + ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.h + ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl.h + ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.h + ${protobuf_source_dir}/src/google/protobuf/message_lite.h + ${protobuf_source_dir}/src/google/protobuf/repeated_field.h + ${protobuf_source_dir}/src/google/protobuf/stubs/bytestream.h + ${protobuf_source_dir}/src/google/protobuf/stubs/common.h + ${protobuf_source_dir}/src/google/protobuf/stubs/int128.h + ${protobuf_source_dir}/src/google/protobuf/stubs/once.h + ${protobuf_source_dir}/src/google/protobuf/stubs/status.h + ${protobuf_source_dir}/src/google/protobuf/stubs/statusor.h + ${protobuf_source_dir}/src/google/protobuf/stubs/stringpiece.h + ${protobuf_source_dir}/src/google/protobuf/stubs/stringprintf.h + ${protobuf_source_dir}/src/google/protobuf/stubs/strutil.h + ${protobuf_source_dir}/src/google/protobuf/stubs/time.h + ${protobuf_source_dir}/src/google/protobuf/wire_format_lite.h +) + +if (MSVC) +set(libprotobuf_lite_rc_files + ${CMAKE_CURRENT_BINARY_DIR}/version.rc +) +endif() + add_library(libprotobuf-lite ${protobuf_SHARED_OR_STATIC} - ${libprotobuf_lite_files}) + ${libprotobuf_lite_files} ${libprotobuf_lite_includes} ${libprotobuf_lite_rc_files}) target_link_libraries(libprotobuf-lite ${CMAKE_THREAD_LIBS_INIT}) target_include_directories(libprotobuf-lite PUBLIC ${protobuf_source_dir}/src) if(MSVC AND protobuf_BUILD_SHARED_LIBS) @@ -34,5 +71,7 @@ if(MSVC AND protobuf_BUILD_SHARED_LIBS) PRIVATE LIBPROTOBUF_EXPORTS) endif() set_target_properties(libprotobuf-lite PROPERTIES + VERSION ${protobuf_VERSION} OUTPUT_NAME ${LIB_PREFIX}protobuf-lite DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}") +add_library(protobuf::libprotobuf-lite ALIAS libprotobuf-lite) diff --git a/third_party/protobuf/cmake/libprotobuf.cmake b/third_party/protobuf/cmake/libprotobuf.cmake index 8930c1ca1ecf..fd70da7e4a76 100644 --- a/third_party/protobuf/cmake/libprotobuf.cmake +++ b/third_party/protobuf/cmake/libprotobuf.cmake @@ -13,11 +13,10 @@ set(libprotobuf_files ${protobuf_source_dir}/src/google/protobuf/extension_set_heavy.cc ${protobuf_source_dir}/src/google/protobuf/field_mask.pb.cc ${protobuf_source_dir}/src/google/protobuf/generated_message_reflection.cc + ${protobuf_source_dir}/src/google/protobuf/generated_message_table_driven.cc ${protobuf_source_dir}/src/google/protobuf/io/gzip_stream.cc ${protobuf_source_dir}/src/google/protobuf/io/printer.cc - ${protobuf_source_dir}/src/google/protobuf/io/strtod.cc ${protobuf_source_dir}/src/google/protobuf/io/tokenizer.cc - ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl.cc ${protobuf_source_dir}/src/google/protobuf/map_field.cc ${protobuf_source_dir}/src/google/protobuf/message.cc ${protobuf_source_dir}/src/google/protobuf/reflection_ops.cc @@ -30,6 +29,7 @@ set(libprotobuf_files ${protobuf_source_dir}/src/google/protobuf/timestamp.pb.cc ${protobuf_source_dir}/src/google/protobuf/type.pb.cc ${protobuf_source_dir}/src/google/protobuf/unknown_field_set.cc + ${protobuf_source_dir}/src/google/protobuf/util/delimited_message_util.cc ${protobuf_source_dir}/src/google/protobuf/util/field_comparator.cc ${protobuf_source_dir}/src/google/protobuf/util/field_mask_util.cc ${protobuf_source_dir}/src/google/protobuf/util/internal/datapiece.cc @@ -54,9 +54,72 @@ set(libprotobuf_files ${protobuf_source_dir}/src/google/protobuf/wrappers.pb.cc ) +set(libprotobuf_includes + ${protobuf_source_dir}/src/google/protobuf/any.h + ${protobuf_source_dir}/src/google/protobuf/any.pb.h + ${protobuf_source_dir}/src/google/protobuf/api.pb.h + ${protobuf_source_dir}/src/google/protobuf/compiler/importer.h + ${protobuf_source_dir}/src/google/protobuf/compiler/parser.h + ${protobuf_source_dir}/src/google/protobuf/descriptor.h + ${protobuf_source_dir}/src/google/protobuf/descriptor.pb.h + ${protobuf_source_dir}/src/google/protobuf/descriptor_database.h + ${protobuf_source_dir}/src/google/protobuf/duration.pb.h + ${protobuf_source_dir}/src/google/protobuf/dynamic_message.h + ${protobuf_source_dir}/src/google/protobuf/empty.pb.h + ${protobuf_source_dir}/src/google/protobuf/field_mask.pb.h + ${protobuf_source_dir}/src/google/protobuf/generated_message_reflection.h + ${protobuf_source_dir}/src/google/protobuf/io/gzip_stream.h + ${protobuf_source_dir}/src/google/protobuf/io/printer.h + ${protobuf_source_dir}/src/google/protobuf/io/tokenizer.h + ${protobuf_source_dir}/src/google/protobuf/map_field.h + ${protobuf_source_dir}/src/google/protobuf/message.h + ${protobuf_source_dir}/src/google/protobuf/reflection_ops.h + ${protobuf_source_dir}/src/google/protobuf/service.h + ${protobuf_source_dir}/src/google/protobuf/source_context.pb.h + ${protobuf_source_dir}/src/google/protobuf/struct.pb.h + ${protobuf_source_dir}/src/google/protobuf/stubs/mathlimits.h + ${protobuf_source_dir}/src/google/protobuf/stubs/substitute.h + ${protobuf_source_dir}/src/google/protobuf/text_format.h + ${protobuf_source_dir}/src/google/protobuf/timestamp.pb.h + ${protobuf_source_dir}/src/google/protobuf/type.pb.h + ${protobuf_source_dir}/src/google/protobuf/unknown_field_set.h + ${protobuf_source_dir}/src/google/protobuf/util/delimited_message_util.h + ${protobuf_source_dir}/src/google/protobuf/util/field_comparator.h + ${protobuf_source_dir}/src/google/protobuf/util/field_mask_util.h + ${protobuf_source_dir}/src/google/protobuf/util/internal/datapiece.h + ${protobuf_source_dir}/src/google/protobuf/util/internal/default_value_objectwriter.h + ${protobuf_source_dir}/src/google/protobuf/util/internal/error_listener.h + ${protobuf_source_dir}/src/google/protobuf/util/internal/field_mask_utility.h + ${protobuf_source_dir}/src/google/protobuf/util/internal/json_escaping.h + ${protobuf_source_dir}/src/google/protobuf/util/internal/json_objectwriter.h + ${protobuf_source_dir}/src/google/protobuf/util/internal/json_stream_parser.h + ${protobuf_source_dir}/src/google/protobuf/util/internal/object_writer.h + ${protobuf_source_dir}/src/google/protobuf/util/internal/proto_writer.h + ${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectsource.h + ${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectwriter.h + ${protobuf_source_dir}/src/google/protobuf/util/internal/type_info.h + ${protobuf_source_dir}/src/google/protobuf/util/internal/type_info_test_helper.h + ${protobuf_source_dir}/src/google/protobuf/util/internal/utility.h + ${protobuf_source_dir}/src/google/protobuf/util/json_util.h + ${protobuf_source_dir}/src/google/protobuf/util/message_differencer.h + ${protobuf_source_dir}/src/google/protobuf/util/time_util.h + ${protobuf_source_dir}/src/google/protobuf/util/type_resolver_util.h + ${protobuf_source_dir}/src/google/protobuf/wire_format.h + ${protobuf_source_dir}/src/google/protobuf/wrappers.pb.h +) + +if (MSVC) +set(libprotobuf_rc_files + ${CMAKE_CURRENT_BINARY_DIR}/version.rc +) +endif() + add_library(libprotobuf ${protobuf_SHARED_OR_STATIC} - ${libprotobuf_lite_files} ${libprotobuf_files}) -target_link_libraries(libprotobuf ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARIES}) + ${libprotobuf_lite_files} ${libprotobuf_files} ${libprotobuf_includes} ${libprotobuf_rc_files}) +target_link_libraries(libprotobuf ${CMAKE_THREAD_LIBS_INIT}) +if(protobuf_WITH_ZLIB) + target_link_libraries(libprotobuf ${ZLIB_LIBRARIES}) +endif() target_include_directories(libprotobuf PUBLIC ${protobuf_source_dir}/src) if(MSVC AND protobuf_BUILD_SHARED_LIBS) target_compile_definitions(libprotobuf @@ -64,5 +127,7 @@ if(MSVC AND protobuf_BUILD_SHARED_LIBS) PRIVATE LIBPROTOBUF_EXPORTS) endif() set_target_properties(libprotobuf PROPERTIES + VERSION ${protobuf_VERSION} OUTPUT_NAME ${LIB_PREFIX}protobuf DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}") +add_library(protobuf::libprotobuf ALIAS libprotobuf) diff --git a/third_party/protobuf/cmake/libprotoc.cmake b/third_party/protobuf/cmake/libprotoc.cmake index 8df8986a1133..b71f2f1ba9a6 100644 --- a/third_party/protobuf/cmake/libprotoc.cmake +++ b/third_party/protobuf/cmake/libprotoc.cmake @@ -11,6 +11,7 @@ set(libprotoc_files ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_map_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_message.cc ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_message_field.cc + ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_service.cc ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_string_field.cc @@ -43,8 +44,6 @@ set(libprotoc_files ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_generator.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_generator_factory.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_helpers.cc - ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_lazy_message_field.cc - ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_map_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_map_field_lite.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message.cc @@ -60,18 +59,8 @@ set(libprotoc_files ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_shared_code_generator.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_string_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_string_field_lite.cc - ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_enum.cc - ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_enum_field.cc - ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_extension.cc - ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_field.cc - ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_file.cc - ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_generator.cc - ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_helpers.cc - ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_map_field.cc - ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_message.cc - ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_message_field.cc - ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/js/js_generator.cc + ${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types_embed.cc ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum.cc ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_extension.cc @@ -84,6 +73,7 @@ set(libprotoc_files ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc + ${protobuf_source_dir}/src/google/protobuf/compiler/php/php_generator.cc ${protobuf_source_dir}/src/google/protobuf/compiler/plugin.cc ${protobuf_source_dir}/src/google/protobuf/compiler/plugin.pb.cc ${protobuf_source_dir}/src/google/protobuf/compiler/python/python_generator.cc @@ -92,8 +82,91 @@ set(libprotoc_files ${protobuf_source_dir}/src/google/protobuf/compiler/zip_writer.cc ) +set(libprotoc_headers + ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_enum.h + ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_enum_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_extension.h + ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_file.h + ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_helpers.h + ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_map_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_message.h + ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_message_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_message_layout_helper.h + ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_options.h + ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.h + ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_primitive_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_service.h + ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_string_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_doc_comment.h + ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_enum.h + ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_enum_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_field_base.h + ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_helpers.h + ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_map_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_message.h + ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_message_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_options.h + ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_primitive_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_reflection_class.h + ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h + ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_context.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_doc_comment.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field_lite.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_lite.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_extension.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_extension_lite.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_file.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_generator_factory.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_helpers.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_map_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_map_field_lite.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_builder.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_builder_lite.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_field_lite.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_lite.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_name_resolver.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_options.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_primitive_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_primitive_field_lite.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_service.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_shared_code_generator.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_string_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_string_field_lite.h + ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum.h + ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_extension.h + ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_file.h + ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_helpers.h + ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_map_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message.h + ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_nsobject_methods.h + ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_oneof.h + ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h + ${protobuf_source_dir}/src/google/protobuf/compiler/scc.h + ${protobuf_source_dir}/src/google/protobuf/compiler/subprocess.h + ${protobuf_source_dir}/src/google/protobuf/compiler/zip_writer.h +) + +if (MSVC) +set(libprotoc_rc_files + ${CMAKE_CURRENT_BINARY_DIR}/version.rc +) +endif() + add_library(libprotoc ${protobuf_SHARED_OR_STATIC} - ${libprotoc_files}) + ${libprotoc_files} ${libprotoc_headers} ${libprotoc_rc_files}) target_link_libraries(libprotoc libprotobuf) if(MSVC AND protobuf_BUILD_SHARED_LIBS) target_compile_definitions(libprotoc @@ -102,5 +175,8 @@ if(MSVC AND protobuf_BUILD_SHARED_LIBS) endif() set_target_properties(libprotoc PROPERTIES COMPILE_DEFINITIONS LIBPROTOC_EXPORTS + VERSION ${protobuf_VERSION} OUTPUT_NAME ${LIB_PREFIX}protoc DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}") +add_library(protobuf::libprotoc ALIAS libprotoc) + diff --git a/third_party/protobuf/cmake/protobuf-config-version.cmake.in b/third_party/protobuf/cmake/protobuf-config-version.cmake.in index 1f171c66497a..3fa01763ee65 100644 --- a/third_party/protobuf/cmake/protobuf-config-version.cmake.in +++ b/third_party/protobuf/cmake/protobuf-config-version.cmake.in @@ -1 +1,60 @@ -set(PACKAGE_VERSION @protobuf_VERSION@) +set(PACKAGE_VERSION "@protobuf_VERSION@") +set(${PACKAGE_FIND_NAME}_VERSION_PRERELEASE "@protobuf_VERSION_PRERELEASE@" PARENT_SCOPE) + +# Prerelease versions cannot be passed in directly via the find_package command, +# so we allow users to specify it in a variable +if(NOT DEFINED "${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE") + set("${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}" "") +else() + set(PACKAGE_FIND_VERSION ${PACKAGE_FIND_VERSION}-${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}) +endif() +set(PACKAGE_FIND_VERSION_PRERELEASE "${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}") + +# VERSION_EQUAL ignores the prerelease strings, so we use STREQUAL. +if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) +endif() + +set(PACKAGE_VERSION_COMPATIBLE TRUE) #Assume true until shown otherwise + +if(PACKAGE_FIND_VERSION) #Only perform version checks if one is given + if(NOT PACKAGE_FIND_VERSION_MAJOR EQUAL "@protobuf_VERSION_MAJOR@") + set(PACKAGE_VERSION_COMPATIBLE FALSE) + elseif(PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + elseif(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) + # Do not match prerelease versions to non-prerelease version requests. + if(NOT "@protobuf_VERSION_PRERELEASE@" STREQUAL "" AND PACKAGE_FIND_VERSION_PRERELEASE STREQUAL "") + message(AUTHOR_WARNING "To use this prerelease version of ${PACKAGE_FIND_NAME}, set ${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE to '@protobuf_VERSION_PRERELEASE@' or greater.") + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() + + # Not robustly SemVer compliant, but protobuf never uses '.' separated prerelease identifiers. + if(PACKAGE_FIND_VERSION_PRERELEASE STRGREATER "@protobuf_VERSION_PRERELEASE@") + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() + endif() +endif() + +# Check and save build options used to create this package +macro(_check_and_save_build_option OPTION VALUE) + if(DEFINED ${PACKAGE_FIND_NAME}_${OPTION} AND + NOT ${PACKAGE_FIND_NAME}_${OPTION} STREQUAL ${VALUE}) + set(PACKAGE_VERSION_UNSUITABLE TRUE) + endif() + set(${PACKAGE_FIND_NAME}_${OPTION} ${VALUE} PARENT_SCOPE) +endmacro() +_check_and_save_build_option(WITH_ZLIB @protobuf_WITH_ZLIB@) +_check_and_save_build_option(MSVC_STATIC_RUNTIME @protobuf_MSVC_STATIC_RUNTIME@) +_check_and_save_build_option(BUILD_SHARED_LIBS @protobuf_BUILD_SHARED_LIBS@) + +# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: +if(CMAKE_SIZEOF_VOID_P AND "@CMAKE_SIZEOF_VOID_P@") + # check that the installed version has the same 32/64bit-ness as the one which is currently searching: + if(NOT CMAKE_SIZEOF_VOID_P EQUAL "@CMAKE_SIZEOF_VOID_P@") + math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") + set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") + set(PACKAGE_VERSION_UNSUITABLE TRUE) + endif() +endif() + diff --git a/third_party/protobuf/cmake/protobuf-config.cmake.in b/third_party/protobuf/cmake/protobuf-config.cmake.in index bb0997b88be7..29e39d88af79 100644 --- a/third_party/protobuf/cmake/protobuf-config.cmake.in +++ b/third_party/protobuf/cmake/protobuf-config.cmake.in @@ -1,27 +1,127 @@ -# Version info variables -set(PROTOBUF_VERSION "@protobuf_VERSION@") -set(PROTOBUF_VERSION_STRING "@protobuf_VERSION_STRING@") +# User options +include("${CMAKE_CURRENT_LIST_DIR}/protobuf-options.cmake") -# Current dir -get_filename_component(_PROTOBUF_PACKAGE_PREFIX - "${CMAKE_CURRENT_LIST_FILE}" PATH) +# Depend packages +@_protobuf_FIND_ZLIB@ # Imported targets -include("${_PROTOBUF_PACKAGE_PREFIX}/protobuf-targets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/protobuf-targets.cmake") -# Compute the installation prefix relative to this file. -get_filename_component(_PROTOBUF_IMPORT_PREFIX - "${_PROTOBUF_PACKAGE_PREFIX}" PATH) -get_filename_component(_PROTOBUF_IMPORT_PREFIX - "${_PROTOBUF_IMPORT_PREFIX}" PATH) -get_filename_component(_PROTOBUF_IMPORT_PREFIX - "${_PROTOBUF_IMPORT_PREFIX}" PATH) +function(protobuf_generate) + include(CMakeParseArguments) + + set(_options APPEND_PATH) + set(_singleargs LANGUAGE OUT_VAR EXPORT_MACRO PROTOC_OUT_DIR) + if(COMMAND target_sources) + list(APPEND _singleargs TARGET) + endif() + set(_multiargs PROTOS IMPORT_DIRS GENERATE_EXTENSIONS) + + cmake_parse_arguments(protobuf_generate "${_options}" "${_singleargs}" "${_multiargs}" "${ARGN}") + + if(NOT protobuf_generate_PROTOS AND NOT protobuf_generate_TARGET) + message(SEND_ERROR "Error: protobuf_generate called without any targets or source files") + return() + endif() + + if(NOT protobuf_generate_OUT_VAR AND NOT protobuf_generate_TARGET) + message(SEND_ERROR "Error: protobuf_generate called without a target or output variable") + return() + endif() + + if(NOT protobuf_generate_LANGUAGE) + set(protobuf_generate_LANGUAGE cpp) + endif() + string(TOLOWER ${protobuf_generate_LANGUAGE} protobuf_generate_LANGUAGE) + + if(NOT protobuf_generate_PROTOC_OUT_DIR) + set(protobuf_generate_PROTOC_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) + endif() + + if(protobuf_generate_EXPORT_MACRO AND protobuf_generate_LANGUAGE STREQUAL cpp) + set(_dll_export_decl "dllexport_decl=${protobuf_generate_EXPORT_MACRO}:") + endif() + + if(NOT protobuf_generate_GENERATE_EXTENSIONS) + if(protobuf_generate_LANGUAGE STREQUAL cpp) + set(protobuf_generate_GENERATE_EXTENSIONS .pb.h .pb.cc) + elseif(protobuf_generate_LANGUAGE STREQUAL python) + set(protobuf_generate_GENERATE_EXTENSIONS _pb2.py) + else() + message(SEND_ERROR "Error: protobuf_generate given unknown Language ${LANGUAGE}, please provide a value for GENERATE_EXTENSIONS") + return() + endif() + endif() + + if(protobuf_generate_TARGET) + get_target_property(_source_list ${protobuf_generate_TARGET} SOURCES) + foreach(_file ${_source_list}) + if(_file MATCHES "proto$") + list(APPEND protobuf_generate_PROTOS ${_file}) + endif() + endforeach() + endif() + + if(NOT protobuf_generate_PROTOS) + message(SEND_ERROR "Error: protobuf_generate could not find any .proto files") + return() + endif() + + if(protobuf_generate_APPEND_PATH) + # Create an include path for each file specified + foreach(_file ${protobuf_generate_PROTOS}) + get_filename_component(_abs_file ${_file} ABSOLUTE) + get_filename_component(_abs_path ${_abs_file} PATH) + list(FIND _protobuf_include_path ${_abs_path} _contains_already) + if(${_contains_already} EQUAL -1) + list(APPEND _protobuf_include_path -I ${_abs_path}) + endif() + endforeach() + else() + set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR}) + endif() + + foreach(DIR ${protobuf_generate_IMPORT_DIRS}) + get_filename_component(ABS_PATH ${DIR} ABSOLUTE) + list(FIND _protobuf_include_path ${ABS_PATH} _contains_already) + if(${_contains_already} EQUAL -1) + list(APPEND _protobuf_include_path -I ${ABS_PATH}) + endif() + endforeach() + + set(_generated_srcs_all) + foreach(_proto ${protobuf_generate_PROTOS}) + get_filename_component(_abs_file ${_proto} ABSOLUTE) + get_filename_component(_abs_dir ${_abs_file} DIRECTORY) + get_filename_component(_basename ${_proto} NAME_WE) + file(RELATIVE_PATH _rel_dir ${CMAKE_CURRENT_SOURCE_DIR} ${_abs_dir}) + + set(_generated_srcs) + foreach(_ext ${protobuf_generate_GENERATE_EXTENSIONS}) + list(APPEND _generated_srcs "${protobuf_generate_PROTOC_OUT_DIR}/${_rel_dir}/${_basename}${_ext}") + endforeach() + list(APPEND _generated_srcs_all ${_generated_srcs}) + + add_custom_command( + OUTPUT ${_generated_srcs} + COMMAND protobuf::protoc + ARGS --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${protobuf_generate_PROTOC_OUT_DIR} ${_protobuf_include_path} ${_abs_file} + DEPENDS ${_abs_file} protobuf::protoc + COMMENT "Running ${protobuf_generate_LANGUAGE} protocol buffer compiler on ${_proto}" + VERBATIM ) + endforeach() + + set_source_files_properties(${_generated_srcs_all} PROPERTIES GENERATED TRUE) + if(protobuf_generate_OUT_VAR) + set(${protobuf_generate_OUT_VAR} ${_generated_srcs_all} PARENT_SCOPE) + endif() + if(protobuf_generate_TARGET) + target_sources(${protobuf_generate_TARGET} PRIVATE ${_generated_srcs_all}) + endif() + +endfunction() # CMake FindProtobuf module compatible file -if(NOT DEFINED PROTOBUF_MODULE_COMPATIBLE OR "${PROTOBUF_MODULE_COMPATIBLE}") - include("${_PROTOBUF_PACKAGE_PREFIX}/protobuf-module.cmake") +if(protobuf_MODULE_COMPATIBLE) + include("${CMAKE_CURRENT_LIST_DIR}/protobuf-module.cmake") endif() - -# Cleanup temporary variables. -set(_PROTOBUF_PACKAGE_PREFIX) -set(_PROTOBUF_IMPORT_PREFIX) diff --git a/third_party/protobuf/cmake/protobuf-lite.pc.cmake b/third_party/protobuf/cmake/protobuf-lite.pc.cmake new file mode 100644 index 000000000000..cbe5426afa43 --- /dev/null +++ b/third_party/protobuf/cmake/protobuf-lite.pc.cmake @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: Protocol Buffers +Description: Google's Data Interchange Format +Version: @protobuf_VERSION@ +Libs: -L${libdir} -lprotobuf-lite @CMAKE_THREAD_LIBS_INIT@ +Cflags: -I${includedir} @CMAKE_THREAD_LIBS_INIT@ +Conflicts: protobuf diff --git a/third_party/protobuf/cmake/protobuf-module.cmake.in b/third_party/protobuf/cmake/protobuf-module.cmake.in index d81dc459b6a5..74c5488729a1 100644 --- a/third_party/protobuf/cmake/protobuf-module.cmake.in +++ b/third_party/protobuf/cmake/protobuf-module.cmake.in @@ -1,89 +1,109 @@ -if(PROTOBUF_SRC_ROOT_FOLDER) - message(AUTHOR_WARNING "Variable PROTOBUF_SRC_ROOT_FOLDER defined, but not" - " used in CONFIG mode") -endif() +# This file contains backwards compatibility patches for various legacy functions and variables +# Functions function(PROTOBUF_GENERATE_CPP SRCS HDRS) - if(NOT ARGN) + cmake_parse_arguments(protobuf_generate_cpp "" "EXPORT_MACRO" "" ${ARGN}) + + set(_proto_files "${protobuf_generate_cpp_UNPARSED_ARGUMENTS}") + if(NOT _proto_files) message(SEND_ERROR "Error: PROTOBUF_GENERATE_CPP() called without any proto files") return() endif() if(PROTOBUF_GENERATE_CPP_APPEND_PATH) - # Create an include path for each file specified - foreach(FIL ${ARGN}) - get_filename_component(ABS_FIL ${FIL} ABSOLUTE) - get_filename_component(ABS_PATH ${ABS_FIL} PATH) - list(FIND _protobuf_include_path ${ABS_PATH} _contains_already) - if(${_contains_already} EQUAL -1) - list(APPEND _protobuf_include_path -I ${ABS_PATH}) - endif() - endforeach() - else() - set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR}) + set(_append_arg APPEND_PATH) endif() - # Add well-known type protos include path - list(APPEND _protobuf_include_path - -I "${_PROTOBUF_IMPORT_PREFIX}/@CMAKE_INSTALL_INCLUDEDIR@") - - if(DEFINED PROTOBUF_IMPORT_DIRS) - foreach(DIR ${PROTOBUF_IMPORT_DIRS}) - get_filename_component(ABS_PATH ${DIR} ABSOLUTE) - list(FIND _protobuf_include_path ${ABS_PATH} _contains_already) - if(${_contains_already} EQUAL -1) - list(APPEND _protobuf_include_path -I ${ABS_PATH}) - endif() - endforeach() + if(DEFINED Protobuf_IMPORT_DIRS) + set(_import_arg IMPORT_DIRS ${Protobuf_IMPORT_DIRS}) endif() + set(_outvar) + protobuf_generate(${_append_arg} LANGUAGE cpp EXPORT_MACRO ${protobuf_generate_cpp_EXPORT_MACRO} OUT_VAR _outvar ${_import_arg} PROTOS ${_proto_files}) + set(${SRCS}) set(${HDRS}) - foreach(FIL ${ARGN}) - get_filename_component(ABS_FIL ${FIL} ABSOLUTE) - get_filename_component(FIL_WE ${FIL} NAME_WE) - - list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc") - list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h") - - add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc" - "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h" - COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} - ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL} - DEPENDS ${ABS_FIL} ${PROTOBUF_PROTOC_EXECUTABLE} - COMMENT "Running C++ protocol buffer compiler on ${FIL}" - VERBATIM) + foreach(_file ${_outvar}) + if(_file MATCHES "cc$") + list(APPEND ${SRCS} ${_file}) + else() + list(APPEND ${HDRS} ${_file}) + endif() endforeach() - - set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE) set(${SRCS} ${${SRCS}} PARENT_SCOPE) set(${HDRS} ${${HDRS}} PARENT_SCOPE) endfunction() +function(PROTOBUF_GENERATE_PYTHON SRCS) + if(NOT ARGN) + message(SEND_ERROR "Error: PROTOBUF_GENERATE_PYTHON() called without any proto files") + return() + endif() + + if(PROTOBUF_GENERATE_CPP_APPEND_PATH) + set(_append_arg APPEND_PATH) + endif() + + if(DEFINED Protobuf_IMPORT_DIRS) + set(_import_arg IMPORT_DIRS ${Protobuf_IMPORT_DIRS}) + endif() + + set(_outvar) + protobuf_generate(${_append_arg} LANGUAGE python OUT_VAR _outvar ${_import_arg} PROTOS ${ARGN}) + set(${SRCS} ${_outvar} PARENT_SCOPE) +endfunction() + +# Environment + +# Backwards compatibility +# Define camel case versions of input variables +foreach(UPPER + PROTOBUF_SRC_ROOT_FOLDER + PROTOBUF_IMPORT_DIRS + PROTOBUF_DEBUG + PROTOBUF_LIBRARY + PROTOBUF_PROTOC_LIBRARY + PROTOBUF_INCLUDE_DIR + PROTOBUF_PROTOC_EXECUTABLE + PROTOBUF_LIBRARY_DEBUG + PROTOBUF_PROTOC_LIBRARY_DEBUG + PROTOBUF_LITE_LIBRARY + PROTOBUF_LITE_LIBRARY_DEBUG + ) + if (DEFINED ${UPPER}) + string(REPLACE "PROTOBUF_" "Protobuf_" Camel ${UPPER}) + if (NOT DEFINED ${Camel}) + set(${Camel} ${${UPPER}}) + endif() + endif() +endforeach() + +if(DEFINED Protobuf_SRC_ROOT_FOLDER) + message(AUTHOR_WARNING "Variable Protobuf_SRC_ROOT_FOLDER defined, but not" + " used in CONFIG mode") +endif() + +include(SelectLibraryConfigurations) + # Internal function: search for normal library as well as a debug one # if the debug one is specified also include debug/optimized keywords # in *_LIBRARIES variable function(_protobuf_find_libraries name filename) - get_target_property(${name}_LIBRARY lib${filename} - IMPORTED_LOCATION_RELEASE) - set(${name}_LIBRARY "${${name}_LIBRARY}" PARENT_SCOPE) - get_target_property(${name}_LIBRARY_DEBUG lib${filename} - IMPORTED_LOCATION_DEBUG) - set(${name}_LIBRARY_DEBUG "${${name}_LIBRARY_DEBUG}" PARENT_SCOPE) - - if(NOT ${name}_LIBRARY_DEBUG) - # There is no debug library - set(${name}_LIBRARY_DEBUG ${${name}_LIBRARY} PARENT_SCOPE) - set(${name}_LIBRARIES ${${name}_LIBRARY} PARENT_SCOPE) - else() - # There IS a debug library - set(${name}_LIBRARIES - optimized ${${name}_LIBRARY} - debug ${${name}_LIBRARY_DEBUG} - PARENT_SCOPE - ) - endif() + if(${name}_LIBRARIES) + # Use result recorded by a previous call. + elseif(${name}_LIBRARY) + # Honor cache entry used by CMake 3.5 and lower. + set(${name}_LIBRARIES "${${name}_LIBRARY}" PARENT_SCOPE) + else() + get_target_property(${name}_LIBRARY_RELEASE protobuf::lib${filename} + LOCATION_RELEASE) + get_target_property(${name}_LIBRARY_DEBUG protobuf::lib${filename} + LOCATION_DEBUG) + + select_library_configurations(${name}) + set(${name}_LIBRARY ${${name}_LIBRARY} PARENT_SCOPE) + set(${name}_LIBRARIES ${${name}_LIBRARIES} PARENT_SCOPE) + endif() endfunction() # Internal function: find threads library @@ -107,33 +127,63 @@ if(NOT DEFINED PROTOBUF_GENERATE_CPP_APPEND_PATH) endif() # The Protobuf library -_protobuf_find_libraries(PROTOBUF protobuf) +_protobuf_find_libraries(Protobuf protobuf) # The Protobuf Lite library -_protobuf_find_libraries(PROTOBUF_LITE protobuf-lite) +_protobuf_find_libraries(Protobuf_LITE protobuf-lite) # The Protobuf Protoc Library -_protobuf_find_libraries(PROTOBUF_PROTOC protoc) +_protobuf_find_libraries(Protobuf_PROTOC protoc) if(UNIX) _protobuf_find_threads() endif() # Set the include directory -set(PROTOBUF_INCLUDE_DIR "${_PROTOBUF_IMPORT_PREFIX}/@CMAKE_INSTALL_INCLUDEDIR@") +get_target_property(Protobuf_INCLUDE_DIRS protobuf::libprotobuf + INTERFACE_INCLUDE_DIRECTORIES) # Set the protoc Executable -get_target_property(PROTOBUF_PROTOC_EXECUTABLE protoc +get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc IMPORTED_LOCATION_RELEASE) -if(NOT PROTOBUF_PROTOC_EXECUTABLE) - get_target_property(PROTOBUF_PROTOC_EXECUTABLE protoc +if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}") + get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc IMPORTED_LOCATION_DEBUG) endif() +if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}") + get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc + IMPORTED_LOCATION_NOCONFIG) +endif() -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROTOBUF DEFAULT_MSG - PROTOBUF_LIBRARY PROTOBUF_INCLUDE_DIR) +# Version info variable +set(Protobuf_VERSION "@protobuf_VERSION@") -if(PROTOBUF_FOUND) - set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIR}) -endif() +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Protobuf + REQUIRED_VARS Protobuf_PROTOC_EXECUTABLE Protobuf_LIBRARIES Protobuf_INCLUDE_DIRS + VERSION_VAR Protobuf_VERSION +) + +# Backwards compatibility +# Define upper case versions of output variables +foreach(Camel + Protobuf_VERSION + Protobuf_SRC_ROOT_FOLDER + Protobuf_IMPORT_DIRS + Protobuf_DEBUG + Protobuf_INCLUDE_DIRS + Protobuf_LIBRARIES + Protobuf_PROTOC_LIBRARIES + Protobuf_LITE_LIBRARIES + Protobuf_LIBRARY + Protobuf_PROTOC_LIBRARY + Protobuf_INCLUDE_DIR + Protobuf_PROTOC_EXECUTABLE + Protobuf_LIBRARY_DEBUG + Protobuf_PROTOC_LIBRARY_DEBUG + Protobuf_LITE_LIBRARY + Protobuf_LITE_LIBRARY_DEBUG + ) + string(TOUPPER ${Camel} UPPER) + set(${UPPER} ${${Camel}}) +endforeach() diff --git a/third_party/protobuf/cmake/protobuf-options.cmake b/third_party/protobuf/cmake/protobuf-options.cmake new file mode 100644 index 000000000000..47fb15825752 --- /dev/null +++ b/third_party/protobuf/cmake/protobuf-options.cmake @@ -0,0 +1,7 @@ +# Verbose output +option(protobuf_VERBOSE "Enable for verbose output" OFF) +mark_as_advanced(protobuf_VERBOSE) + +# FindProtobuf module compatibel +option(protobuf_MODULE_COMPATIBLE "CMake build-in FindProtobuf.cmake module compatible" OFF) +mark_as_advanced(protobuf_MODULE_COMPATIBLE) diff --git a/third_party/protobuf/cmake/protobuf.pc.cmake b/third_party/protobuf/cmake/protobuf.pc.cmake new file mode 100644 index 000000000000..d33e98cca8f0 --- /dev/null +++ b/third_party/protobuf/cmake/protobuf.pc.cmake @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: Protocol Buffers +Description: Google's Data Interchange Format +Version: @protobuf_VERSION@ +Libs: -L${libdir} -lprotobuf @CMAKE_THREAD_LIBS_INIT@ +Cflags: -I${includedir} @CMAKE_THREAD_LIBS_INIT@ +Conflicts: protobuf-lite diff --git a/third_party/protobuf/cmake/protoc.cmake b/third_party/protobuf/cmake/protoc.cmake index 4f07c389c976..f90e525e8003 100644 --- a/third_party/protobuf/cmake/protoc.cmake +++ b/third_party/protobuf/cmake/protoc.cmake @@ -2,5 +2,15 @@ set(protoc_files ${protobuf_source_dir}/src/google/protobuf/compiler/main.cc ) -add_executable(protoc ${protoc_files}) -target_link_libraries(protoc libprotobuf libprotoc) +if (MSVC) +set(protoc_rc_files + ${CMAKE_CURRENT_BINARY_DIR}/version.rc +) +endif() + +add_executable(protoc ${protoc_files} ${protoc_rc_files}) +target_link_libraries(protoc libprotoc libprotobuf) +add_executable(protobuf::protoc ALIAS protoc) + +set_target_properties(protoc PROPERTIES + VERSION ${protobuf_VERSION}) diff --git a/third_party/protobuf/cmake/tests.cmake b/third_party/protobuf/cmake/tests.cmake index 76fdf8efdf32..72269617efbd 100644 --- a/third_party/protobuf/cmake/tests.cmake +++ b/third_party/protobuf/cmake/tests.cmake @@ -1,22 +1,31 @@ -if (NOT EXISTS "${PROJECT_SOURCE_DIR}/../gmock/CMakeLists.txt") - message(FATAL_ERROR "Cannot find gmock directory.") +if (NOT EXISTS "${PROJECT_SOURCE_DIR}/../third_party/googletest/CMakeLists.txt") + message(FATAL_ERROR + "Cannot find third_party/googletest directory that's needed to " + "build tests. If you use git, make sure you have cloned submodules:\n" + " git submodule update --init --recursive\n" + "If instead you want to skip tests, run cmake with:\n" + " cmake -Dprotobuf_BUILD_TESTS=OFF\n") endif() option(protobuf_ABSOLUTE_TEST_PLUGIN_PATH "Using absolute test_plugin path in tests" ON) +mark_as_advanced(protobuf_ABSOLUTE_TEST_PLUGIN_PATH) +set(googlemock_source_dir "${protobuf_source_dir}/third_party/googletest/googlemock") +set(googletest_source_dir "${protobuf_source_dir}/third_party/googletest/googletest") include_directories( - ${protobuf_source_dir}/gmock - ${protobuf_source_dir}/gmock/gtest - ${protobuf_source_dir}/gmock/gtest/include - ${protobuf_source_dir}/gmock/include + ${googlemock_source_dir} + ${googletest_source_dir} + ${googletest_source_dir}/include + ${googlemock_source_dir}/include ) add_library(gmock STATIC - ${protobuf_source_dir}/gmock/src/gmock-all.cc - ${protobuf_source_dir}/gmock/gtest/src/gtest-all.cc + "${googlemock_source_dir}/src/gmock-all.cc" + "${googletest_source_dir}/src/gtest-all.cc" ) -add_library(gmock_main STATIC ${protobuf_source_dir}/gmock/src/gmock_main.cc) +target_link_libraries(gmock ${CMAKE_THREAD_LIBS_INIT}) +add_library(gmock_main STATIC "${googlemock_source_dir}/src/gmock_main.cc") target_link_libraries(gmock_main gmock) set(lite_test_protos @@ -41,6 +50,9 @@ set(tests_protos google/protobuf/unittest_empty.proto google/protobuf/unittest_import.proto google/protobuf/unittest_import_public.proto + google/protobuf/unittest_lazy_dependencies.proto + google/protobuf/unittest_lazy_dependencies_custom_option.proto + google/protobuf/unittest_lazy_dependencies_enum.proto google/protobuf/unittest_lite_imports_nonlite.proto google/protobuf/unittest_mset.proto google/protobuf/unittest_mset_wire_format.proto @@ -51,6 +63,7 @@ set(tests_protos google/protobuf/unittest_optimize_for.proto google/protobuf/unittest_preserve_unknown_enum.proto google/protobuf/unittest_preserve_unknown_enum2.proto + google/protobuf/unittest_proto3.proto google/protobuf/unittest_proto3_arena.proto google/protobuf/unittest_proto3_arena_lite.proto google/protobuf/unittest_proto3_lite.proto @@ -62,8 +75,11 @@ set(tests_protos google/protobuf/util/internal/testdata/field_mask.proto google/protobuf/util/internal/testdata/maps.proto google/protobuf/util/internal/testdata/oneofs.proto + google/protobuf/util/internal/testdata/proto3.proto google/protobuf/util/internal/testdata/struct.proto google/protobuf/util/internal/testdata/timestamp_duration.proto + google/protobuf/util/internal/testdata/wrappers.proto + google/protobuf/util/json_format.proto google/protobuf/util/json_format_proto3.proto google/protobuf/util/message_differencer_unittest.proto ) @@ -100,6 +116,7 @@ set(common_test_files ${protobuf_source_dir}/src/google/protobuf/arena_test_util.cc ${protobuf_source_dir}/src/google/protobuf/map_test_util.cc ${protobuf_source_dir}/src/google/protobuf/test_util.cc + ${protobuf_source_dir}/src/google/protobuf/test_util.inc ${protobuf_source_dir}/src/google/protobuf/testing/file.cc ${protobuf_source_dir}/src/google/protobuf/testing/googletest.cc ) @@ -114,11 +131,15 @@ set(tests_files ${protobuf_source_dir}/src/google/protobuf/any_test.cc ${protobuf_source_dir}/src/google/protobuf/arena_unittest.cc ${protobuf_source_dir}/src/google/protobuf/arenastring_unittest.cc + ${protobuf_source_dir}/src/google/protobuf/compiler/annotation_test_util.cc ${protobuf_source_dir}/src/google/protobuf/compiler/command_line_interface_unittest.cc ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc + ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_move_unittest.cc ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_unittest.cc + ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_unittest.inc ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/metadata_test.cc + ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc ${protobuf_source_dir}/src/google/protobuf/compiler/importer_unittest.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_doc_comment_unittest.cc @@ -135,24 +156,26 @@ set(tests_files ${protobuf_source_dir}/src/google/protobuf/extension_set_unittest.cc ${protobuf_source_dir}/src/google/protobuf/generated_message_reflection_unittest.cc ${protobuf_source_dir}/src/google/protobuf/io/coded_stream_unittest.cc + ${protobuf_source_dir}/src/google/protobuf/io/io_win32_unittest.cc ${protobuf_source_dir}/src/google/protobuf/io/printer_unittest.cc ${protobuf_source_dir}/src/google/protobuf/io/tokenizer_unittest.cc ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_unittest.cc ${protobuf_source_dir}/src/google/protobuf/map_field_test.cc ${protobuf_source_dir}/src/google/protobuf/map_test.cc ${protobuf_source_dir}/src/google/protobuf/message_unittest.cc + ${protobuf_source_dir}/src/google/protobuf/message_unittest.inc ${protobuf_source_dir}/src/google/protobuf/no_field_presence_test.cc ${protobuf_source_dir}/src/google/protobuf/preserve_unknown_enum_test.cc ${protobuf_source_dir}/src/google/protobuf/proto3_arena_lite_unittest.cc ${protobuf_source_dir}/src/google/protobuf/proto3_arena_unittest.cc ${protobuf_source_dir}/src/google/protobuf/proto3_lite_unittest.cc + ${protobuf_source_dir}/src/google/protobuf/proto3_lite_unittest.inc ${protobuf_source_dir}/src/google/protobuf/reflection_ops_unittest.cc ${protobuf_source_dir}/src/google/protobuf/repeated_field_reflection_unittest.cc ${protobuf_source_dir}/src/google/protobuf/repeated_field_unittest.cc ${protobuf_source_dir}/src/google/protobuf/stubs/bytestream_unittest.cc ${protobuf_source_dir}/src/google/protobuf/stubs/common_unittest.cc ${protobuf_source_dir}/src/google/protobuf/stubs/int128_unittest.cc - ${protobuf_source_dir}/src/google/protobuf/stubs/once_unittest.cc ${protobuf_source_dir}/src/google/protobuf/stubs/status_test.cc ${protobuf_source_dir}/src/google/protobuf/stubs/statusor_test.cc ${protobuf_source_dir}/src/google/protobuf/stubs/stringpiece_unittest.cc @@ -161,9 +184,9 @@ set(tests_files ${protobuf_source_dir}/src/google/protobuf/stubs/strutil_unittest.cc ${protobuf_source_dir}/src/google/protobuf/stubs/template_util_unittest.cc ${protobuf_source_dir}/src/google/protobuf/stubs/time_test.cc - ${protobuf_source_dir}/src/google/protobuf/stubs/type_traits_unittest.cc ${protobuf_source_dir}/src/google/protobuf/text_format_unittest.cc ${protobuf_source_dir}/src/google/protobuf/unknown_field_set_unittest.cc + ${protobuf_source_dir}/src/google/protobuf/util/delimited_message_util_test.cc ${protobuf_source_dir}/src/google/protobuf/util/field_comparator_test.cc ${protobuf_source_dir}/src/google/protobuf/util/field_mask_util_test.cc ${protobuf_source_dir}/src/google/protobuf/util/internal/default_value_objectwriter_test.cc @@ -184,6 +207,17 @@ if(protobuf_ABSOLUTE_TEST_PLUGIN_PATH) add_compile_options(-DGOOGLE_PROTOBUF_TEST_PLUGIN_PATH="$") endif() +if(MINGW) + set_source_files_properties(${tests_files} PROPERTIES COMPILE_FLAGS "-Wno-narrowing") + + # required for tests on MinGW Win64 + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,16777216") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj") + endif() + +endif() + add_executable(tests ${tests_files} ${common_test_files} ${tests_proto_files} ${lite_test_proto_files}) target_link_libraries(tests libprotoc libprotobuf gmock_main) @@ -201,7 +235,7 @@ set(lite_test_files ${protobuf_source_dir}/src/google/protobuf/lite_unittest.cc ) add_executable(lite-test ${lite_test_files} ${common_lite_test_files} ${lite_test_proto_files}) -target_link_libraries(lite-test libprotobuf-lite) +target_link_libraries(lite-test libprotobuf-lite gmock_main) set(lite_arena_test_files ${protobuf_source_dir}/src/google/protobuf/lite_arena_unittest.cc @@ -211,4 +245,5 @@ target_link_libraries(lite-arena-test libprotobuf-lite gmock_main) add_custom_target(check COMMAND tests + DEPENDS tests test_plugin WORKING_DIRECTORY ${protobuf_source_dir}) diff --git a/third_party/protobuf/cmake/version.rc.in b/third_party/protobuf/cmake/version.rc.in new file mode 100644 index 000000000000..f6e7c4a3f9e4 --- /dev/null +++ b/third_party/protobuf/cmake/version.rc.in @@ -0,0 +1,45 @@ +#define VS_FF_DEBUG 0x1L +#define VS_VERSION_INFO 0x1L +#define VS_FFI_FILEFLAGSMASK 0x17L +#define VER_PRIVATEBUILD 0x0L +#define VER_PRERELEASE 0x0L +#define VOS__WINDOWS32 0x4L +#define VFT_DLL 0x2L +#define VFT2_UNKNOWN 0x0L + +#ifndef DEBUG +#define VER_DEBUG 0 +#else +#define VER_DEBUG VS_FF_DEBUG +#endif + + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @protobuf_RC_FILEVERSION@ + PRODUCTVERSION @protobuf_RC_FILEVERSION@ + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS VER_DEBUG + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL +BEGIN + BLOCK "VarFileInfo" + BEGIN + // English language (0x409) and the Windows Unicode codepage (1200) + VALUE "Translation", 0x409, 1200 + END + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "Compiled with @CMAKE_CXX_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@\0" + VALUE "ProductVersion", "@protobuf_VERSION@\0" + VALUE "FileVersion", "@protobuf_VERSION@\0" + VALUE "InternalName", "protobuf\0" + VALUE "ProductName", "Protocol Buffers - Google's Data Interchange Format\0" + VALUE "CompanyName", "Google Inc.\0" + VALUE "LegalCopyright", "Copyright 2008 Google Inc. All rights reserved.\0" + VALUE "Licence", "BSD\0" + VALUE "Info", "https://developers.google.com/protocol-buffers/\0" + END + END +END diff --git a/third_party/protobuf/compiler_config_setting.bzl b/third_party/protobuf/compiler_config_setting.bzl new file mode 100644 index 000000000000..5e52a6524ffe --- /dev/null +++ b/third_party/protobuf/compiler_config_setting.bzl @@ -0,0 +1,21 @@ +"""Creates config_setting that allows selecting based on 'compiler' value.""" + +def create_compiler_config_setting(name, value): + # The "do_not_use_tools_cpp_compiler_present" attribute exists to + # distinguish between older versions of Bazel that do not support + # "@bazel_tools//tools/cpp:compiler" flag_value, and newer ones that do. + # In the future, the only way to select on the compiler will be through + # flag_values{"@bazel_tools//tools/cpp:compiler"} and the else branch can + # be removed. + if hasattr(cc_common, "do_not_use_tools_cpp_compiler_present"): + native.config_setting( + name = name, + flag_values = { + "@bazel_tools//tools/cpp:compiler": value, + }, + ) + else: + native.config_setting( + name = name, + values = {"compiler": value}, + ) diff --git a/third_party/protobuf/composer.json b/third_party/protobuf/composer.json new file mode 100644 index 000000000000..2c64ad220f7d --- /dev/null +++ b/third_party/protobuf/composer.json @@ -0,0 +1,23 @@ +{ + "name": "google/protobuf", + "type": "library", + "description": "proto library for PHP", + "keywords": ["proto"], + "homepage": "https://developers.google.com/protocol-buffers/", + "license": "BSD-3-Clause", + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": ">=4.8.0" + }, + "suggest": { + "ext-bcmath": "Need to support JSON deserialization" + }, + "autoload": { + "psr-4": { + "Google\\Protobuf\\": "php/src/Google/Protobuf", + "GPBMetadata\\Google\\Protobuf\\": "php/src/GPBMetadata/Google/Protobuf" + } + } +} diff --git a/third_party/protobuf/configure.ac b/third_party/protobuf/configure.ac index bdc72ee69680..8d973e39defe 100644 --- a/third_party/protobuf/configure.ac +++ b/third_party/protobuf/configure.ac @@ -4,15 +4,20 @@ AC_PREREQ(2.59) # Note: If you change the version, you must also update it in: -# * java/pom.xml -# * python/setup.py +# * Protobuf.podspec +# * csharp/Google.Protobuf.Tools.nuspec +# * csharp/src/*/AssemblyInfo.cs +# * csharp/src/Google.Protobuf/Google.Protobuf.nuspec +# * java/*/pom.xml +# * python/google/protobuf/__init__.py +# * protoc-artifacts/pom.xml # * src/google/protobuf/stubs/common.h # * src/Makefile.am (Update -version-info for LDFLAGS if needed) # # In the SVN trunk, the version should always be the next anticipated release # version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed # the size of one file name in the dist tarfile over the 99-char limit.) -AC_INIT([Protocol Buffers],[3.0.0-beta-3],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.9.0],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) @@ -26,7 +31,7 @@ AC_CONFIG_MACRO_DIR([m4]) AC_ARG_VAR(DIST_LANG, [language to include in the distribution package (i.e., make dist)]) case "$DIST_LANG" in "") DIST_LANG=all ;; - all | cpp | csharp | java | python | javanano | objectivec | ruby | js) ;; + all | cpp | csharp | java | python | javanano | objectivec | ruby | js | php) ;; *) AC_MSG_FAILURE([unknown language: $DIST_LANG]) ;; esac AC_SUBST(DIST_LANG) @@ -42,11 +47,26 @@ AC_CANONICAL_TARGET AM_INIT_AUTOMAKE([1.9 tar-ustar subdir-objects]) +# Silent rules enabled: the output is minimal but informative. +# In particular, the warnings from the compiler stick out very clearly. +# To see all logs, use the --disable-silent-rules on configure or via make V=1 +AM_SILENT_RULES([yes]) + AC_ARG_WITH([zlib], [AS_HELP_STRING([--with-zlib], [include classes for streaming compressed data in and out @<:@default=check@:>@])], [],[with_zlib=check]) +AC_ARG_WITH([zlib-include], + [AS_HELP_STRING([--with-zlib-include=PATH], + [zlib include directory])], + [CPPFLAGS="-I$withval $CPPFLAGS"]) + +AC_ARG_WITH([zlib-lib], + [AS_HELP_STRING([--with-zlib-lib=PATH], + [zlib lib directory])], + [LDFLAGS="-L$withval $LDFLAGS"]) + AC_ARG_WITH([protoc], [AS_HELP_STRING([--with-protoc=COMMAND], [use the given protoc command instead of building a new one when building tests (useful for cross-compiling)])], @@ -55,6 +75,7 @@ AC_ARG_WITH([protoc], # Checks for programs. AC_PROG_CC AC_PROG_CXX +AC_PROG_CXX_FOR_BUILD AC_LANG([C++]) ACX_USE_SYSTEM_EXTENSIONS m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) @@ -72,7 +93,7 @@ AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],[ # Protocol Buffers contains several checks that are intended to be used only # for debugging and which might hurt performance. Most users are probably # end users who don't want these checks, so add -DNDEBUG by default. - CXXFLAGS="$CXXFLAGS -DNDEBUG" + CXXFLAGS="$CXXFLAGS -std=c++11 -DNDEBUG" AC_MSG_RESULT([use default: $PROTOBUF_OPT_FLAG $CXXFLAGS]) ],[ @@ -87,6 +108,25 @@ ACX_CHECK_SUNCC # to the link AC_PROG_LIBTOOL +# Check whether the linker supports version scripts +AC_MSG_CHECKING([whether the linker supports version scripts]) +save_LDFLAGS=$LDFLAGS +LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map" +cat > conftest.map < + #include + std::atomic v; + int main() { + return v; + } +]])], STD_ATOMIC_NEED_LIBATOMIC=no, STD_ATOMIC_NEED_LIBATOMIC=yes) +AC_MSG_RESULT($STD_ATOMIC_NEED_LIBATOMIC) +if test "x$STD_ATOMIC_NEED_LIBATOMIC" = xyes; then + LIBATOMIC_LIBS="-latomic" +fi +AC_SUBST([LIBATOMIC_LIBS]) + AS_IF([test "$with_protoc" != "no"], [ PROTOC=$with_protoc AS_IF([test "$with_protoc" = "yes"], [ @@ -149,21 +209,11 @@ AS_IF([test "$with_protoc" != "no"], [ ]) AM_CONDITIONAL([USE_EXTERNAL_PROTOC], [test "$with_protoc" != "no"]) -ACX_PTHREAD -AM_CONDITIONAL([HAVE_PTHREAD], [test "x$acx_pthread_ok" = "xyes"]) - +AX_PTHREAD +AM_CONDITIONAL([HAVE_PTHREAD], [test "x$ax_pthread_ok" = "xyes"]) # We still keep this for improving pbconfig.h for unsupported platforms. AC_CXX_STL_HASH -case "$target_os" in - mingw* | cygwin* | win*) - ;; - *) - # Need to link against rt on Solaris - AC_SEARCH_LIBS([sched_yield], [rt], [], [AC_MSG_FAILURE([sched_yield was not found on your system])]) - ;; -esac - # Enable ObjC support for conformance directory on OS X. OBJC_CONFORMANCE_TEST=0 case "$target_os" in @@ -178,7 +228,7 @@ AM_CONDITIONAL([OBJC_CONFORMANCE_TEST], [test $OBJC_CONFORMANCE_TEST = 1]) # too. export CFLAGS export CXXFLAGS -AC_CONFIG_SUBDIRS([gmock]) +AC_CONFIG_SUBDIRS([third_party/googletest]) AC_CONFIG_FILES([Makefile src/Makefile benchmarks/Makefile conformance/Makefile protobuf.pc protobuf-lite.pc]) AC_OUTPUT diff --git a/third_party/protobuf/conformance/ConformanceJava.java b/third_party/protobuf/conformance/ConformanceJava.java index 43787ffcb274..c5b3f4e16345 100644 --- a/third_party/protobuf/conformance/ConformanceJava.java +++ b/third_party/protobuf/conformance/ConformanceJava.java @@ -1,8 +1,19 @@ - +import com.google.protobuf.AbstractMessage; +import com.google.protobuf.ByteString; +import com.google.protobuf.CodedInputStream; +import com.google.protobuf.ExtensionRegistry; +import com.google.protobuf.InvalidProtocolBufferException; +import com.google.protobuf.Parser; +import com.google.protobuf.TextFormat; import com.google.protobuf.conformance.Conformance; import com.google.protobuf.util.JsonFormat; import com.google.protobuf.util.JsonFormat.TypeRegistry; -import com.google.protobuf.InvalidProtocolBufferException; +import com.google.protobuf_test_messages.proto2.TestMessagesProto2; +import com.google.protobuf_test_messages.proto2.TestMessagesProto2.TestAllTypesProto2; +import com.google.protobuf_test_messages.proto3.TestMessagesProto3; +import com.google.protobuf_test_messages.proto3.TestMessagesProto3.TestAllTypesProto3; +import java.nio.ByteBuffer; +import java.util.ArrayList; class ConformanceJava { private int testCount = 0; @@ -47,29 +58,224 @@ private void writeLittleEndianIntToStdout(int val) throws Exception { writeToStdout(buf); } + private enum BinaryDecoderType { + BTYE_STRING_DECODER, + BYTE_ARRAY_DECODER, + ARRAY_BYTE_BUFFER_DECODER, + READONLY_ARRAY_BYTE_BUFFER_DECODER, + DIRECT_BYTE_BUFFER_DECODER, + READONLY_DIRECT_BYTE_BUFFER_DECODER, + INPUT_STREAM_DECODER; + } + + private static class BinaryDecoder { + public MessageType decode (ByteString bytes, BinaryDecoderType type, + Parser parser, ExtensionRegistry extensions) + throws InvalidProtocolBufferException { + switch (type) { + case BTYE_STRING_DECODER: + return parser.parseFrom(bytes, extensions); + case BYTE_ARRAY_DECODER: + return parser.parseFrom(bytes.toByteArray(), extensions); + case ARRAY_BYTE_BUFFER_DECODER: { + ByteBuffer buffer = ByteBuffer.allocate(bytes.size()); + bytes.copyTo(buffer); + buffer.flip(); + try { + return parser.parseFrom(CodedInputStream.newInstance(buffer), extensions); + } catch (InvalidProtocolBufferException e) { + throw e; + } + } + case READONLY_ARRAY_BYTE_BUFFER_DECODER: { + try { + return parser.parseFrom( + CodedInputStream.newInstance(bytes.asReadOnlyByteBuffer()), extensions); + } catch (InvalidProtocolBufferException e) { + throw e; + } + } + case DIRECT_BYTE_BUFFER_DECODER: { + ByteBuffer buffer = ByteBuffer.allocateDirect(bytes.size()); + bytes.copyTo(buffer); + buffer.flip(); + try { + return parser.parseFrom(CodedInputStream.newInstance(buffer), extensions); + } catch (InvalidProtocolBufferException e) { + throw e; + } + } + case READONLY_DIRECT_BYTE_BUFFER_DECODER: { + ByteBuffer buffer = ByteBuffer.allocateDirect(bytes.size()); + bytes.copyTo(buffer); + buffer.flip(); + try { + return parser.parseFrom( + CodedInputStream.newInstance(buffer.asReadOnlyBuffer()), extensions); + } catch (InvalidProtocolBufferException e) { + throw e; + } + } + case INPUT_STREAM_DECODER: { + try { + return parser.parseFrom(bytes.newInput(), extensions); + } catch (InvalidProtocolBufferException e) { + throw e; + } + } + default : + return null; + } + } + } + + private MessageType parseBinary( + ByteString bytes, Parser parser, ExtensionRegistry extensions) + throws InvalidProtocolBufferException { + ArrayList messages = new ArrayList (); + ArrayList exceptions = + new ArrayList (); + + for (int i = 0; i < BinaryDecoderType.values().length; i++) { + messages.add(null); + exceptions.add(null); + } + BinaryDecoder decoder = new BinaryDecoder (); + + boolean hasMessage = false; + boolean hasException = false; + for (int i = 0; i < BinaryDecoderType.values().length; ++i) { + try { + //= BinaryDecoderType.values()[i].parseProto3(bytes); + messages.set(i, decoder.decode(bytes, BinaryDecoderType.values()[i], parser, extensions)); + hasMessage = true; + } catch (InvalidProtocolBufferException e) { + exceptions.set(i, e); + hasException = true; + } + } + + if (hasMessage && hasException) { + StringBuilder sb = + new StringBuilder("Binary decoders disagreed on whether the payload was valid.\n"); + for (int i = 0; i < BinaryDecoderType.values().length; ++i) { + sb.append(BinaryDecoderType.values()[i].name()); + if (messages.get(i) != null) { + sb.append(" accepted the payload.\n"); + } else { + sb.append(" rejected the payload.\n"); + } + } + throw new RuntimeException(sb.toString()); + } + + if (hasException) { + // We do not check if exceptions are equal. Different implementations may return different + // exception messages. Throw an arbitrary one out instead. + throw exceptions.get(0); + } + + // Fast path comparing all the messages with the first message, assuming equality being + // symmetric and transitive. + boolean allEqual = true; + for (int i = 1; i < messages.size(); ++i) { + if (!messages.get(0).equals(messages.get(i))) { + allEqual = false; + break; + } + } + + // Slow path: compare and find out all unequal pairs. + if (!allEqual) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < messages.size() - 1; ++i) { + for (int j = i + 1; j < messages.size(); ++j) { + if (!messages.get(i).equals(messages.get(j))) { + sb.append(BinaryDecoderType.values()[i].name()) + .append(" and ") + .append(BinaryDecoderType.values()[j].name()) + .append(" parsed the payload differently.\n"); + } + } + } + throw new RuntimeException(sb.toString()); + } + + return messages.get(0); + } + private Conformance.ConformanceResponse doTest(Conformance.ConformanceRequest request) { - Conformance.TestAllTypes testMessage; + com.google.protobuf.AbstractMessage testMessage; + boolean isProto3 = request.getMessageType().equals("protobuf_test_messages.proto3.TestAllTypesProto3"); + boolean isProto2 = request.getMessageType().equals("protobuf_test_messages.proto2.TestAllTypesProto2"); switch (request.getPayloadCase()) { case PROTOBUF_PAYLOAD: { - try { - testMessage = Conformance.TestAllTypes.parseFrom(request.getProtobufPayload()); - } catch (InvalidProtocolBufferException e) { - return Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build(); + if (isProto3) { + try { + ExtensionRegistry extensions = ExtensionRegistry.newInstance(); + TestMessagesProto3.registerAllExtensions(extensions); + testMessage = parseBinary(request.getProtobufPayload(), TestAllTypesProto3.parser(), extensions); + } catch (InvalidProtocolBufferException e) { + return Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build(); + } + } else if (isProto2) { + try { + ExtensionRegistry extensions = ExtensionRegistry.newInstance(); + TestMessagesProto2.registerAllExtensions(extensions); + testMessage = parseBinary(request.getProtobufPayload(), TestAllTypesProto2.parser(), extensions); + } catch (InvalidProtocolBufferException e) { + return Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build(); + } + } else { + throw new RuntimeException("Protobuf request doesn't have specific payload type."); } break; } case JSON_PAYLOAD: { try { - Conformance.TestAllTypes.Builder builder = Conformance.TestAllTypes.newBuilder(); - JsonFormat.parser().usingTypeRegistry(typeRegistry) - .merge(request.getJsonPayload(), builder); + TestMessagesProto3.TestAllTypesProto3.Builder builder = + TestMessagesProto3.TestAllTypesProto3.newBuilder(); + JsonFormat.Parser parser = JsonFormat.parser().usingTypeRegistry(typeRegistry); + if (request.getTestCategory() + == Conformance.TestCategory.JSON_IGNORE_UNKNOWN_PARSING_TEST) { + parser = parser.ignoringUnknownFields(); + } + parser.merge(request.getJsonPayload(), builder); testMessage = builder.build(); } catch (InvalidProtocolBufferException e) { return Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build(); } break; } + case TEXT_PAYLOAD: { + if (isProto3) { + try { + TestMessagesProto3.TestAllTypesProto3.Builder builder = + TestMessagesProto3.TestAllTypesProto3.newBuilder(); + TextFormat.merge(request.getTextPayload(), builder); + testMessage = builder.build(); + } catch (TextFormat.ParseException e) { + return Conformance.ConformanceResponse.newBuilder() + .setParseError(e.getMessage()) + .build(); + } + } else if (isProto2) { + try { + TestMessagesProto2.TestAllTypesProto2.Builder builder = + TestMessagesProto2.TestAllTypesProto2.newBuilder(); + TextFormat.merge(request.getTextPayload(), builder); + testMessage = builder.build(); + } catch (TextFormat.ParseException e) { + return Conformance.ConformanceResponse.newBuilder() + .setParseError(e.getMessage()) + .build(); + } + } else { + throw new RuntimeException("Protobuf request doesn't have specific payload type."); + } + break; + } case PAYLOAD_NOT_SET: { throw new RuntimeException("Request didn't have payload."); } @@ -83,8 +289,10 @@ private Conformance.ConformanceResponse doTest(Conformance.ConformanceRequest re case UNSPECIFIED: throw new RuntimeException("Unspecified output format."); - case PROTOBUF: - return Conformance.ConformanceResponse.newBuilder().setProtobufPayload(testMessage.toByteString()).build(); + case PROTOBUF: { + ByteString MessageString = testMessage.toByteString(); + return Conformance.ConformanceResponse.newBuilder().setProtobufPayload(MessageString).build(); + } case JSON: try { @@ -95,6 +303,10 @@ private Conformance.ConformanceResponse doTest(Conformance.ConformanceRequest re e.getMessage()).build(); } + case TEXT_FORMAT: + return Conformance.ConformanceResponse.newBuilder().setTextPayload( + TextFormat.printToString(testMessage)).build(); + default: { throw new RuntimeException("Unexpected request output."); } @@ -127,7 +339,7 @@ private boolean doTestIo() throws Exception { public void run() throws Exception { typeRegistry = TypeRegistry.newBuilder().add( - Conformance.TestAllTypes.getDescriptor()).build(); + TestMessagesProto3.TestAllTypesProto3.getDescriptor()).build(); while (doTestIo()) { this.testCount++; } diff --git a/third_party/protobuf/conformance/ConformanceJavaLite.java b/third_party/protobuf/conformance/ConformanceJavaLite.java index 121dc7d1b6a1..016f79326fba 100644 --- a/third_party/protobuf/conformance/ConformanceJavaLite.java +++ b/third_party/protobuf/conformance/ConformanceJavaLite.java @@ -58,7 +58,7 @@ private Conformance.ConformanceResponse doTest(Conformance.ConformanceRequest re } case JSON_PAYLOAD: { return Conformance.ConformanceResponse.newBuilder().setSkipped( - "Lite runtime does not suport Json Formant.").build(); + "Lite runtime does not support JSON format.").build(); } case PAYLOAD_NOT_SET: { throw new RuntimeException("Request didn't have payload."); @@ -78,7 +78,7 @@ private Conformance.ConformanceResponse doTest(Conformance.ConformanceRequest re case JSON: return Conformance.ConformanceResponse.newBuilder().setSkipped( - "Lite runtime does not suport Json Formant.").build(); + "Lite runtime does not support JSON format.").build(); default: { throw new RuntimeException("Unexpected request output."); diff --git a/third_party/protobuf/conformance/Makefile.am b/third_party/protobuf/conformance/Makefile.am index 31a9e40868bd..e47fd1081d1c 100644 --- a/third_party/protobuf/conformance/Makefile.am +++ b/third_party/protobuf/conformance/Makefile.am @@ -1,7 +1,13 @@ ## Process this file with automake to produce Makefile.in conformance_protoc_inputs = \ - conformance.proto + conformance.proto \ + $(top_srcdir)/src/google/protobuf/test_messages_proto3.proto + +# proto2 input files, should be separated with proto3, as we +# can't generate proto2 files for ruby, php and objc +conformance_proto2_protoc_inputs = \ + $(top_srcdir)/src/google/protobuf/test_messages_proto2.proto well_known_type_protoc_inputs = \ $(top_srcdir)/src/google/protobuf/any.proto \ @@ -20,7 +26,8 @@ other_language_protoc_outputs = \ conformance_pb2.py \ Conformance.pbobjc.h \ Conformance.pbobjc.m \ - conformance.rb \ + conformance_pb.js \ + conformance_pb.rb \ com/google/protobuf/Any.java \ com/google/protobuf/AnyOrBuilder.java \ com/google/protobuf/AnyProto.java \ @@ -61,6 +68,8 @@ other_language_protoc_outputs = \ com/google/protobuf/Value.java \ com/google/protobuf/ValueOrBuilder.java \ com/google/protobuf/WrappersProto.java \ + com/google/protobuf_test_messages/proto3/TestMessagesProto3.java \ + com/google/protobuf_test_messages/proto2/TestMessagesProto2.java \ google/protobuf/any.pb.cc \ google/protobuf/any.pb.h \ google/protobuf/any.rb \ @@ -77,6 +86,17 @@ other_language_protoc_outputs = \ google/protobuf/struct.pb.h \ google/protobuf/struct.rb \ google/protobuf/struct_pb2.py \ + google/protobuf/TestMessagesProto2.pbobjc.h \ + google/protobuf/TestMessagesProto2.pbobjc.m \ + google/protobuf/TestMessagesProto3.pbobjc.h \ + google/protobuf/TestMessagesProto3.pbobjc.m \ + google/protobuf/test_messages_proto3.pb.cc \ + google/protobuf/test_messages_proto3.pb.h \ + google/protobuf/test_messages_proto2.pb.cc \ + google/protobuf/test_messages_proto2.pb.h \ + google/protobuf/test_messages_proto3_pb.rb \ + google/protobuf/test_messages_proto3_pb2.py \ + google/protobuf/test_messages_proto2_pb2.py \ google/protobuf/timestamp.pb.cc \ google/protobuf/timestamp.pb.h \ google/protobuf/timestamp.rb \ @@ -85,46 +105,80 @@ other_language_protoc_outputs = \ google/protobuf/wrappers.pb.h \ google/protobuf/wrappers.rb \ google/protobuf/wrappers_pb2.py \ - lite/com/google/protobuf/Any.java \ - lite/com/google/protobuf/AnyOrBuilder.java \ - lite/com/google/protobuf/AnyProto.java \ - lite/com/google/protobuf/BoolValue.java \ - lite/com/google/protobuf/BoolValueOrBuilder.java \ - lite/com/google/protobuf/BytesValue.java \ - lite/com/google/protobuf/BytesValueOrBuilder.java \ - lite/com/google/protobuf/conformance/Conformance.java \ - lite/com/google/protobuf/DoubleValue.java \ - lite/com/google/protobuf/DoubleValueOrBuilder.java \ - lite/com/google/protobuf/Duration.java \ - lite/com/google/protobuf/DurationOrBuilder.java \ - lite/com/google/protobuf/DurationProto.java \ - lite/com/google/protobuf/FieldMask.java \ - lite/com/google/protobuf/FieldMaskOrBuilder.java \ - lite/com/google/protobuf/FieldMaskProto.java \ - lite/com/google/protobuf/FloatValue.java \ - lite/com/google/protobuf/FloatValueOrBuilder.java \ - lite/com/google/protobuf/Int32Value.java \ - lite/com/google/protobuf/Int32ValueOrBuilder.java \ - lite/com/google/protobuf/Int64Value.java \ - lite/com/google/protobuf/Int64ValueOrBuilder.java \ - lite/com/google/protobuf/ListValue.java \ - lite/com/google/protobuf/ListValueOrBuilder.java \ - lite/com/google/protobuf/NullValue.java \ - lite/com/google/protobuf/StringValue.java \ - lite/com/google/protobuf/StringValueOrBuilder.java \ - lite/com/google/protobuf/Struct.java \ - lite/com/google/protobuf/StructOrBuilder.java \ - lite/com/google/protobuf/StructProto.java \ - lite/com/google/protobuf/Timestamp.java \ - lite/com/google/protobuf/TimestampOrBuilder.java \ - lite/com/google/protobuf/TimestampProto.java \ - lite/com/google/protobuf/UInt32Value.java \ - lite/com/google/protobuf/UInt32ValueOrBuilder.java \ - lite/com/google/protobuf/UInt64Value.java \ - lite/com/google/protobuf/UInt64ValueOrBuilder.java \ - lite/com/google/protobuf/Value.java \ - lite/com/google/protobuf/ValueOrBuilder.java \ - lite/com/google/protobuf/WrappersProto.java + Conformance/ConformanceRequest.php \ + Conformance/ConformanceResponse.php \ + Conformance/FailureSet.php \ + Conformance/WireFormat.php \ + GPBMetadata/Conformance.php \ + GPBMetadata/Google/Protobuf/Any.php \ + GPBMetadata/Google/Protobuf/Duration.php \ + GPBMetadata/Google/Protobuf/FieldMask.php \ + GPBMetadata/Google/Protobuf/Struct.php \ + GPBMetadata/Google/Protobuf/TestMessagesProto3.php \ + GPBMetadata/Google/Protobuf/Timestamp.php \ + GPBMetadata/Google/Protobuf/Wrappers.php \ + Google/Protobuf/Any.php \ + Google/Protobuf/BoolValue.php \ + Google/Protobuf/BytesValue.php \ + Google/Protobuf/DoubleValue.php \ + Google/Protobuf/Duration.php \ + Google/Protobuf/FieldMask.php \ + Google/Protobuf/FloatValue.php \ + Google/Protobuf/Int32Value.php \ + Google/Protobuf/Int64Value.php \ + Google/Protobuf/ListValue.php \ + Google/Protobuf/NullValue.php \ + Google/Protobuf/StringValue.php \ + Google/Protobuf/Struct.php \ + Google/Protobuf/Timestamp.php \ + Google/Protobuf/UInt32Value.php \ + Google/Protobuf/UInt64Value.php \ + Google/Protobuf/Value.php \ + Protobuf_test_messages/Proto3/ForeignEnum.php \ + Protobuf_test_messages/Proto3/ForeignMessage.php \ + Protobuf_test_messages/Proto3/TestAllTypes_NestedEnum.php \ + Protobuf_test_messages/Proto3/TestAllTypes_NestedMessage.php \ + Protobuf_test_messages/Proto3/TestAllTypes.php + # lite/com/google/protobuf/Any.java \ + # lite/com/google/protobuf/AnyOrBuilder.java \ + # lite/com/google/protobuf/AnyProto.java \ + # lite/com/google/protobuf/BoolValue.java \ + # lite/com/google/protobuf/BoolValueOrBuilder.java \ + # lite/com/google/protobuf/BytesValue.java \ + # lite/com/google/protobuf/BytesValueOrBuilder.java \ + # lite/com/google/protobuf/conformance/Conformance.java \ + # lite/com/google/protobuf/DoubleValue.java \ + # lite/com/google/protobuf/DoubleValueOrBuilder.java \ + # lite/com/google/protobuf/Duration.java \ + # lite/com/google/protobuf/DurationOrBuilder.java \ + # lite/com/google/protobuf/DurationProto.java \ + # lite/com/google/protobuf/FieldMask.java \ + # lite/com/google/protobuf/FieldMaskOrBuilder.java \ + # lite/com/google/protobuf/FieldMaskProto.java \ + # lite/com/google/protobuf/FloatValue.java \ + # lite/com/google/protobuf/FloatValueOrBuilder.java \ + # lite/com/google/protobuf/Int32Value.java \ + # lite/com/google/protobuf/Int32ValueOrBuilder.java \ + # lite/com/google/protobuf/Int64Value.java \ + # lite/com/google/protobuf/Int64ValueOrBuilder.java \ + # lite/com/google/protobuf/ListValue.java \ + # lite/com/google/protobuf/ListValueOrBuilder.java \ + # lite/com/google/protobuf/NullValue.java \ + # lite/com/google/protobuf/StringValue.java \ + # lite/com/google/protobuf/StringValueOrBuilder.java \ + # lite/com/google/protobuf/Struct.java \ + # lite/com/google/protobuf/StructOrBuilder.java \ + # lite/com/google/protobuf/StructProto.java \ + # lite/com/google/protobuf/Timestamp.java \ + # lite/com/google/protobuf/TimestampOrBuilder.java \ + # lite/com/google/protobuf/TimestampProto.java \ + # lite/com/google/protobuf/UInt32Value.java \ + # lite/com/google/protobuf/UInt32ValueOrBuilder.java \ + # lite/com/google/protobuf/UInt64Value.java \ + # lite/com/google/protobuf/UInt64ValueOrBuilder.java \ + # lite/com/google/protobuf/Value.java \ + # lite/com/google/protobuf/ValueOrBuilder.java \ + # lite/com/google/protobuf/WrappersProto.java bin_PROGRAMS = conformance-test-runner conformance-cpp @@ -138,21 +192,30 @@ EXTRA_DIST = \ conformance.proto \ conformance_python.py \ conformance_ruby.rb \ + conformance_php.php \ failure_list_cpp.txt \ failure_list_csharp.txt \ failure_list_java.txt \ + failure_list_js.txt \ failure_list_objc.txt \ failure_list_python.txt \ failure_list_python_cpp.txt \ failure_list_python-post26.txt \ - failure_list_ruby.txt + failure_list_ruby.txt \ + failure_list_php.txt \ + failure_list_php_c.txt conformance_test_runner_LDADD = $(top_srcdir)/src/libprotobuf.la conformance_test_runner_SOURCES = conformance_test.h conformance_test.cc \ + conformance_test_main.cc \ + binary_json_conformance_suite.h \ + binary_json_conformance_suite.cc \ + text_format_conformance_suite.h \ + text_format_conformance_suite.cc \ conformance_test_runner.cc \ third_party/jsoncpp/json.h \ third_party/jsoncpp/jsoncpp.cpp -nodist_conformance_test_runner_SOURCES = conformance.pb.cc +nodist_conformance_test_runner_SOURCES = conformance.pb.cc google/protobuf/test_messages_proto3.pb.cc google/protobuf/test_messages_proto2.pb.cc conformance_test_runner_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir) conformance_test_runner_CXXFLAGS = -std=c++11 # Explicit deps beacuse BUILT_SOURCES are only done before a "make all/check" @@ -162,7 +225,7 @@ conformance_test_runner-conformance_test_runner.$(OBJEXT): conformance.pb.h conformance_cpp_LDADD = $(top_srcdir)/src/libprotobuf.la conformance_cpp_SOURCES = conformance_cpp.cc -nodist_conformance_cpp_SOURCES = conformance.pb.cc +nodist_conformance_cpp_SOURCES = conformance.pb.cc google/protobuf/test_messages_proto3.pb.cc google/protobuf/test_messages_proto2.pb.cc conformance_cpp_CPPFLAGS = -I$(top_srcdir)/src # Explicit dep beacuse BUILT_SOURCES are only done before a "make all/check" # so a direct "make test_cpp" could fail if parallel enough. @@ -173,7 +236,7 @@ if OBJC_CONFORMANCE_TEST bin_PROGRAMS += conformance-objc conformance_objc_SOURCES = conformance_objc.m ../objectivec/GPBProtocolBuffers.m -nodist_conformance_objc_SOURCES = Conformance.pbobjc.m +nodist_conformance_objc_SOURCES = Conformance.pbobjc.m google/protobuf/TestMessagesProto2.pbobjc.m google/protobuf/TestMessagesProto3.pbobjc.m # On travis, the build fails without the isysroot because whatever system # headers are being found don't include generics support for # NSArray/NSDictionary, the only guess is their image at one time had an odd @@ -182,17 +245,25 @@ conformance_objc_CPPFLAGS = -I$(top_srcdir)/objectivec -isysroot `xcrun --sdk ma conformance_objc_LDFLAGS = -framework Foundation # Explicit dep beacuse BUILT_SOURCES are only done before a "make all/check" # so a direct "make test_objc" could fail if parallel enough. -conformance_objc-conformance_objc.$(OBJEXT): Conformance.pbobjc.h +conformance_objc-conformance_objc.$(OBJEXT): Conformance.pbobjc.h google/protobuf/TestMessagesProto2.pbobjc.h google/protobuf/TestMessagesProto3.pbobjc.h endif +# JavaScript well-known types are expected to be in a directory called +# google-protobuf, because they are usually in the google-protobuf npm +# package. But we want to use the sources from our tree, so we recreate +# that directory structure here. +google-protobuf: + mkdir google-protobuf + if USE_EXTERNAL_PROTOC # Some implementations include pre-generated versions of well-known types. -protoc_middleman: $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) - $(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --objc_out=. --python_out=. $(conformance_protoc_inputs) - $(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --python_out=. $(well_known_type_protoc_inputs) - $(PROTOC) -I$(srcdir) -I$(top_srcdir) --java_out=lite:lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) +protoc_middleman: $(conformance_protoc_inputs) $(conformance_proto2_protoc_inputs) $(well_known_type_protoc_inputs) google-protobuf + $(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --objc_out=. --python_out=. --php_out=. --js_out=import_style=commonjs,binary:. $(conformance_protoc_inputs) + $(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --objc_out=. --python_out=. --js_out=import_style=commonjs,binary:. $(conformance_proto2_protoc_inputs) + $(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --python_out=. --js_out=import_style=commonjs,binary:google-protobuf $(well_known_type_protoc_inputs) + ## $(PROTOC) -I$(srcdir) -I$(top_srcdir) --java_out=lite:lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) touch protoc_middleman else @@ -200,11 +271,12 @@ else # We have to cd to $(srcdir) before executing protoc because $(protoc_inputs) is # relative to srcdir, which may not be the same as the current directory when # building out-of-tree. -protoc_middleman: $(top_srcdir)/src/protoc$(EXEEXT) $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) - oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --objc_out=$$oldpwd --python_out=$$oldpwd $(conformance_protoc_inputs) ) - oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --python_out=$$oldpwd $(well_known_type_protoc_inputs) ) - @mkdir -p lite - oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --java_out=lite:$$oldpwd/lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) ) +protoc_middleman: $(top_srcdir)/src/protoc$(EXEEXT) $(conformance_protoc_inputs) $(conformance_proto2_protoc_inputs) $(well_known_type_protoc_inputs) google-protobuf + oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --objc_out=$$oldpwd --python_out=$$oldpwd --php_out=$$oldpwd --js_out=import_style=commonjs,binary:$$oldpwd $(conformance_protoc_inputs) ) + oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --objc_out=. --python_out=$$oldpwd --js_out=import_style=commonjs,binary:$$oldpwd $(conformance_proto2_protoc_inputs) ) + oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --python_out=$$oldpwd --js_out=import_style=commonjs,binary:$$oldpwd/google-protobuf $(well_known_type_protoc_inputs) ) + ## @mkdir -p lite + ## oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --java_out=lite:$$oldpwd/lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) ) touch protoc_middleman endif @@ -213,15 +285,13 @@ $(protoc_outputs): protoc_middleman $(other_language_protoc_outputs): protoc_middleman -BUILT_SOURCES = $(protoc_outputs) $(other_language_protoc_outputs) - -CLEANFILES = $(protoc_outputs) protoc_middleman javac_middleman conformance-java javac_middleman_lite conformance-java-lite conformance-csharp $(other_language_protoc_outputs) +CLEANFILES = $(protoc_outputs) protoc_middleman javac_middleman conformance-java javac_middleman_lite conformance-java-lite conformance-csharp conformance-php conformance-php-c $(other_language_protoc_outputs) MAINTAINERCLEANFILES = \ Makefile.in javac_middleman: ConformanceJava.java protoc_middleman $(other_language_protoc_outputs) - jar=`ls ../java/util/target/*jar-with-dependencies.jar` && javac -classpath ../java/target/classes:$$jar ConformanceJava.java com/google/protobuf/conformance/Conformance.java + jar=`ls ../java/util/target/*jar-with-dependencies.jar` && javac -classpath ../java/target/classes:$$jar ConformanceJava.java com/google/protobuf/conformance/Conformance.java com/google/protobuf_test_messages/proto3/TestMessagesProto3.java com/google/protobuf_test_messages/proto2/TestMessagesProto2.java @touch javac_middleman conformance-java: javac_middleman @@ -246,36 +316,63 @@ conformance-java-lite: javac_middleman_lite conformance-csharp: $(other_language_protoc_outputs) @echo "Writing shortcut script conformance-csharp..." @echo '#! /bin/sh' > conformance-csharp - @echo 'mono ../csharp/src/Google.Protobuf.Conformance/bin/Release/Google.Protobuf.Conformance.exe "$$@"' >> conformance-csharp + @echo 'dotnet ../csharp/src/Google.Protobuf.Conformance/bin/Release/netcoreapp2.1/Google.Protobuf.Conformance.dll "$$@"' >> conformance-csharp @chmod +x conformance-csharp +conformance-php: + @echo "Writing shortcut script conformance-php..." + @echo '#! /bin/sh' > conformance-php + @echo 'php -d auto_prepend_file=autoload.php ./conformance_php.php' >> conformance-php + @chmod +x conformance-php + +conformance-php-c: + @echo "Writing shortcut script conformance-php-c..." + @echo '#! /bin/sh' > conformance-php-c + @echo 'php -dextension=../php/ext/google/protobuf/modules/protobuf.so ./conformance_php.php' >> conformance-php-c + @chmod +x conformance-php-c + # Targets for actually running tests. test_cpp: protoc_middleman conformance-test-runner conformance-cpp - ./conformance-test-runner --failure_list failure_list_cpp.txt ./conformance-cpp + ./conformance-test-runner --enforce_recommended --failure_list failure_list_cpp.txt ./conformance-cpp test_java: protoc_middleman conformance-test-runner conformance-java - ./conformance-test-runner --failure_list failure_list_java.txt ./conformance-java + ./conformance-test-runner --enforce_recommended --failure_list failure_list_java.txt --text_format_failure_list text_format_failure_list_java.txt ./conformance-java test_java_lite: protoc_middleman conformance-test-runner conformance-java-lite - ./conformance-test-runner ./conformance-java-lite + ./conformance-test-runner --enforce_recommended ./conformance-java-lite test_csharp: protoc_middleman conformance-test-runner conformance-csharp - ./conformance-test-runner --failure_list failure_list_csharp.txt ./conformance-csharp + ./conformance-test-runner --enforce_recommended --failure_list failure_list_csharp.txt --text_format_failure_list text_format_failure_list_csharp.txt ./conformance-csharp test_ruby: protoc_middleman conformance-test-runner $(other_language_protoc_outputs) - RUBYLIB=../ruby/lib:. ./conformance-test-runner --failure_list failure_list_ruby.txt ./conformance_ruby.rb + RUBYLIB=../ruby/lib:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_ruby.txt --text_format_failure_list text_format_failure_list_ruby.txt ./conformance_ruby.rb + +test_ruby_mac: protoc_middleman conformance-test-runner $(other_language_protoc_outputs) + RUBYLIB=../ruby/lib:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_ruby_mac.txt --text_format_failure_list text_format_failure_list_ruby.txt ./conformance_ruby.rb + +test_php: protoc_middleman conformance-test-runner conformance-php $(other_language_protoc_outputs) + ./conformance-test-runner --enforce_recommended --failure_list failure_list_php.txt --text_format_failure_list text_format_failure_list_php.txt ./conformance-php + +test_php_c: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs) + ./conformance-test-runner --enforce_recommended --failure_list failure_list_php_c.txt --text_format_failure_list text_format_failure_list_php.txt ./conformance-php-c + +test_php_zts_c: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs) + ./conformance-test-runner --enforce_recommended --failure_list failure_list_php_zts_c.txt --text_format_failure_list text_format_failure_list_php.txt ./conformance-php-c # These depend on library paths being properly set up. The easiest way to # run them is to just use "tox" from the python dir. test_python: protoc_middleman conformance-test-runner - ./conformance-test-runner --failure_list failure_list_python.txt $(CONFORMANCE_PYTHON_EXTRA_FAILURES) ./conformance_python.py + ./conformance-test-runner --enforce_recommended --failure_list failure_list_python.txt --text_format_failure_list text_format_failure_list_python.txt ./conformance_python.py test_python_cpp: protoc_middleman conformance-test-runner - ./conformance-test-runner --failure_list failure_list_python_cpp.txt $(CONFORMANCE_PYTHON_EXTRA_FAILURES) ./conformance_python.py + ./conformance-test-runner --enforce_recommended --failure_list failure_list_python_cpp.txt ./conformance_python.py + +test_nodejs: protoc_middleman conformance-test-runner $(other_language_protoc_outputs) + NODE_PATH=../js:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_js.txt ./conformance_nodejs.js if OBJC_CONFORMANCE_TEST test_objc: protoc_middleman conformance-test-runner conformance-objc - ./conformance-test-runner --failure_list failure_list_objc.txt ./conformance-objc + ./conformance-test-runner --enforce_recommended --failure_list failure_list_objc.txt ./conformance-objc endif diff --git a/third_party/protobuf/conformance/README.md b/third_party/protobuf/conformance/README.md index 9388055fba59..06925dbb55fe 100644 --- a/third_party/protobuf/conformance/README.md +++ b/third_party/protobuf/conformance/README.md @@ -1,8 +1,6 @@ Protocol Buffers - Google's data interchange format =================================================== -[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf) - Copyright 2008 Google Inc. This directory contains conformance tests for testing completeness and @@ -19,11 +17,39 @@ directory to build `protoc`, since all the tests depend on it. $ make -Then to run the tests against the C++ implementation, run: +Running the tests for C++ +------------------------- + +To run the tests against the C++ implementation, run: $ cd conformance && make test_cpp -More tests and languages will be added soon! +Running the tests for JavaScript (Node.js) +------------------------------------------ + +To run the JavaScript tests against Node.js, make sure you have "node" +on your path and then run: + + $ cd conformance && make test_nodejs + +Running the tests for Ruby (MRI) +-------------------------------- + +To run the Ruby tests against MRI, first build the C extension: + + $ cd ruby && rake + +Then run the tests like so: + + $ cd conformance && make test_ruby + +Running the tests for other languages +------------------------------------- + +Most of the languages in the Protobuf source tree are set up to run +conformance tests. However some of them are more tricky to set up +properly. See `tests.sh` in the base of the repository to see how +Travis runs the tests. Testing other Protocol Buffer implementations --------------------------------------------- @@ -31,10 +57,10 @@ Testing other Protocol Buffer implementations To run these tests against a new Protocol Buffers implementation, write a program in your language that uses the protobuf implementation you want to test. This program should implement the testing protocol defined in -[conformance.proto](https://github.com/google/protobuf/blob/master/conformance/conformance.proto). +[conformance.proto](https://github.com/protocolbuffers/protobuf/blob/master/conformance/conformance.proto). This is designed to be as easy as possible: the C++ version is only 150 lines and is a good example for what this program should look like -(see [conformance_cpp.cc](https://github.com/google/protobuf/blob/master/conformance/conformance_cpp.cc)). +(see [conformance_cpp.cc](https://github.com/protocolbuffers/protobuf/blob/master/conformance/conformance_cpp.cc)). The program only needs to be able to read from stdin and write to stdout. Portability diff --git a/third_party/protobuf/conformance/autoload.php b/third_party/protobuf/conformance/autoload.php new file mode 100644 index 000000000000..0f49aecb16ae --- /dev/null +++ b/third_party/protobuf/conformance/autoload.php @@ -0,0 +1,21 @@ + +#include + +#include +#include +#include +#include +#include +#include + +using conformance::ConformanceRequest; +using conformance::ConformanceResponse; +using conformance::WireFormat; +using google::protobuf::Descriptor; +using google::protobuf::FieldDescriptor; +using google::protobuf::Message; +using google::protobuf::internal::WireFormatLite; +using google::protobuf::TextFormat; +using google::protobuf::util::NewTypeResolverForDescriptorPool; +using protobuf_test_messages::proto3::TestAllTypesProto3; +using protobuf_test_messages::proto2::TestAllTypesProto2; +using std::string; + +namespace { + +static const char kTypeUrlPrefix[] = "type.googleapis.com"; + +static string GetTypeUrl(const Descriptor* message) { + return string(kTypeUrlPrefix) + "/" + message->full_name(); +} + +/* Routines for building arbitrary protos *************************************/ + +// We would use CodedOutputStream except that we want more freedom to build +// arbitrary protos (even invalid ones). + +const string empty; + +string cat(const string& a, const string& b, + const string& c = empty, + const string& d = empty, + const string& e = empty, + const string& f = empty, + const string& g = empty, + const string& h = empty, + const string& i = empty, + const string& j = empty, + const string& k = empty, + const string& l = empty) { + string ret; + ret.reserve(a.size() + b.size() + c.size() + d.size() + e.size() + f.size() + + g.size() + h.size() + i.size() + j.size() + k.size() + l.size()); + ret.append(a); + ret.append(b); + ret.append(c); + ret.append(d); + ret.append(e); + ret.append(f); + ret.append(g); + ret.append(h); + ret.append(i); + ret.append(j); + ret.append(k); + ret.append(l); + return ret; +} + +// The maximum number of bytes that it takes to encode a 64-bit varint. +#define VARINT_MAX_LEN 10 + +size_t vencode64(uint64_t val, int over_encoded_bytes, char *buf) { + if (val == 0) { buf[0] = 0; return 1; } + size_t i = 0; + while (val) { + uint8_t byte = val & 0x7fU; + val >>= 7; + if (val || over_encoded_bytes) byte |= 0x80U; + buf[i++] = byte; + } + while (over_encoded_bytes--) { + assert(i < 10); + uint8_t byte = over_encoded_bytes ? 0x80 : 0; + buf[i++] = byte; + } + return i; +} + +string varint(uint64_t x) { + char buf[VARINT_MAX_LEN]; + size_t len = vencode64(x, 0, buf); + return string(buf, len); +} + +// Encodes a varint that is |extra| bytes longer than it needs to be, but still +// valid. +string longvarint(uint64_t x, int extra) { + char buf[VARINT_MAX_LEN]; + size_t len = vencode64(x, extra, buf); + return string(buf, len); +} + +// TODO: proper byte-swapping for big-endian machines. +string fixed32(void *data) { return string(static_cast(data), 4); } +string fixed64(void *data) { return string(static_cast(data), 8); } + +string delim(const string& buf) { return cat(varint(buf.size()), buf); } +string u32(uint32_t u32) { return fixed32(&u32); } +string u64(uint64_t u64) { return fixed64(&u64); } +string flt(float f) { return fixed32(&f); } +string dbl(double d) { return fixed64(&d); } +string zz32(int32_t x) { return varint(WireFormatLite::ZigZagEncode32(x)); } +string zz64(int64_t x) { return varint(WireFormatLite::ZigZagEncode64(x)); } + +string tag(uint32_t fieldnum, char wire_type) { + return varint((fieldnum << 3) | wire_type); +} + +string submsg(uint32_t fn, const string& buf) { + return cat( tag(fn, WireFormatLite::WIRETYPE_LENGTH_DELIMITED), delim(buf) ); +} + +#define UNKNOWN_FIELD 666 + +const FieldDescriptor* GetFieldForType(FieldDescriptor::Type type, + bool repeated, bool is_proto3) { + + const Descriptor* d = is_proto3 ? + TestAllTypesProto3().GetDescriptor() : TestAllTypesProto2().GetDescriptor(); + for (int i = 0; i < d->field_count(); i++) { + const FieldDescriptor* f = d->field(i); + if (f->type() == type && f->is_repeated() == repeated) { + return f; + } + } + GOOGLE_LOG(FATAL) << "Couldn't find field with type " << (int)type; + return nullptr; +} + +string UpperCase(string str) { + for (int i = 0; i < str.size(); i++) { + str[i] = toupper(str[i]); + } + return str; +} + +std::unique_ptr NewTestMessage(bool is_proto3) { + std::unique_ptr prototype; + if (is_proto3) { + prototype.reset(new TestAllTypesProto3()); + } else { + prototype.reset(new TestAllTypesProto2()); + } + return prototype; +} + +} // anonymous namespace + +namespace google { +namespace protobuf { + +bool BinaryAndJsonConformanceSuite::ParseJsonResponse( + const ConformanceResponse& response, + Message* test_message) { + string binary_protobuf; + util::Status status = + JsonToBinaryString(type_resolver_.get(), type_url_, + response.json_payload(), &binary_protobuf); + + if (!status.ok()) { + return false; + } + + if (!test_message->ParseFromString(binary_protobuf)) { + GOOGLE_LOG(FATAL) + << "INTERNAL ERROR: internal JSON->protobuf transcode " + << "yielded unparseable proto."; + return false; + } + + return true; +} + +bool BinaryAndJsonConformanceSuite::ParseResponse( + const ConformanceResponse& response, + const ConformanceRequestSetting& setting, + Message* test_message) { + const ConformanceRequest& request = setting.GetRequest(); + WireFormat requested_output = request.requested_output_format(); + const string& test_name = setting.GetTestName(); + ConformanceLevel level = setting.GetLevel(); + + switch (response.result_case()) { + case ConformanceResponse::kProtobufPayload: { + if (requested_output != conformance::PROTOBUF) { + ReportFailure( + test_name, level, request, response, + StrCat("Test was asked for ", WireFormatToString(requested_output), + " output but provided PROTOBUF instead.").c_str()); + return false; + } + + if (!test_message->ParseFromString(response.protobuf_payload())) { + ReportFailure(test_name, level, request, response, + "Protobuf output we received from test was unparseable."); + return false; + } + + break; + } + + case ConformanceResponse::kJsonPayload: { + if (requested_output != conformance::JSON) { + ReportFailure( + test_name, level, request, response, + StrCat("Test was asked for ", WireFormatToString(requested_output), + " output but provided JSON instead.").c_str()); + return false; + } + + if (!ParseJsonResponse(response, test_message)) { + ReportFailure(test_name, level, request, response, + "JSON output we received from test was unparseable."); + return false; + } + + break; + } + + default: + GOOGLE_LOG(FATAL) << test_name << ": unknown payload type: " + << response.result_case(); + } + + return true; +} + +void BinaryAndJsonConformanceSuite::ExpectParseFailureForProtoWithProtoVersion ( + const string& proto, const string& test_name, ConformanceLevel level, + bool is_proto3) { + std::unique_ptr prototype = NewTestMessage(is_proto3); + // We don't expect output, but if the program erroneously accepts the protobuf + // we let it send its response as this. We must not leave it unspecified. + ConformanceRequestSetting setting( + level, conformance::PROTOBUF, conformance::PROTOBUF, + conformance::BINARY_TEST, + *prototype, test_name, proto); + + const ConformanceRequest& request = setting.GetRequest(); + ConformanceResponse response; + string effective_test_name = + StrCat(setting.ConformanceLevelToString(level), + (is_proto3 ? ".Proto3" : ".Proto2"), + ".ProtobufInput.", test_name); + + RunTest(effective_test_name, request, &response); + if (response.result_case() == ConformanceResponse::kParseError) { + ReportSuccess(effective_test_name); + } else if (response.result_case() == ConformanceResponse::kSkipped) { + ReportSkip(effective_test_name, request, response); + } else { + ReportFailure(effective_test_name, level, request, response, + "Should have failed to parse, but didn't."); + } +} + +// Expect that this precise protobuf will cause a parse error. +void BinaryAndJsonConformanceSuite::ExpectParseFailureForProto( + const string& proto, const string& test_name, ConformanceLevel level) { + ExpectParseFailureForProtoWithProtoVersion(proto, test_name, level, true); + ExpectParseFailureForProtoWithProtoVersion(proto, test_name, level, false); +} + +// Expect that this protobuf will cause a parse error, even if it is followed +// by valid protobuf data. We can try running this twice: once with this +// data verbatim and once with this data followed by some valid data. +// +// TODO(haberman): implement the second of these. +void BinaryAndJsonConformanceSuite::ExpectHardParseFailureForProto( + const string& proto, const string& test_name, ConformanceLevel level) { + return ExpectParseFailureForProto(proto, test_name, level); +} + +void BinaryAndJsonConformanceSuite::RunValidJsonTest( + const string& test_name, ConformanceLevel level, const string& input_json, + const string& equivalent_text_format) { + TestAllTypesProto3 prototype; + ConformanceRequestSetting setting1( + level, conformance::JSON, conformance::PROTOBUF, + conformance::JSON_TEST, + prototype, test_name, input_json); + RunValidInputTest(setting1, equivalent_text_format); + ConformanceRequestSetting setting2( + level, conformance::JSON, conformance::JSON, + conformance::JSON_TEST, + prototype, test_name, input_json); + RunValidInputTest(setting2, equivalent_text_format); +} + +void BinaryAndJsonConformanceSuite::RunValidJsonTestWithProtobufInput( + const string& test_name, ConformanceLevel level, const TestAllTypesProto3& input, + const string& equivalent_text_format) { + ConformanceRequestSetting setting( + level, conformance::PROTOBUF, conformance::JSON, + conformance::JSON_TEST, + input, test_name, input.SerializeAsString()); + RunValidInputTest(setting, equivalent_text_format); +} + +void BinaryAndJsonConformanceSuite::RunValidJsonIgnoreUnknownTest( + const string& test_name, ConformanceLevel level, const string& input_json, + const string& equivalent_text_format) { + TestAllTypesProto3 prototype; + ConformanceRequestSetting setting( + level, conformance::JSON, conformance::PROTOBUF, + conformance::JSON_IGNORE_UNKNOWN_PARSING_TEST, + prototype, test_name, input_json); + RunValidInputTest(setting, equivalent_text_format); +} + +void BinaryAndJsonConformanceSuite::RunValidProtobufTest( + const string& test_name, ConformanceLevel level, + const string& input_protobuf, const string& equivalent_text_format, + bool is_proto3) { + std::unique_ptr prototype = NewTestMessage(is_proto3); + + ConformanceRequestSetting setting1( + level, conformance::PROTOBUF, conformance::PROTOBUF, + conformance::BINARY_TEST, + *prototype, test_name, input_protobuf); + RunValidInputTest(setting1, equivalent_text_format); + + if (is_proto3) { + ConformanceRequestSetting setting2( + level, conformance::PROTOBUF, conformance::JSON, + conformance::BINARY_TEST, + *prototype, test_name, input_protobuf); + RunValidInputTest(setting2, equivalent_text_format); + } +} + +void BinaryAndJsonConformanceSuite::RunValidBinaryProtobufTest( + const string& test_name, ConformanceLevel level, + const string& input_protobuf, bool is_proto3) { + std::unique_ptr prototype = NewTestMessage(is_proto3); + ConformanceRequestSetting setting( + level, conformance::PROTOBUF, conformance::PROTOBUF, + conformance::BINARY_TEST, + *prototype, test_name, input_protobuf); + RunValidBinaryInputTest(setting, input_protobuf); +} + +void BinaryAndJsonConformanceSuite::RunValidProtobufTestWithMessage( + const string& test_name, ConformanceLevel level, const Message *input, + const string& equivalent_text_format, bool is_proto3) { + RunValidProtobufTest(test_name, level, input->SerializeAsString(), + equivalent_text_format, is_proto3); +} + +// According to proto3 JSON specification, JSON serializers follow more strict +// rules than parsers (e.g., a serializer must serialize int32 values as JSON +// numbers while the parser is allowed to accept them as JSON strings). This +// method allows strict checking on a proto3 JSON serializer by inspecting +// the JSON output directly. +void BinaryAndJsonConformanceSuite::RunValidJsonTestWithValidator( + const string& test_name, ConformanceLevel level, const string& input_json, + const Validator& validator) { + TestAllTypesProto3 prototype; + ConformanceRequestSetting setting( + level, conformance::JSON, conformance::JSON, + conformance::JSON_TEST, + prototype, test_name, input_json); + const ConformanceRequest& request = setting.GetRequest(); + ConformanceResponse response; + string effective_test_name = + StrCat(setting.ConformanceLevelToString(level), + ".Proto3.JsonInput.", + test_name, ".Validator"); + + RunTest(effective_test_name, request, &response); + + if (response.result_case() == ConformanceResponse::kSkipped) { + ReportSkip(effective_test_name, request, response); + return; + } + + if (response.result_case() != ConformanceResponse::kJsonPayload) { + ReportFailure(effective_test_name, level, request, response, + "Expected JSON payload but got type %d.", + response.result_case()); + return; + } + Json::Reader reader; + Json::Value value; + if (!reader.parse(response.json_payload(), value)) { + ReportFailure(effective_test_name, level, request, response, + "JSON payload cannot be parsed as valid JSON: %s", + reader.getFormattedErrorMessages().c_str()); + return; + } + if (!validator(value)) { + ReportFailure(effective_test_name, level, request, response, + "JSON payload validation failed."); + return; + } + ReportSuccess(effective_test_name); +} + +void BinaryAndJsonConformanceSuite::ExpectParseFailureForJson( + const string& test_name, ConformanceLevel level, const string& input_json) { + TestAllTypesProto3 prototype; + // We don't expect output, but if the program erroneously accepts the protobuf + // we let it send its response as this. We must not leave it unspecified. + ConformanceRequestSetting setting( + level, conformance::JSON, conformance::JSON, + conformance::JSON_TEST, + prototype, test_name, input_json); + const ConformanceRequest& request = setting.GetRequest(); + ConformanceResponse response; + string effective_test_name = + StrCat(setting.ConformanceLevelToString(level), + ".Proto3.JsonInput.", test_name); + + RunTest(effective_test_name, request, &response); + if (response.result_case() == ConformanceResponse::kParseError) { + ReportSuccess(effective_test_name); + } else if (response.result_case() == ConformanceResponse::kSkipped) { + ReportSkip(effective_test_name, request, response); + } else { + ReportFailure(effective_test_name, level, request, response, + "Should have failed to parse, but didn't."); + } +} + +void BinaryAndJsonConformanceSuite::ExpectSerializeFailureForJson( + const string& test_name, ConformanceLevel level, const string& text_format) { + TestAllTypesProto3 payload_message; + GOOGLE_CHECK( + TextFormat::ParseFromString(text_format, &payload_message)) + << "Failed to parse: " << text_format; + + TestAllTypesProto3 prototype; + ConformanceRequestSetting setting( + level, conformance::PROTOBUF, conformance::JSON, + conformance::JSON_TEST, + prototype, test_name, payload_message.SerializeAsString()); + const ConformanceRequest& request = setting.GetRequest(); + ConformanceResponse response; + string effective_test_name = + StrCat(setting.ConformanceLevelToString(level), + ".", test_name, ".JsonOutput"); + + RunTest(effective_test_name, request, &response); + if (response.result_case() == ConformanceResponse::kSerializeError) { + ReportSuccess(effective_test_name); + } else if (response.result_case() == ConformanceResponse::kSkipped) { + ReportSkip(effective_test_name, request, response); + } else { + ReportFailure(effective_test_name, level, request, response, + "Should have failed to serialize, but didn't."); + } +} + +//TODO: proto2? +void BinaryAndJsonConformanceSuite::TestPrematureEOFForType( + FieldDescriptor::Type type) { + // Incomplete values for each wire type. + static const string incompletes[6] = { + string("\x80"), // VARINT + string("abcdefg"), // 64BIT + string("\x80"), // DELIMITED (partial length) + string(), // START_GROUP (no value required) + string(), // END_GROUP (no value required) + string("abc") // 32BIT + }; + + const FieldDescriptor* field = GetFieldForType(type, false, true); + const FieldDescriptor* rep_field = GetFieldForType(type, true, true); + WireFormatLite::WireType wire_type = WireFormatLite::WireTypeForFieldType( + static_cast(type)); + const string& incomplete = incompletes[wire_type]; + const string type_name = + UpperCase(string(".") + FieldDescriptor::TypeName(type)); + + ExpectParseFailureForProto( + tag(field->number(), wire_type), + "PrematureEofBeforeKnownNonRepeatedValue" + type_name, REQUIRED); + + ExpectParseFailureForProto( + tag(rep_field->number(), wire_type), + "PrematureEofBeforeKnownRepeatedValue" + type_name, REQUIRED); + + ExpectParseFailureForProto( + tag(UNKNOWN_FIELD, wire_type), + "PrematureEofBeforeUnknownValue" + type_name, REQUIRED); + + ExpectParseFailureForProto( + cat( tag(field->number(), wire_type), incomplete ), + "PrematureEofInsideKnownNonRepeatedValue" + type_name, REQUIRED); + + ExpectParseFailureForProto( + cat( tag(rep_field->number(), wire_type), incomplete ), + "PrematureEofInsideKnownRepeatedValue" + type_name, REQUIRED); + + ExpectParseFailureForProto( + cat( tag(UNKNOWN_FIELD, wire_type), incomplete ), + "PrematureEofInsideUnknownValue" + type_name, REQUIRED); + + if (wire_type == WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + ExpectParseFailureForProto( + cat( tag(field->number(), wire_type), varint(1) ), + "PrematureEofInDelimitedDataForKnownNonRepeatedValue" + type_name, + REQUIRED); + + ExpectParseFailureForProto( + cat( tag(rep_field->number(), wire_type), varint(1) ), + "PrematureEofInDelimitedDataForKnownRepeatedValue" + type_name, + REQUIRED); + + // EOF in the middle of delimited data for unknown value. + ExpectParseFailureForProto( + cat( tag(UNKNOWN_FIELD, wire_type), varint(1) ), + "PrematureEofInDelimitedDataForUnknownValue" + type_name, REQUIRED); + + if (type == FieldDescriptor::TYPE_MESSAGE) { + // Submessage ends in the middle of a value. + string incomplete_submsg = + cat( tag(WireFormatLite::TYPE_INT32, WireFormatLite::WIRETYPE_VARINT), + incompletes[WireFormatLite::WIRETYPE_VARINT] ); + ExpectHardParseFailureForProto( + cat( tag(field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED), + varint(incomplete_submsg.size()), + incomplete_submsg ), + "PrematureEofInSubmessageValue" + type_name, REQUIRED); + } + } else if (type != FieldDescriptor::TYPE_GROUP) { + // Non-delimited, non-group: eligible for packing. + + // Packed region ends in the middle of a value. + ExpectHardParseFailureForProto( + cat(tag(rep_field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED), + varint(incomplete.size()), incomplete), + "PrematureEofInPackedFieldValue" + type_name, REQUIRED); + + // EOF in the middle of packed region. + ExpectParseFailureForProto( + cat(tag(rep_field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED), + varint(1)), + "PrematureEofInPackedField" + type_name, REQUIRED); + } +} + +void BinaryAndJsonConformanceSuite::TestValidDataForType( + FieldDescriptor::Type type, + std::vector> values) { + for (int is_proto3 = 0; is_proto3 < 2; is_proto3++) { + const string type_name = + UpperCase(string(".") + FieldDescriptor::TypeName(type)); + WireFormatLite::WireType wire_type = WireFormatLite::WireTypeForFieldType( + static_cast(type)); + const FieldDescriptor* field = GetFieldForType(type, false, is_proto3); + const FieldDescriptor* rep_field = GetFieldForType(type, true, is_proto3); + + RunValidProtobufTest("ValidDataScalar" + type_name, REQUIRED, + cat(tag(field->number(), wire_type), values[0].first), + field->name() + ": " + values[0].second, is_proto3); + + string proto; + string text = field->name() + ": " + values.back().second; + for (size_t i = 0; i < values.size(); i++) { + proto += cat(tag(field->number(), wire_type), values[i].first); + } + RunValidProtobufTest("RepeatedScalarSelectsLast" + type_name, REQUIRED, + proto, text, is_proto3); + + proto.clear(); + text.clear(); + + for (size_t i = 0; i < values.size(); i++) { + proto += cat(tag(rep_field->number(), wire_type), values[i].first); + text += rep_field->name() + ": " + values[i].second + " "; + } + RunValidProtobufTest("ValidDataRepeated" + type_name, REQUIRED, + proto, text, is_proto3); + } +} + +// TODO: proto2? +void BinaryAndJsonConformanceSuite::TestIllegalTags() { + // field num 0 is illegal + string nullfield[] = { + "\1DEADBEEF", + "\2\1\1", + "\3\4", + "\5DEAD" + }; + for (int i = 0; i < 4; i++) { + string name = "IllegalZeroFieldNum_Case_0"; + name.back() += i; + ExpectParseFailureForProto(nullfield[i], name, REQUIRED); + } +} +template +void BinaryAndJsonConformanceSuite::TestOneofMessage ( + MessageType &message, bool is_proto3) { + message.set_oneof_uint32(0); + RunValidProtobufTestWithMessage( + "OneofZeroUint32", RECOMMENDED, &message, "oneof_uint32: 0", is_proto3); + message.mutable_oneof_nested_message()->set_a(0); + RunValidProtobufTestWithMessage( + "OneofZeroMessage", RECOMMENDED, &message, + is_proto3 ? "oneof_nested_message: {}" : "oneof_nested_message: {a: 0}", + is_proto3); + message.mutable_oneof_nested_message()->set_a(1); + RunValidProtobufTestWithMessage( + "OneofZeroMessageSetTwice", RECOMMENDED, &message, + "oneof_nested_message: {a: 1}", + is_proto3); + message.set_oneof_string(""); + RunValidProtobufTestWithMessage( + "OneofZeroString", RECOMMENDED, &message, "oneof_string: \"\"", is_proto3); + message.set_oneof_bytes(""); + RunValidProtobufTestWithMessage( + "OneofZeroBytes", RECOMMENDED, &message, "oneof_bytes: \"\"", is_proto3); + message.set_oneof_bool(false); + RunValidProtobufTestWithMessage( + "OneofZeroBool", RECOMMENDED, &message, "oneof_bool: false", is_proto3); + message.set_oneof_uint64(0); + RunValidProtobufTestWithMessage( + "OneofZeroUint64", RECOMMENDED, &message, "oneof_uint64: 0", is_proto3); + message.set_oneof_float(0.0f); + RunValidProtobufTestWithMessage( + "OneofZeroFloat", RECOMMENDED, &message, "oneof_float: 0", is_proto3); + message.set_oneof_double(0.0); + RunValidProtobufTestWithMessage( + "OneofZeroDouble", RECOMMENDED, &message, "oneof_double: 0", is_proto3); + message.set_oneof_enum(MessageType::FOO); + RunValidProtobufTestWithMessage( + "OneofZeroEnum", RECOMMENDED, &message, "oneof_enum: FOO", is_proto3); +} + +template +void BinaryAndJsonConformanceSuite::TestUnknownMessage( + MessageType& message, bool is_proto3) { + message.ParseFromString("\xA8\x1F\x01"); + RunValidBinaryProtobufTest("UnknownVarint", REQUIRED, + message.SerializeAsString(), is_proto3); +} + +void BinaryAndJsonConformanceSuite::RunSuiteImpl() { + // Hack to get the list of test failures based on whether + // GOOGLE3_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER is enabled or not. + conformance::FailureSet failure_set; + ConformanceRequest req; + ConformanceResponse res; + req.set_message_type(failure_set.GetTypeName()); + req.set_protobuf_payload(""); + req.set_requested_output_format(conformance::WireFormat::PROTOBUF); + RunTest("FindFailures", req, &res); + GOOGLE_CHECK(failure_set.MergeFromString(res.protobuf_payload())); + for (const string& failure : failure_set.failure()) { + AddExpectedFailedTest(failure); + } + + type_resolver_.reset(NewTypeResolverForDescriptorPool( + kTypeUrlPrefix, DescriptorPool::generated_pool())); + type_url_ = GetTypeUrl(TestAllTypesProto3::descriptor()); + + for (int i = 1; i <= FieldDescriptor::MAX_TYPE; i++) { + if (i == FieldDescriptor::TYPE_GROUP) continue; + TestPrematureEOFForType(static_cast(i)); + } + + TestIllegalTags(); + + int64 kInt64Min = -9223372036854775808ULL; + int64 kInt64Max = 9223372036854775807ULL; + uint64 kUint64Max = 18446744073709551615ULL; + int32 kInt32Max = 2147483647; + int32 kInt32Min = -2147483648; + uint32 kUint32Max = 4294967295UL; + + TestValidDataForType(FieldDescriptor::TYPE_DOUBLE, { + {dbl(0.1), "0.1"}, + {dbl(1.7976931348623157e+308), "1.7976931348623157e+308"}, + {dbl(2.22507385850720138309e-308), "2.22507385850720138309e-308"} + }); + TestValidDataForType(FieldDescriptor::TYPE_FLOAT, { + {flt(0.1), "0.1"}, + {flt(1.00000075e-36), "1.00000075e-36"}, + {flt(3.402823e+38), "3.402823e+38"}, // 3.40282347e+38 + {flt(1.17549435e-38f), "1.17549435e-38"} + }); + TestValidDataForType(FieldDescriptor::TYPE_INT64, { + {varint(12345), "12345"}, + {varint(kInt64Max), std::to_string(kInt64Max)}, + {varint(kInt64Min), std::to_string(kInt64Min)} + }); + TestValidDataForType(FieldDescriptor::TYPE_UINT64, { + {varint(12345), "12345"}, + {varint(kUint64Max), std::to_string(kUint64Max)}, + {varint(0), "0"} + }); + TestValidDataForType(FieldDescriptor::TYPE_INT32, { + {varint(12345), "12345"}, + {longvarint(12345, 2), "12345"}, + {longvarint(12345, 7), "12345"}, + {varint(kInt32Max), std::to_string(kInt32Max)}, + {varint(kInt32Min), std::to_string(kInt32Min)}, + {varint(1LL << 33), std::to_string(static_cast(1LL << 33))}, + {varint((1LL << 33) - 1), + std::to_string(static_cast((1LL << 33) - 1))}, + }); + TestValidDataForType(FieldDescriptor::TYPE_UINT32, { + {varint(12345), "12345"}, + {longvarint(12345, 2), "12345"}, + {longvarint(12345, 7), "12345"}, + {varint(kUint32Max), std::to_string(kUint32Max)}, // UINT32_MAX + {varint(0), "0"}, + {varint(1LL << 33), std::to_string(static_cast(1LL << 33))}, + {varint((1LL << 33) - 1), + std::to_string(static_cast((1LL << 33) - 1))}, + }); + TestValidDataForType(FieldDescriptor::TYPE_FIXED64, { + {u64(12345), "12345"}, + {u64(kUint64Max), std::to_string(kUint64Max)}, + {u64(0), "0"} + }); + TestValidDataForType(FieldDescriptor::TYPE_FIXED32, { + {u32(12345), "12345"}, + {u32(kUint32Max), std::to_string(kUint32Max)}, // UINT32_MAX + {u32(0), "0"} + }); + TestValidDataForType(FieldDescriptor::TYPE_SFIXED64, { + {u64(12345), "12345"}, + {u64(kInt64Max), std::to_string(kInt64Max)}, + {u64(kInt64Min), std::to_string(kInt64Min)} + }); + TestValidDataForType(FieldDescriptor::TYPE_SFIXED32, { + {u32(12345), "12345"}, + {u32(kInt32Max), std::to_string(kInt32Max)}, + {u32(kInt32Min), std::to_string(kInt32Min)} + }); + TestValidDataForType(FieldDescriptor::TYPE_BOOL, { + {varint(1), "true"}, + {varint(0), "false"}, + {varint(12345678), "true"} + }); + TestValidDataForType(FieldDescriptor::TYPE_SINT32, { + {zz32(12345), "12345"}, + {zz32(kInt32Max), std::to_string(kInt32Max)}, + {zz32(kInt32Min), std::to_string(kInt32Min)} + }); + TestValidDataForType(FieldDescriptor::TYPE_SINT64, { + {zz64(12345), "12345"}, + {zz64(kInt64Max), std::to_string(kInt64Max)}, + {zz64(kInt64Min), std::to_string(kInt64Min)} + }); + + // TODO(haberman): + // TestValidDataForType(FieldDescriptor::TYPE_STRING + // TestValidDataForType(FieldDescriptor::TYPE_GROUP + // TestValidDataForType(FieldDescriptor::TYPE_MESSAGE + // TestValidDataForType(FieldDescriptor::TYPE_BYTES + // TestValidDataForType(FieldDescriptor::TYPE_ENUM + + RunValidJsonTest("HelloWorld", REQUIRED, + "{\"optionalString\":\"Hello, World!\"}", + "optional_string: 'Hello, World!'"); + + // NOTE: The spec for JSON support is still being sorted out, these may not + // all be correct. + // Test field name conventions. + RunValidJsonTest( + "FieldNameInSnakeCase", REQUIRED, + R"({ + "fieldname1": 1, + "fieldName2": 2, + "FieldName3": 3, + "fieldName4": 4 + })", + R"( + fieldname1: 1 + field_name2: 2 + _field_name3: 3 + field__name4_: 4 + )"); + RunValidJsonTest( + "FieldNameWithNumbers", REQUIRED, + R"({ + "field0name5": 5, + "field0Name6": 6 + })", + R"( + field0name5: 5 + field_0_name6: 6 + )"); + RunValidJsonTest( + "FieldNameWithMixedCases", REQUIRED, + R"({ + "fieldName7": 7, + "FieldName8": 8, + "fieldName9": 9, + "FieldName10": 10, + "FIELDNAME11": 11, + "FIELDName12": 12 + })", + R"( + fieldName7: 7 + FieldName8: 8 + field_Name9: 9 + Field_Name10: 10 + FIELD_NAME11: 11 + FIELD_name12: 12 + )"); + RunValidJsonTest( + "FieldNameWithDoubleUnderscores", RECOMMENDED, + R"({ + "FieldName13": 13, + "FieldName14": 14, + "fieldName15": 15, + "fieldName16": 16, + "fieldName17": 17, + "FieldName18": 18 + })", + R"( + __field_name13: 13 + __Field_name14: 14 + field__name15: 15 + field__Name16: 16 + field_name17__: 17 + Field_name18__: 18 + )"); + // Using the original proto field name in JSON is also allowed. + RunValidJsonTest( + "OriginalProtoFieldName", REQUIRED, + R"({ + "fieldname1": 1, + "field_name2": 2, + "_field_name3": 3, + "field__name4_": 4, + "field0name5": 5, + "field_0_name6": 6, + "fieldName7": 7, + "FieldName8": 8, + "field_Name9": 9, + "Field_Name10": 10, + "FIELD_NAME11": 11, + "FIELD_name12": 12, + "__field_name13": 13, + "__Field_name14": 14, + "field__name15": 15, + "field__Name16": 16, + "field_name17__": 17, + "Field_name18__": 18 + })", + R"( + fieldname1: 1 + field_name2: 2 + _field_name3: 3 + field__name4_: 4 + field0name5: 5 + field_0_name6: 6 + fieldName7: 7 + FieldName8: 8 + field_Name9: 9 + Field_Name10: 10 + FIELD_NAME11: 11 + FIELD_name12: 12 + __field_name13: 13 + __Field_name14: 14 + field__name15: 15 + field__Name16: 16 + field_name17__: 17 + Field_name18__: 18 + )"); + // Field names can be escaped. + RunValidJsonTest( + "FieldNameEscaped", REQUIRED, + R"({"fieldn\u0061me1": 1})", + "fieldname1: 1"); + // String ends with escape character. + ExpectParseFailureForJson( + "StringEndsWithEscapeChar", RECOMMENDED, + "{\"optionalString\": \"abc\\"); + // Field names must be quoted (or it's not valid JSON). + ExpectParseFailureForJson( + "FieldNameNotQuoted", RECOMMENDED, + "{fieldname1: 1}"); + // Trailing comma is not allowed (not valid JSON). + ExpectParseFailureForJson( + "TrailingCommaInAnObject", RECOMMENDED, + R"({"fieldname1":1,})"); + ExpectParseFailureForJson( + "TrailingCommaInAnObjectWithSpace", RECOMMENDED, + R"({"fieldname1":1 ,})"); + ExpectParseFailureForJson( + "TrailingCommaInAnObjectWithSpaceCommaSpace", RECOMMENDED, + R"({"fieldname1":1 , })"); + ExpectParseFailureForJson( + "TrailingCommaInAnObjectWithNewlines", RECOMMENDED, + R"({ + "fieldname1":1, + })"); + // JSON doesn't support comments. + ExpectParseFailureForJson( + "JsonWithComments", RECOMMENDED, + R"({ + // This is a comment. + "fieldname1": 1 + })"); + // JSON spec says whitespace doesn't matter, so try a few spacings to be sure. + RunValidJsonTest( + "OneLineNoSpaces", RECOMMENDED, + "{\"optionalInt32\":1,\"optionalInt64\":2}", + R"( + optional_int32: 1 + optional_int64: 2 + )"); + RunValidJsonTest( + "OneLineWithSpaces", RECOMMENDED, + "{ \"optionalInt32\" : 1 , \"optionalInt64\" : 2 }", + R"( + optional_int32: 1 + optional_int64: 2 + )"); + RunValidJsonTest( + "MultilineNoSpaces", RECOMMENDED, + "{\n\"optionalInt32\"\n:\n1\n,\n\"optionalInt64\"\n:\n2\n}", + R"( + optional_int32: 1 + optional_int64: 2 + )"); + RunValidJsonTest( + "MultilineWithSpaces", RECOMMENDED, + "{\n \"optionalInt32\" : 1\n ,\n \"optionalInt64\" : 2\n}\n", + R"( + optional_int32: 1 + optional_int64: 2 + )"); + // Missing comma between key/value pairs. + ExpectParseFailureForJson( + "MissingCommaOneLine", RECOMMENDED, + "{ \"optionalInt32\": 1 \"optionalInt64\": 2 }"); + ExpectParseFailureForJson( + "MissingCommaMultiline", RECOMMENDED, + "{\n \"optionalInt32\": 1\n \"optionalInt64\": 2\n}"); + // Duplicated field names are not allowed. + ExpectParseFailureForJson( + "FieldNameDuplicate", RECOMMENDED, + R"({ + "optionalNestedMessage": {a: 1}, + "optionalNestedMessage": {} + })"); + ExpectParseFailureForJson( + "FieldNameDuplicateDifferentCasing1", RECOMMENDED, + R"({ + "optional_nested_message": {a: 1}, + "optionalNestedMessage": {} + })"); + ExpectParseFailureForJson( + "FieldNameDuplicateDifferentCasing2", RECOMMENDED, + R"({ + "optionalNestedMessage": {a: 1}, + "optional_nested_message": {} + })"); + // Serializers should use lowerCamelCase by default. + RunValidJsonTestWithValidator( + "FieldNameInLowerCamelCase", REQUIRED, + R"({ + "fieldname1": 1, + "fieldName2": 2, + "FieldName3": 3, + "fieldName4": 4 + })", + [](const Json::Value& value) { + return value.isMember("fieldname1") && + value.isMember("fieldName2") && + value.isMember("FieldName3") && + value.isMember("fieldName4"); + }); + RunValidJsonTestWithValidator( + "FieldNameWithNumbers", REQUIRED, + R"({ + "field0name5": 5, + "field0Name6": 6 + })", + [](const Json::Value& value) { + return value.isMember("field0name5") && + value.isMember("field0Name6"); + }); + RunValidJsonTestWithValidator( + "FieldNameWithMixedCases", REQUIRED, + R"({ + "fieldName7": 7, + "FieldName8": 8, + "fieldName9": 9, + "FieldName10": 10, + "FIELDNAME11": 11, + "FIELDName12": 12 + })", + [](const Json::Value& value) { + return value.isMember("fieldName7") && + value.isMember("FieldName8") && + value.isMember("fieldName9") && + value.isMember("FieldName10") && + value.isMember("FIELDNAME11") && + value.isMember("FIELDName12"); + }); + RunValidJsonTestWithValidator( + "FieldNameWithDoubleUnderscores", RECOMMENDED, + R"({ + "FieldName13": 13, + "FieldName14": 14, + "fieldName15": 15, + "fieldName16": 16, + "fieldName17": 17, + "FieldName18": 18 + })", + [](const Json::Value& value) { + return value.isMember("FieldName13") && + value.isMember("FieldName14") && + value.isMember("fieldName15") && + value.isMember("fieldName16") && + value.isMember("fieldName17") && + value.isMember("FieldName18"); + }); + + // Integer fields. + RunValidJsonTest( + "Int32FieldMaxValue", REQUIRED, + R"({"optionalInt32": 2147483647})", + "optional_int32: 2147483647"); + RunValidJsonTest( + "Int32FieldMinValue", REQUIRED, + R"({"optionalInt32": -2147483648})", + "optional_int32: -2147483648"); + RunValidJsonTest( + "Uint32FieldMaxValue", REQUIRED, + R"({"optionalUint32": 4294967295})", + "optional_uint32: 4294967295"); + RunValidJsonTest( + "Int64FieldMaxValue", REQUIRED, + R"({"optionalInt64": "9223372036854775807"})", + "optional_int64: 9223372036854775807"); + RunValidJsonTest( + "Int64FieldMinValue", REQUIRED, + R"({"optionalInt64": "-9223372036854775808"})", + "optional_int64: -9223372036854775808"); + RunValidJsonTest( + "Uint64FieldMaxValue", REQUIRED, + R"({"optionalUint64": "18446744073709551615"})", + "optional_uint64: 18446744073709551615"); + // While not the largest Int64, this is the largest + // Int64 which can be exactly represented within an + // IEEE-754 64-bit float, which is the expected level + // of interoperability guarantee. Larger values may + // work in some implementations, but should not be + // relied upon. + RunValidJsonTest( + "Int64FieldMaxValueNotQuoted", REQUIRED, + R"({"optionalInt64": 9223372036854774784})", + "optional_int64: 9223372036854774784"); + RunValidJsonTest( + "Int64FieldMinValueNotQuoted", REQUIRED, + R"({"optionalInt64": -9223372036854775808})", + "optional_int64: -9223372036854775808"); + // Largest interoperable Uint64; see comment above + // for Int64FieldMaxValueNotQuoted. + RunValidJsonTest( + "Uint64FieldMaxValueNotQuoted", REQUIRED, + R"({"optionalUint64": 18446744073709549568})", + "optional_uint64: 18446744073709549568"); + // Values can be represented as JSON strings. + RunValidJsonTest( + "Int32FieldStringValue", REQUIRED, + R"({"optionalInt32": "2147483647"})", + "optional_int32: 2147483647"); + RunValidJsonTest( + "Int32FieldStringValueEscaped", REQUIRED, + R"({"optionalInt32": "2\u003147483647"})", + "optional_int32: 2147483647"); + + // Parsers reject out-of-bound integer values. + ExpectParseFailureForJson( + "Int32FieldTooLarge", REQUIRED, + R"({"optionalInt32": 2147483648})"); + ExpectParseFailureForJson( + "Int32FieldTooSmall", REQUIRED, + R"({"optionalInt32": -2147483649})"); + ExpectParseFailureForJson( + "Uint32FieldTooLarge", REQUIRED, + R"({"optionalUint32": 4294967296})"); + ExpectParseFailureForJson( + "Int64FieldTooLarge", REQUIRED, + R"({"optionalInt64": "9223372036854775808"})"); + ExpectParseFailureForJson( + "Int64FieldTooSmall", REQUIRED, + R"({"optionalInt64": "-9223372036854775809"})"); + ExpectParseFailureForJson( + "Uint64FieldTooLarge", REQUIRED, + R"({"optionalUint64": "18446744073709551616"})"); + // Parser reject non-integer numeric values as well. + ExpectParseFailureForJson( + "Int32FieldNotInteger", REQUIRED, + R"({"optionalInt32": 0.5})"); + ExpectParseFailureForJson( + "Uint32FieldNotInteger", REQUIRED, + R"({"optionalUint32": 0.5})"); + ExpectParseFailureForJson( + "Int64FieldNotInteger", REQUIRED, + R"({"optionalInt64": "0.5"})"); + ExpectParseFailureForJson( + "Uint64FieldNotInteger", REQUIRED, + R"({"optionalUint64": "0.5"})"); + + // Integers but represented as float values are accepted. + RunValidJsonTest( + "Int32FieldFloatTrailingZero", REQUIRED, + R"({"optionalInt32": 100000.000})", + "optional_int32: 100000"); + RunValidJsonTest( + "Int32FieldExponentialFormat", REQUIRED, + R"({"optionalInt32": 1e5})", + "optional_int32: 100000"); + RunValidJsonTest( + "Int32FieldMaxFloatValue", REQUIRED, + R"({"optionalInt32": 2.147483647e9})", + "optional_int32: 2147483647"); + RunValidJsonTest( + "Int32FieldMinFloatValue", REQUIRED, + R"({"optionalInt32": -2.147483648e9})", + "optional_int32: -2147483648"); + RunValidJsonTest( + "Uint32FieldMaxFloatValue", REQUIRED, + R"({"optionalUint32": 4.294967295e9})", + "optional_uint32: 4294967295"); + + // Parser reject non-numeric values. + ExpectParseFailureForJson( + "Int32FieldNotNumber", REQUIRED, + R"({"optionalInt32": "3x3"})"); + ExpectParseFailureForJson( + "Uint32FieldNotNumber", REQUIRED, + R"({"optionalUint32": "3x3"})"); + ExpectParseFailureForJson( + "Int64FieldNotNumber", REQUIRED, + R"({"optionalInt64": "3x3"})"); + ExpectParseFailureForJson( + "Uint64FieldNotNumber", REQUIRED, + R"({"optionalUint64": "3x3"})"); + // JSON does not allow "+" on numric values. + ExpectParseFailureForJson( + "Int32FieldPlusSign", REQUIRED, + R"({"optionalInt32": +1})"); + // JSON doesn't allow leading 0s. + ExpectParseFailureForJson( + "Int32FieldLeadingZero", REQUIRED, + R"({"optionalInt32": 01})"); + ExpectParseFailureForJson( + "Int32FieldNegativeWithLeadingZero", REQUIRED, + R"({"optionalInt32": -01})"); + // String values must follow the same syntax rule. Specifically leading + // or trailing spaces are not allowed. + ExpectParseFailureForJson( + "Int32FieldLeadingSpace", REQUIRED, + R"({"optionalInt32": " 1"})"); + ExpectParseFailureForJson( + "Int32FieldTrailingSpace", REQUIRED, + R"({"optionalInt32": "1 "})"); + + // 64-bit values are serialized as strings. + RunValidJsonTestWithValidator( + "Int64FieldBeString", RECOMMENDED, + R"({"optionalInt64": 1})", + [](const Json::Value& value) { + return value["optionalInt64"].type() == Json::stringValue && + value["optionalInt64"].asString() == "1"; + }); + RunValidJsonTestWithValidator( + "Uint64FieldBeString", RECOMMENDED, + R"({"optionalUint64": 1})", + [](const Json::Value& value) { + return value["optionalUint64"].type() == Json::stringValue && + value["optionalUint64"].asString() == "1"; + }); + + // Bool fields. + RunValidJsonTest( + "BoolFieldTrue", REQUIRED, + R"({"optionalBool":true})", + "optional_bool: true"); + RunValidJsonTest( + "BoolFieldFalse", REQUIRED, + R"({"optionalBool":false})", + "optional_bool: false"); + + // Other forms are not allowed. + ExpectParseFailureForJson( + "BoolFieldIntegerZero", RECOMMENDED, + R"({"optionalBool":0})"); + ExpectParseFailureForJson( + "BoolFieldIntegerOne", RECOMMENDED, + R"({"optionalBool":1})"); + ExpectParseFailureForJson( + "BoolFieldCamelCaseTrue", RECOMMENDED, + R"({"optionalBool":True})"); + ExpectParseFailureForJson( + "BoolFieldCamelCaseFalse", RECOMMENDED, + R"({"optionalBool":False})"); + ExpectParseFailureForJson( + "BoolFieldAllCapitalTrue", RECOMMENDED, + R"({"optionalBool":TRUE})"); + ExpectParseFailureForJson( + "BoolFieldAllCapitalFalse", RECOMMENDED, + R"({"optionalBool":FALSE})"); + ExpectParseFailureForJson( + "BoolFieldDoubleQuotedTrue", RECOMMENDED, + R"({"optionalBool":"true"})"); + ExpectParseFailureForJson( + "BoolFieldDoubleQuotedFalse", RECOMMENDED, + R"({"optionalBool":"false"})"); + + // Float fields. + RunValidJsonTest( + "FloatFieldMinPositiveValue", REQUIRED, + R"({"optionalFloat": 1.175494e-38})", + "optional_float: 1.175494e-38"); + RunValidJsonTest( + "FloatFieldMaxNegativeValue", REQUIRED, + R"({"optionalFloat": -1.175494e-38})", + "optional_float: -1.175494e-38"); + RunValidJsonTest( + "FloatFieldMaxPositiveValue", REQUIRED, + R"({"optionalFloat": 3.402823e+38})", + "optional_float: 3.402823e+38"); + RunValidJsonTest( + "FloatFieldMinNegativeValue", REQUIRED, + R"({"optionalFloat": 3.402823e+38})", + "optional_float: 3.402823e+38"); + // Values can be quoted. + RunValidJsonTest( + "FloatFieldQuotedValue", REQUIRED, + R"({"optionalFloat": "1"})", + "optional_float: 1"); + // Special values. + RunValidJsonTest( + "FloatFieldNan", REQUIRED, + R"({"optionalFloat": "NaN"})", + "optional_float: nan"); + RunValidJsonTest( + "FloatFieldInfinity", REQUIRED, + R"({"optionalFloat": "Infinity"})", + "optional_float: inf"); + RunValidJsonTest( + "FloatFieldNegativeInfinity", REQUIRED, + R"({"optionalFloat": "-Infinity"})", + "optional_float: -inf"); + // Non-cannonical Nan will be correctly normalized. + { + TestAllTypesProto3 message; + // IEEE floating-point standard 32-bit quiet NaN: + // 0111 1111 1xxx xxxx xxxx xxxx xxxx xxxx + message.set_optional_float( + WireFormatLite::DecodeFloat(0x7FA12345)); + RunValidJsonTestWithProtobufInput( + "FloatFieldNormalizeQuietNan", REQUIRED, message, + "optional_float: nan"); + // IEEE floating-point standard 64-bit signaling NaN: + // 1111 1111 1xxx xxxx xxxx xxxx xxxx xxxx + message.set_optional_float( + WireFormatLite::DecodeFloat(0xFFB54321)); + RunValidJsonTestWithProtobufInput( + "FloatFieldNormalizeSignalingNan", REQUIRED, message, + "optional_float: nan"); + } + + // Special values must be quoted. + ExpectParseFailureForJson( + "FloatFieldNanNotQuoted", RECOMMENDED, + R"({"optionalFloat": NaN})"); + ExpectParseFailureForJson( + "FloatFieldInfinityNotQuoted", RECOMMENDED, + R"({"optionalFloat": Infinity})"); + ExpectParseFailureForJson( + "FloatFieldNegativeInfinityNotQuoted", RECOMMENDED, + R"({"optionalFloat": -Infinity})"); + // Parsers should reject out-of-bound values. + ExpectParseFailureForJson( + "FloatFieldTooSmall", REQUIRED, + R"({"optionalFloat": -3.502823e+38})"); + ExpectParseFailureForJson( + "FloatFieldTooLarge", REQUIRED, + R"({"optionalFloat": 3.502823e+38})"); + + // Double fields. + RunValidJsonTest( + "DoubleFieldMinPositiveValue", REQUIRED, + R"({"optionalDouble": 2.22507e-308})", + "optional_double: 2.22507e-308"); + RunValidJsonTest( + "DoubleFieldMaxNegativeValue", REQUIRED, + R"({"optionalDouble": -2.22507e-308})", + "optional_double: -2.22507e-308"); + RunValidJsonTest( + "DoubleFieldMaxPositiveValue", REQUIRED, + R"({"optionalDouble": 1.79769e+308})", + "optional_double: 1.79769e+308"); + RunValidJsonTest( + "DoubleFieldMinNegativeValue", REQUIRED, + R"({"optionalDouble": -1.79769e+308})", + "optional_double: -1.79769e+308"); + // Values can be quoted. + RunValidJsonTest( + "DoubleFieldQuotedValue", REQUIRED, + R"({"optionalDouble": "1"})", + "optional_double: 1"); + // Speical values. + RunValidJsonTest( + "DoubleFieldNan", REQUIRED, + R"({"optionalDouble": "NaN"})", + "optional_double: nan"); + RunValidJsonTest( + "DoubleFieldInfinity", REQUIRED, + R"({"optionalDouble": "Infinity"})", + "optional_double: inf"); + RunValidJsonTest( + "DoubleFieldNegativeInfinity", REQUIRED, + R"({"optionalDouble": "-Infinity"})", + "optional_double: -inf"); + // Non-cannonical Nan will be correctly normalized. + { + TestAllTypesProto3 message; + message.set_optional_double( + WireFormatLite::DecodeDouble(0x7FFA123456789ABCLL)); + RunValidJsonTestWithProtobufInput( + "DoubleFieldNormalizeQuietNan", REQUIRED, message, + "optional_double: nan"); + message.set_optional_double( + WireFormatLite::DecodeDouble(0xFFFBCBA987654321LL)); + RunValidJsonTestWithProtobufInput( + "DoubleFieldNormalizeSignalingNan", REQUIRED, message, + "optional_double: nan"); + } + + // Special values must be quoted. + ExpectParseFailureForJson( + "DoubleFieldNanNotQuoted", RECOMMENDED, + R"({"optionalDouble": NaN})"); + ExpectParseFailureForJson( + "DoubleFieldInfinityNotQuoted", RECOMMENDED, + R"({"optionalDouble": Infinity})"); + ExpectParseFailureForJson( + "DoubleFieldNegativeInfinityNotQuoted", RECOMMENDED, + R"({"optionalDouble": -Infinity})"); + + // Parsers should reject out-of-bound values. + ExpectParseFailureForJson( + "DoubleFieldTooSmall", REQUIRED, + R"({"optionalDouble": -1.89769e+308})"); + ExpectParseFailureForJson( + "DoubleFieldTooLarge", REQUIRED, + R"({"optionalDouble": +1.89769e+308})"); + + // Enum fields. + RunValidJsonTest( + "EnumField", REQUIRED, + R"({"optionalNestedEnum": "FOO"})", + "optional_nested_enum: FOO"); + // Enum fields with alias + RunValidJsonTest( + "EnumFieldWithAlias", REQUIRED, + R"({"optionalAliasedEnum": "ALIAS_BAZ"})", + "optional_aliased_enum: ALIAS_BAZ"); + RunValidJsonTest( + "EnumFieldWithAliasUseAlias", REQUIRED, + R"({"optionalAliasedEnum": "QUX"})", + "optional_aliased_enum: ALIAS_BAZ"); + RunValidJsonTest( + "EnumFieldWithAliasLowerCase", REQUIRED, + R"({"optionalAliasedEnum": "qux"})", + "optional_aliased_enum: ALIAS_BAZ"); + RunValidJsonTest( + "EnumFieldWithAliasDifferentCase", REQUIRED, + R"({"optionalAliasedEnum": "bAz"})", + "optional_aliased_enum: ALIAS_BAZ"); + // Enum values must be represented as strings. + ExpectParseFailureForJson( + "EnumFieldNotQuoted", REQUIRED, + R"({"optionalNestedEnum": FOO})"); + // Numeric values are allowed. + RunValidJsonTest( + "EnumFieldNumericValueZero", REQUIRED, + R"({"optionalNestedEnum": 0})", + "optional_nested_enum: FOO"); + RunValidJsonTest( + "EnumFieldNumericValueNonZero", REQUIRED, + R"({"optionalNestedEnum": 1})", + "optional_nested_enum: BAR"); + // Unknown enum values are represented as numeric values. + RunValidJsonTestWithValidator( + "EnumFieldUnknownValue", REQUIRED, + R"({"optionalNestedEnum": 123})", + [](const Json::Value& value) { + return value["optionalNestedEnum"].type() == Json::intValue && + value["optionalNestedEnum"].asInt() == 123; + }); + + // String fields. + RunValidJsonTest( + "StringField", REQUIRED, + R"({"optionalString": "Hello world!"})", + "optional_string: \"Hello world!\""); + RunValidJsonTest( + "StringFieldUnicode", REQUIRED, + // Google in Chinese. + R"({"optionalString": "谷歌"})", + R"(optional_string: "谷歌")"); + RunValidJsonTest( + "StringFieldEscape", REQUIRED, + R"({"optionalString": "\"\\\/\b\f\n\r\t"})", + R"(optional_string: "\"\\/\b\f\n\r\t")"); + RunValidJsonTest( + "StringFieldUnicodeEscape", REQUIRED, + R"({"optionalString": "\u8C37\u6B4C"})", + R"(optional_string: "谷歌")"); + RunValidJsonTest( + "StringFieldUnicodeEscapeWithLowercaseHexLetters", REQUIRED, + R"({"optionalString": "\u8c37\u6b4c"})", + R"(optional_string: "谷歌")"); + RunValidJsonTest( + "StringFieldSurrogatePair", REQUIRED, + // The character is an emoji: grinning face with smiling eyes. 😠+ R"({"optionalString": "\uD83D\uDE01"})", + R"(optional_string: "\xF0\x9F\x98\x81")"); + + // Unicode escapes must start with "\u" (lowercase u). + ExpectParseFailureForJson( + "StringFieldUppercaseEscapeLetter", RECOMMENDED, + R"({"optionalString": "\U8C37\U6b4C"})"); + ExpectParseFailureForJson( + "StringFieldInvalidEscape", RECOMMENDED, + R"({"optionalString": "\uXXXX\u6B4C"})"); + ExpectParseFailureForJson( + "StringFieldUnterminatedEscape", RECOMMENDED, + R"({"optionalString": "\u8C3"})"); + ExpectParseFailureForJson( + "StringFieldUnpairedHighSurrogate", RECOMMENDED, + R"({"optionalString": "\uD800"})"); + ExpectParseFailureForJson( + "StringFieldUnpairedLowSurrogate", RECOMMENDED, + R"({"optionalString": "\uDC00"})"); + ExpectParseFailureForJson( + "StringFieldSurrogateInWrongOrder", RECOMMENDED, + R"({"optionalString": "\uDE01\uD83D"})"); + ExpectParseFailureForJson( + "StringFieldNotAString", REQUIRED, + R"({"optionalString": 12345})"); + + // Bytes fields. + RunValidJsonTest( + "BytesField", REQUIRED, + R"({"optionalBytes": "AQI="})", + R"(optional_bytes: "\x01\x02")"); + RunValidJsonTest( + "BytesFieldBase64Url", RECOMMENDED, + R"({"optionalBytes": "-_"})", + R"(optional_bytes: "\xfb")"); + + // Message fields. + RunValidJsonTest( + "MessageField", REQUIRED, + R"({"optionalNestedMessage": {"a": 1234}})", + "optional_nested_message: {a: 1234}"); + + // Oneof fields. + ExpectParseFailureForJson( + "OneofFieldDuplicate", REQUIRED, + R"({"oneofUint32": 1, "oneofString": "test"})"); + // Ensure zero values for oneof make it out/backs. + TestAllTypesProto3 messageProto3; + TestAllTypesProto2 messageProto2; + TestOneofMessage(messageProto3, true); + TestOneofMessage(messageProto2, false); + RunValidJsonTest( + "OneofZeroUint32", RECOMMENDED, + R"({"oneofUint32": 0})", "oneof_uint32: 0"); + RunValidJsonTest( + "OneofZeroMessage", RECOMMENDED, + R"({"oneofNestedMessage": {}})", "oneof_nested_message: {}"); + RunValidJsonTest( + "OneofZeroString", RECOMMENDED, + R"({"oneofString": ""})", "oneof_string: \"\""); + RunValidJsonTest( + "OneofZeroBytes", RECOMMENDED, + R"({"oneofBytes": ""})", "oneof_bytes: \"\""); + RunValidJsonTest( + "OneofZeroBool", RECOMMENDED, + R"({"oneofBool": false})", "oneof_bool: false"); + RunValidJsonTest( + "OneofZeroUint64", RECOMMENDED, + R"({"oneofUint64": 0})", "oneof_uint64: 0"); + RunValidJsonTest( + "OneofZeroFloat", RECOMMENDED, + R"({"oneofFloat": 0.0})", "oneof_float: 0"); + RunValidJsonTest( + "OneofZeroDouble", RECOMMENDED, + R"({"oneofDouble": 0.0})", "oneof_double: 0"); + RunValidJsonTest( + "OneofZeroEnum", RECOMMENDED, + R"({"oneofEnum":"FOO"})", "oneof_enum: FOO"); + + // Repeated fields. + RunValidJsonTest( + "PrimitiveRepeatedField", REQUIRED, + R"({"repeatedInt32": [1, 2, 3, 4]})", + "repeated_int32: [1, 2, 3, 4]"); + RunValidJsonTest( + "EnumRepeatedField", REQUIRED, + R"({"repeatedNestedEnum": ["FOO", "BAR", "BAZ"]})", + "repeated_nested_enum: [FOO, BAR, BAZ]"); + RunValidJsonTest( + "StringRepeatedField", REQUIRED, + R"({"repeatedString": ["Hello", "world"]})", + R"(repeated_string: ["Hello", "world"])"); + RunValidJsonTest( + "BytesRepeatedField", REQUIRED, + R"({"repeatedBytes": ["AAEC", "AQI="]})", + R"(repeated_bytes: ["\x00\x01\x02", "\x01\x02"])"); + RunValidJsonTest( + "MessageRepeatedField", REQUIRED, + R"({"repeatedNestedMessage": [{"a": 1234}, {"a": 5678}]})", + "repeated_nested_message: {a: 1234}" + "repeated_nested_message: {a: 5678}"); + + // Repeated field elements are of incorrect type. + ExpectParseFailureForJson( + "RepeatedFieldWrongElementTypeExpectingIntegersGotBool", REQUIRED, + R"({"repeatedInt32": [1, false, 3, 4]})"); + ExpectParseFailureForJson( + "RepeatedFieldWrongElementTypeExpectingIntegersGotString", REQUIRED, + R"({"repeatedInt32": [1, 2, "name", 4]})"); + ExpectParseFailureForJson( + "RepeatedFieldWrongElementTypeExpectingIntegersGotMessage", REQUIRED, + R"({"repeatedInt32": [1, 2, 3, {"a": 4}]})"); + ExpectParseFailureForJson( + "RepeatedFieldWrongElementTypeExpectingStringsGotInt", REQUIRED, + R"({"repeatedString": ["1", 2, "3", "4"]})"); + ExpectParseFailureForJson( + "RepeatedFieldWrongElementTypeExpectingStringsGotBool", REQUIRED, + R"({"repeatedString": ["1", "2", false, "4"]})"); + ExpectParseFailureForJson( + "RepeatedFieldWrongElementTypeExpectingStringsGotMessage", REQUIRED, + R"({"repeatedString": ["1", 2, "3", {"a": 4}]})"); + ExpectParseFailureForJson( + "RepeatedFieldWrongElementTypeExpectingMessagesGotInt", REQUIRED, + R"({"repeatedNestedMessage": [{"a": 1}, 2]})"); + ExpectParseFailureForJson( + "RepeatedFieldWrongElementTypeExpectingMessagesGotBool", REQUIRED, + R"({"repeatedNestedMessage": [{"a": 1}, false]})"); + ExpectParseFailureForJson( + "RepeatedFieldWrongElementTypeExpectingMessagesGotString", REQUIRED, + R"({"repeatedNestedMessage": [{"a": 1}, "2"]})"); + // Trailing comma in the repeated field is not allowed. + ExpectParseFailureForJson( + "RepeatedFieldTrailingComma", RECOMMENDED, + R"({"repeatedInt32": [1, 2, 3, 4,]})"); + ExpectParseFailureForJson( + "RepeatedFieldTrailingCommaWithSpace", RECOMMENDED, + "{\"repeatedInt32\": [1, 2, 3, 4 ,]}"); + ExpectParseFailureForJson( + "RepeatedFieldTrailingCommaWithSpaceCommaSpace", RECOMMENDED, + "{\"repeatedInt32\": [1, 2, 3, 4 , ]}"); + ExpectParseFailureForJson( + "RepeatedFieldTrailingCommaWithNewlines", RECOMMENDED, + "{\"repeatedInt32\": [\n 1,\n 2,\n 3,\n 4,\n]}"); + + // Map fields. + RunValidJsonTest( + "Int32MapField", REQUIRED, + R"({"mapInt32Int32": {"1": 2, "3": 4}})", + "map_int32_int32: {key: 1 value: 2}" + "map_int32_int32: {key: 3 value: 4}"); + ExpectParseFailureForJson( + "Int32MapFieldKeyNotQuoted", RECOMMENDED, + R"({"mapInt32Int32": {1: 2, 3: 4}})"); + RunValidJsonTest( + "Uint32MapField", REQUIRED, + R"({"mapUint32Uint32": {"1": 2, "3": 4}})", + "map_uint32_uint32: {key: 1 value: 2}" + "map_uint32_uint32: {key: 3 value: 4}"); + ExpectParseFailureForJson( + "Uint32MapFieldKeyNotQuoted", RECOMMENDED, + R"({"mapUint32Uint32": {1: 2, 3: 4}})"); + RunValidJsonTest( + "Int64MapField", REQUIRED, + R"({"mapInt64Int64": {"1": 2, "3": 4}})", + "map_int64_int64: {key: 1 value: 2}" + "map_int64_int64: {key: 3 value: 4}"); + ExpectParseFailureForJson( + "Int64MapFieldKeyNotQuoted", RECOMMENDED, + R"({"mapInt64Int64": {1: 2, 3: 4}})"); + RunValidJsonTest( + "Uint64MapField", REQUIRED, + R"({"mapUint64Uint64": {"1": 2, "3": 4}})", + "map_uint64_uint64: {key: 1 value: 2}" + "map_uint64_uint64: {key: 3 value: 4}"); + ExpectParseFailureForJson( + "Uint64MapFieldKeyNotQuoted", RECOMMENDED, + R"({"mapUint64Uint64": {1: 2, 3: 4}})"); + RunValidJsonTest( + "BoolMapField", REQUIRED, + R"({"mapBoolBool": {"true": true, "false": false}})", + "map_bool_bool: {key: true value: true}" + "map_bool_bool: {key: false value: false}"); + ExpectParseFailureForJson( + "BoolMapFieldKeyNotQuoted", RECOMMENDED, + R"({"mapBoolBool": {true: true, false: false}})"); + RunValidJsonTest( + "MessageMapField", REQUIRED, + R"({ + "mapStringNestedMessage": { + "hello": {"a": 1234}, + "world": {"a": 5678} + } + })", + R"( + map_string_nested_message: { + key: "hello" + value: {a: 1234} + } + map_string_nested_message: { + key: "world" + value: {a: 5678} + } + )"); + // Since Map keys are represented as JSON strings, escaping should be allowed. + RunValidJsonTest( + "Int32MapEscapedKey", REQUIRED, + R"({"mapInt32Int32": {"\u0031": 2}})", + "map_int32_int32: {key: 1 value: 2}"); + RunValidJsonTest( + "Int64MapEscapedKey", REQUIRED, + R"({"mapInt64Int64": {"\u0031": 2}})", + "map_int64_int64: {key: 1 value: 2}"); + RunValidJsonTest( + "BoolMapEscapedKey", REQUIRED, + R"({"mapBoolBool": {"tr\u0075e": true}})", + "map_bool_bool: {key: true value: true}"); + + // "null" is accepted for all fields types. + RunValidJsonTest( + "AllFieldAcceptNull", REQUIRED, + R"({ + "optionalInt32": null, + "optionalInt64": null, + "optionalUint32": null, + "optionalUint64": null, + "optionalSint32": null, + "optionalSint64": null, + "optionalFixed32": null, + "optionalFixed64": null, + "optionalSfixed32": null, + "optionalSfixed64": null, + "optionalFloat": null, + "optionalDouble": null, + "optionalBool": null, + "optionalString": null, + "optionalBytes": null, + "optionalNestedEnum": null, + "optionalNestedMessage": null, + "repeatedInt32": null, + "repeatedInt64": null, + "repeatedUint32": null, + "repeatedUint64": null, + "repeatedSint32": null, + "repeatedSint64": null, + "repeatedFixed32": null, + "repeatedFixed64": null, + "repeatedSfixed32": null, + "repeatedSfixed64": null, + "repeatedFloat": null, + "repeatedDouble": null, + "repeatedBool": null, + "repeatedString": null, + "repeatedBytes": null, + "repeatedNestedEnum": null, + "repeatedNestedMessage": null, + "mapInt32Int32": null, + "mapBoolBool": null, + "mapStringNestedMessage": null + })", + ""); + + // Repeated field elements cannot be null. + ExpectParseFailureForJson( + "RepeatedFieldPrimitiveElementIsNull", RECOMMENDED, + R"({"repeatedInt32": [1, null, 2]})"); + ExpectParseFailureForJson( + "RepeatedFieldMessageElementIsNull", RECOMMENDED, + R"({"repeatedNestedMessage": [{"a":1}, null, {"a":2}]})"); + // Map field keys cannot be null. + ExpectParseFailureForJson( + "MapFieldKeyIsNull", RECOMMENDED, + R"({"mapInt32Int32": {null: 1}})"); + // Map field values cannot be null. + ExpectParseFailureForJson( + "MapFieldValueIsNull", RECOMMENDED, + R"({"mapInt32Int32": {"0": null}})"); + + // http://www.rfc-editor.org/rfc/rfc7159.txt says strings have to use double + // quotes. + ExpectParseFailureForJson( + "StringFieldSingleQuoteKey", RECOMMENDED, + R"({'optionalString': "Hello world!"})"); + ExpectParseFailureForJson( + "StringFieldSingleQuoteValue", RECOMMENDED, + R"({"optionalString": 'Hello world!'})"); + ExpectParseFailureForJson( + "StringFieldSingleQuoteBoth", RECOMMENDED, + R"({'optionalString': 'Hello world!'})"); + + // Unknown fields. + { + TestAllTypesProto3 messageProto3; + TestAllTypesProto2 messageProto2; + //TODO(yilunchong): update this behavior when unknown field's behavior + // changed in open source. Also delete + // Required.Proto3.ProtobufInput.UnknownVarint.ProtobufOutput + // from failure list of python_cpp python java + TestUnknownMessage(messageProto3, true); + TestUnknownMessage(messageProto2, false); + } + + // Wrapper types. + RunValidJsonTest( + "OptionalBoolWrapper", REQUIRED, + R"({"optionalBoolWrapper": false})", + "optional_bool_wrapper: {value: false}"); + RunValidJsonTest( + "OptionalInt32Wrapper", REQUIRED, + R"({"optionalInt32Wrapper": 0})", + "optional_int32_wrapper: {value: 0}"); + RunValidJsonTest( + "OptionalUint32Wrapper", REQUIRED, + R"({"optionalUint32Wrapper": 0})", + "optional_uint32_wrapper: {value: 0}"); + RunValidJsonTest( + "OptionalInt64Wrapper", REQUIRED, + R"({"optionalInt64Wrapper": 0})", + "optional_int64_wrapper: {value: 0}"); + RunValidJsonTest( + "OptionalUint64Wrapper", REQUIRED, + R"({"optionalUint64Wrapper": 0})", + "optional_uint64_wrapper: {value: 0}"); + RunValidJsonTest( + "OptionalFloatWrapper", REQUIRED, + R"({"optionalFloatWrapper": 0})", + "optional_float_wrapper: {value: 0}"); + RunValidJsonTest( + "OptionalDoubleWrapper", REQUIRED, + R"({"optionalDoubleWrapper": 0})", + "optional_double_wrapper: {value: 0}"); + RunValidJsonTest( + "OptionalStringWrapper", REQUIRED, + R"({"optionalStringWrapper": ""})", + R"(optional_string_wrapper: {value: ""})"); + RunValidJsonTest( + "OptionalBytesWrapper", REQUIRED, + R"({"optionalBytesWrapper": ""})", + R"(optional_bytes_wrapper: {value: ""})"); + RunValidJsonTest( + "OptionalWrapperTypesWithNonDefaultValue", REQUIRED, + R"({ + "optionalBoolWrapper": true, + "optionalInt32Wrapper": 1, + "optionalUint32Wrapper": 1, + "optionalInt64Wrapper": "1", + "optionalUint64Wrapper": "1", + "optionalFloatWrapper": 1, + "optionalDoubleWrapper": 1, + "optionalStringWrapper": "1", + "optionalBytesWrapper": "AQI=" + })", + R"( + optional_bool_wrapper: {value: true} + optional_int32_wrapper: {value: 1} + optional_uint32_wrapper: {value: 1} + optional_int64_wrapper: {value: 1} + optional_uint64_wrapper: {value: 1} + optional_float_wrapper: {value: 1} + optional_double_wrapper: {value: 1} + optional_string_wrapper: {value: "1"} + optional_bytes_wrapper: {value: "\x01\x02"} + )"); + RunValidJsonTest( + "RepeatedBoolWrapper", REQUIRED, + R"({"repeatedBoolWrapper": [true, false]})", + "repeated_bool_wrapper: {value: true}" + "repeated_bool_wrapper: {value: false}"); + RunValidJsonTest( + "RepeatedInt32Wrapper", REQUIRED, + R"({"repeatedInt32Wrapper": [0, 1]})", + "repeated_int32_wrapper: {value: 0}" + "repeated_int32_wrapper: {value: 1}"); + RunValidJsonTest( + "RepeatedUint32Wrapper", REQUIRED, + R"({"repeatedUint32Wrapper": [0, 1]})", + "repeated_uint32_wrapper: {value: 0}" + "repeated_uint32_wrapper: {value: 1}"); + RunValidJsonTest( + "RepeatedInt64Wrapper", REQUIRED, + R"({"repeatedInt64Wrapper": [0, 1]})", + "repeated_int64_wrapper: {value: 0}" + "repeated_int64_wrapper: {value: 1}"); + RunValidJsonTest( + "RepeatedUint64Wrapper", REQUIRED, + R"({"repeatedUint64Wrapper": [0, 1]})", + "repeated_uint64_wrapper: {value: 0}" + "repeated_uint64_wrapper: {value: 1}"); + RunValidJsonTest( + "RepeatedFloatWrapper", REQUIRED, + R"({"repeatedFloatWrapper": [0, 1]})", + "repeated_float_wrapper: {value: 0}" + "repeated_float_wrapper: {value: 1}"); + RunValidJsonTest( + "RepeatedDoubleWrapper", REQUIRED, + R"({"repeatedDoubleWrapper": [0, 1]})", + "repeated_double_wrapper: {value: 0}" + "repeated_double_wrapper: {value: 1}"); + RunValidJsonTest( + "RepeatedStringWrapper", REQUIRED, + R"({"repeatedStringWrapper": ["", "AQI="]})", + R"( + repeated_string_wrapper: {value: ""} + repeated_string_wrapper: {value: "AQI="} + )"); + RunValidJsonTest( + "RepeatedBytesWrapper", REQUIRED, + R"({"repeatedBytesWrapper": ["", "AQI="]})", + R"( + repeated_bytes_wrapper: {value: ""} + repeated_bytes_wrapper: {value: "\x01\x02"} + )"); + RunValidJsonTest( + "WrapperTypesWithNullValue", REQUIRED, + R"({ + "optionalBoolWrapper": null, + "optionalInt32Wrapper": null, + "optionalUint32Wrapper": null, + "optionalInt64Wrapper": null, + "optionalUint64Wrapper": null, + "optionalFloatWrapper": null, + "optionalDoubleWrapper": null, + "optionalStringWrapper": null, + "optionalBytesWrapper": null, + "repeatedBoolWrapper": null, + "repeatedInt32Wrapper": null, + "repeatedUint32Wrapper": null, + "repeatedInt64Wrapper": null, + "repeatedUint64Wrapper": null, + "repeatedFloatWrapper": null, + "repeatedDoubleWrapper": null, + "repeatedStringWrapper": null, + "repeatedBytesWrapper": null + })", + ""); + + // Duration + RunValidJsonTest( + "DurationMinValue", REQUIRED, + R"({"optionalDuration": "-315576000000.999999999s"})", + "optional_duration: {seconds: -315576000000 nanos: -999999999}"); + RunValidJsonTest( + "DurationMaxValue", REQUIRED, + R"({"optionalDuration": "315576000000.999999999s"})", + "optional_duration: {seconds: 315576000000 nanos: 999999999}"); + RunValidJsonTest( + "DurationRepeatedValue", REQUIRED, + R"({"repeatedDuration": ["1.5s", "-1.5s"]})", + "repeated_duration: {seconds: 1 nanos: 500000000}" + "repeated_duration: {seconds: -1 nanos: -500000000}"); + RunValidJsonTest( + "DurationNull", REQUIRED, + R"({"optionalDuration": null})", + ""); + + ExpectParseFailureForJson( + "DurationMissingS", REQUIRED, + R"({"optionalDuration": "1"})"); + ExpectParseFailureForJson( + "DurationJsonInputTooSmall", REQUIRED, + R"({"optionalDuration": "-315576000001.000000000s"})"); + ExpectParseFailureForJson( + "DurationJsonInputTooLarge", REQUIRED, + R"({"optionalDuration": "315576000001.000000000s"})"); + ExpectSerializeFailureForJson( + "DurationProtoInputTooSmall", REQUIRED, + "optional_duration: {seconds: -315576000001 nanos: 0}"); + ExpectSerializeFailureForJson( + "DurationProtoInputTooLarge", REQUIRED, + "optional_duration: {seconds: 315576000001 nanos: 0}"); + + RunValidJsonTestWithValidator( + "DurationHasZeroFractionalDigit", RECOMMENDED, + R"({"optionalDuration": "1.000000000s"})", + [](const Json::Value& value) { + return value["optionalDuration"].asString() == "1s"; + }); + RunValidJsonTestWithValidator( + "DurationHas3FractionalDigits", RECOMMENDED, + R"({"optionalDuration": "1.010000000s"})", + [](const Json::Value& value) { + return value["optionalDuration"].asString() == "1.010s"; + }); + RunValidJsonTestWithValidator( + "DurationHas6FractionalDigits", RECOMMENDED, + R"({"optionalDuration": "1.000010000s"})", + [](const Json::Value& value) { + return value["optionalDuration"].asString() == "1.000010s"; + }); + RunValidJsonTestWithValidator( + "DurationHas9FractionalDigits", RECOMMENDED, + R"({"optionalDuration": "1.000000010s"})", + [](const Json::Value& value) { + return value["optionalDuration"].asString() == "1.000000010s"; + }); + + // Timestamp + RunValidJsonTest( + "TimestampMinValue", REQUIRED, + R"({"optionalTimestamp": "0001-01-01T00:00:00Z"})", + "optional_timestamp: {seconds: -62135596800}"); + RunValidJsonTest( + "TimestampMaxValue", REQUIRED, + R"({"optionalTimestamp": "9999-12-31T23:59:59.999999999Z"})", + "optional_timestamp: {seconds: 253402300799 nanos: 999999999}"); + RunValidJsonTest( + "TimestampRepeatedValue", REQUIRED, + R"({ + "repeatedTimestamp": [ + "0001-01-01T00:00:00Z", + "9999-12-31T23:59:59.999999999Z" + ] + })", + "repeated_timestamp: {seconds: -62135596800}" + "repeated_timestamp: {seconds: 253402300799 nanos: 999999999}"); + RunValidJsonTest( + "TimestampWithPositiveOffset", REQUIRED, + R"({"optionalTimestamp": "1970-01-01T08:00:01+08:00"})", + "optional_timestamp: {seconds: 1}"); + RunValidJsonTest( + "TimestampWithNegativeOffset", REQUIRED, + R"({"optionalTimestamp": "1969-12-31T16:00:01-08:00"})", + "optional_timestamp: {seconds: 1}"); + RunValidJsonTest( + "TimestampNull", REQUIRED, + R"({"optionalTimestamp": null})", + ""); + + ExpectParseFailureForJson( + "TimestampJsonInputTooSmall", REQUIRED, + R"({"optionalTimestamp": "0000-01-01T00:00:00Z"})"); + ExpectParseFailureForJson( + "TimestampJsonInputTooLarge", REQUIRED, + R"({"optionalTimestamp": "10000-01-01T00:00:00Z"})"); + ExpectParseFailureForJson( + "TimestampJsonInputMissingZ", REQUIRED, + R"({"optionalTimestamp": "0001-01-01T00:00:00"})"); + ExpectParseFailureForJson( + "TimestampJsonInputMissingT", REQUIRED, + R"({"optionalTimestamp": "0001-01-01 00:00:00Z"})"); + ExpectParseFailureForJson( + "TimestampJsonInputLowercaseZ", REQUIRED, + R"({"optionalTimestamp": "0001-01-01T00:00:00z"})"); + ExpectParseFailureForJson( + "TimestampJsonInputLowercaseT", REQUIRED, + R"({"optionalTimestamp": "0001-01-01t00:00:00Z"})"); + ExpectSerializeFailureForJson( + "TimestampProtoInputTooSmall", REQUIRED, + "optional_timestamp: {seconds: -62135596801}"); + ExpectSerializeFailureForJson( + "TimestampProtoInputTooLarge", REQUIRED, + "optional_timestamp: {seconds: 253402300800}"); + RunValidJsonTestWithValidator( + "TimestampZeroNormalized", RECOMMENDED, + R"({"optionalTimestamp": "1969-12-31T16:00:00-08:00"})", + [](const Json::Value& value) { + return value["optionalTimestamp"].asString() == + "1970-01-01T00:00:00Z"; + }); + RunValidJsonTestWithValidator( + "TimestampHasZeroFractionalDigit", RECOMMENDED, + R"({"optionalTimestamp": "1970-01-01T00:00:00.000000000Z"})", + [](const Json::Value& value) { + return value["optionalTimestamp"].asString() == + "1970-01-01T00:00:00Z"; + }); + RunValidJsonTestWithValidator( + "TimestampHas3FractionalDigits", RECOMMENDED, + R"({"optionalTimestamp": "1970-01-01T00:00:00.010000000Z"})", + [](const Json::Value& value) { + return value["optionalTimestamp"].asString() == + "1970-01-01T00:00:00.010Z"; + }); + RunValidJsonTestWithValidator( + "TimestampHas6FractionalDigits", RECOMMENDED, + R"({"optionalTimestamp": "1970-01-01T00:00:00.000010000Z"})", + [](const Json::Value& value) { + return value["optionalTimestamp"].asString() == + "1970-01-01T00:00:00.000010Z"; + }); + RunValidJsonTestWithValidator( + "TimestampHas9FractionalDigits", RECOMMENDED, + R"({"optionalTimestamp": "1970-01-01T00:00:00.000000010Z"})", + [](const Json::Value& value) { + return value["optionalTimestamp"].asString() == + "1970-01-01T00:00:00.000000010Z"; + }); + + // FieldMask + RunValidJsonTest( + "FieldMask", REQUIRED, + R"({"optionalFieldMask": "foo,barBaz"})", + R"(optional_field_mask: {paths: "foo" paths: "bar_baz"})"); + RunValidJsonTest( + "EmptyFieldMask", REQUIRED, + R"({"optionalFieldMask": ""})", + R"(optional_field_mask: {})"); + ExpectParseFailureForJson( + "FieldMaskInvalidCharacter", RECOMMENDED, + R"({"optionalFieldMask": "foo,bar_bar"})"); + ExpectSerializeFailureForJson( + "FieldMaskPathsDontRoundTrip", RECOMMENDED, + R"(optional_field_mask: {paths: "fooBar"})"); + ExpectSerializeFailureForJson( + "FieldMaskNumbersDontRoundTrip", RECOMMENDED, + R"(optional_field_mask: {paths: "foo_3_bar"})"); + ExpectSerializeFailureForJson( + "FieldMaskTooManyUnderscore", RECOMMENDED, + R"(optional_field_mask: {paths: "foo__bar"})"); + + // Struct + RunValidJsonTest( + "Struct", REQUIRED, + R"({ + "optionalStruct": { + "nullValue": null, + "intValue": 1234, + "boolValue": true, + "doubleValue": 1234.5678, + "stringValue": "Hello world!", + "listValue": [1234, "5678"], + "objectValue": { + "value": 0 + } + } + })", + R"( + optional_struct: { + fields: { + key: "nullValue" + value: {null_value: NULL_VALUE} + } + fields: { + key: "intValue" + value: {number_value: 1234} + } + fields: { + key: "boolValue" + value: {bool_value: true} + } + fields: { + key: "doubleValue" + value: {number_value: 1234.5678} + } + fields: { + key: "stringValue" + value: {string_value: "Hello world!"} + } + fields: { + key: "listValue" + value: { + list_value: { + values: { + number_value: 1234 + } + values: { + string_value: "5678" + } + } + } + } + fields: { + key: "objectValue" + value: { + struct_value: { + fields: { + key: "value" + value: { + number_value: 0 + } + } + } + } + } + } + )"); + RunValidJsonTest( + "StructWithEmptyListValue", REQUIRED, + R"({ + "optionalStruct": { + "listValue": [] + } + })", + R"( + optional_struct: { + fields: { + key: "listValue" + value: { + list_value: { + } + } + } + } + )"); + // Value + RunValidJsonTest( + "ValueAcceptInteger", REQUIRED, + R"({"optionalValue": 1})", + "optional_value: { number_value: 1}"); + RunValidJsonTest( + "ValueAcceptFloat", REQUIRED, + R"({"optionalValue": 1.5})", + "optional_value: { number_value: 1.5}"); + RunValidJsonTest( + "ValueAcceptBool", REQUIRED, + R"({"optionalValue": false})", + "optional_value: { bool_value: false}"); + RunValidJsonTest( + "ValueAcceptNull", REQUIRED, + R"({"optionalValue": null})", + "optional_value: { null_value: NULL_VALUE}"); + RunValidJsonTest( + "ValueAcceptString", REQUIRED, + R"({"optionalValue": "hello"})", + R"(optional_value: { string_value: "hello"})"); + RunValidJsonTest( + "ValueAcceptList", REQUIRED, + R"({"optionalValue": [0, "hello"]})", + R"( + optional_value: { + list_value: { + values: { + number_value: 0 + } + values: { + string_value: "hello" + } + } + } + )"); + RunValidJsonTest( + "ValueAcceptObject", REQUIRED, + R"({"optionalValue": {"value": 1}})", + R"( + optional_value: { + struct_value: { + fields: { + key: "value" + value: { + number_value: 1 + } + } + } + } + )"); + RunValidJsonTest( + "RepeatedValue", REQUIRED, + R"({ + "repeatedValue": [["a"]] + })", + R"( + repeated_value: [ + { + list_value: { + values: [ + { string_value: "a"} + ] + } + } + ] + )"); + RunValidJsonTest( + "RepeatedListValue", REQUIRED, + R"({ + "repeatedListValue": [["a"]] + })", + R"( + repeated_list_value: [ + { + values: [ + { string_value: "a"} + ] + } + ] + )"); + + // Any + RunValidJsonTest( + "Any", REQUIRED, + R"({ + "optionalAny": { + "@type": "type.googleapis.com/protobuf_test_messages.proto3.TestAllTypesProto3", + "optionalInt32": 12345 + } + })", + R"( + optional_any: { + [type.googleapis.com/protobuf_test_messages.proto3.TestAllTypesProto3] { + optional_int32: 12345 + } + } + )"); + RunValidJsonTest( + "AnyNested", REQUIRED, + R"({ + "optionalAny": { + "@type": "type.googleapis.com/google.protobuf.Any", + "value": { + "@type": "type.googleapis.com/protobuf_test_messages.proto3.TestAllTypesProto3", + "optionalInt32": 12345 + } + } + })", + R"( + optional_any: { + [type.googleapis.com/google.protobuf.Any] { + [type.googleapis.com/protobuf_test_messages.proto3.TestAllTypesProto3] { + optional_int32: 12345 + } + } + } + )"); + // The special "@type" tag is not required to appear first. + RunValidJsonTest( + "AnyUnorderedTypeTag", REQUIRED, + R"({ + "optionalAny": { + "optionalInt32": 12345, + "@type": "type.googleapis.com/protobuf_test_messages.proto3.TestAllTypesProto3" + } + })", + R"( + optional_any: { + [type.googleapis.com/protobuf_test_messages.proto3.TestAllTypesProto3] { + optional_int32: 12345 + } + } + )"); + // Well-known types in Any. + RunValidJsonTest( + "AnyWithInt32ValueWrapper", REQUIRED, + R"({ + "optionalAny": { + "@type": "type.googleapis.com/google.protobuf.Int32Value", + "value": 12345 + } + })", + R"( + optional_any: { + [type.googleapis.com/google.protobuf.Int32Value] { + value: 12345 + } + } + )"); + RunValidJsonTest( + "AnyWithDuration", REQUIRED, + R"({ + "optionalAny": { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.5s" + } + })", + R"( + optional_any: { + [type.googleapis.com/google.protobuf.Duration] { + seconds: 1 + nanos: 500000000 + } + } + )"); + RunValidJsonTest( + "AnyWithTimestamp", REQUIRED, + R"({ + "optionalAny": { + "@type": "type.googleapis.com/google.protobuf.Timestamp", + "value": "1970-01-01T00:00:00Z" + } + })", + R"( + optional_any: { + [type.googleapis.com/google.protobuf.Timestamp] { + seconds: 0 + nanos: 0 + } + } + )"); + RunValidJsonTest( + "AnyWithFieldMask", REQUIRED, + R"({ + "optionalAny": { + "@type": "type.googleapis.com/google.protobuf.FieldMask", + "value": "foo,barBaz" + } + })", + R"( + optional_any: { + [type.googleapis.com/google.protobuf.FieldMask] { + paths: ["foo", "bar_baz"] + } + } + )"); + RunValidJsonTest( + "AnyWithStruct", REQUIRED, + R"({ + "optionalAny": { + "@type": "type.googleapis.com/google.protobuf.Struct", + "value": { + "foo": 1 + } + } + })", + R"( + optional_any: { + [type.googleapis.com/google.protobuf.Struct] { + fields: { + key: "foo" + value: { + number_value: 1 + } + } + } + } + )"); + RunValidJsonTest( + "AnyWithValueForJsonObject", REQUIRED, + R"({ + "optionalAny": { + "@type": "type.googleapis.com/google.protobuf.Value", + "value": { + "foo": 1 + } + } + })", + R"( + optional_any: { + [type.googleapis.com/google.protobuf.Value] { + struct_value: { + fields: { + key: "foo" + value: { + number_value: 1 + } + } + } + } + } + )"); + RunValidJsonTest( + "AnyWithValueForInteger", REQUIRED, + R"({ + "optionalAny": { + "@type": "type.googleapis.com/google.protobuf.Value", + "value": 1 + } + })", + R"( + optional_any: { + [type.googleapis.com/google.protobuf.Value] { + number_value: 1 + } + } + )"); + + RunValidJsonIgnoreUnknownTest( + "IgnoreUnknownJsonNumber", REQUIRED, + R"({ + "unknown": 1 + })", + ""); + RunValidJsonIgnoreUnknownTest( + "IgnoreUnknownJsonString", REQUIRED, + R"({ + "unknown": "a" + })", + ""); + RunValidJsonIgnoreUnknownTest( + "IgnoreUnknownJsonTrue", REQUIRED, + R"({ + "unknown": true + })", + ""); + RunValidJsonIgnoreUnknownTest( + "IgnoreUnknownJsonFalse", REQUIRED, + R"({ + "unknown": false + })", + ""); + RunValidJsonIgnoreUnknownTest( + "IgnoreUnknownJsonNull", REQUIRED, + R"({ + "unknown": null + })", + ""); + RunValidJsonIgnoreUnknownTest( + "IgnoreUnknownJsonObject", REQUIRED, + R"({ + "unknown": {"a": 1} + })", + ""); + + ExpectParseFailureForJson("RejectTopLevelNull", REQUIRED, "null"); +} + +} // namespace protobuf +} // namespace google diff --git a/third_party/protobuf/conformance/binary_json_conformance_suite.h b/third_party/protobuf/conformance/binary_json_conformance_suite.h new file mode 100644 index 000000000000..7a03545fa5d3 --- /dev/null +++ b/third_party/protobuf/conformance/binary_json_conformance_suite.h @@ -0,0 +1,121 @@ +// 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 CONFORMANCE_BINARY_JSON_CONFORMANCE_SUITE_H +#define CONFORMANCE_BINARY_JSON_CONFORMANCE_SUITE_H + +#include "conformance_test.h" +#include "third_party/jsoncpp/json.h" + +namespace google { +namespace protobuf { + +class BinaryAndJsonConformanceSuite : public ConformanceTestSuite { + public: + BinaryAndJsonConformanceSuite() {} + + private: + void RunSuiteImpl(); + void RunValidJsonTest(const string& test_name, + ConformanceLevel level, + const string& input_json, + const string& equivalent_text_format); + void RunValidJsonTestWithProtobufInput( + const string& test_name, + ConformanceLevel level, + const protobuf_test_messages::proto3::TestAllTypesProto3& input, + const string& equivalent_text_format); + void RunValidJsonIgnoreUnknownTest( + const string& test_name, ConformanceLevel level, const string& input_json, + const string& equivalent_text_format); + void RunValidProtobufTest(const string& test_name, ConformanceLevel level, + const string& input_protobuf, + const string& equivalent_text_format, + bool is_proto3); + void RunValidBinaryProtobufTest(const string& test_name, + ConformanceLevel level, + const string& input_protobuf, + bool is_proto3); + void RunValidProtobufTestWithMessage( + const string& test_name, ConformanceLevel level, + const Message *input, + const string& equivalent_text_format, + bool is_proto3); + + bool ParseJsonResponse( + const conformance::ConformanceResponse& response, + Message* test_message); + bool ParseResponse( + const conformance::ConformanceResponse& response, + const ConformanceRequestSetting& setting, + Message* test_message) override; + + typedef std::function Validator; + void RunValidJsonTestWithValidator(const string& test_name, + ConformanceLevel level, + const string& input_json, + const Validator& validator); + void ExpectParseFailureForJson(const string& test_name, + ConformanceLevel level, + const string& input_json); + void ExpectSerializeFailureForJson(const string& test_name, + ConformanceLevel level, + const string& text_format); + void ExpectParseFailureForProtoWithProtoVersion (const string& proto, + const string& test_name, + ConformanceLevel level, + bool is_proto3); + void ExpectParseFailureForProto(const std::string& proto, + const std::string& test_name, + ConformanceLevel level); + void ExpectHardParseFailureForProto(const std::string& proto, + const std::string& test_name, + ConformanceLevel level); + void TestPrematureEOFForType(google::protobuf::FieldDescriptor::Type type); + void TestIllegalTags(); + template + void TestOneofMessage (MessageType &message, + bool is_proto3); + template + void TestUnknownMessage (MessageType &message, + bool is_proto3); + void TestValidDataForType( + google::protobuf::FieldDescriptor::Type, + std::vector> values); + + std::unique_ptr + type_resolver_; + std::string type_url_; +}; + +} // namespace protobuf +} // namespace google + +#endif // CONFORMANCE_BINARY_JSON_CONFORMANCE_SUITE_H diff --git a/third_party/protobuf/conformance/conformance.proto b/third_party/protobuf/conformance/conformance.proto index fc96074ac807..54da406c3cfa 100644 --- a/third_party/protobuf/conformance/conformance.proto +++ b/third_party/protobuf/conformance/conformance.proto @@ -32,13 +32,6 @@ syntax = "proto3"; package conformance; option java_package = "com.google.protobuf.conformance"; -import "google/protobuf/any.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - // This defines the conformance testing protocol. This protocol exists between // the conformance test suite itself and the code being tested. For each test, // the suite will send a ConformanceRequest message and expect a @@ -62,6 +55,32 @@ enum WireFormat { UNSPECIFIED = 0; PROTOBUF = 1; JSON = 2; + JSPB = 3; // Google internal only. Opensource testees just skip it. + TEXT_FORMAT = 4; +} + +enum TestCategory { + UNSPECIFIED_TEST = 0; + BINARY_TEST = 1; // Test binary wire format. + JSON_TEST = 2; // Test json wire format. + // Similar to JSON_TEST. However, during parsing json, testee should ignore + // unknown fields. This feature is optional. Each implementation can descide + // whether to support it. See + // https://developers.google.com/protocol-buffers/docs/proto3#json_options + // for more detail. + JSON_IGNORE_UNKNOWN_PARSING_TEST = 3; + // Test jspb wire format. Google internal only. Opensource testees just skip it. + JSPB_TEST = 4; + // Test text format. For cpp, java and python, testees can already deal with + // this type. Testees of other languages can simply skip it. + TEXT_FORMAT_TEST = 5; +} + +// The conformance runner will request a list of failures as the first request. +// This will be known by message_type == "conformance.FailureSet", a conformance +// test should return a serialized FailureSet in protobuf_payload. +message FailureSet { + repeated string failure = 1; } // Represents a single test case's input. The testee should: @@ -70,15 +89,40 @@ enum WireFormat { // 2. parse the protobuf or JSON payload in "payload" (which may fail) // 3. if the parse succeeded, serialize the message in the requested format. message ConformanceRequest { - // The payload (whether protobuf of JSON) is always for a TestAllTypes proto - // (see below). + // The payload (whether protobuf of JSON) is always for a + // protobuf_test_messages.proto3.TestAllTypes proto (as defined in + // src/google/protobuf/proto3_test_messages.proto). + // + // TODO(haberman): if/when we expand the conformance tests to support proto2, + // we will want to include a field that lets the payload/response be a + // protobuf_test_messages.proto2.TestAllTypes message instead. oneof payload { bytes protobuf_payload = 1; string json_payload = 2; + // Google internal only. Opensource testees just skip it. + string jspb_payload = 7; + string text_payload = 8; } // Which format should the testee serialize its message to? WireFormat requested_output_format = 3; + + // The full name for the test message to use; for the moment, either: + // protobuf_test_messages.proto3.TestAllTypesProto3 or + // protobuf_test_messages.proto2.TestAllTypesProto2. + string message_type = 4; + + // Each test is given a specific test category. Some category may need + // spedific support in testee programs. Refer to the defintion of TestCategory + // for more information. + TestCategory test_category = 5; + + // Specify details for how to encode jspb. + JspbEncodingConfig jspb_encoding_options = 6; + + // This can be used in json and text format. If true, testee should print + // unknown fields instead of ignore. This feature is optional. + bool print_unknown_fields = 9; } // Represents a single test case's output. @@ -112,162 +156,21 @@ message ConformanceResponse { // For when the testee skipped the test, likely because a certain feature // wasn't supported, like JSON input/output. string skipped = 5; - } -} - -// This proto includes every type of field in both singular and repeated -// forms. -message TestAllTypes { - message NestedMessage { - int32 a = 1; - TestAllTypes corecursive = 2; - } - - enum NestedEnum { - FOO = 0; - BAR = 1; - BAZ = 2; - NEG = -1; // Intentionally negative. - } - - // Singular - int32 optional_int32 = 1; - int64 optional_int64 = 2; - uint32 optional_uint32 = 3; - uint64 optional_uint64 = 4; - sint32 optional_sint32 = 5; - sint64 optional_sint64 = 6; - fixed32 optional_fixed32 = 7; - fixed64 optional_fixed64 = 8; - sfixed32 optional_sfixed32 = 9; - sfixed64 optional_sfixed64 = 10; - float optional_float = 11; - double optional_double = 12; - bool optional_bool = 13; - string optional_string = 14; - bytes optional_bytes = 15; - NestedMessage optional_nested_message = 18; - ForeignMessage optional_foreign_message = 19; + // If the input was successfully parsed and the requested output was JSPB, + // serialize to JSPB and set it in this field. JSPB is google internal only + // format. Opensource testees can just skip it. + string jspb_payload = 7; - NestedEnum optional_nested_enum = 21; - ForeignEnum optional_foreign_enum = 22; - - string optional_string_piece = 24 [ctype=STRING_PIECE]; - string optional_cord = 25 [ctype=CORD]; - - TestAllTypes recursive_message = 27; - - // Repeated - repeated int32 repeated_int32 = 31; - repeated int64 repeated_int64 = 32; - repeated uint32 repeated_uint32 = 33; - repeated uint64 repeated_uint64 = 34; - repeated sint32 repeated_sint32 = 35; - repeated sint64 repeated_sint64 = 36; - repeated fixed32 repeated_fixed32 = 37; - repeated fixed64 repeated_fixed64 = 38; - repeated sfixed32 repeated_sfixed32 = 39; - repeated sfixed64 repeated_sfixed64 = 40; - repeated float repeated_float = 41; - repeated double repeated_double = 42; - repeated bool repeated_bool = 43; - repeated string repeated_string = 44; - repeated bytes repeated_bytes = 45; - - repeated NestedMessage repeated_nested_message = 48; - repeated ForeignMessage repeated_foreign_message = 49; - - repeated NestedEnum repeated_nested_enum = 51; - repeated ForeignEnum repeated_foreign_enum = 52; - - repeated string repeated_string_piece = 54 [ctype=STRING_PIECE]; - repeated string repeated_cord = 55 [ctype=CORD]; - - // Map - map < int32, int32> map_int32_int32 = 56; - map < int64, int64> map_int64_int64 = 57; - map < uint32, uint32> map_uint32_uint32 = 58; - map < uint64, uint64> map_uint64_uint64 = 59; - map < sint32, sint32> map_sint32_sint32 = 60; - map < sint64, sint64> map_sint64_sint64 = 61; - map < fixed32, fixed32> map_fixed32_fixed32 = 62; - map < fixed64, fixed64> map_fixed64_fixed64 = 63; - map map_sfixed32_sfixed32 = 64; - map map_sfixed64_sfixed64 = 65; - map < int32, float> map_int32_float = 66; - map < int32, double> map_int32_double = 67; - map < bool, bool> map_bool_bool = 68; - map < string, string> map_string_string = 69; - map < string, bytes> map_string_bytes = 70; - map < string, NestedMessage> map_string_nested_message = 71; - map < string, ForeignMessage> map_string_foreign_message = 72; - map < string, NestedEnum> map_string_nested_enum = 73; - map < string, ForeignEnum> map_string_foreign_enum = 74; - - oneof oneof_field { - uint32 oneof_uint32 = 111; - NestedMessage oneof_nested_message = 112; - string oneof_string = 113; - bytes oneof_bytes = 114; + // If the input was successfully parsed and the requested output was + // TEXT_FORMAT, serialize to TEXT_FORMAT and set it in this field. + string text_payload = 8; } - - // Well-known types - google.protobuf.BoolValue optional_bool_wrapper = 201; - google.protobuf.Int32Value optional_int32_wrapper = 202; - google.protobuf.Int64Value optional_int64_wrapper = 203; - google.protobuf.UInt32Value optional_uint32_wrapper = 204; - google.protobuf.UInt64Value optional_uint64_wrapper = 205; - google.protobuf.FloatValue optional_float_wrapper = 206; - google.protobuf.DoubleValue optional_double_wrapper = 207; - google.protobuf.StringValue optional_string_wrapper = 208; - google.protobuf.BytesValue optional_bytes_wrapper = 209; - - repeated google.protobuf.BoolValue repeated_bool_wrapper = 211; - repeated google.protobuf.Int32Value repeated_int32_wrapper = 212; - repeated google.protobuf.Int64Value repeated_int64_wrapper = 213; - repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 214; - repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 215; - repeated google.protobuf.FloatValue repeated_float_wrapper = 216; - repeated google.protobuf.DoubleValue repeated_double_wrapper = 217; - repeated google.protobuf.StringValue repeated_string_wrapper = 218; - repeated google.protobuf.BytesValue repeated_bytes_wrapper = 219; - - google.protobuf.Duration optional_duration = 301; - google.protobuf.Timestamp optional_timestamp = 302; - google.protobuf.FieldMask optional_field_mask = 303; - google.protobuf.Struct optional_struct = 304; - google.protobuf.Any optional_any = 305; - google.protobuf.Value optional_value = 306; - - repeated google.protobuf.Duration repeated_duration = 311; - repeated google.protobuf.Timestamp repeated_timestamp = 312; - repeated google.protobuf.FieldMask repeated_fieldmask = 313; - repeated google.protobuf.Struct repeated_struct = 324; - repeated google.protobuf.Any repeated_any = 315; - repeated google.protobuf.Value repeated_value = 316; - - // Test field-name-to-JSON-name convention. - int32 fieldname1 = 401; - int32 field_name2 = 402; - int32 _field_name3 = 403; - int32 field__name4_ = 404; - int32 field0name5 = 405; - int32 field_0_name6 = 406; - int32 fieldName7 = 407; - int32 FieldName8 = 408; - int32 field_Name9 = 409; - int32 Field_Name10 = 410; - int32 FIELD_NAME11 = 411; - int32 FIELD_name12 = 412; } -message ForeignMessage { - int32 c = 1; +// Encoding options for jspb format. +message JspbEncodingConfig { + // Encode the value field of Any as jspb array if ture, otherwise binary. + bool use_jspb_array_any_format = 1; } -enum ForeignEnum { - FOREIGN_FOO = 0; - FOREIGN_BAR = 1; - FOREIGN_BAZ = 2; -} diff --git a/third_party/protobuf/conformance/conformance_cpp.cc b/third_party/protobuf/conformance/conformance_cpp.cc index 1a2654932587..5a1f21404dec 100644 --- a/third_party/protobuf/conformance/conformance_cpp.cc +++ b/third_party/protobuf/conformance/conformance_cpp.cc @@ -33,24 +33,61 @@ #include #include "conformance.pb.h" +#include +#include +#include +#include #include #include using conformance::ConformanceRequest; using conformance::ConformanceResponse; -using conformance::TestAllTypes; using google::protobuf::Descriptor; using google::protobuf::DescriptorPool; -using google::protobuf::internal::scoped_ptr; +using google::protobuf::Message; +using google::protobuf::MessageFactory; +using google::protobuf::TextFormat; using google::protobuf::util::BinaryToJsonString; +using google::protobuf::util::JsonParseOptions; using google::protobuf::util::JsonToBinaryString; using google::protobuf::util::NewTypeResolverForDescriptorPool; using google::protobuf::util::Status; using google::protobuf::util::TypeResolver; +using protobuf_test_messages::proto2::TestAllTypesProto2; +using protobuf_test_messages::proto3::TestAllTypesProto3; using std::string; static const char kTypeUrlPrefix[] = "type.googleapis.com"; +const char* kFailures[] = { +#if !GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER + "Required.Proto2.ProtobufInput." + "PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE", + "Required.Proto2.ProtobufInput." + "PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.BOOL", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.ENUM", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT32", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT64", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT32", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT64", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT32", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT64", + "Required.Proto3.ProtobufInput." + "PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE", + "Required.Proto3.ProtobufInput." + "PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.BOOL", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.ENUM", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT32", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT64", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT32", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT64", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT32", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT64", +#endif +}; + static string GetTypeUrl(const Descriptor* message) { return string(kTypeUrlPrefix) + "/" + message->full_name(); } @@ -86,29 +123,41 @@ void CheckedWrite(int fd, const void *buf, size_t len) { } void DoTest(const ConformanceRequest& request, ConformanceResponse* response) { - TestAllTypes test_message; + Message *test_message; + const Descriptor *descriptor = DescriptorPool::generated_pool()->FindMessageTypeByName( + request.message_type()); + if (!descriptor) { + GOOGLE_LOG(FATAL) << "No such message type: " << request.message_type(); + } + test_message = MessageFactory::generated_factory()->GetPrototype(descriptor)->New(); switch (request.payload_case()) { - case ConformanceRequest::kProtobufPayload: - if (!test_message.ParseFromString(request.protobuf_payload())) { + case ConformanceRequest::kProtobufPayload: { + if (!test_message->ParseFromString(request.protobuf_payload())) { // Getting parse details would involve something like: // http://stackoverflow.com/questions/22121922/how-can-i-get-more-details-about-errors-generated-during-protobuf-parsing-c response->set_parse_error("Parse error (no more details available)."); return; } break; + } case ConformanceRequest::kJsonPayload: { string proto_binary; + JsonParseOptions options; + options.ignore_unknown_fields = + (request.test_category() == + conformance::JSON_IGNORE_UNKNOWN_PARSING_TEST); Status status = JsonToBinaryString(type_resolver, *type_url, - request.json_payload(), &proto_binary); + request.json_payload(), &proto_binary, + options); if (!status.ok()) { response->set_parse_error(string("Parse error: ") + status.error_message().as_string()); return; } - if (!test_message.ParseFromString(proto_binary)) { + if (!test_message->ParseFromString(proto_binary)) { response->set_runtime_error( "Parsing JSON generates invalid proto output."); return; @@ -116,9 +165,28 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) { break; } + case ConformanceRequest::kTextPayload: { + if (!TextFormat::ParseFromString(request.text_payload(), test_message)) { + response->set_parse_error("Parse error"); + return; + } + break; + } + case ConformanceRequest::PAYLOAD_NOT_SET: GOOGLE_LOG(FATAL) << "Request didn't have payload."; break; + + default: + GOOGLE_LOG(FATAL) << "unknown payload type: " + << request.payload_case(); + break; + } + + conformance::FailureSet failures; + if (descriptor == failures.GetDescriptor()) { + for (const char* s : kFailures) failures.add_failure(s); + test_message = &failures; } switch (request.requested_output_format()) { @@ -126,14 +194,14 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) { GOOGLE_LOG(FATAL) << "Unspecified output format"; break; - case conformance::PROTOBUF: - GOOGLE_CHECK( - test_message.SerializeToString(response->mutable_protobuf_payload())); + case conformance::PROTOBUF: { + GOOGLE_CHECK(test_message->SerializeToString(response->mutable_protobuf_payload())); break; + } case conformance::JSON: { string proto_binary; - GOOGLE_CHECK(test_message.SerializeToString(&proto_binary)); + GOOGLE_CHECK(test_message->SerializeToString(&proto_binary)); Status status = BinaryToJsonString(type_resolver, *type_url, proto_binary, response->mutable_json_payload()); if (!status.ok()) { @@ -145,6 +213,14 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) { break; } + case conformance::TEXT_FORMAT: { + TextFormat::Printer printer; + printer.SetHideUnknownFields(!request.print_unknown_fields()); + GOOGLE_CHECK(printer.PrintToString(*test_message, + response->mutable_text_payload())); + break; + } + default: GOOGLE_LOG(FATAL) << "Unknown output format: " << request.requested_output_format(); @@ -196,7 +272,7 @@ bool DoTestIo() { int main() { type_resolver = NewTypeResolverForDescriptorPool( kTypeUrlPrefix, DescriptorPool::generated_pool()); - type_url = new string(GetTypeUrl(TestAllTypes::descriptor())); + type_url = new string(GetTypeUrl(TestAllTypesProto3::descriptor())); while (1) { if (!DoTestIo()) { fprintf(stderr, "conformance-cpp: received EOF from test runner " diff --git a/third_party/protobuf/conformance/conformance_nodejs.js b/third_party/protobuf/conformance/conformance_nodejs.js new file mode 100755 index 000000000000..4d96a3851e0c --- /dev/null +++ b/third_party/protobuf/conformance/conformance_nodejs.js @@ -0,0 +1,186 @@ +#!/usr/bin/env node + +/* + * 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. + */ + +var conformance = require('conformance_pb'); +var test_messages_proto3 = require('google/protobuf/test_messages_proto3_pb'); +var test_messages_proto2 = require('google/protobuf/test_messages_proto2_pb'); +var fs = require('fs'); + +var testCount = 0; + +function doTest(request) { + var testMessage; + var response = new conformance.ConformanceResponse(); + + try { + if (request.getRequestedOutputFormat() === conformance.WireFormat.JSON) { + response.setSkipped("JSON not supported."); + return response; + } + + switch (request.getPayloadCase()) { + case conformance.ConformanceRequest.PayloadCase.PROTOBUF_PAYLOAD: { + if (request.getMessageType() == "protobuf_test_messages.proto3.TestAllTypesProto3") { + try { + testMessage = test_messages_proto3.TestAllTypesProto3.deserializeBinary( + request.getProtobufPayload()); + } catch (err) { + response.setParseError(err.toString()); + return response; + } + } else if (request.getMessageType() == "protobuf_test_messages.proto2.TestAllTypesProto2"){ + try { + testMessage = test_messages_proto2.TestAllTypesProto2.deserializeBinary( + request.getProtobufPayload()); + } catch (err) { + response.setParseError(err.toString()); + return response; + } + } else { + throw "Protobuf request doesn\'t have specific payload type"; + } + } + + case conformance.ConformanceRequest.PayloadCase.JSON_PAYLOAD: + response.setSkipped("JSON not supported."); + return response; + + case conformance.ConformanceRequest.PayloadCase.TEXT_PAYLOAD: + response.setSkipped("Text format not supported."); + return response; + + case conformance.ConformanceRequest.PayloadCase.PAYLOAD_NOT_SET: + response.setRuntimeError("Request didn't have payload"); + return response; + } + + switch (request.getRequestedOutputFormat()) { + case conformance.WireFormat.UNSPECIFIED: + response.setRuntimeError("Unspecified output format"); + return response; + + case conformance.WireFormat.PROTOBUF: + response.setProtobufPayload(testMessage.serializeBinary()); + + case conformance.WireFormat.JSON: + response.setSkipped("JSON not supported."); + return response; + + default: + throw "Request didn't have requested output format"; + } + } catch (err) { + response.setRuntimeError(err.toString()); + } + + return response; +} + +function onEof(totalRead) { + if (totalRead == 0) { + return undefined; + } else { + throw "conformance_nodejs: premature EOF on stdin."; + } +} + +// Utility function to read a buffer of N bytes. +function readBuffer(bytes) { + var buf = new Buffer(bytes); + var totalRead = 0; + while (totalRead < bytes) { + var read = 0; + try { + read = fs.readSync(process.stdin.fd, buf, totalRead, bytes - totalRead); + } catch (e) { + if (e.code == 'EOF') { + return onEof(totalRead) + } else if (e.code == 'EAGAIN') { + } else { + throw "conformance_nodejs: Error reading from stdin." + e; + } + } + + totalRead += read; + } + + return buf; +} + +function writeBuffer(buffer) { + var totalWritten = 0; + while (totalWritten < buffer.length) { + totalWritten += fs.writeSync( + process.stdout.fd, buffer, totalWritten, buffer.length - totalWritten); + } +} + +// Returns true if the test ran successfully, false on legitimate EOF. +// If EOF is encountered in an unexpected place, raises IOError. +function doTestIo() { + var lengthBuf = readBuffer(4); + if (!lengthBuf) { + return false; + } + + var length = lengthBuf.readInt32LE(0); + var serializedRequest = readBuffer(length); + if (!serializedRequest) { + throw "conformance_nodejs: Failed to read request."; + } + + serializedRequest = new Uint8Array(serializedRequest); + var request = + conformance.ConformanceRequest.deserializeBinary(serializedRequest); + var response = doTest(request); + + var serializedResponse = response.serializeBinary(); + + lengthBuf = new Buffer(4); + lengthBuf.writeInt32LE(serializedResponse.length, 0); + writeBuffer(lengthBuf); + writeBuffer(new Buffer(serializedResponse)); + + testCount += 1 + + return true; +} + +while (true) { + if (!doTestIo()) { + console.error('conformance_nodejs: received EOF from test runner ' + + "after " + testCount + " tests, exiting") + break; + } +} diff --git a/third_party/protobuf/conformance/conformance_objc.m b/third_party/protobuf/conformance/conformance_objc.m index 1124bfeba1e3..60b2ac59ed19 100644 --- a/third_party/protobuf/conformance/conformance_objc.m +++ b/third_party/protobuf/conformance/conformance_objc.m @@ -31,6 +31,8 @@ #import #import "Conformance.pbobjc.h" +#import "google/protobuf/TestMessagesProto2.pbobjc.h" +#import "google/protobuf/TestMessagesProto3.pbobjc.h" static void Die(NSString *format, ...) __dead2; @@ -62,7 +64,7 @@ static void Die(NSString *format, ...) { static ConformanceResponse *DoTest(ConformanceRequest *request) { ConformanceResponse *response = [ConformanceResponse message]; - TestAllTypes *testMessage = nil; + GPBMessage *testMessage = nil; switch (request.payloadOneOfCase) { case ConformanceRequest_Payload_OneOfCase_GPBUnsetOneOfCase: @@ -70,9 +72,16 @@ static void Die(NSString *format, ...) { break; case ConformanceRequest_Payload_OneOfCase_ProtobufPayload: { + Class msgClass = nil; + if ([request.messageType isEqual:@"protobuf_test_messages.proto3.TestAllTypesProto3"]) { + msgClass = [Proto3TestAllTypesProto3 class]; + } else if ([request.messageType isEqual:@"protobuf_test_messages.proto2.TestAllTypesProto2"]) { + msgClass = [TestAllTypesProto2 class]; + } else { + Die(@"Protobuf request had an unknown message_type: %@", request.messageType); + } NSError *error = nil; - testMessage = [TestAllTypes parseFromData:request.protobufPayload - error:&error]; + testMessage = [msgClass parseFromData:request.protobufPayload error:&error]; if (!testMessage) { response.parseError = [NSString stringWithFormat:@"Parse error: %@", error]; @@ -83,6 +92,16 @@ static void Die(NSString *format, ...) { case ConformanceRequest_Payload_OneOfCase_JsonPayload: response.skipped = @"ObjC doesn't support parsing JSON"; break; + + case ConformanceRequest_Payload_OneOfCase_JspbPayload: + response.skipped = + @"ConformanceRequest had a jspb_payload ConformanceRequest.payload;" + " those aren't supposed to happen with opensource."; + break; + + case ConformanceRequest_Payload_OneOfCase_TextPayload: + response.skipped = @"ObjC doesn't support parsing TextFormat"; + break; } if (testMessage) { @@ -103,6 +122,18 @@ static void Die(NSString *format, ...) { case WireFormat_Json: response.skipped = @"ObjC doesn't support generating JSON"; break; + + case WireFormat_Jspb: + response.skipped = + @"ConformanceRequest had a requested_output_format of JSPB WireFormat; that" + " isn't supposed to happen with opensource."; + break; + + case WireFormat_TextFormat: + // ObjC only has partial objc generation, so don't attempt any tests that need + // support. + response.skipped = @"ObjC doesn't support generating TextFormat"; + break; } } diff --git a/third_party/protobuf/conformance/conformance_php.php b/third_party/protobuf/conformance/conformance_php.php new file mode 100755 index 000000000000..9eef0c5a4abc --- /dev/null +++ b/third_party/protobuf/conformance/conformance_php.php @@ -0,0 +1,120 @@ +getPayload() == "protobuf_payload") { + if ($request->getMessageType() == "conformance.FailureSet") { + $response->setProtobufPayload(""); + return $response; + } elseif ($request->getMessageType() == "protobuf_test_messages.proto3.TestAllTypesProto3") { + try { + $test_message->mergeFromString($request->getProtobufPayload()); + } catch (Exception $e) { + $response->setParseError($e->getMessage()); + return $response; + } + } elseif ($request->getMessageType() == "protobuf_test_messages.proto2.TestAllTypesProto2") { + $response->setSkipped("PHP doesn't support proto2"); + return $response; + } else { + trigger_error("Protobuf request doesn't have specific payload type", E_USER_ERROR); + } + } elseif ($request->getPayload() == "json_payload") { + $ignore_json_unknown = + ($request->getTestCategory() == + TestCategory::JSON_IGNORE_UNKNOWN_PARSING_TEST); + try { + $test_message->mergeFromJsonString($request->getJsonPayload(), + $ignore_json_unknown); + } catch (Exception $e) { + $response->setParseError($e->getMessage()); + return $response; + } + } elseif ($request->getPayload() == "text_payload") { + $response->setSkipped("PHP doesn't support text format yet"); + return $response; + } else { + trigger_error("Request didn't have payload.", E_USER_ERROR); + } + + if ($request->getRequestedOutputFormat() == WireFormat::UNSPECIFIED) { + trigger_error("Unspecified output format.", E_USER_ERROR); + } elseif ($request->getRequestedOutputFormat() == WireFormat::PROTOBUF) { + $response->setProtobufPayload($test_message->serializeToString()); + } elseif ($request->getRequestedOutputFormat() == WireFormat::JSON) { + try { + $response->setJsonPayload($test_message->serializeToJsonString()); + } catch (Exception $e) { + $response->setSerializeError($e->getMessage()); + return $response; + } + } + + return $response; +} + +function doTestIO() +{ + $length_bytes = fread(STDIN, 4); + if (strlen($length_bytes) == 0) { + return false; # EOF + } elseif (strlen($length_bytes) != 4) { + fwrite(STDERR, "I/O error\n"); + return false; + } + + $length = unpack("V", $length_bytes)[1]; + $serialized_request = fread(STDIN, $length); + if (strlen($serialized_request) != $length) { + trigger_error("I/O error", E_USER_ERROR); + } + + $request = new \Conformance\ConformanceRequest(); + $request->mergeFromString($serialized_request); + + $response = doTest($request); + + $serialized_response = $response->serializeToString(); + fwrite(STDOUT, pack("V", strlen($serialized_response))); + fwrite(STDOUT, $serialized_response); + + $GLOBALS['test_count'] += 1; + + return true; +} + +while(true){ + if (!doTestIO()) { + fprintf(STDERR, + "conformance_php: received EOF from test runner " + + "after %d tests, exiting\n", $test_count); + exit; + } +} diff --git a/third_party/protobuf/conformance/conformance_python.py b/third_party/protobuf/conformance/conformance_python.py index a490c8e8e54b..88d9749389e8 100755 --- a/third_party/protobuf/conformance/conformance_python.py +++ b/third_party/protobuf/conformance/conformance_python.py @@ -38,8 +38,13 @@ import struct import sys import os -from google.protobuf import message +from google.protobuf import descriptor +from google.protobuf import descriptor_pool from google.protobuf import json_format +from google.protobuf import message +from google.protobuf import test_messages_proto3_pb2 +from google.protobuf import test_messages_proto2_pb2 +from google.protobuf import text_format import conformance_pb2 sys.stdout = os.fdopen(sys.stdout.fileno(), 'wb', 0) @@ -52,9 +57,71 @@ class ProtocolError(Exception): pass def do_test(request): - test_message = conformance_pb2.TestAllTypes() response = conformance_pb2.ConformanceResponse() - test_message = conformance_pb2.TestAllTypes() + + if request.message_type == "conformance.FailureSet": + failure_set = conformance_pb2.FailureSet() + failures = [] + # TODO(gerbens): Remove, this is a hack to detect if the old vs new + # parser is used by the cpp code. Relying on a bug in the old parser. + hack_proto = test_messages_proto2_pb2.TestAllTypesProto2() + old_parser = True + try: + hack_proto.ParseFromString(b"\322\002\001") + except message.DecodeError as e: + old_parser = False + if old_parser: + # the string above is one of the failing conformance test strings of the + # old parser. If we succeed the c++ implementation is using the old + # parser so we add the list of failing conformance tests. + failures = [ + "Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE", + "Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.BOOL", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.DOUBLE", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.ENUM", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.FIXED32", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.FIXED64", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.FLOAT", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT32", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT64", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.SFIXED32", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.SFIXED64", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT32", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT64", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT32", + "Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT64", + "Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE", + "Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.BOOL", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.DOUBLE", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.ENUM", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.FIXED32", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.FIXED64", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.FLOAT", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT32", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT64", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.SFIXED32", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.SFIXED64", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT32", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT64", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT32", + "Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT64", + ] + for x in failures: + failure_set.failure.append(x) + response.protobuf_payload = failure_set.SerializeToString() + return response + + isProto3 = (request.message_type == "protobuf_test_messages.proto3.TestAllTypesProto3") + isJson = (request.WhichOneof('payload') == 'json_payload') + isProto2 = (request.message_type == "protobuf_test_messages.proto2.TestAllTypesProto2") + + if (not isProto3) and (not isJson) and (not isProto2): + raise ProtocolError("Protobuf request doesn't have specific payload type") + + test_message = test_messages_proto2_pb2.TestAllTypesProto2() if isProto2 else \ + test_messages_proto3_pb2.TestAllTypesProto3() try: if request.WhichOneof('payload') == 'protobuf_payload': @@ -66,8 +133,19 @@ def do_test(request): elif request.WhichOneof('payload') == 'json_payload': try: - json_format.Parse(request.json_payload, test_message) - except json_format.ParseError as e: + ignore_unknown_fields = \ + request.test_category == \ + conformance_pb2.JSON_IGNORE_UNKNOWN_PARSING_TEST + json_format.Parse(request.json_payload, test_message, + ignore_unknown_fields) + except Exception as e: + response.parse_error = str(e) + return response + + elif request.WhichOneof('payload') == 'text_payload': + try: + text_format.Parse(request.text_payload, test_message) + except Exception as e: response.parse_error = str(e) return response @@ -81,7 +159,15 @@ def do_test(request): response.protobuf_payload = test_message.SerializeToString() elif request.requested_output_format == conformance_pb2.JSON: - response.json_payload = json_format.MessageToJson(test_message) + try: + response.json_payload = json_format.MessageToJson(test_message) + except Exception as e: + response.serialize_error = str(e) + return response + + elif request.requested_output_format == conformance_pb2.TEXT_FORMAT: + response.text_payload = text_format.MessageToString( + test_message, print_unknown_fields=request.print_unknown_fields) except Exception as e: response.runtime_error = str(e) diff --git a/third_party/protobuf/conformance/conformance_ruby.rb b/third_party/protobuf/conformance/conformance_ruby.rb index c716facdd6f3..79d8d3dd9e94 100755 --- a/third_party/protobuf/conformance/conformance_ruby.rb +++ b/third_party/protobuf/conformance/conformance_ruby.rb @@ -30,33 +30,48 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -require 'conformance' +require 'conformance_pb' +require 'google/protobuf/test_messages_proto3_pb' $test_count = 0 $verbose = false def do_test(request) - test_message = Conformance::TestAllTypes.new + test_message = ProtobufTestMessages::Proto3::TestAllTypesProto3.new response = Conformance::ConformanceResponse.new begin case request.payload when :protobuf_payload - begin - test_message = - Conformance::TestAllTypes.decode(request.protobuf_payload) - rescue Google::Protobuf::ParseError => err - response.parse_error = err.message.encode('utf-8') + if request.message_type.eql?('protobuf_test_messages.proto3.TestAllTypesProto3') + begin + test_message = ProtobufTestMessages::Proto3::TestAllTypesProto3.decode( + request.protobuf_payload) + rescue Google::Protobuf::ParseError => err + response.parse_error = err.message.encode('utf-8') + return response + end + elsif request.message_type.eql?('protobuf_test_messages.proto2.TestAllTypesProto2') + response.skipped = "Ruby doesn't support proto2" return response + else + fail "Protobuf request doesn't have specific payload type" end when :json_payload begin - test_message = Conformance::TestAllTypes.decode_json(request.json_payload) + test_message = ProtobufTestMessages::Proto3::TestAllTypesProto3.decode_json( + request.json_payload) rescue Google::Protobuf::ParseError => err response.parse_error = err.message.encode('utf-8') return response end + + when :text_payload + begin + response.skipped = "Ruby doesn't support proto2" + return response + end when nil fail "Request didn't have payload" diff --git a/third_party/protobuf/conformance/conformance_test.cc b/third_party/protobuf/conformance/conformance_test.cc index fc0605bfc4a2..6325b354a3de 100644 --- a/third_party/protobuf/conformance/conformance_test.cc +++ b/third_party/protobuf/conformance/conformance_test.cc @@ -28,148 +28,138 @@ // (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 "conformance.pb.h" #include "conformance_test.h" -#include + #include +#include +#include #include -#include #include +#include #include -#include -#include - -#include "third_party/jsoncpp/json.h" using conformance::ConformanceRequest; using conformance::ConformanceResponse; -using conformance::TestAllTypes; using conformance::WireFormat; -using google::protobuf::Descriptor; -using google::protobuf::FieldDescriptor; -using google::protobuf::internal::WireFormatLite; using google::protobuf::TextFormat; using google::protobuf::util::DefaultFieldComparator; using google::protobuf::util::JsonToBinaryString; using google::protobuf::util::MessageDifferencer; -using google::protobuf::util::NewTypeResolverForDescriptorPool; using google::protobuf::util::Status; using std::string; -namespace { - -static const char kTypeUrlPrefix[] = "type.googleapis.com"; +namespace google { +namespace protobuf { -static string GetTypeUrl(const Descriptor* message) { - return string(kTypeUrlPrefix) + "/" + message->full_name(); -} +ConformanceTestSuite::ConformanceRequestSetting::ConformanceRequestSetting( + ConformanceLevel level, + conformance::WireFormat input_format, + conformance::WireFormat output_format, + conformance::TestCategory test_category, + const Message& prototype_message, + const string& test_name, const string& input) + : level_(level), + input_format_(input_format), + output_format_(output_format), + prototype_message_(prototype_message), + prototype_message_for_compare_(prototype_message.New()), + test_name_(test_name) { + switch (input_format) { + case conformance::PROTOBUF: { + request_.set_protobuf_payload(input); + break; + } -/* Routines for building arbitrary protos *************************************/ + case conformance::JSON: { + request_.set_json_payload(input); + break; + } -// We would use CodedOutputStream except that we want more freedom to build -// arbitrary protos (even invalid ones). + case conformance::JSPB: { + request_.set_jspb_payload(input); + break; + } -const string empty; + case conformance::TEXT_FORMAT: { + request_.set_text_payload(input); + break; + } -string cat(const string& a, const string& b, - const string& c = empty, - const string& d = empty, - const string& e = empty, - const string& f = empty, - const string& g = empty, - const string& h = empty, - const string& i = empty, - const string& j = empty, - const string& k = empty, - const string& l = empty) { - string ret; - ret.reserve(a.size() + b.size() + c.size() + d.size() + e.size() + f.size() + - g.size() + h.size() + i.size() + j.size() + k.size() + l.size()); - ret.append(a); - ret.append(b); - ret.append(c); - ret.append(d); - ret.append(e); - ret.append(f); - ret.append(g); - ret.append(h); - ret.append(i); - ret.append(j); - ret.append(k); - ret.append(l); - return ret; -} + default: + GOOGLE_LOG(FATAL) << "Unspecified input format"; + } -// The maximum number of bytes that it takes to encode a 64-bit varint. -#define VARINT_MAX_LEN 10 + request_.set_test_category(test_category); -size_t vencode64(uint64_t val, char *buf) { - if (val == 0) { buf[0] = 0; return 1; } - size_t i = 0; - while (val) { - uint8_t byte = val & 0x7fU; - val >>= 7; - if (val) byte |= 0x80U; - buf[i++] = byte; - } - return i; + request_.set_message_type(prototype_message.GetDescriptor()->full_name()); + request_.set_requested_output_format(output_format); } -string varint(uint64_t x) { - char buf[VARINT_MAX_LEN]; - size_t len = vencode64(x, buf); - return string(buf, len); +Message* ConformanceTestSuite::ConformanceRequestSetting:: + GetTestMessage() const { + return prototype_message_for_compare_->New(); } -// TODO: proper byte-swapping for big-endian machines. -string fixed32(void *data) { return string(static_cast(data), 4); } -string fixed64(void *data) { return string(static_cast(data), 8); } - -string delim(const string& buf) { return cat(varint(buf.size()), buf); } -string uint32(uint32_t u32) { return fixed32(&u32); } -string uint64(uint64_t u64) { return fixed64(&u64); } -string flt(float f) { return fixed32(&f); } -string dbl(double d) { return fixed64(&d); } -string zz32(int32_t x) { return varint(WireFormatLite::ZigZagEncode32(x)); } -string zz64(int64_t x) { return varint(WireFormatLite::ZigZagEncode64(x)); } - -string tag(uint32_t fieldnum, char wire_type) { - return varint((fieldnum << 3) | wire_type); +string ConformanceTestSuite::ConformanceRequestSetting:: + GetTestName() const { + string rname = + prototype_message_.GetDescriptor()->file()->syntax() == + FileDescriptor::SYNTAX_PROTO3 ? "Proto3" : "Proto2"; + + return StrCat(ConformanceLevelToString(level_), ".", + rname, ".", + InputFormatString(input_format_), + ".", test_name_, ".", + OutputFormatString(output_format_)); } -string submsg(uint32_t fn, const string& buf) { - return cat( tag(fn, WireFormatLite::WIRETYPE_LENGTH_DELIMITED), delim(buf) ); +string ConformanceTestSuite::ConformanceRequestSetting:: + ConformanceLevelToString( + ConformanceLevel level) const { + switch (level) { + case REQUIRED: return "Required"; + case RECOMMENDED: return "Recommended"; + } + GOOGLE_LOG(FATAL) << "Unknown value: " << level; + return ""; } -#define UNKNOWN_FIELD 666 - -uint32_t GetFieldNumberForType(FieldDescriptor::Type type, bool repeated) { - const Descriptor* d = TestAllTypes().GetDescriptor(); - for (int i = 0; i < d->field_count(); i++) { - const FieldDescriptor* f = d->field(i); - if (f->type() == type && f->is_repeated() == repeated) { - return f->number(); - } +string ConformanceTestSuite::ConformanceRequestSetting:: + InputFormatString(conformance::WireFormat format) const { + switch (format) { + case conformance::PROTOBUF: + return "ProtobufInput"; + case conformance::JSON: + return "JsonInput"; + case conformance::TEXT_FORMAT: + return "TextFormatInput"; + default: + GOOGLE_LOG(FATAL) << "Unspecified output format"; } - GOOGLE_LOG(FATAL) << "Couldn't find field with type " << (int)type; - return 0; + return ""; } -string UpperCase(string str) { - for (int i = 0; i < str.size(); i++) { - str[i] = toupper(str[i]); +string ConformanceTestSuite::ConformanceRequestSetting:: + OutputFormatString(conformance::WireFormat format) const { + switch (format) { + case conformance::PROTOBUF: + return "ProtobufOutput"; + case conformance::JSON: + return "JsonOutput"; + case conformance::TEXT_FORMAT: + return "TextFormatOutput"; + default: + GOOGLE_LOG(FATAL) << "Unspecified output format"; } - return str; + return ""; } -} // anonymous namespace - -namespace google { -namespace protobuf { - void ConformanceTestSuite::ReportSuccess(const string& test_name) { if (expected_to_fail_.erase(test_name) != 0) { StringAppendF(&output_, @@ -182,6 +172,7 @@ void ConformanceTestSuite::ReportSuccess(const string& test_name) { } void ConformanceTestSuite::ReportFailure(const string& test_name, + ConformanceLevel level, const ConformanceRequest& request, const ConformanceResponse& response, const char* fmt, ...) { @@ -189,6 +180,8 @@ void ConformanceTestSuite::ReportFailure(const string& test_name, expected_failures_++; if (!verbose_) return; + } else if (level == RECOMMENDED && !enforce_recommended_) { + StringAppendF(&output_, "WARNING, test=%s: ", test_name.c_str()); } else { StringAppendF(&output_, "ERROR, test=%s: ", test_name.c_str()); unexpected_failing_tests_.insert(test_name); @@ -213,122 +206,61 @@ void ConformanceTestSuite::ReportSkip(const string& test_name, skipped_.insert(test_name); } -void ConformanceTestSuite::RunTest(const string& test_name, - const ConformanceRequest& request, - ConformanceResponse* response) { - if (test_names_.insert(test_name).second == false) { - GOOGLE_LOG(FATAL) << "Duplicated test name: " << test_name; - } - - string serialized_request; - string serialized_response; - request.SerializeToString(&serialized_request); - - runner_->RunTest(test_name, serialized_request, &serialized_response); - - if (!response->ParseFromString(serialized_response)) { - response->Clear(); - response->set_runtime_error("response proto could not be parsed."); - } - - if (verbose_) { - StringAppendF(&output_, "conformance test: name=%s, request=%s, response=%s\n", - test_name.c_str(), - request.ShortDebugString().c_str(), - response->ShortDebugString().c_str()); - } -} - void ConformanceTestSuite::RunValidInputTest( - const string& test_name, const string& input, WireFormat input_format, - const string& equivalent_text_format, WireFormat requested_output) { - TestAllTypes reference_message; + const ConformanceRequestSetting& setting, + const string& equivalent_text_format) { + Message* reference_message = setting.GetTestMessage(); GOOGLE_CHECK( - TextFormat::ParseFromString(equivalent_text_format, &reference_message)) - << "Failed to parse data for test case: " << test_name + TextFormat::ParseFromString(equivalent_text_format, reference_message)) + << "Failed to parse data for test case: " << setting.GetTestName() << ", data: " << equivalent_text_format; + const string equivalent_wire_format = reference_message->SerializeAsString(); + RunValidBinaryInputTest(setting, equivalent_wire_format); +} - ConformanceRequest request; +void ConformanceTestSuite::RunValidBinaryInputTest( + const ConformanceRequestSetting& setting, + const string& equivalent_wire_format) { + const ConformanceRequest& request = setting.GetRequest(); ConformanceResponse response; + RunTest(setting.GetTestName(), request, &response); + VerifyResponse(setting, equivalent_wire_format, response, true); +} - switch (input_format) { - case conformance::PROTOBUF: - request.set_protobuf_payload(input); - break; - - case conformance::JSON: - request.set_json_payload(input); - break; - - default: - GOOGLE_LOG(FATAL) << "Unspecified input format"; - } - - request.set_requested_output_format(requested_output); - - RunTest(test_name, request, &response); +void ConformanceTestSuite::VerifyResponse( + const ConformanceRequestSetting& setting, + const string& equivalent_wire_format, + const ConformanceResponse& response, + bool need_report_success) { + Message* test_message = setting.GetTestMessage(); + const ConformanceRequest& request = setting.GetRequest(); + const string& test_name = setting.GetTestName(); + ConformanceLevel level = setting.GetLevel(); + Message* reference_message = setting.GetTestMessage(); - TestAllTypes test_message; + GOOGLE_CHECK( + reference_message->ParseFromString(equivalent_wire_format)) + << "Failed to parse wire data for test case: " << test_name; switch (response.result_case()) { + case ConformanceResponse::RESULT_NOT_SET: + ReportFailure(test_name, level, request, response, + "Response didn't have any field in the Response."); + return; + case ConformanceResponse::kParseError: case ConformanceResponse::kRuntimeError: case ConformanceResponse::kSerializeError: - ReportFailure(test_name, request, response, - "Failed to parse JSON input or produce JSON output."); + ReportFailure(test_name, level, request, response, + "Failed to parse input or produce output."); return; case ConformanceResponse::kSkipped: ReportSkip(test_name, request, response); return; - case ConformanceResponse::kJsonPayload: { - if (requested_output != conformance::JSON) { - ReportFailure( - test_name, request, response, - "Test was asked for protobuf output but provided JSON instead."); - return; - } - string binary_protobuf; - Status status = - JsonToBinaryString(type_resolver_.get(), type_url_, - response.json_payload(), &binary_protobuf); - if (!status.ok()) { - ReportFailure(test_name, request, response, - "JSON output we received from test was unparseable."); - return; - } - - if (!test_message.ParseFromString(binary_protobuf)) { - ReportFailure(test_name, request, response, - "INTERNAL ERROR: internal JSON->protobuf transcode " - "yielded unparseable proto."); - return; - } - - break; - } - - case ConformanceResponse::kProtobufPayload: { - if (requested_output != conformance::PROTOBUF) { - ReportFailure( - test_name, request, response, - "Test was asked for JSON output but provided protobuf instead."); - return; - } - - if (!test_message.ParseFromString(response.protobuf_payload())) { - ReportFailure(test_name, request, response, - "Protobuf output we received from test was unparseable."); - return; - } - - break; - } - default: - GOOGLE_LOG(FATAL) << test_name << ": unknown payload type: " - << response.result_case(); + if (!ParseResponse(response, setting, test_message)) return; } MessageDifferencer differencer; @@ -338,267 +270,105 @@ void ConformanceTestSuite::RunValidInputTest( string differences; differencer.ReportDifferencesToString(&differences); - if (differencer.Compare(reference_message, test_message)) { - ReportSuccess(test_name); + bool check; + check = differencer.Compare(*reference_message, *test_message); + if (check) { + if (need_report_success) { + ReportSuccess(test_name); + } } else { - ReportFailure(test_name, request, response, + ReportFailure(test_name, level, request, response, "Output was not equivalent to reference message: %s.", differences.c_str()); } } -// Expect that this precise protobuf will cause a parse error. -void ConformanceTestSuite::ExpectParseFailureForProto( - const string& proto, const string& test_name) { - ConformanceRequest request; - ConformanceResponse response; - request.set_protobuf_payload(proto); - string effective_test_name = "ProtobufInput." + test_name; - - // We don't expect output, but if the program erroneously accepts the protobuf - // we let it send its response as this. We must not leave it unspecified. - request.set_requested_output_format(conformance::PROTOBUF); - - RunTest(effective_test_name, request, &response); - if (response.result_case() == ConformanceResponse::kParseError) { - ReportSuccess(effective_test_name); - } else if (response.result_case() == ConformanceResponse::kSkipped) { - ReportSkip(effective_test_name, request, response); - } else { - ReportFailure(effective_test_name, request, response, - "Should have failed to parse, but didn't."); - } -} - -// Expect that this protobuf will cause a parse error, even if it is followed -// by valid protobuf data. We can try running this twice: once with this -// data verbatim and once with this data followed by some valid data. -// -// TODO(haberman): implement the second of these. -void ConformanceTestSuite::ExpectHardParseFailureForProto( - const string& proto, const string& test_name) { - return ExpectParseFailureForProto(proto, test_name); -} - -void ConformanceTestSuite::RunValidJsonTest( - const string& test_name, const string& input_json, - const string& equivalent_text_format) { - RunValidInputTest("JsonInput." + test_name + ".ProtobufOutput", input_json, - conformance::JSON, equivalent_text_format, - conformance::PROTOBUF); - RunValidInputTest("JsonInput." + test_name + ".JsonOutput", input_json, - conformance::JSON, equivalent_text_format, - conformance::JSON); -} - -void ConformanceTestSuite::RunValidJsonTestWithProtobufInput( - const string& test_name, const TestAllTypes& input, - const string& equivalent_text_format) { - RunValidInputTest("ProtobufInput." + test_name + ".JsonOutput", - input.SerializeAsString(), conformance::PROTOBUF, - equivalent_text_format, conformance::JSON); -} - -// According to proto3 JSON specification, JSON serializers follow more strict -// rules than parsers (e.g., a serializer must serialize int32 values as JSON -// numbers while the parser is allowed to accept them as JSON strings). This -// method allows strict checking on a proto3 JSON serializer by inspecting -// the JSON output directly. -void ConformanceTestSuite::RunValidJsonTestWithValidator( - const string& test_name, const string& input_json, - const Validator& validator) { - ConformanceRequest request; - ConformanceResponse response; - request.set_json_payload(input_json); - request.set_requested_output_format(conformance::JSON); - - string effective_test_name = "JsonInput." + test_name + ".Validator"; - - RunTest(effective_test_name, request, &response); - - if (response.result_case() == ConformanceResponse::kSkipped) { - ReportSkip(effective_test_name, request, response); - return; - } - - if (response.result_case() != ConformanceResponse::kJsonPayload) { - ReportFailure(effective_test_name, request, response, - "Expected JSON payload but got type %d.", - response.result_case()); - return; - } - Json::Reader reader; - Json::Value value; - if (!reader.parse(response.json_payload(), value)) { - ReportFailure(effective_test_name, request, response, - "JSON payload cannot be parsed as valid JSON: %s", - reader.getFormattedErrorMessages().c_str()); - return; - } - if (!validator(value)) { - ReportFailure(effective_test_name, request, response, - "JSON payload validation failed."); - return; - } - ReportSuccess(effective_test_name); -} - -void ConformanceTestSuite::ExpectParseFailureForJson( - const string& test_name, const string& input_json) { - ConformanceRequest request; - ConformanceResponse response; - request.set_json_payload(input_json); - string effective_test_name = "JsonInput." + test_name; - - // We don't expect output, but if the program erroneously accepts the protobuf - // we let it send its response as this. We must not leave it unspecified. - request.set_requested_output_format(conformance::JSON); - - RunTest(effective_test_name, request, &response); - if (response.result_case() == ConformanceResponse::kParseError) { - ReportSuccess(effective_test_name); - } else if (response.result_case() == ConformanceResponse::kSkipped) { - ReportSkip(effective_test_name, request, response); - } else { - ReportFailure(effective_test_name, request, response, - "Should have failed to parse, but didn't."); +void ConformanceTestSuite::RunTest(const string& test_name, + const ConformanceRequest& request, + ConformanceResponse* response) { + if (test_names_.insert(test_name).second == false) { + GOOGLE_LOG(FATAL) << "Duplicated test name: " << test_name; } -} -void ConformanceTestSuite::ExpectSerializeFailureForJson( - const string& test_name, const string& text_format) { - TestAllTypes payload_message; - GOOGLE_CHECK( - TextFormat::ParseFromString(text_format, &payload_message)) - << "Failed to parse: " << text_format; + string serialized_request; + string serialized_response; + request.SerializeToString(&serialized_request); - ConformanceRequest request; - ConformanceResponse response; - request.set_protobuf_payload(payload_message.SerializeAsString()); - string effective_test_name = test_name + ".JsonOutput"; - request.set_requested_output_format(conformance::JSON); + runner_->RunTest(test_name, serialized_request, &serialized_response); - RunTest(effective_test_name, request, &response); - if (response.result_case() == ConformanceResponse::kSerializeError) { - ReportSuccess(effective_test_name); - } else if (response.result_case() == ConformanceResponse::kSkipped) { - ReportSkip(effective_test_name, request, response); - } else { - ReportFailure(effective_test_name, request, response, - "Should have failed to serialize, but didn't."); + if (!response->ParseFromString(serialized_response)) { + response->Clear(); + response->set_runtime_error("response proto could not be parsed."); } -} - -void ConformanceTestSuite::TestPrematureEOFForType(FieldDescriptor::Type type) { - // Incomplete values for each wire type. - static const string incompletes[6] = { - string("\x80"), // VARINT - string("abcdefg"), // 64BIT - string("\x80"), // DELIMITED (partial length) - string(), // START_GROUP (no value required) - string(), // END_GROUP (no value required) - string("abc") // 32BIT - }; - - uint32_t fieldnum = GetFieldNumberForType(type, false); - uint32_t rep_fieldnum = GetFieldNumberForType(type, true); - WireFormatLite::WireType wire_type = WireFormatLite::WireTypeForFieldType( - static_cast(type)); - const string& incomplete = incompletes[wire_type]; - const string type_name = - UpperCase(string(".") + FieldDescriptor::TypeName(type)); - - ExpectParseFailureForProto( - tag(fieldnum, wire_type), - "PrematureEofBeforeKnownNonRepeatedValue" + type_name); - - ExpectParseFailureForProto( - tag(rep_fieldnum, wire_type), - "PrematureEofBeforeKnownRepeatedValue" + type_name); - - ExpectParseFailureForProto( - tag(UNKNOWN_FIELD, wire_type), - "PrematureEofBeforeUnknownValue" + type_name); - - ExpectParseFailureForProto( - cat( tag(fieldnum, wire_type), incomplete ), - "PrematureEofInsideKnownNonRepeatedValue" + type_name); - - ExpectParseFailureForProto( - cat( tag(rep_fieldnum, wire_type), incomplete ), - "PrematureEofInsideKnownRepeatedValue" + type_name); - - ExpectParseFailureForProto( - cat( tag(UNKNOWN_FIELD, wire_type), incomplete ), - "PrematureEofInsideUnknownValue" + type_name); - - if (wire_type == WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - ExpectParseFailureForProto( - cat( tag(fieldnum, wire_type), varint(1) ), - "PrematureEofInDelimitedDataForKnownNonRepeatedValue" + type_name); - - ExpectParseFailureForProto( - cat( tag(rep_fieldnum, wire_type), varint(1) ), - "PrematureEofInDelimitedDataForKnownRepeatedValue" + type_name); - // EOF in the middle of delimited data for unknown value. - ExpectParseFailureForProto( - cat( tag(UNKNOWN_FIELD, wire_type), varint(1) ), - "PrematureEofInDelimitedDataForUnknownValue" + type_name); - - if (type == FieldDescriptor::TYPE_MESSAGE) { - // Submessage ends in the middle of a value. - string incomplete_submsg = - cat( tag(WireFormatLite::TYPE_INT32, WireFormatLite::WIRETYPE_VARINT), - incompletes[WireFormatLite::WIRETYPE_VARINT] ); - ExpectHardParseFailureForProto( - cat( tag(fieldnum, WireFormatLite::WIRETYPE_LENGTH_DELIMITED), - varint(incomplete_submsg.size()), - incomplete_submsg ), - "PrematureEofInSubmessageValue" + type_name); - } - } else if (type != FieldDescriptor::TYPE_GROUP) { - // Non-delimited, non-group: eligible for packing. - - // Packed region ends in the middle of a value. - ExpectHardParseFailureForProto( - cat( tag(rep_fieldnum, WireFormatLite::WIRETYPE_LENGTH_DELIMITED), - varint(incomplete.size()), - incomplete ), - "PrematureEofInPackedFieldValue" + type_name); - - // EOF in the middle of packed region. - ExpectParseFailureForProto( - cat( tag(rep_fieldnum, WireFormatLite::WIRETYPE_LENGTH_DELIMITED), - varint(1) ), - "PrematureEofInPackedField" + type_name); + if (verbose_) { + StringAppendF(&output_, + "conformance test: name=%s, request=%s, response=%s\n", + test_name.c_str(), + request.ShortDebugString().c_str(), + response->ShortDebugString().c_str()); } } -void ConformanceTestSuite::SetFailureList(const vector& failure_list) { - expected_to_fail_.clear(); - std::copy(failure_list.begin(), failure_list.end(), - std::inserter(expected_to_fail_, expected_to_fail_.end())); -} - -bool ConformanceTestSuite::CheckSetEmpty(const set& set_to_check, - const char* msg) { +bool ConformanceTestSuite::CheckSetEmpty( + const std::set& set_to_check, + const std::string& write_to_file, + const std::string& msg) { if (set_to_check.empty()) { return true; } else { StringAppendF(&output_, "\n"); - StringAppendF(&output_, "%s:\n", msg); - for (set::const_iterator iter = set_to_check.begin(); + StringAppendF(&output_, "%s\n\n", msg.c_str()); + for (std::set::const_iterator iter = set_to_check.begin(); iter != set_to_check.end(); ++iter) { StringAppendF(&output_, " %s\n", iter->c_str()); } StringAppendF(&output_, "\n"); + + if (!write_to_file.empty()) { + std::ofstream os(write_to_file); + if (os) { + for (std::set::const_iterator iter = set_to_check.begin(); + iter != set_to_check.end(); ++iter) { + os << *iter << "\n"; + } + } else { + StringAppendF(&output_, "Failed to open file: %s\n", + write_to_file.c_str()); + } + } + return false; } } +string ConformanceTestSuite::WireFormatToString( + WireFormat wire_format) { + switch (wire_format) { + case conformance::PROTOBUF: + return "PROTOBUF"; + case conformance::JSON: + return "JSON"; + case conformance::JSPB: + return "JSPB"; + case conformance::TEXT_FORMAT: + return "TEXT_FORMAT"; + case conformance::UNSPECIFIED: + return "UNSPECIFIED"; + default: + GOOGLE_LOG(FATAL) << "unknown wire type: " + << wire_format; + } + return ""; +} + +void ConformanceTestSuite::AddExpectedFailedTest(const std::string& test_name) { + expected_to_fail_.insert(test_name); +} + bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, - std::string* output) { + std::string* output, const string& filename, + conformance::FailureSet* failure_list) { runner_ = runner; successes_ = 0; expected_failures_ = 0; @@ -606,1386 +376,45 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, test_names_.clear(); unexpected_failing_tests_.clear(); unexpected_succeeding_tests_.clear(); - type_resolver_.reset(NewTypeResolverForDescriptorPool( - kTypeUrlPrefix, DescriptorPool::generated_pool())); - type_url_ = GetTypeUrl(TestAllTypes::descriptor()); output_ = "\nCONFORMANCE TEST BEGIN ====================================\n\n"; - for (int i = 1; i <= FieldDescriptor::MAX_TYPE; i++) { - if (i == FieldDescriptor::TYPE_GROUP) continue; - TestPrematureEOFForType(static_cast(i)); - } - - RunValidJsonTest("HelloWorld", "{\"optionalString\":\"Hello, World!\"}", - "optional_string: 'Hello, World!'"); - - // Test field name conventions. - RunValidJsonTest( - "FieldNameInSnakeCase", - R"({ - "fieldname1": 1, - "fieldName2": 2, - "FieldName3": 3 - })", - R"( - fieldname1: 1 - field_name2: 2 - _field_name3: 3 - )"); - RunValidJsonTest( - "FieldNameWithNumbers", - R"({ - "field0name5": 5, - "field0Name6": 6 - })", - R"( - field0name5: 5 - field_0_name6: 6 - )"); - RunValidJsonTest( - "FieldNameWithMixedCases", - R"({ - "fieldName7": 7, - "fieldName8": 8, - "fieldName9": 9, - "fieldName10": 10, - "fIELDNAME11": 11, - "fIELDName12": 12 - })", - R"( - fieldName7: 7 - FieldName8: 8 - field_Name9: 9 - Field_Name10: 10 - FIELD_NAME11: 11 - FIELD_name12: 12 - )"); - // Using the original proto field name in JSON is also allowed. - RunValidJsonTest( - "OriginalProtoFieldName", - R"({ - "fieldname1": 1, - "field_name2": 2, - "_field_name3": 3, - "field0name5": 5, - "field_0_name6": 6, - "fieldName7": 7, - "FieldName8": 8, - "field_Name9": 9, - "Field_Name10": 10, - "FIELD_NAME11": 11, - "FIELD_name12": 12 - })", - R"( - fieldname1: 1 - field_name2: 2 - _field_name3: 3 - field0name5: 5 - field_0_name6: 6 - fieldName7: 7 - FieldName8: 8 - field_Name9: 9 - Field_Name10: 10 - FIELD_NAME11: 11 - FIELD_name12: 12 - )"); - // Field names can be escaped. - RunValidJsonTest( - "FieldNameEscaped", - R"({"fieldn\u0061me1": 1})", - "fieldname1: 1"); - // Field names must be quoted (or it's not valid JSON). - ExpectParseFailureForJson( - "FieldNameNotQuoted", - "{fieldname1: 1}"); - // Trailing comma is not allowed (not valid JSON). - ExpectParseFailureForJson( - "TrailingCommaInAnObject", - R"({"fieldname1":1,})"); - // JSON doesn't support comments. - ExpectParseFailureForJson( - "JsonWithComments", - R"({ - // This is a comment. - "fieldname1": 1 - })"); - // Duplicated field names are not allowed. - ExpectParseFailureForJson( - "FieldNameDuplicate", - R"({ - "optionalNestedMessage": {a: 1}, - "optionalNestedMessage": {} - })"); - ExpectParseFailureForJson( - "FieldNameDuplicateDifferentCasing1", - R"({ - "optional_nested_message": {a: 1}, - "optionalNestedMessage": {} - })"); - ExpectParseFailureForJson( - "FieldNameDuplicateDifferentCasing2", - R"({ - "optionalNestedMessage": {a: 1}, - "optional_nested_message": {} - })"); - // Serializers should use lowerCamelCase by default. - RunValidJsonTestWithValidator( - "FieldNameInLowerCamelCase", - R"({ - "fieldname1": 1, - "fieldName2": 2, - "FieldName3": 3 - })", - [](const Json::Value& value) { - return value.isMember("fieldname1") && - value.isMember("fieldName2") && - value.isMember("FieldName3"); - }); - RunValidJsonTestWithValidator( - "FieldNameWithNumbers", - R"({ - "field0name5": 5, - "field0Name6": 6 - })", - [](const Json::Value& value) { - return value.isMember("field0name5") && - value.isMember("field0Name6"); - }); - RunValidJsonTestWithValidator( - "FieldNameWithMixedCases", - R"({ - "fieldName7": 7, - "fieldName8": 8, - "fieldName9": 9, - "fieldName10": 10, - "fIELDNAME11": 11, - "fIELDName12": 12 - })", - [](const Json::Value& value) { - return value.isMember("fieldName7") && - value.isMember("fieldName8") && - value.isMember("fieldName9") && - value.isMember("fieldName10") && - value.isMember("fIELDNAME11") && - value.isMember("fIELDName12"); - }); - - // Integer fields. - RunValidJsonTest( - "Int32FieldMaxValue", - R"({"optionalInt32": 2147483647})", - "optional_int32: 2147483647"); - RunValidJsonTest( - "Int32FieldMinValue", - R"({"optionalInt32": -2147483648})", - "optional_int32: -2147483648"); - RunValidJsonTest( - "Uint32FieldMaxValue", - R"({"optionalUint32": 4294967295})", - "optional_uint32: 4294967295"); - RunValidJsonTest( - "Int64FieldMaxValue", - R"({"optionalInt64": "9223372036854775807"})", - "optional_int64: 9223372036854775807"); - RunValidJsonTest( - "Int64FieldMinValue", - R"({"optionalInt64": "-9223372036854775808"})", - "optional_int64: -9223372036854775808"); - RunValidJsonTest( - "Uint64FieldMaxValue", - R"({"optionalUint64": "18446744073709551615"})", - "optional_uint64: 18446744073709551615"); - RunValidJsonTest( - "Int64FieldMaxValueNotQuoted", - R"({"optionalInt64": 9223372036854775807})", - "optional_int64: 9223372036854775807"); - RunValidJsonTest( - "Int64FieldMinValueNotQuoted", - R"({"optionalInt64": -9223372036854775808})", - "optional_int64: -9223372036854775808"); - RunValidJsonTest( - "Uint64FieldMaxValueNotQuoted", - R"({"optionalUint64": 18446744073709551615})", - "optional_uint64: 18446744073709551615"); - // Values can be represented as JSON strings. - RunValidJsonTest( - "Int32FieldStringValue", - R"({"optionalInt32": "2147483647"})", - "optional_int32: 2147483647"); - RunValidJsonTest( - "Int32FieldStringValueEscaped", - R"({"optionalInt32": "2\u003147483647"})", - "optional_int32: 2147483647"); - - // Parsers reject out-of-bound integer values. - ExpectParseFailureForJson( - "Int32FieldTooLarge", - R"({"optionalInt32": 2147483648})"); - ExpectParseFailureForJson( - "Int32FieldTooSmall", - R"({"optionalInt32": -2147483649})"); - ExpectParseFailureForJson( - "Uint32FieldTooLarge", - R"({"optionalUint32": 4294967296})"); - ExpectParseFailureForJson( - "Int64FieldTooLarge", - R"({"optionalInt64": "9223372036854775808"})"); - ExpectParseFailureForJson( - "Int64FieldTooSmall", - R"({"optionalInt64": "-9223372036854775809"})"); - ExpectParseFailureForJson( - "Uint64FieldTooLarge", - R"({"optionalUint64": "18446744073709551616"})"); - // Parser reject non-integer numeric values as well. - ExpectParseFailureForJson( - "Int32FieldNotInteger", - R"({"optionalInt32": 0.5})"); - ExpectParseFailureForJson( - "Uint32FieldNotInteger", - R"({"optionalUint32": 0.5})"); - ExpectParseFailureForJson( - "Int64FieldNotInteger", - R"({"optionalInt64": "0.5"})"); - ExpectParseFailureForJson( - "Uint64FieldNotInteger", - R"({"optionalUint64": "0.5"})"); - - // Integers but represented as float values are accepted. - RunValidJsonTest( - "Int32FieldFloatTrailingZero", - R"({"optionalInt32": 100000.000})", - "optional_int32: 100000"); - RunValidJsonTest( - "Int32FieldExponentialFormat", - R"({"optionalInt32": 1e5})", - "optional_int32: 100000"); - RunValidJsonTest( - "Int32FieldMaxFloatValue", - R"({"optionalInt32": 2.147483647e9})", - "optional_int32: 2147483647"); - RunValidJsonTest( - "Int32FieldMinFloatValue", - R"({"optionalInt32": -2.147483648e9})", - "optional_int32: -2147483648"); - RunValidJsonTest( - "Uint32FieldMaxFloatValue", - R"({"optionalUint32": 4.294967295e9})", - "optional_uint32: 4294967295"); - - // Parser reject non-numeric values. - ExpectParseFailureForJson( - "Int32FieldNotNumber", - R"({"optionalInt32": "3x3"})"); - ExpectParseFailureForJson( - "Uint32FieldNotNumber", - R"({"optionalUint32": "3x3"})"); - ExpectParseFailureForJson( - "Int64FieldNotNumber", - R"({"optionalInt64": "3x3"})"); - ExpectParseFailureForJson( - "Uint64FieldNotNumber", - R"({"optionalUint64": "3x3"})"); - // JSON does not allow "+" on numric values. - ExpectParseFailureForJson( - "Int32FieldPlusSign", - R"({"optionalInt32": +1})"); - // JSON doesn't allow leading 0s. - ExpectParseFailureForJson( - "Int32FieldLeadingZero", - R"({"optionalInt32": 01})"); - ExpectParseFailureForJson( - "Int32FieldNegativeWithLeadingZero", - R"({"optionalInt32": -01})"); - // String values must follow the same syntax rule. Specifically leading - // or traling spaces are not allowed. - ExpectParseFailureForJson( - "Int32FieldLeadingSpace", - R"({"optionalInt32": " 1"})"); - ExpectParseFailureForJson( - "Int32FieldTrailingSpace", - R"({"optionalInt32": "1 "})"); - - // 64-bit values are serialized as strings. - RunValidJsonTestWithValidator( - "Int64FieldBeString", - R"({"optionalInt64": 1})", - [](const Json::Value& value) { - return value["optionalInt64"].type() == Json::stringValue && - value["optionalInt64"].asString() == "1"; - }); - RunValidJsonTestWithValidator( - "Uint64FieldBeString", - R"({"optionalUint64": 1})", - [](const Json::Value& value) { - return value["optionalUint64"].type() == Json::stringValue && - value["optionalUint64"].asString() == "1"; - }); - - // Bool fields. - RunValidJsonTest( - "BoolFieldTrue", - R"({"optionalBool":true})", - "optional_bool: true"); - RunValidJsonTest( - "BoolFieldFalse", - R"({"optionalBool":false})", - "optional_bool: false"); - - // Other forms are not allowed. - ExpectParseFailureForJson( - "BoolFieldIntegerZero", - R"({"optionalBool":0})"); - ExpectParseFailureForJson( - "BoolFieldIntegerOne", - R"({"optionalBool":1})"); - ExpectParseFailureForJson( - "BoolFieldCamelCaseTrue", - R"({"optionalBool":True})"); - ExpectParseFailureForJson( - "BoolFieldCamelCaseFalse", - R"({"optionalBool":False})"); - ExpectParseFailureForJson( - "BoolFieldAllCapitalTrue", - R"({"optionalBool":TRUE})"); - ExpectParseFailureForJson( - "BoolFieldAllCapitalFalse", - R"({"optionalBool":FALSE})"); - ExpectParseFailureForJson( - "BoolFieldDoubleQuotedTrue", - R"({"optionalBool":"true"})"); - ExpectParseFailureForJson( - "BoolFieldDoubleQuotedFalse", - R"({"optionalBool":"false"})"); - - // Float fields. - RunValidJsonTest( - "FloatFieldMinPositiveValue", - R"({"optionalFloat": 1.175494e-38})", - "optional_float: 1.175494e-38"); - RunValidJsonTest( - "FloatFieldMaxNegativeValue", - R"({"optionalFloat": -1.175494e-38})", - "optional_float: -1.175494e-38"); - RunValidJsonTest( - "FloatFieldMaxPositiveValue", - R"({"optionalFloat": 3.402823e+38})", - "optional_float: 3.402823e+38"); - RunValidJsonTest( - "FloatFieldMinNegativeValue", - R"({"optionalFloat": 3.402823e+38})", - "optional_float: 3.402823e+38"); - // Values can be quoted. - RunValidJsonTest( - "FloatFieldQuotedValue", - R"({"optionalFloat": "1"})", - "optional_float: 1"); - // Special values. - RunValidJsonTest( - "FloatFieldNan", - R"({"optionalFloat": "NaN"})", - "optional_float: nan"); - RunValidJsonTest( - "FloatFieldInfinity", - R"({"optionalFloat": "Infinity"})", - "optional_float: inf"); - RunValidJsonTest( - "FloatFieldNegativeInfinity", - R"({"optionalFloat": "-Infinity"})", - "optional_float: -inf"); - // Non-cannonical Nan will be correctly normalized. - { - TestAllTypes message; - // IEEE floating-point standard 32-bit quiet NaN: - // 0111 1111 1xxx xxxx xxxx xxxx xxxx xxxx - message.set_optional_float( - WireFormatLite::DecodeFloat(0x7FA12345)); - RunValidJsonTestWithProtobufInput( - "FloatFieldNormalizeQuietNan", message, - "optional_float: nan"); - // IEEE floating-point standard 64-bit signaling NaN: - // 1111 1111 1xxx xxxx xxxx xxxx xxxx xxxx - message.set_optional_float( - WireFormatLite::DecodeFloat(0xFFB54321)); - RunValidJsonTestWithProtobufInput( - "FloatFieldNormalizeSignalingNan", message, - "optional_float: nan"); - } - - // Special values must be quoted. - ExpectParseFailureForJson( - "FloatFieldNanNotQuoted", - R"({"optionalFloat": NaN})"); - ExpectParseFailureForJson( - "FloatFieldInfinityNotQuoted", - R"({"optionalFloat": Infinity})"); - ExpectParseFailureForJson( - "FloatFieldNegativeInfinityNotQuoted", - R"({"optionalFloat": -Infinity})"); - // Parsers should reject out-of-bound values. - ExpectParseFailureForJson( - "FloatFieldTooSmall", - R"({"optionalFloat": -3.502823e+38})"); - ExpectParseFailureForJson( - "FloatFieldTooLarge", - R"({"optionalFloat": 3.502823e+38})"); - - // Double fields. - RunValidJsonTest( - "DoubleFieldMinPositiveValue", - R"({"optionalDouble": 2.22507e-308})", - "optional_double: 2.22507e-308"); - RunValidJsonTest( - "DoubleFieldMaxNegativeValue", - R"({"optionalDouble": -2.22507e-308})", - "optional_double: -2.22507e-308"); - RunValidJsonTest( - "DoubleFieldMaxPositiveValue", - R"({"optionalDouble": 1.79769e+308})", - "optional_double: 1.79769e+308"); - RunValidJsonTest( - "DoubleFieldMinNegativeValue", - R"({"optionalDouble": -1.79769e+308})", - "optional_double: -1.79769e+308"); - // Values can be quoted. - RunValidJsonTest( - "DoubleFieldQuotedValue", - R"({"optionalDouble": "1"})", - "optional_double: 1"); - // Speical values. - RunValidJsonTest( - "DoubleFieldNan", - R"({"optionalDouble": "NaN"})", - "optional_double: nan"); - RunValidJsonTest( - "DoubleFieldInfinity", - R"({"optionalDouble": "Infinity"})", - "optional_double: inf"); - RunValidJsonTest( - "DoubleFieldNegativeInfinity", - R"({"optionalDouble": "-Infinity"})", - "optional_double: -inf"); - // Non-cannonical Nan will be correctly normalized. - { - TestAllTypes message; - message.set_optional_double( - WireFormatLite::DecodeDouble(0x7FFA123456789ABCLL)); - RunValidJsonTestWithProtobufInput( - "DoubleFieldNormalizeQuietNan", message, - "optional_double: nan"); - message.set_optional_double( - WireFormatLite::DecodeDouble(0xFFFBCBA987654321LL)); - RunValidJsonTestWithProtobufInput( - "DoubleFieldNormalizeSignalingNan", message, - "optional_double: nan"); + failure_list_filename_ = filename; + expected_to_fail_.clear(); + for (const string& failure : failure_list->failure()) { + AddExpectedFailedTest(failure); } - - // Special values must be quoted. - ExpectParseFailureForJson( - "DoubleFieldNanNotQuoted", - R"({"optionalDouble": NaN})"); - ExpectParseFailureForJson( - "DoubleFieldInfinityNotQuoted", - R"({"optionalDouble": Infinity})"); - ExpectParseFailureForJson( - "DoubleFieldNegativeInfinityNotQuoted", - R"({"optionalDouble": -Infinity})"); - - // Parsers should reject out-of-bound values. - ExpectParseFailureForJson( - "DoubleFieldTooSmall", - R"({"optionalDouble": -1.89769e+308})"); - ExpectParseFailureForJson( - "DoubleFieldTooLarge", - R"({"optionalDouble": +1.89769e+308})"); - - // Enum fields. - RunValidJsonTest( - "EnumField", - R"({"optionalNestedEnum": "FOO"})", - "optional_nested_enum: FOO"); - // Enum values must be represented as strings. - ExpectParseFailureForJson( - "EnumFieldNotQuoted", - R"({"optionalNestedEnum": FOO})"); - // Numeric values are allowed. - RunValidJsonTest( - "EnumFieldNumericValueZero", - R"({"optionalNestedEnum": 0})", - "optional_nested_enum: FOO"); - RunValidJsonTest( - "EnumFieldNumericValueNonZero", - R"({"optionalNestedEnum": 1})", - "optional_nested_enum: BAR"); - // Unknown enum values are represented as numeric values. - RunValidJsonTestWithValidator( - "EnumFieldUnknownValue", - R"({"optionalNestedEnum": 123})", - [](const Json::Value& value) { - return value["optionalNestedEnum"].type() == Json::intValue && - value["optionalNestedEnum"].asInt() == 123; - }); - - // String fields. - RunValidJsonTest( - "StringField", - R"({"optionalString": "Hello world!"})", - "optional_string: \"Hello world!\""); - RunValidJsonTest( - "StringFieldUnicode", - // Google in Chinese. - R"({"optionalString": "谷歌"})", - R"(optional_string: "谷歌")"); - RunValidJsonTest( - "StringFieldEscape", - R"({"optionalString": "\"\\\/\b\f\n\r\t"})", - R"(optional_string: "\"\\/\b\f\n\r\t")"); - RunValidJsonTest( - "StringFieldUnicodeEscape", - R"({"optionalString": "\u8C37\u6B4C"})", - R"(optional_string: "谷歌")"); - RunValidJsonTest( - "StringFieldUnicodeEscapeWithLowercaseHexLetters", - R"({"optionalString": "\u8c37\u6b4c"})", - R"(optional_string: "谷歌")"); - RunValidJsonTest( - "StringFieldSurrogatePair", - // The character is an emoji: grinning face with smiling eyes. 😠- R"({"optionalString": "\uD83D\uDE01"})", - R"(optional_string: "\xF0\x9F\x98\x81")"); - - // Unicode escapes must start with "\u" (lowercase u). - ExpectParseFailureForJson( - "StringFieldUppercaseEscapeLetter", - R"({"optionalString": "\U8C37\U6b4C"})"); - ExpectParseFailureForJson( - "StringFieldInvalidEscape", - R"({"optionalString": "\uXXXX\u6B4C"})"); - ExpectParseFailureForJson( - "StringFieldUnterminatedEscape", - R"({"optionalString": "\u8C3"})"); - ExpectParseFailureForJson( - "StringFieldUnpairedHighSurrogate", - R"({"optionalString": "\uD800"})"); - ExpectParseFailureForJson( - "StringFieldUnpairedLowSurrogate", - R"({"optionalString": "\uDC00"})"); - ExpectParseFailureForJson( - "StringFieldSurrogateInWrongOrder", - R"({"optionalString": "\uDE01\uD83D"})"); - ExpectParseFailureForJson( - "StringFieldNotAString", - R"({"optionalString": 12345})"); - - // Bytes fields. - RunValidJsonTest( - "BytesField", - R"({"optionalBytes": "AQI="})", - R"(optional_bytes: "\x01\x02")"); - ExpectParseFailureForJson( - "BytesFieldNoPadding", - R"({"optionalBytes": "AQI"})"); - ExpectParseFailureForJson( - "BytesFieldInvalidBase64Characters", - R"({"optionalBytes": "-_=="})"); - - // Message fields. - RunValidJsonTest( - "MessageField", - R"({"optionalNestedMessage": {"a": 1234}})", - "optional_nested_message: {a: 1234}"); - - // Oneof fields. - ExpectParseFailureForJson( - "OneofFieldDuplicate", - R"({"oneofUint32": 1, "oneofString": "test"})"); - - // Repeated fields. - RunValidJsonTest( - "PrimitiveRepeatedField", - R"({"repeatedInt32": [1, 2, 3, 4]})", - "repeated_int32: [1, 2, 3, 4]"); - RunValidJsonTest( - "EnumRepeatedField", - R"({"repeatedNestedEnum": ["FOO", "BAR", "BAZ"]})", - "repeated_nested_enum: [FOO, BAR, BAZ]"); - RunValidJsonTest( - "StringRepeatedField", - R"({"repeatedString": ["Hello", "world"]})", - R"(repeated_string: ["Hello", "world"])"); - RunValidJsonTest( - "BytesRepeatedField", - R"({"repeatedBytes": ["AAEC", "AQI="]})", - R"(repeated_bytes: ["\x00\x01\x02", "\x01\x02"])"); - RunValidJsonTest( - "MessageRepeatedField", - R"({"repeatedNestedMessage": [{"a": 1234}, {"a": 5678}]})", - "repeated_nested_message: {a: 1234}" - "repeated_nested_message: {a: 5678}"); - - // Repeated field elements are of incorrect type. - ExpectParseFailureForJson( - "RepeatedFieldWrongElementTypeExpectingIntegersGotBool", - R"({"repeatedInt32": [1, false, 3, 4]})"); - ExpectParseFailureForJson( - "RepeatedFieldWrongElementTypeExpectingIntegersGotString", - R"({"repeatedInt32": [1, 2, "name", 4]})"); - ExpectParseFailureForJson( - "RepeatedFieldWrongElementTypeExpectingIntegersGotMessage", - R"({"repeatedInt32": [1, 2, 3, {"a": 4}]})"); - ExpectParseFailureForJson( - "RepeatedFieldWrongElementTypeExpectingStringsGotInt", - R"({"repeatedString": ["1", 2, "3", "4"]})"); - ExpectParseFailureForJson( - "RepeatedFieldWrongElementTypeExpectingStringsGotBool", - R"({"repeatedString": ["1", "2", false, "4"]})"); - ExpectParseFailureForJson( - "RepeatedFieldWrongElementTypeExpectingStringsGotMessage", - R"({"repeatedString": ["1", 2, "3", {"a": 4}]})"); - ExpectParseFailureForJson( - "RepeatedFieldWrongElementTypeExpectingMessagesGotInt", - R"({"repeatedNestedMessage": [{"a": 1}, 2]})"); - ExpectParseFailureForJson( - "RepeatedFieldWrongElementTypeExpectingMessagesGotBool", - R"({"repeatedNestedMessage": [{"a": 1}, false]})"); - ExpectParseFailureForJson( - "RepeatedFieldWrongElementTypeExpectingMessagesGotString", - R"({"repeatedNestedMessage": [{"a": 1}, "2"]})"); - // Trailing comma in the repeated field is not allowed. - ExpectParseFailureForJson( - "RepeatedFieldTrailingComma", - R"({"repeatedInt32": [1, 2, 3, 4,]})"); - - // Map fields. - RunValidJsonTest( - "Int32MapField", - R"({"mapInt32Int32": {"1": 2, "3": 4}})", - "map_int32_int32: {key: 1 value: 2}" - "map_int32_int32: {key: 3 value: 4}"); - ExpectParseFailureForJson( - "Int32MapFieldKeyNotQuoted", - R"({"mapInt32Int32": {1: 2, 3: 4}})"); - RunValidJsonTest( - "Uint32MapField", - R"({"mapUint32Uint32": {"1": 2, "3": 4}})", - "map_uint32_uint32: {key: 1 value: 2}" - "map_uint32_uint32: {key: 3 value: 4}"); - ExpectParseFailureForJson( - "Uint32MapFieldKeyNotQuoted", - R"({"mapUint32Uint32": {1: 2, 3: 4}})"); - RunValidJsonTest( - "Int64MapField", - R"({"mapInt64Int64": {"1": 2, "3": 4}})", - "map_int64_int64: {key: 1 value: 2}" - "map_int64_int64: {key: 3 value: 4}"); - ExpectParseFailureForJson( - "Int64MapFieldKeyNotQuoted", - R"({"mapInt64Int64": {1: 2, 3: 4}})"); - RunValidJsonTest( - "Uint64MapField", - R"({"mapUint64Uint64": {"1": 2, "3": 4}})", - "map_uint64_uint64: {key: 1 value: 2}" - "map_uint64_uint64: {key: 3 value: 4}"); - ExpectParseFailureForJson( - "Uint64MapFieldKeyNotQuoted", - R"({"mapUint64Uint64": {1: 2, 3: 4}})"); - RunValidJsonTest( - "BoolMapField", - R"({"mapBoolBool": {"true": true, "false": false}})", - "map_bool_bool: {key: true value: true}" - "map_bool_bool: {key: false value: false}"); - ExpectParseFailureForJson( - "BoolMapFieldKeyNotQuoted", - R"({"mapBoolBool": {true: true, false: false}})"); - RunValidJsonTest( - "MessageMapField", - R"({ - "mapStringNestedMessage": { - "hello": {"a": 1234}, - "world": {"a": 5678} - } - })", - R"( - map_string_nested_message: { - key: "hello" - value: {a: 1234} - } - map_string_nested_message: { - key: "world" - value: {a: 5678} - } - )"); - // Since Map keys are represented as JSON strings, escaping should be allowed. - RunValidJsonTest( - "Int32MapEscapedKey", - R"({"mapInt32Int32": {"\u0031": 2}})", - "map_int32_int32: {key: 1 value: 2}"); - RunValidJsonTest( - "Int64MapEscapedKey", - R"({"mapInt64Int64": {"\u0031": 2}})", - "map_int64_int64: {key: 1 value: 2}"); - RunValidJsonTest( - "BoolMapEscapedKey", - R"({"mapBoolBool": {"tr\u0075e": true}})", - "map_bool_bool: {key: true value: true}"); - - // "null" is accepted for all fields types. - RunValidJsonTest( - "AllFieldAcceptNull", - R"({ - "optionalInt32": null, - "optionalInt64": null, - "optionalUint32": null, - "optionalUint64": null, - "optionalBool": null, - "optionalString": null, - "optionalBytes": null, - "optionalNestedEnum": null, - "optionalNestedMessage": null, - "repeatedInt32": null, - "repeatedInt64": null, - "repeatedUint32": null, - "repeatedUint64": null, - "repeatedBool": null, - "repeatedString": null, - "repeatedBytes": null, - "repeatedNestedEnum": null, - "repeatedNestedMessage": null, - "mapInt32Int32": null, - "mapBoolBool": null, - "mapStringNestedMessage": null - })", - ""); - - // Repeated field elements cannot be null. - ExpectParseFailureForJson( - "RepeatedFieldPrimitiveElementIsNull", - R"({"repeatedInt32": [1, null, 2]})"); - ExpectParseFailureForJson( - "RepeatedFieldMessageElementIsNull", - R"({"repeatedNestedMessage": [{"a":1}, null, {"a":2}]})"); - // Map field keys cannot be null. - ExpectParseFailureForJson( - "MapFieldKeyIsNull", - R"({"mapInt32Int32": {null: 1}})"); - // Map field values cannot be null. - ExpectParseFailureForJson( - "MapFieldValueIsNull", - R"({"mapInt32Int32": {"0": null}})"); - - // Wrapper types. - RunValidJsonTest( - "OptionalBoolWrapper", - R"({"optionalBoolWrapper": false})", - "optional_bool_wrapper: {value: false}"); - RunValidJsonTest( - "OptionalInt32Wrapper", - R"({"optionalInt32Wrapper": 0})", - "optional_int32_wrapper: {value: 0}"); - RunValidJsonTest( - "OptionalUint32Wrapper", - R"({"optionalUint32Wrapper": 0})", - "optional_uint32_wrapper: {value: 0}"); - RunValidJsonTest( - "OptionalInt64Wrapper", - R"({"optionalInt64Wrapper": 0})", - "optional_int64_wrapper: {value: 0}"); - RunValidJsonTest( - "OptionalUint64Wrapper", - R"({"optionalUint64Wrapper": 0})", - "optional_uint64_wrapper: {value: 0}"); - RunValidJsonTest( - "OptionalFloatWrapper", - R"({"optionalFloatWrapper": 0})", - "optional_float_wrapper: {value: 0}"); - RunValidJsonTest( - "OptionalDoubleWrapper", - R"({"optionalDoubleWrapper": 0})", - "optional_double_wrapper: {value: 0}"); - RunValidJsonTest( - "OptionalStringWrapper", - R"({"optionalStringWrapper": ""})", - R"(optional_string_wrapper: {value: ""})"); - RunValidJsonTest( - "OptionalBytesWrapper", - R"({"optionalBytesWrapper": ""})", - R"(optional_bytes_wrapper: {value: ""})"); - RunValidJsonTest( - "OptionalWrapperTypesWithNonDefaultValue", - R"({ - "optionalBoolWrapper": true, - "optionalInt32Wrapper": 1, - "optionalUint32Wrapper": 1, - "optionalInt64Wrapper": "1", - "optionalUint64Wrapper": "1", - "optionalFloatWrapper": 1, - "optionalDoubleWrapper": 1, - "optionalStringWrapper": "1", - "optionalBytesWrapper": "AQI=" - })", - R"( - optional_bool_wrapper: {value: true} - optional_int32_wrapper: {value: 1} - optional_uint32_wrapper: {value: 1} - optional_int64_wrapper: {value: 1} - optional_uint64_wrapper: {value: 1} - optional_float_wrapper: {value: 1} - optional_double_wrapper: {value: 1} - optional_string_wrapper: {value: "1"} - optional_bytes_wrapper: {value: "\x01\x02"} - )"); - RunValidJsonTest( - "RepeatedBoolWrapper", - R"({"repeatedBoolWrapper": [true, false]})", - "repeated_bool_wrapper: {value: true}" - "repeated_bool_wrapper: {value: false}"); - RunValidJsonTest( - "RepeatedInt32Wrapper", - R"({"repeatedInt32Wrapper": [0, 1]})", - "repeated_int32_wrapper: {value: 0}" - "repeated_int32_wrapper: {value: 1}"); - RunValidJsonTest( - "RepeatedUint32Wrapper", - R"({"repeatedUint32Wrapper": [0, 1]})", - "repeated_uint32_wrapper: {value: 0}" - "repeated_uint32_wrapper: {value: 1}"); - RunValidJsonTest( - "RepeatedInt64Wrapper", - R"({"repeatedInt64Wrapper": [0, 1]})", - "repeated_int64_wrapper: {value: 0}" - "repeated_int64_wrapper: {value: 1}"); - RunValidJsonTest( - "RepeatedUint64Wrapper", - R"({"repeatedUint64Wrapper": [0, 1]})", - "repeated_uint64_wrapper: {value: 0}" - "repeated_uint64_wrapper: {value: 1}"); - RunValidJsonTest( - "RepeatedFloatWrapper", - R"({"repeatedFloatWrapper": [0, 1]})", - "repeated_float_wrapper: {value: 0}" - "repeated_float_wrapper: {value: 1}"); - RunValidJsonTest( - "RepeatedDoubleWrapper", - R"({"repeatedDoubleWrapper": [0, 1]})", - "repeated_double_wrapper: {value: 0}" - "repeated_double_wrapper: {value: 1}"); - RunValidJsonTest( - "RepeatedStringWrapper", - R"({"repeatedStringWrapper": ["", "AQI="]})", - R"( - repeated_string_wrapper: {value: ""} - repeated_string_wrapper: {value: "AQI="} - )"); - RunValidJsonTest( - "RepeatedBytesWrapper", - R"({"repeatedBytesWrapper": ["", "AQI="]})", - R"( - repeated_bytes_wrapper: {value: ""} - repeated_bytes_wrapper: {value: "\x01\x02"} - )"); - RunValidJsonTest( - "WrapperTypesWithNullValue", - R"({ - "optionalBoolWrapper": null, - "optionalInt32Wrapper": null, - "optionalUint32Wrapper": null, - "optionalInt64Wrapper": null, - "optionalUint64Wrapper": null, - "optionalFloatWrapper": null, - "optionalDoubleWrapper": null, - "optionalStringWrapper": null, - "optionalBytesWrapper": null, - "repeatedBoolWrapper": null, - "repeatedInt32Wrapper": null, - "repeatedUint32Wrapper": null, - "repeatedInt64Wrapper": null, - "repeatedUint64Wrapper": null, - "repeatedFloatWrapper": null, - "repeatedDoubleWrapper": null, - "repeatedStringWrapper": null, - "repeatedBytesWrapper": null - })", - ""); - - // Duration - RunValidJsonTest( - "DurationMinValue", - R"({"optionalDuration": "-315576000000.999999999s"})", - "optional_duration: {seconds: -315576000000 nanos: -999999999}"); - RunValidJsonTest( - "DurationMaxValue", - R"({"optionalDuration": "315576000000.999999999s"})", - "optional_duration: {seconds: 315576000000 nanos: 999999999}"); - RunValidJsonTest( - "DurationRepeatedValue", - R"({"repeatedDuration": ["1.5s", "-1.5s"]})", - "repeated_duration: {seconds: 1 nanos: 500000000}" - "repeated_duration: {seconds: -1 nanos: -500000000}"); - - ExpectParseFailureForJson( - "DurationMissingS", - R"({"optionalDuration": "1"})"); - ExpectParseFailureForJson( - "DurationJsonInputTooSmall", - R"({"optionalDuration": "-315576000001.000000000s"})"); - ExpectParseFailureForJson( - "DurationJsonInputTooLarge", - R"({"optionalDuration": "315576000001.000000000s"})"); - ExpectSerializeFailureForJson( - "DurationProtoInputTooSmall", - "optional_duration: {seconds: -315576000001 nanos: 0}"); - ExpectSerializeFailureForJson( - "DurationProtoInputTooLarge", - "optional_duration: {seconds: 315576000001 nanos: 0}"); - - RunValidJsonTestWithValidator( - "DurationHasZeroFractionalDigit", - R"({"optionalDuration": "1.000000000s"})", - [](const Json::Value& value) { - return value["optionalDuration"].asString() == "1s"; - }); - RunValidJsonTestWithValidator( - "DurationHas3FractionalDigits", - R"({"optionalDuration": "1.010000000s"})", - [](const Json::Value& value) { - return value["optionalDuration"].asString() == "1.010s"; - }); - RunValidJsonTestWithValidator( - "DurationHas6FractionalDigits", - R"({"optionalDuration": "1.000010000s"})", - [](const Json::Value& value) { - return value["optionalDuration"].asString() == "1.000010s"; - }); - RunValidJsonTestWithValidator( - "DurationHas9FractionalDigits", - R"({"optionalDuration": "1.000000010s"})", - [](const Json::Value& value) { - return value["optionalDuration"].asString() == "1.000000010s"; - }); - - // Timestamp - RunValidJsonTest( - "TimestampMinValue", - R"({"optionalTimestamp": "0001-01-01T00:00:00Z"})", - "optional_timestamp: {seconds: -62135596800}"); - RunValidJsonTest( - "TimestampMaxValue", - R"({"optionalTimestamp": "9999-12-31T23:59:59.999999999Z"})", - "optional_timestamp: {seconds: 253402300799 nanos: 999999999}"); - RunValidJsonTest( - "TimestampRepeatedValue", - R"({ - "repeatedTimestamp": [ - "0001-01-01T00:00:00Z", - "9999-12-31T23:59:59.999999999Z" - ] - })", - "repeated_timestamp: {seconds: -62135596800}" - "repeated_timestamp: {seconds: 253402300799 nanos: 999999999}"); - RunValidJsonTest( - "TimestampWithPositiveOffset", - R"({"optionalTimestamp": "1970-01-01T08:00:00+08:00"})", - "optional_timestamp: {seconds: 0}"); - RunValidJsonTest( - "TimestampWithNegativeOffset", - R"({"optionalTimestamp": "1969-12-31T16:00:00-08:00"})", - "optional_timestamp: {seconds: 0}"); - - ExpectParseFailureForJson( - "TimestampJsonInputTooSmall", - R"({"optionalTimestamp": "0000-01-01T00:00:00Z"})"); - ExpectParseFailureForJson( - "TimestampJsonInputTooLarge", - R"({"optionalTimestamp": "10000-01-01T00:00:00Z"})"); - ExpectParseFailureForJson( - "TimestampJsonInputMissingZ", - R"({"optionalTimestamp": "0001-01-01T00:00:00"})"); - ExpectParseFailureForJson( - "TimestampJsonInputMissingT", - R"({"optionalTimestamp": "0001-01-01 00:00:00Z"})"); - ExpectParseFailureForJson( - "TimestampJsonInputLowercaseZ", - R"({"optionalTimestamp": "0001-01-01T00:00:00z"})"); - ExpectParseFailureForJson( - "TimestampJsonInputLowercaseT", - R"({"optionalTimestamp": "0001-01-01t00:00:00Z"})"); - ExpectSerializeFailureForJson( - "TimestampProtoInputTooSmall", - "optional_timestamp: {seconds: -62135596801}"); - ExpectSerializeFailureForJson( - "TimestampProtoInputTooLarge", - "optional_timestamp: {seconds: 253402300800}"); - RunValidJsonTestWithValidator( - "TimestampZeroNormalized", - R"({"optionalTimestamp": "1969-12-31T16:00:00-08:00"})", - [](const Json::Value& value) { - return value["optionalTimestamp"].asString() == - "1970-01-01T00:00:00Z"; - }); - RunValidJsonTestWithValidator( - "TimestampHasZeroFractionalDigit", - R"({"optionalTimestamp": "1970-01-01T00:00:00.000000000Z"})", - [](const Json::Value& value) { - return value["optionalTimestamp"].asString() == - "1970-01-01T00:00:00Z"; - }); - RunValidJsonTestWithValidator( - "TimestampHas3FractionalDigits", - R"({"optionalTimestamp": "1970-01-01T00:00:00.010000000Z"})", - [](const Json::Value& value) { - return value["optionalTimestamp"].asString() == - "1970-01-01T00:00:00.010Z"; - }); - RunValidJsonTestWithValidator( - "TimestampHas6FractionalDigits", - R"({"optionalTimestamp": "1970-01-01T00:00:00.000010000Z"})", - [](const Json::Value& value) { - return value["optionalTimestamp"].asString() == - "1970-01-01T00:00:00.000010Z"; - }); - RunValidJsonTestWithValidator( - "TimestampHas9FractionalDigits", - R"({"optionalTimestamp": "1970-01-01T00:00:00.000000010Z"})", - [](const Json::Value& value) { - return value["optionalTimestamp"].asString() == - "1970-01-01T00:00:00.000000010Z"; - }); - - // FieldMask - RunValidJsonTest( - "FieldMask", - R"({"optionalFieldMask": "foo,barBaz"})", - R"(optional_field_mask: {paths: "foo" paths: "bar_baz"})"); - ExpectParseFailureForJson( - "FieldMaskInvalidCharacter", - R"({"optionalFieldMask": "foo,bar_bar"})"); - ExpectSerializeFailureForJson( - "FieldMaskPathsDontRoundTrip", - R"(optional_field_mask: {paths: "fooBar"})"); - ExpectSerializeFailureForJson( - "FieldMaskNumbersDontRoundTrip", - R"(optional_field_mask: {paths: "foo_3_bar"})"); - ExpectSerializeFailureForJson( - "FieldMaskTooManyUnderscore", - R"(optional_field_mask: {paths: "foo__bar"})"); - - // Struct - RunValidJsonTest( - "Struct", - R"({ - "optionalStruct": { - "nullValue": null, - "intValue": 1234, - "boolValue": true, - "doubleValue": 1234.5678, - "stringValue": "Hello world!", - "listValue": [1234, "5678"], - "objectValue": { - "value": 0 - } - } - })", - R"( - optional_struct: { - fields: { - key: "nullValue" - value: {null_value: NULL_VALUE} - } - fields: { - key: "intValue" - value: {number_value: 1234} - } - fields: { - key: "boolValue" - value: {bool_value: true} - } - fields: { - key: "doubleValue" - value: {number_value: 1234.5678} - } - fields: { - key: "stringValue" - value: {string_value: "Hello world!"} - } - fields: { - key: "listValue" - value: { - list_value: { - values: { - number_value: 1234 - } - values: { - string_value: "5678" - } - } - } - } - fields: { - key: "objectValue" - value: { - struct_value: { - fields: { - key: "value" - value: { - number_value: 0 - } - } - } - } - } - } - )"); - // Value - RunValidJsonTest( - "ValueAcceptInteger", - R"({"optionalValue": 1})", - "optional_value: { number_value: 1}"); - RunValidJsonTest( - "ValueAcceptFloat", - R"({"optionalValue": 1.5})", - "optional_value: { number_value: 1.5}"); - RunValidJsonTest( - "ValueAcceptBool", - R"({"optionalValue": false})", - "optional_value: { bool_value: false}"); - RunValidJsonTest( - "ValueAcceptNull", - R"({"optionalValue": null})", - "optional_value: { null_value: NULL_VALUE}"); - RunValidJsonTest( - "ValueAcceptString", - R"({"optionalValue": "hello"})", - R"(optional_value: { string_value: "hello"})"); - RunValidJsonTest( - "ValueAcceptList", - R"({"optionalValue": [0, "hello"]})", - R"( - optional_value: { - list_value: { - values: { - number_value: 0 - } - values: { - string_value: "hello" - } - } - } - )"); - RunValidJsonTest( - "ValueAcceptObject", - R"({"optionalValue": {"value": 1}})", - R"( - optional_value: { - struct_value: { - fields: { - key: "value" - value: { - number_value: 1 - } - } - } - } - )"); - - // Any - RunValidJsonTest( - "Any", - R"({ - "optionalAny": { - "@type": "type.googleapis.com/conformance.TestAllTypes", - "optionalInt32": 12345 - } - })", - R"( - optional_any: { - [type.googleapis.com/conformance.TestAllTypes] { - optional_int32: 12345 - } - } - )"); - RunValidJsonTest( - "AnyNested", - R"({ - "optionalAny": { - "@type": "type.googleapis.com/google.protobuf.Any", - "value": { - "@type": "type.googleapis.com/conformance.TestAllTypes", - "optionalInt32": 12345 - } - } - })", - R"( - optional_any: { - [type.googleapis.com/google.protobuf.Any] { - [type.googleapis.com/conformance.TestAllTypes] { - optional_int32: 12345 - } - } - } - )"); - // The special "@type" tag is not required to appear first. - RunValidJsonTest( - "AnyUnorderedTypeTag", - R"({ - "optionalAny": { - "optionalInt32": 12345, - "@type": "type.googleapis.com/conformance.TestAllTypes" - } - })", - R"( - optional_any: { - [type.googleapis.com/conformance.TestAllTypes] { - optional_int32: 12345 - } - } - )"); - // Well-known types in Any. - RunValidJsonTest( - "AnyWithInt32ValueWrapper", - R"({ - "optionalAny": { - "@type": "type.googleapis.com/google.protobuf.Int32Value", - "value": 12345 - } - })", - R"( - optional_any: { - [type.googleapis.com/google.protobuf.Int32Value] { - value: 12345 - } - } - )"); - RunValidJsonTest( - "AnyWithDuration", - R"({ - "optionalAny": { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.5s" - } - })", - R"( - optional_any: { - [type.googleapis.com/google.protobuf.Duration] { - seconds: 1 - nanos: 500000000 - } - } - )"); - RunValidJsonTest( - "AnyWithTimestamp", - R"({ - "optionalAny": { - "@type": "type.googleapis.com/google.protobuf.Timestamp", - "value": "1970-01-01T00:00:00Z" - } - })", - R"( - optional_any: { - [type.googleapis.com/google.protobuf.Timestamp] { - seconds: 0 - nanos: 0 - } - } - )"); - RunValidJsonTest( - "AnyWithFieldMask", - R"({ - "optionalAny": { - "@type": "type.googleapis.com/google.protobuf.FieldMask", - "value": "foo,barBaz" - } - })", - R"( - optional_any: { - [type.googleapis.com/google.protobuf.FieldMask] { - paths: ["foo", "bar_baz"] - } - } - )"); - RunValidJsonTest( - "AnyWithStruct", - R"({ - "optionalAny": { - "@type": "type.googleapis.com/google.protobuf.Struct", - "value": { - "foo": 1 - } - } - })", - R"( - optional_any: { - [type.googleapis.com/google.protobuf.Struct] { - fields: { - key: "foo" - value: { - number_value: 1 - } - } - } - } - )"); - RunValidJsonTest( - "AnyWithValueForJsonObject", - R"({ - "optionalAny": { - "@type": "type.googleapis.com/google.protobuf.Value", - "value": { - "foo": 1 - } - } - })", - R"( - optional_any: { - [type.googleapis.com/google.protobuf.Value] { - struct_value: { - fields: { - key: "foo" - value: { - number_value: 1 - } - } - } - } - } - )"); - RunValidJsonTest( - "AnyWithValueForInteger", - R"({ - "optionalAny": { - "@type": "type.googleapis.com/google.protobuf.Value", - "value": 1 - } - })", - R"( - optional_any: { - [type.googleapis.com/google.protobuf.Value] { - number_value: 1 - } - } - )"); + RunSuiteImpl(); bool ok = true; - if (!CheckSetEmpty(expected_to_fail_, + if (!CheckSetEmpty(expected_to_fail_, "nonexistent_tests.txt", "These tests were listed in the failure list, but they " - "don't exist. Remove them from the failure list")) { + "don't exist. Remove them from the failure list by " + "running:\n" + " ./update_failure_list.py " + failure_list_filename_ + + " --remove nonexistent_tests.txt")) { ok = false; } - if (!CheckSetEmpty(unexpected_failing_tests_, + if (!CheckSetEmpty(unexpected_failing_tests_, "failing_tests.txt", "These tests failed. If they can't be fixed right now, " "you can add them to the failure list so the overall " - "suite can succeed")) { + "suite can succeed. Add them to the failure list by " + "running:\n" + " ./update_failure_list.py " + failure_list_filename_ + + " --add failing_tests.txt")) { + ok = false; + } + if (!CheckSetEmpty(unexpected_succeeding_tests_, "succeeding_tests.txt", + "These tests succeeded, even though they were listed in " + "the failure list. Remove them from the failure list " + "by running:\n" + " ./update_failure_list.py " + failure_list_filename_ + + " --remove succeeding_tests.txt")) { ok = false; } - - // Sometimes the testee may be fixed before we update the failure list (e.g., - // the testee is from a different component). We warn about this case but - // don't consider it an overall test failure. - CheckSetEmpty(unexpected_succeeding_tests_, - "These tests succeeded, even though they were listed in " - "the failure list. Remove them from the failure list"); if (verbose_) { - CheckSetEmpty(skipped_, + CheckSetEmpty(skipped_, "", "These tests were skipped (probably because support for some " "features is not implemented)"); } diff --git a/third_party/protobuf/conformance/conformance_test.h b/third_party/protobuf/conformance/conformance_test.h index 75fc97bc1a2c..4d741e7f1506 100644 --- a/third_party/protobuf/conformance/conformance_test.h +++ b/third_party/protobuf/conformance/conformance_test.h @@ -40,21 +40,30 @@ #include #include + +#include #include #include #include -#include "third_party/jsoncpp/json.h" +#include "conformance.pb.h" namespace conformance { class ConformanceRequest; class ConformanceResponse; -class TestAllTypes; } // namespace conformance +namespace protobuf_test_messages { +namespace proto3 { +class TestAllTypesProto3; +} // namespace proto3 +} // namespace protobuf_test_messages + namespace google { namespace protobuf { +class ConformanceTestSuite; + class ConformanceTestRunner { public: virtual ~ConformanceTestRunner() {} @@ -71,84 +80,220 @@ class ConformanceTestRunner { std::string* output) = 0; }; +// Test runner that spawns the process being tested and communicates with it +// over a pipe. +class ForkPipeRunner : public ConformanceTestRunner { + public: + // Note: Run() doesn't take ownership of the pointers inside suites. + static int Run(int argc, char *argv[], + const std::vector& suites); + + ForkPipeRunner(const std::string &executable) + : child_pid_(-1), executable_(executable) {} + + virtual ~ForkPipeRunner() {} + + void RunTest(const std::string& test_name, + const std::string& request, + std::string* response); + + private: + void SpawnTestProgram(); + + void CheckedWrite(int fd, const void *buf, size_t len); + bool TryRead(int fd, void *buf, size_t len); + void CheckedRead(int fd, void *buf, size_t len); + + int write_fd_; + int read_fd_; + pid_t child_pid_; + std::string executable_; + std::string current_test_name_; +}; + // Class representing the test suite itself. To run it, implement your own -// class derived from ConformanceTestRunner and then write code like: +// class derived from ConformanceTestRunner, class derived from +// ConformanceTestSuite and then write code like: +// +// class MyConformanceTestSuite : public ConformanceTestSuite { +// public: +// void RunSuiteImpl() { +// // INSERT ACTURAL TESTS. +// } +// }; // // class MyConformanceTestRunner : public ConformanceTestRunner { // public: +// static int Run(int argc, char *argv[], +// ConformanceTestSuite* suite); +// +// private: // virtual void RunTest(...) { // // INSERT YOUR FRAMEWORK-SPECIFIC CODE HERE. // } // }; // // int main() { -// MyConformanceTestRunner runner; -// google::protobuf::ConformanceTestSuite suite; -// -// std::string output; -// suite.RunSuite(&runner, &output); +// MyConformanceTestSuite suite; +// MyConformanceTestRunner::Run(argc, argv, &suite); // } // class ConformanceTestSuite { public: - ConformanceTestSuite() : verbose_(false) {} + ConformanceTestSuite() + : verbose_(false), + enforce_recommended_(false), + failure_list_flag_name_("--failure_list") {} + virtual ~ConformanceTestSuite() {} void SetVerbose(bool verbose) { verbose_ = verbose; } - // Sets the list of tests that are expected to fail when RunSuite() is called. - // RunSuite() will fail unless the set of failing tests is exactly the same - // as this list. - void SetFailureList(const std::vector& failure_list); + // Whether to require the testee to pass RECOMMENDED tests. By default failing + // a RECOMMENDED test case will not fail the entire suite but will only + // generated a warning. If this flag is set to true, RECOMMENDED tests will + // be treated the same way as REQUIRED tests and failing a RECOMMENDED test + // case will cause the entire test suite to fail as well. An implementation + // can enable this if it wants to be strictly conforming to protobuf spec. + // See the comments about ConformanceLevel below to learn more about the + // difference between REQUIRED and RECOMMENDED test cases. + void SetEnforceRecommended(bool value) { + enforce_recommended_ = value; + } + + // Gets the flag name to the failure list file. + // By default, this would return --failure_list + string GetFailureListFlagName() { + return failure_list_flag_name_; + } + + void SetFailureListFlagName(const std::string& failure_list_flag_name) { + failure_list_flag_name_ = failure_list_flag_name; + } // Run all the conformance tests against the given test runner. // Test output will be stored in "output". // // Returns true if the set of failing tests was exactly the same as the - // failure list. If SetFailureList() was not called, returns true if all - // tests passed. - bool RunSuite(ConformanceTestRunner* runner, std::string* output); + // failure list. + // The filename here is *only* used to create/format useful error messages for + // how to update the failure list. We do NOT read this file at all. + bool RunSuite(ConformanceTestRunner* runner, std::string* output, + const std::string& filename, + conformance::FailureSet* failure_list); + + protected: + // Test cases are classified into a few categories: + // REQUIRED: the test case must be passed for an implementation to be + // interoperable with other implementations. For example, a + // parser implementaiton must accept both packed and unpacked + // form of repeated primitive fields. + // RECOMMENDED: the test case is not required for the implementation to + // be interoperable with other implementations, but is + // recommended for best performance and compatibility. For + // example, a proto3 serializer should serialize repeated + // primitive fields in packed form, but an implementation + // failing to do so will still be able to communicate with + // other implementations. + enum ConformanceLevel { + REQUIRED = 0, + RECOMMENDED = 1, + }; + + class ConformanceRequestSetting { + public: + ConformanceRequestSetting( + ConformanceLevel level, + conformance::WireFormat input_format, + conformance::WireFormat output_format, + conformance::TestCategory test_category, + const Message& prototype_message, + const string& test_name, const string& input); + virtual ~ConformanceRequestSetting() {} + + Message* GetTestMessage() const; + + string GetTestName() const; + + const conformance::ConformanceRequest& GetRequest() const { + return request_; + } + + const ConformanceLevel GetLevel() const { + return level_; + } + + string ConformanceLevelToString(ConformanceLevel level) const; + + void SetPrintUnknownFields(bool print_unknown_fields) { + request_.set_print_unknown_fields(true); + } + + void SetPrototypeMessageForCompare(const Message& message) { + prototype_message_for_compare_.reset(message.New()); + } + + protected: + virtual string InputFormatString(conformance::WireFormat format) const; + virtual string OutputFormatString(conformance::WireFormat format) const; + conformance::ConformanceRequest request_; + + private: + ConformanceLevel level_; + ::conformance::WireFormat input_format_; + ::conformance::WireFormat output_format_; + const Message& prototype_message_; + std::unique_ptr prototype_message_for_compare_; + string test_name_; + }; + + bool CheckSetEmpty(const std::set& set_to_check, + const std::string& write_to_file, const std::string& msg); + string WireFormatToString(conformance::WireFormat wire_format); + + // Parse payload in the response to the given message. Returns true on + // success. + virtual bool ParseResponse( + const conformance::ConformanceResponse& response, + const ConformanceRequestSetting& setting, + Message* test_message) = 0; + + void VerifyResponse( + const ConformanceRequestSetting& setting, + const string& equivalent_wire_format, + const conformance::ConformanceResponse& response, + bool need_report_success); - private: void ReportSuccess(const std::string& test_name); void ReportFailure(const string& test_name, + ConformanceLevel level, const conformance::ConformanceRequest& request, const conformance::ConformanceResponse& response, const char* fmt, ...); void ReportSkip(const string& test_name, const conformance::ConformanceRequest& request, const conformance::ConformanceResponse& response); + + void RunValidInputTest(const ConformanceRequestSetting& setting, + const string& equivalent_text_format); + void RunValidBinaryInputTest(const ConformanceRequestSetting& setting, + const string& equivalent_wire_format); + void RunTest(const std::string& test_name, const conformance::ConformanceRequest& request, conformance::ConformanceResponse* response); - void RunValidInputTest(const string& test_name, const string& input, - conformance::WireFormat input_format, - const string& equivalent_text_format, - conformance::WireFormat requested_output); - void RunValidJsonTest(const string& test_name, const string& input_json, - const string& equivalent_text_format); - void RunValidJsonTestWithProtobufInput(const string& test_name, - const conformance::TestAllTypes& input, - const string& equivalent_text_format); - - typedef std::function Validator; - void RunValidJsonTestWithValidator(const string& test_name, - const string& input_json, - const Validator& validator); - void ExpectParseFailureForJson(const string& test_name, - const string& input_json); - void ExpectSerializeFailureForJson(const string& test_name, - const string& text_format); - void ExpectParseFailureForProto(const std::string& proto, - const std::string& test_name); - void ExpectHardParseFailureForProto(const std::string& proto, - const std::string& test_name); - void TestPrematureEOFForType(google::protobuf::FieldDescriptor::Type type); - bool CheckSetEmpty(const set& set_to_check, const char* msg); + + void AddExpectedFailedTest(const std::string& test_name); + + virtual void RunSuiteImpl() = 0; + ConformanceTestRunner* runner_; int successes_; int expected_failures_; bool verbose_; + bool enforce_recommended_; std::string output_; + std::string failure_list_flag_name_; + std::string failure_list_filename_; // The set of test names that are expected to fail in this run, but haven't // failed yet. @@ -166,10 +311,6 @@ class ConformanceTestSuite { // The set of tests that the testee opted out of; std::set skipped_; - - google::protobuf::internal::scoped_ptr - type_resolver_; - std::string type_url_; }; } // namespace protobuf diff --git a/third_party/protobuf/conformance/conformance_test_main.cc b/third_party/protobuf/conformance/conformance_test_main.cc new file mode 100644 index 000000000000..c7ac9fc55a78 --- /dev/null +++ b/third_party/protobuf/conformance/conformance_test_main.cc @@ -0,0 +1,40 @@ +// 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 "binary_json_conformance_suite.h" +#include "conformance_test.h" +#include "text_format_conformance_suite.h" + +int main(int argc, char *argv[]) { + google::protobuf::BinaryAndJsonConformanceSuite binary_and_json_suite; + google::protobuf::TextFormatConformanceTestSuite text_format_suite; + return google::protobuf::ForkPipeRunner::Run( + argc, argv, {&binary_and_json_suite, &text_format_suite}); +} diff --git a/third_party/protobuf/conformance/conformance_test_runner.cc b/third_party/protobuf/conformance/conformance_test_runner.cc index 376a60b9aa6e..e7aa0a552a1c 100644 --- a/third_party/protobuf/conformance/conformance_test_runner.cc +++ b/third_party/protobuf/conformance/conformance_test_runner.cc @@ -66,10 +66,9 @@ #include "conformance.pb.h" #include "conformance_test.h" -using conformance::ConformanceRequest; using conformance::ConformanceResponse; -using google::protobuf::internal::scoped_array; using google::protobuf::StringAppendF; +using google::protobuf::ConformanceTestSuite; using std::string; using std::vector; @@ -81,162 +80,31 @@ using std::vector; exit(1); \ } -// Test runner that spawns the process being tested and communicates with it -// over a pipe. -class ForkPipeRunner : public google::protobuf::ConformanceTestRunner { - public: - ForkPipeRunner(const std::string &executable) - : child_pid_(-1), executable_(executable) {} +namespace google { +namespace protobuf { - virtual ~ForkPipeRunner() {} - - void RunTest(const std::string& test_name, - const std::string& request, - std::string* response) { - if (child_pid_ < 0) { - SpawnTestProgram(); - } - - current_test_name_ = test_name; - - uint32_t len = request.size(); - CheckedWrite(write_fd_, &len, sizeof(uint32_t)); - CheckedWrite(write_fd_, request.c_str(), request.size()); - - if (!TryRead(read_fd_, &len, sizeof(uint32_t))) { - // We failed to read from the child, assume a crash and try to reap. - GOOGLE_LOG(INFO) << "Trying to reap child, pid=" << child_pid_; - - int status; - waitpid(child_pid_, &status, WEXITED); - - string error_msg; - if (WIFEXITED(status)) { - StringAppendF(&error_msg, - "child exited, status=%d", WEXITSTATUS(status)); - } else if (WIFSIGNALED(status)) { - StringAppendF(&error_msg, - "child killed by signal %d", WTERMSIG(status)); - } - GOOGLE_LOG(INFO) << error_msg; - child_pid_ = -1; - - conformance::ConformanceResponse response_obj; - response_obj.set_runtime_error(error_msg); - response_obj.SerializeToString(response); - return; - } - - response->resize(len); - CheckedRead(read_fd_, (void*)response->c_str(), len); - } - - private: - // TODO(haberman): make this work on Windows, instead of using these - // UNIX-specific APIs. - // - // There is a platform-agnostic API in - // src/google/protobuf/compiler/subprocess.h - // - // However that API only supports sending a single message to the subprocess. - // We really want to be able to send messages and receive responses one at a - // time: - // - // 1. Spawning a new process for each test would take way too long for thousands - // of tests and subprocesses like java that can take 100ms or more to start - // up. - // - // 2. Sending all the tests in one big message and receiving all results in one - // big message would take away our visibility about which test(s) caused a - // crash or other fatal error. It would also give us only a single failure - // instead of all of them. - void SpawnTestProgram() { - int toproc_pipe_fd[2]; - int fromproc_pipe_fd[2]; - if (pipe(toproc_pipe_fd) < 0 || pipe(fromproc_pipe_fd) < 0) { - perror("pipe"); - exit(1); - } - - pid_t pid = fork(); - if (pid < 0) { - perror("fork"); - exit(1); - } - - if (pid) { - // Parent. - CHECK_SYSCALL(close(toproc_pipe_fd[0])); - CHECK_SYSCALL(close(fromproc_pipe_fd[1])); - write_fd_ = toproc_pipe_fd[1]; - read_fd_ = fromproc_pipe_fd[0]; - child_pid_ = pid; - } else { - // Child. - CHECK_SYSCALL(close(STDIN_FILENO)); - CHECK_SYSCALL(close(STDOUT_FILENO)); - CHECK_SYSCALL(dup2(toproc_pipe_fd[0], STDIN_FILENO)); - CHECK_SYSCALL(dup2(fromproc_pipe_fd[1], STDOUT_FILENO)); - - CHECK_SYSCALL(close(toproc_pipe_fd[0])); - CHECK_SYSCALL(close(fromproc_pipe_fd[1])); - CHECK_SYSCALL(close(toproc_pipe_fd[1])); - CHECK_SYSCALL(close(fromproc_pipe_fd[0])); - - scoped_array executable(new char[executable_.size() + 1]); - memcpy(executable.get(), executable_.c_str(), executable_.size()); - executable[executable_.size()] = '\0'; - - char *const argv[] = {executable.get(), NULL}; - CHECK_SYSCALL(execv(executable.get(), argv)); // Never returns. - } - } +void ParseFailureList(const char *filename, + conformance::FailureSet *failure_list) { + std::ifstream infile(filename); - void CheckedWrite(int fd, const void *buf, size_t len) { - if (write(fd, buf, len) != len) { - GOOGLE_LOG(FATAL) << current_test_name_ - << ": error writing to test program: " - << strerror(errno); - } + if (!infile.is_open()) { + fprintf(stderr, "Couldn't open failure list file: %s\n", filename); + exit(1); } - bool TryRead(int fd, void *buf, size_t len) { - size_t ofs = 0; - while (len > 0) { - ssize_t bytes_read = read(fd, (char*)buf + ofs, len); - - if (bytes_read == 0) { - GOOGLE_LOG(ERROR) << current_test_name_ - << ": unexpected EOF from test program"; - return false; - } else if (bytes_read < 0) { - GOOGLE_LOG(ERROR) << current_test_name_ - << ": error reading from test program: " - << strerror(errno); - return false; - } - - len -= bytes_read; - ofs += bytes_read; - } + for (string line; getline(infile, line);) { + // Remove whitespace. + line.erase(std::remove_if(line.begin(), line.end(), ::isspace), + line.end()); - return true; - } + // Remove comments. + line = line.substr(0, line.find("#")); - void CheckedRead(int fd, void *buf, size_t len) { - if (!TryRead(fd, buf, len)) { - GOOGLE_LOG(FATAL) << current_test_name_ - << ": error reading from test program: " - << strerror(errno); + if (!line.empty()) { + failure_list->add_failure(line); } } - - int write_fd_; - int read_fd_; - pid_t child_pid_; - std::string executable_; - std::string current_test_name_; -}; +} void UsageError() { fprintf(stderr, @@ -251,62 +119,225 @@ void UsageError() { " should contain one test name per\n"); fprintf(stderr, " line. Use '#' for comments.\n"); + fprintf(stderr, + " --text_format_failure_list Use to specify list \n"); + fprintf(stderr, + " of tests that are expected to \n"); + fprintf(stderr, + " fail in the \n"); + fprintf(stderr, + " text_format_conformance_suite. \n"); + fprintf(stderr, + " File should contain one test name \n"); + fprintf(stderr, + " per line. Use '#' for comments.\n"); + + fprintf(stderr, + " --enforce_recommended Enforce that recommended test\n"); + fprintf(stderr, + " cases are also passing. Specify\n"); + fprintf(stderr, + " this flag if you want to be\n"); + fprintf(stderr, + " strictly conforming to protobuf\n"); + fprintf(stderr, + " spec.\n"); exit(1); } -void ParseFailureList(const char *filename, vector* failure_list) { - std::ifstream infile(filename); - - if (!infile.is_open()) { - fprintf(stderr, "Couldn't open failure list file: %s\n", filename); - exit(1); +void ForkPipeRunner::RunTest( + const std::string& test_name, + const std::string& request, + std::string* response) { + if (child_pid_ < 0) { + SpawnTestProgram(); } - for (string line; getline(infile, line);) { - // Remove whitespace. - line.erase(std::remove_if(line.begin(), line.end(), ::isspace), - line.end()); + current_test_name_ = test_name; - // Remove comments. - line = line.substr(0, line.find("#")); + uint32_t len = request.size(); + CheckedWrite(write_fd_, &len, sizeof(uint32_t)); + CheckedWrite(write_fd_, request.c_str(), request.size()); - if (!line.empty()) { - failure_list->push_back(line); + if (!TryRead(read_fd_, &len, sizeof(uint32_t))) { + // We failed to read from the child, assume a crash and try to reap. + GOOGLE_LOG(INFO) << "Trying to reap child, pid=" << child_pid_; + + int status; + waitpid(child_pid_, &status, WEXITED); + + string error_msg; + if (WIFEXITED(status)) { + StringAppendF(&error_msg, + "child exited, status=%d", WEXITSTATUS(status)); + } else if (WIFSIGNALED(status)) { + StringAppendF(&error_msg, + "child killed by signal %d", WTERMSIG(status)); } + GOOGLE_LOG(INFO) << error_msg; + child_pid_ = -1; + + conformance::ConformanceResponse response_obj; + response_obj.set_runtime_error(error_msg); + response_obj.SerializeToString(response); + return; } + + response->resize(len); + CheckedRead(read_fd_, (void*)response->c_str(), len); } -int main(int argc, char *argv[]) { - char *program; - google::protobuf::ConformanceTestSuite suite; - - vector failure_list; - - for (int arg = 1; arg < argc; ++arg) { - if (strcmp(argv[arg], "--failure_list") == 0) { - if (++arg == argc) UsageError(); - ParseFailureList(argv[arg], &failure_list); - } else if (strcmp(argv[arg], "--verbose") == 0) { - suite.SetVerbose(true); - } else if (argv[arg][0] == '-') { - fprintf(stderr, "Unknown option: %s\n", argv[arg]); - UsageError(); - } else { - if (arg != argc - 1) { - fprintf(stderr, "Too many arguments.\n"); - UsageError(); +int ForkPipeRunner::Run( + int argc, char *argv[], const std::vector& suites) { + if (suites.empty()) { + fprintf(stderr, "No test suites found.\n"); + return EXIT_FAILURE; + } + bool all_ok = true; + for (ConformanceTestSuite* suite : suites) { + char *program; + string failure_list_filename; + conformance::FailureSet failure_list; + + for (int arg = 1; arg < argc; ++arg) { + if (strcmp(argv[arg], suite->GetFailureListFlagName().c_str()) == 0) { + if (++arg == argc) UsageError(); + failure_list_filename = argv[arg]; + ParseFailureList(argv[arg], &failure_list); + } else if (strcmp(argv[arg], "--verbose") == 0) { + suite->SetVerbose(true); + } else if (strcmp(argv[arg], "--enforce_recommended") == 0) { + suite->SetEnforceRecommended(true); + } else if (argv[arg][0] == '-') { + bool recognized_flag = false; + for (ConformanceTestSuite* suite : suites) { + if (strcmp(argv[arg], suite->GetFailureListFlagName().c_str()) == 0) { + if (++arg == argc) UsageError(); + recognized_flag = true; + } + } + if (!recognized_flag) { + fprintf(stderr, "Unknown option: %s\n", argv[arg]); + UsageError(); + } + } else { + if (arg != argc - 1) { + fprintf(stderr, "Too many arguments.\n"); + UsageError(); + } + program = argv[arg]; } - program = argv[arg]; } + + ForkPipeRunner runner(program); + + std::string output; + all_ok = all_ok && + suite->RunSuite(&runner, &output, failure_list_filename, &failure_list); + + fwrite(output.c_str(), 1, output.size(), stderr); } + return all_ok ? EXIT_SUCCESS : EXIT_FAILURE; +} + +// TODO(haberman): make this work on Windows, instead of using these +// UNIX-specific APIs. +// +// There is a platform-agnostic API in +// src/google/protobuf/compiler/subprocess.h +// +// However that API only supports sending a single message to the subprocess. +// We really want to be able to send messages and receive responses one at a +// time: +// +// 1. Spawning a new process for each test would take way too long for thousands +// of tests and subprocesses like java that can take 100ms or more to start +// up. +// +// 2. Sending all the tests in one big message and receiving all results in one +// big message would take away our visibility about which test(s) caused a +// crash or other fatal error. It would also give us only a single failure +// instead of all of them. +void ForkPipeRunner::SpawnTestProgram() { + int toproc_pipe_fd[2]; + int fromproc_pipe_fd[2]; + if (pipe(toproc_pipe_fd) < 0 || pipe(fromproc_pipe_fd) < 0) { + perror("pipe"); + exit(1); + } + + pid_t pid = fork(); + if (pid < 0) { + perror("fork"); + exit(1); + } + + if (pid) { + // Parent. + CHECK_SYSCALL(close(toproc_pipe_fd[0])); + CHECK_SYSCALL(close(fromproc_pipe_fd[1])); + write_fd_ = toproc_pipe_fd[1]; + read_fd_ = fromproc_pipe_fd[0]; + child_pid_ = pid; + } else { + // Child. + CHECK_SYSCALL(close(STDIN_FILENO)); + CHECK_SYSCALL(close(STDOUT_FILENO)); + CHECK_SYSCALL(dup2(toproc_pipe_fd[0], STDIN_FILENO)); + CHECK_SYSCALL(dup2(fromproc_pipe_fd[1], STDOUT_FILENO)); + + CHECK_SYSCALL(close(toproc_pipe_fd[0])); + CHECK_SYSCALL(close(fromproc_pipe_fd[1])); + CHECK_SYSCALL(close(toproc_pipe_fd[1])); + CHECK_SYSCALL(close(fromproc_pipe_fd[0])); + + std::unique_ptr executable(new char[executable_.size() + 1]); + memcpy(executable.get(), executable_.c_str(), executable_.size()); + executable[executable_.size()] = '\0'; + + char *const argv[] = {executable.get(), NULL}; + CHECK_SYSCALL(execv(executable.get(), argv)); // Never returns. + } +} + +void ForkPipeRunner::CheckedWrite(int fd, const void *buf, size_t len) { + if (write(fd, buf, len) != len) { + GOOGLE_LOG(FATAL) << current_test_name_ + << ": error writing to test program: " + << strerror(errno); + } +} - suite.SetFailureList(failure_list); - ForkPipeRunner runner(program); +bool ForkPipeRunner::TryRead(int fd, void *buf, size_t len) { + size_t ofs = 0; + while (len > 0) { + ssize_t bytes_read = read(fd, (char*)buf + ofs, len); + + if (bytes_read == 0) { + GOOGLE_LOG(ERROR) << current_test_name_ + << ": unexpected EOF from test program"; + return false; + } else if (bytes_read < 0) { + GOOGLE_LOG(ERROR) << current_test_name_ + << ": error reading from test program: " + << strerror(errno); + return false; + } - std::string output; - bool ok = suite.RunSuite(&runner, &output); + len -= bytes_read; + ofs += bytes_read; + } - fwrite(output.c_str(), 1, output.size(), stderr); + return true; +} - return ok ? EXIT_SUCCESS : EXIT_FAILURE; +void ForkPipeRunner::CheckedRead(int fd, void *buf, size_t len) { + if (!TryRead(fd, buf, len)) { + GOOGLE_LOG(FATAL) << current_test_name_ + << ": error reading from test program: " + << strerror(errno); + } } + +} // namespace protobuf +} // namespace google diff --git a/third_party/protobuf/conformance/failure_list_cpp.txt b/third_party/protobuf/conformance/failure_list_cpp.txt index 2ddf831c03ec..0c01e1e40c7e 100644 --- a/third_party/protobuf/conformance/failure_list_cpp.txt +++ b/third_party/protobuf/conformance/failure_list_cpp.txt @@ -7,100 +7,30 @@ # TODO(haberman): insert links to corresponding bugs tracking the issue. # Should we use GitHub issues or the Google-internal bug tracker? -FieldMaskNumbersDontRoundTrip.JsonOutput -FieldMaskPathsDontRoundTrip.JsonOutput -FieldMaskTooManyUnderscore.JsonOutput -JsonInput.AnyUnorderedTypeTag.JsonOutput -JsonInput.AnyUnorderedTypeTag.ProtobufOutput -JsonInput.AnyWithValueForInteger.JsonOutput -JsonInput.AnyWithValueForInteger.ProtobufOutput -JsonInput.AnyWithValueForJsonObject.JsonOutput -JsonInput.AnyWithValueForJsonObject.ProtobufOutput -JsonInput.BoolFieldDoubleQuotedFalse -JsonInput.BoolFieldDoubleQuotedTrue -JsonInput.BoolFieldIntegerOne -JsonInput.BoolFieldIntegerZero -JsonInput.BytesFieldInvalidBase64Characters -JsonInput.BytesFieldNoPadding -JsonInput.DoubleFieldTooSmall -JsonInput.DurationHasZeroFractionalDigit.Validator -JsonInput.DurationJsonInputTooLarge -JsonInput.DurationJsonInputTooSmall -JsonInput.DurationMissingS -JsonInput.EnumFieldUnknownValue.Validator -JsonInput.FieldMaskInvalidCharacter -JsonInput.FieldNameDuplicate -JsonInput.FieldNameDuplicateDifferentCasing1 -JsonInput.FieldNameDuplicateDifferentCasing2 -JsonInput.FieldNameInLowerCamelCase.Validator -JsonInput.FieldNameInSnakeCase.JsonOutput -JsonInput.FieldNameInSnakeCase.ProtobufOutput -JsonInput.FieldNameNotQuoted -JsonInput.FloatFieldTooLarge -JsonInput.FloatFieldTooSmall -JsonInput.Int32FieldLeadingSpace -JsonInput.Int32FieldLeadingZero -JsonInput.Int32FieldMinFloatValue.JsonOutput -JsonInput.Int32FieldMinFloatValue.ProtobufOutput -JsonInput.Int32FieldMinValue.JsonOutput -JsonInput.Int32FieldMinValue.ProtobufOutput -JsonInput.Int32FieldNegativeWithLeadingZero -JsonInput.Int32FieldNotInteger -JsonInput.Int32FieldNotNumber -JsonInput.Int32FieldTooLarge -JsonInput.Int32FieldTooSmall -JsonInput.Int32FieldTrailingSpace -JsonInput.Int64FieldNotInteger -JsonInput.Int64FieldNotNumber -JsonInput.Int64FieldTooLarge -JsonInput.Int64FieldTooSmall -JsonInput.MapFieldValueIsNull -JsonInput.OneofFieldDuplicate -JsonInput.RepeatedFieldMessageElementIsNull -JsonInput.RepeatedFieldPrimitiveElementIsNull -JsonInput.RepeatedFieldTrailingComma -JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool -JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotMessage -JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotString -JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotBool -JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotInt -JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotString -JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool -JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt -JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotMessage -JsonInput.StringFieldNotAString -JsonInput.StringFieldSurrogateInWrongOrder -JsonInput.StringFieldSurrogatePair.JsonOutput -JsonInput.StringFieldSurrogatePair.ProtobufOutput -JsonInput.StringFieldUnpairedHighSurrogate -JsonInput.StringFieldUnpairedLowSurrogate -JsonInput.StringFieldUppercaseEscapeLetter -JsonInput.TimestampJsonInputLowercaseT -JsonInput.TimestampJsonInputLowercaseZ -JsonInput.TimestampJsonInputMissingT -JsonInput.TimestampJsonInputMissingZ -JsonInput.TimestampJsonInputTooLarge -JsonInput.TimestampJsonInputTooSmall -JsonInput.TrailingCommaInAnObject -JsonInput.Uint32FieldNotInteger -JsonInput.Uint32FieldNotNumber -JsonInput.Uint32FieldTooLarge -JsonInput.Uint64FieldNotInteger -JsonInput.Uint64FieldNotNumber -JsonInput.Uint64FieldTooLarge -JsonInput.WrapperTypesWithNullValue.JsonOutput -JsonInput.WrapperTypesWithNullValue.ProtobufOutput -ProtobufInput.PrematureEofBeforeKnownRepeatedValue.MESSAGE -ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE -ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE -ProtobufInput.PrematureEofInPackedField.BOOL -ProtobufInput.PrematureEofInPackedField.ENUM -ProtobufInput.PrematureEofInPackedField.INT32 -ProtobufInput.PrematureEofInPackedField.INT64 -ProtobufInput.PrematureEofInPackedField.SINT32 -ProtobufInput.PrematureEofInPackedField.SINT64 -ProtobufInput.PrematureEofInPackedField.UINT32 -ProtobufInput.PrematureEofInPackedField.UINT64 -ProtobufInput.PrematureEofInsideKnownRepeatedValue.MESSAGE -TimestampProtoInputTooLarge.JsonOutput -TimestampProtoInputTooSmall.JsonOutput +Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput +Recommended.FieldMaskPathsDontRoundTrip.JsonOutput +Recommended.FieldMaskTooManyUnderscore.JsonOutput +Recommended.Proto3.JsonInput.BoolFieldDoubleQuotedFalse +Recommended.Proto3.JsonInput.BoolFieldDoubleQuotedTrue +Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput +Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput +Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter +Recommended.Proto3.JsonInput.FieldNameDuplicate +Recommended.Proto3.JsonInput.FieldNameDuplicateDifferentCasing1 +Recommended.Proto3.JsonInput.FieldNameDuplicateDifferentCasing2 +Recommended.Proto3.JsonInput.FieldNameNotQuoted +Recommended.Proto3.JsonInput.MapFieldValueIsNull +Recommended.Proto3.JsonInput.RepeatedFieldMessageElementIsNull +Recommended.Proto3.JsonInput.RepeatedFieldPrimitiveElementIsNull +Recommended.Proto3.JsonInput.RepeatedFieldTrailingComma +Recommended.Proto3.JsonInput.RepeatedFieldTrailingCommaWithNewlines +Recommended.Proto3.JsonInput.RepeatedFieldTrailingCommaWithSpace +Recommended.Proto3.JsonInput.RepeatedFieldTrailingCommaWithSpaceCommaSpace +Recommended.Proto3.JsonInput.StringFieldSingleQuoteBoth +Recommended.Proto3.JsonInput.StringFieldSingleQuoteKey +Recommended.Proto3.JsonInput.StringFieldSingleQuoteValue +Recommended.Proto3.JsonInput.StringFieldUppercaseEscapeLetter +Recommended.Proto3.JsonInput.TrailingCommaInAnObject +Recommended.Proto3.JsonInput.TrailingCommaInAnObjectWithNewlines +Recommended.Proto3.JsonInput.TrailingCommaInAnObjectWithSpace +Recommended.Proto3.JsonInput.TrailingCommaInAnObjectWithSpaceCommaSpace diff --git a/third_party/protobuf/conformance/failure_list_csharp.txt b/third_party/protobuf/conformance/failure_list_csharp.txt index a46cee472b43..2a20aa78e7ff 100644 --- a/third_party/protobuf/conformance/failure_list_csharp.txt +++ b/third_party/protobuf/conformance/failure_list_csharp.txt @@ -1,16 +1,2 @@ -JsonInput.AnyWithValueForInteger.JsonOutput -JsonInput.AnyWithValueForJsonObject.JsonOutput -JsonInput.FieldNameInLowerCamelCase.Validator -JsonInput.FieldNameInSnakeCase.JsonOutput -JsonInput.FieldNameInSnakeCase.ProtobufOutput -JsonInput.FieldNameWithMixedCases.JsonOutput -JsonInput.FieldNameWithMixedCases.ProtobufOutput -JsonInput.FieldNameWithMixedCases.Validator -JsonInput.Int32FieldMinFloatValue.JsonOutput -JsonInput.Int32FieldMinValue.JsonOutput -JsonInput.Int64FieldMaxValueNotQuoted.JsonOutput -JsonInput.Int64FieldMaxValueNotQuoted.ProtobufOutput -JsonInput.OriginalProtoFieldName.JsonOutput -JsonInput.StringFieldSurrogatePair.JsonOutput -JsonInput.Uint64FieldMaxValueNotQuoted.JsonOutput -JsonInput.Uint64FieldMaxValueNotQuoted.ProtobufOutput +Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput +Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput diff --git a/third_party/protobuf/conformance/failure_list_java.txt b/third_party/protobuf/conformance/failure_list_java.txt index 552c0cc9c429..dc1f9ba5c9fa 100644 --- a/third_party/protobuf/conformance/failure_list_java.txt +++ b/third_party/protobuf/conformance/failure_list_java.txt @@ -4,46 +4,44 @@ # By listing them here we can keep tabs on which ones are failing and be sure # that we don't introduce regressions in other tests. -FieldMaskNumbersDontRoundTrip.JsonOutput -FieldMaskPathsDontRoundTrip.JsonOutput -FieldMaskTooManyUnderscore.JsonOutput -JsonInput.AnyWithFieldMask.ProtobufOutput -JsonInput.AnyWithValueForInteger.JsonOutput -JsonInput.AnyWithValueForJsonObject.JsonOutput -JsonInput.BoolFieldAllCapitalFalse -JsonInput.BoolFieldAllCapitalTrue -JsonInput.BoolFieldCamelCaseFalse -JsonInput.BoolFieldCamelCaseTrue -JsonInput.BoolFieldDoubleQuotedFalse -JsonInput.BoolFieldDoubleQuotedTrue -JsonInput.BoolMapFieldKeyNotQuoted -JsonInput.DoubleFieldInfinityNotQuoted -JsonInput.DoubleFieldNanNotQuoted -JsonInput.DoubleFieldNegativeInfinityNotQuoted -JsonInput.EnumFieldNotQuoted -JsonInput.FieldMask.ProtobufOutput -JsonInput.FieldMaskInvalidCharacter -JsonInput.FieldNameDuplicate -JsonInput.FieldNameInSnakeCase.JsonOutput -JsonInput.FieldNameNotQuoted -JsonInput.FloatFieldInfinityNotQuoted -JsonInput.FloatFieldNanNotQuoted -JsonInput.FloatFieldNegativeInfinityNotQuoted -JsonInput.Int32FieldLeadingZero -JsonInput.Int32FieldMinFloatValue.JsonOutput -JsonInput.Int32FieldMinValue.JsonOutput -JsonInput.Int32FieldNegativeWithLeadingZero -JsonInput.Int32FieldPlusSign -JsonInput.Int32MapFieldKeyNotQuoted -JsonInput.Int64MapFieldKeyNotQuoted -JsonInput.JsonWithComments -JsonInput.OriginalProtoFieldName.JsonOutput -JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool -JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt -JsonInput.StringFieldNotAString -JsonInput.StringFieldSurrogateInWrongOrder -JsonInput.StringFieldUnpairedHighSurrogate -JsonInput.StringFieldUnpairedLowSurrogate -JsonInput.StringFieldUppercaseEscapeLetter -JsonInput.Uint32MapFieldKeyNotQuoted -JsonInput.Uint64MapFieldKeyNotQuoted +Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput +Recommended.FieldMaskPathsDontRoundTrip.JsonOutput +Recommended.FieldMaskTooManyUnderscore.JsonOutput +Recommended.Proto3.JsonInput.BoolFieldAllCapitalFalse +Recommended.Proto3.JsonInput.BoolFieldAllCapitalTrue +Recommended.Proto3.JsonInput.BoolFieldCamelCaseFalse +Recommended.Proto3.JsonInput.BoolFieldCamelCaseTrue +Recommended.Proto3.JsonInput.BoolFieldDoubleQuotedFalse +Recommended.Proto3.JsonInput.BoolFieldDoubleQuotedTrue +Recommended.Proto3.JsonInput.BoolMapFieldKeyNotQuoted +Recommended.Proto3.JsonInput.DoubleFieldInfinityNotQuoted +Recommended.Proto3.JsonInput.DoubleFieldNanNotQuoted +Recommended.Proto3.JsonInput.DoubleFieldNegativeInfinityNotQuoted +Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter +Recommended.Proto3.JsonInput.FieldNameDuplicate +Recommended.Proto3.JsonInput.FieldNameNotQuoted +Recommended.Proto3.JsonInput.FloatFieldInfinityNotQuoted +Recommended.Proto3.JsonInput.FloatFieldNanNotQuoted +Recommended.Proto3.JsonInput.FloatFieldNegativeInfinityNotQuoted +Recommended.Proto3.JsonInput.Int32MapFieldKeyNotQuoted +Recommended.Proto3.JsonInput.Int64MapFieldKeyNotQuoted +Recommended.Proto3.JsonInput.JsonWithComments +Recommended.Proto3.JsonInput.StringFieldSingleQuoteBoth +Recommended.Proto3.JsonInput.StringFieldSingleQuoteKey +Recommended.Proto3.JsonInput.StringFieldSingleQuoteValue +Recommended.Proto3.JsonInput.StringFieldSurrogateInWrongOrder +Recommended.Proto3.JsonInput.StringFieldUnpairedHighSurrogate +Recommended.Proto3.JsonInput.StringFieldUnpairedLowSurrogate +Recommended.Proto3.JsonInput.Uint32MapFieldKeyNotQuoted +Recommended.Proto3.JsonInput.Uint64MapFieldKeyNotQuoted +Required.Proto3.JsonInput.EnumFieldNotQuoted +Required.Proto3.JsonInput.Int32FieldLeadingZero +Required.Proto3.JsonInput.Int32FieldNegativeWithLeadingZero +Required.Proto3.JsonInput.Int32FieldPlusSign +Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool +Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt +Required.Proto3.JsonInput.StringFieldNotAString +Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE +Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE +Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE +Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE diff --git a/third_party/protobuf/conformance/failure_list_js.txt b/third_party/protobuf/conformance/failure_list_js.txt new file mode 100644 index 000000000000..f8f6a578fa21 --- /dev/null +++ b/third_party/protobuf/conformance/failure_list_js.txt @@ -0,0 +1,13 @@ +Required.Proto3.ProtobufInput.ValidDataRepeated.BOOL.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.INT32.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.INT64.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.SINT32.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.SINT64.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.UINT32.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.UINT64.ProtobufOutput diff --git a/third_party/protobuf/conformance/failure_list_objc.txt b/third_party/protobuf/conformance/failure_list_objc.txt index 5dac3501f1d5..e34501ead734 100644 --- a/third_party/protobuf/conformance/failure_list_objc.txt +++ b/third_party/protobuf/conformance/failure_list_objc.txt @@ -1,4 +1,2 @@ -# No tests currently failing. -# -# json input or output tests are skipped (in conformance_objc.m) as mobile -# platforms don't support json wire format to avoid code bloat. +# JSON input or output tests are skipped (in conformance_objc.m) as mobile +# platforms don't support JSON wire format to avoid code bloat. diff --git a/third_party/protobuf/conformance/failure_list_php.txt b/third_party/protobuf/conformance/failure_list_php.txt new file mode 100644 index 000000000000..28ca461d472b --- /dev/null +++ b/third_party/protobuf/conformance/failure_list_php.txt @@ -0,0 +1,20 @@ +Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput +Recommended.FieldMaskPathsDontRoundTrip.JsonOutput +Recommended.FieldMaskTooManyUnderscore.JsonOutput +Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput +Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput +Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter +Required.Proto3.JsonInput.FloatFieldTooLarge +Required.Proto3.JsonInput.FloatFieldTooSmall +Required.Proto3.JsonInput.DoubleFieldTooSmall +Required.Proto3.JsonInput.Int32FieldNotInteger +Required.Proto3.JsonInput.Int64FieldNotInteger +Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt +Required.Proto3.JsonInput.RepeatedListValue.JsonOutput +Required.Proto3.JsonInput.RepeatedListValue.ProtobufOutput +Required.Proto3.JsonInput.StringFieldNotAString +Required.Proto3.JsonInput.Uint32FieldNotInteger +Required.Proto3.JsonInput.Uint64FieldNotInteger +Required.Proto3.JsonInput.Int32FieldLeadingSpace +Required.Proto3.JsonInput.OneofFieldDuplicate +Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput diff --git a/third_party/protobuf/conformance/failure_list_php_c.txt b/third_party/protobuf/conformance/failure_list_php_c.txt new file mode 100644 index 000000000000..8f7af61855ec --- /dev/null +++ b/third_party/protobuf/conformance/failure_list_php_c.txt @@ -0,0 +1,44 @@ +Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput +Recommended.FieldMaskPathsDontRoundTrip.JsonOutput +Recommended.FieldMaskTooManyUnderscore.JsonOutput +Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput +Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput +Recommended.Proto3.JsonInput.DurationHas3FractionalDigits.Validator +Recommended.Proto3.JsonInput.DurationHas6FractionalDigits.Validator +Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter +Recommended.Proto3.JsonInput.MapFieldValueIsNull +Recommended.Proto3.JsonInput.OneofZeroBytes.JsonOutput +Recommended.Proto3.JsonInput.RepeatedFieldMessageElementIsNull +Recommended.Proto3.JsonInput.RepeatedFieldPrimitiveElementIsNull +Recommended.Proto3.JsonInput.StringEndsWithEscapeChar +Recommended.Proto3.JsonInput.StringFieldSurrogateInWrongOrder +Recommended.Proto3.JsonInput.StringFieldUnpairedHighSurrogate +Recommended.Proto3.JsonInput.StringFieldUnpairedLowSurrogate +Recommended.Proto3.JsonInput.TimestampHas3FractionalDigits.Validator +Recommended.Proto3.JsonInput.TimestampHas6FractionalDigits.Validator +Recommended.Proto3.ProtobufInput.OneofZeroBytes.JsonOutput +Required.DurationProtoInputTooLarge.JsonOutput +Required.DurationProtoInputTooSmall.JsonOutput +Required.TimestampProtoInputTooLarge.JsonOutput +Required.TimestampProtoInputTooSmall.JsonOutput +Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput +Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput +Required.Proto3.JsonInput.DoubleFieldMinPositiveValue.JsonOutput +Required.Proto3.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput +Required.Proto3.JsonInput.DoubleFieldNan.JsonOutput +Required.Proto3.JsonInput.DurationMinValue.JsonOutput +Required.Proto3.JsonInput.DurationRepeatedValue.JsonOutput +Required.Proto3.JsonInput.FloatFieldInfinity.JsonOutput +Required.Proto3.JsonInput.FloatFieldNan.JsonOutput +Required.Proto3.JsonInput.FloatFieldNegativeInfinity.JsonOutput +Required.Proto3.JsonInput.OneofFieldDuplicate +Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput +Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput +Required.Proto3.JsonInput.StringFieldSurrogatePair.JsonOutput +Required.Proto3.JsonInput.StringFieldSurrogatePair.ProtobufOutput +Required.Proto3.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput +Required.Proto3.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput +Required.Proto3.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput +Required.Proto3.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput +Required.Proto3.JsonInput.RejectTopLevelNull diff --git a/third_party/protobuf/conformance/failure_list_php_zts_c.txt b/third_party/protobuf/conformance/failure_list_php_zts_c.txt new file mode 100644 index 000000000000..d9a8fe36d98b --- /dev/null +++ b/third_party/protobuf/conformance/failure_list_php_zts_c.txt @@ -0,0 +1,225 @@ +Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput +Recommended.FieldMaskPathsDontRoundTrip.JsonOutput +Recommended.FieldMaskTooManyUnderscore.JsonOutput +Recommended.JsonInput.BoolFieldIntegerOne +Recommended.JsonInput.BoolFieldIntegerZero +Recommended.JsonInput.DurationHas3FractionalDigits.Validator +Recommended.JsonInput.DurationHas6FractionalDigits.Validator +Recommended.JsonInput.DurationHas9FractionalDigits.Validator +Recommended.JsonInput.DurationHasZeroFractionalDigit.Validator +Recommended.JsonInput.Int64FieldBeString.Validator +Recommended.JsonInput.OneofZeroBytes.JsonOutput +Recommended.JsonInput.OneofZeroBytes.ProtobufOutput +Recommended.JsonInput.OneofZeroDouble.JsonOutput +Recommended.JsonInput.OneofZeroDouble.ProtobufOutput +Recommended.JsonInput.OneofZeroFloat.JsonOutput +Recommended.JsonInput.OneofZeroFloat.ProtobufOutput +Recommended.JsonInput.OneofZeroString.JsonOutput +Recommended.JsonInput.OneofZeroString.ProtobufOutput +Recommended.JsonInput.OneofZeroUint32.JsonOutput +Recommended.JsonInput.OneofZeroUint32.ProtobufOutput +Recommended.JsonInput.OneofZeroUint64.JsonOutput +Recommended.JsonInput.OneofZeroUint64.ProtobufOutput +Recommended.JsonInput.StringEndsWithEscapeChar +Recommended.JsonInput.StringFieldSurrogateInWrongOrder +Recommended.JsonInput.StringFieldUnpairedHighSurrogate +Recommended.JsonInput.StringFieldUnpairedLowSurrogate +Recommended.JsonInput.TimestampHas3FractionalDigits.Validator +Recommended.JsonInput.TimestampHas6FractionalDigits.Validator +Recommended.JsonInput.TimestampHas9FractionalDigits.Validator +Recommended.JsonInput.TimestampHasZeroFractionalDigit.Validator +Recommended.JsonInput.TimestampZeroNormalized.Validator +Recommended.JsonInput.Uint64FieldBeString.Validator +Recommended.ProtobufInput.OneofZeroBytes.JsonOutput +Recommended.ProtobufInput.OneofZeroBytes.ProtobufOutput +Recommended.ProtobufInput.OneofZeroString.JsonOutput +Recommended.ProtobufInput.OneofZeroString.ProtobufOutput +Required.DurationProtoInputTooLarge.JsonOutput +Required.DurationProtoInputTooSmall.JsonOutput +Required.JsonInput.AllFieldAcceptNull.ProtobufOutput +Required.JsonInput.Any.JsonOutput +Required.JsonInput.Any.ProtobufOutput +Required.JsonInput.AnyNested.JsonOutput +Required.JsonInput.AnyNested.ProtobufOutput +Required.JsonInput.AnyUnorderedTypeTag.JsonOutput +Required.JsonInput.AnyUnorderedTypeTag.ProtobufOutput +Required.JsonInput.AnyWithDuration.JsonOutput +Required.JsonInput.AnyWithDuration.ProtobufOutput +Required.JsonInput.AnyWithFieldMask.JsonOutput +Required.JsonInput.AnyWithFieldMask.ProtobufOutput +Required.JsonInput.AnyWithInt32ValueWrapper.JsonOutput +Required.JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput +Required.JsonInput.AnyWithStruct.JsonOutput +Required.JsonInput.AnyWithStruct.ProtobufOutput +Required.JsonInput.AnyWithTimestamp.JsonOutput +Required.JsonInput.AnyWithTimestamp.ProtobufOutput +Required.JsonInput.AnyWithValueForInteger.JsonOutput +Required.JsonInput.AnyWithValueForInteger.ProtobufOutput +Required.JsonInput.AnyWithValueForJsonObject.JsonOutput +Required.JsonInput.AnyWithValueForJsonObject.ProtobufOutput +Required.JsonInput.BoolFieldFalse.ProtobufOutput +Required.JsonInput.BoolMapField.JsonOutput +Required.JsonInput.DoubleFieldInfinity.JsonOutput +Required.JsonInput.DoubleFieldInfinity.ProtobufOutput +Required.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput +Required.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput +Required.JsonInput.DoubleFieldMaxPositiveValue.JsonOutput +Required.JsonInput.DoubleFieldMaxPositiveValue.ProtobufOutput +Required.JsonInput.DoubleFieldMinNegativeValue.JsonOutput +Required.JsonInput.DoubleFieldMinNegativeValue.ProtobufOutput +Required.JsonInput.DoubleFieldMinPositiveValue.JsonOutput +Required.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput +Required.JsonInput.DoubleFieldNan.JsonOutput +Required.JsonInput.DoubleFieldNan.ProtobufOutput +Required.JsonInput.DoubleFieldNegativeInfinity.JsonOutput +Required.JsonInput.DoubleFieldNegativeInfinity.ProtobufOutput +Required.JsonInput.DoubleFieldQuotedValue.JsonOutput +Required.JsonInput.DoubleFieldQuotedValue.ProtobufOutput +Required.JsonInput.DurationMaxValue.JsonOutput +Required.JsonInput.DurationMaxValue.ProtobufOutput +Required.JsonInput.DurationMinValue.JsonOutput +Required.JsonInput.DurationMinValue.ProtobufOutput +Required.JsonInput.DurationRepeatedValue.JsonOutput +Required.JsonInput.DurationRepeatedValue.ProtobufOutput +Required.JsonInput.EnumField.ProtobufOutput +Required.JsonInput.EnumFieldNumericValueNonZero.JsonOutput +Required.JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput +Required.JsonInput.EnumFieldNumericValueZero.JsonOutput +Required.JsonInput.EnumFieldNumericValueZero.ProtobufOutput +Required.JsonInput.EnumFieldUnknownValue.Validator +Required.JsonInput.FieldMask.JsonOutput +Required.JsonInput.FieldMask.ProtobufOutput +Required.JsonInput.FloatFieldInfinity.JsonOutput +Required.JsonInput.FloatFieldInfinity.ProtobufOutput +Required.JsonInput.FloatFieldNan.JsonOutput +Required.JsonInput.FloatFieldNan.ProtobufOutput +Required.JsonInput.FloatFieldNegativeInfinity.JsonOutput +Required.JsonInput.FloatFieldNegativeInfinity.ProtobufOutput +Required.JsonInput.FloatFieldQuotedValue.JsonOutput +Required.JsonInput.FloatFieldQuotedValue.ProtobufOutput +Required.JsonInput.FloatFieldTooLarge +Required.JsonInput.FloatFieldTooSmall +Required.JsonInput.Int32FieldExponentialFormat.JsonOutput +Required.JsonInput.Int32FieldExponentialFormat.ProtobufOutput +Required.JsonInput.Int32FieldFloatTrailingZero.JsonOutput +Required.JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput +Required.JsonInput.Int32FieldMaxFloatValue.JsonOutput +Required.JsonInput.Int32FieldMaxFloatValue.ProtobufOutput +Required.JsonInput.Int32FieldMinFloatValue.JsonOutput +Required.JsonInput.Int32FieldMinFloatValue.ProtobufOutput +Required.JsonInput.Int32FieldStringValue.JsonOutput +Required.JsonInput.Int32FieldStringValue.ProtobufOutput +Required.JsonInput.Int32FieldStringValueEscaped.JsonOutput +Required.JsonInput.Int32FieldStringValueEscaped.ProtobufOutput +Required.JsonInput.Int32MapEscapedKey.JsonOutput +Required.JsonInput.Int32MapEscapedKey.ProtobufOutput +Required.JsonInput.Int32MapField.JsonOutput +Required.JsonInput.Int32MapField.ProtobufOutput +Required.JsonInput.Int64FieldMaxValue.JsonOutput +Required.JsonInput.Int64FieldMaxValue.ProtobufOutput +Required.JsonInput.Int64FieldMinValue.JsonOutput +Required.JsonInput.Int64FieldMinValue.ProtobufOutput +Required.JsonInput.Int64MapEscapedKey.JsonOutput +Required.JsonInput.Int64MapEscapedKey.ProtobufOutput +Required.JsonInput.Int64MapField.JsonOutput +Required.JsonInput.Int64MapField.ProtobufOutput +Required.JsonInput.MessageField.JsonOutput +Required.JsonInput.MessageField.ProtobufOutput +Required.JsonInput.MessageMapField.JsonOutput +Required.JsonInput.MessageMapField.ProtobufOutput +Required.JsonInput.MessageRepeatedField.JsonOutput +Required.JsonInput.MessageRepeatedField.ProtobufOutput +Required.JsonInput.OptionalBoolWrapper.JsonOutput +Required.JsonInput.OptionalBoolWrapper.ProtobufOutput +Required.JsonInput.OptionalBytesWrapper.JsonOutput +Required.JsonInput.OptionalBytesWrapper.ProtobufOutput +Required.JsonInput.OptionalDoubleWrapper.JsonOutput +Required.JsonInput.OptionalDoubleWrapper.ProtobufOutput +Required.JsonInput.OptionalFloatWrapper.JsonOutput +Required.JsonInput.OptionalFloatWrapper.ProtobufOutput +Required.JsonInput.OptionalInt32Wrapper.JsonOutput +Required.JsonInput.OptionalInt32Wrapper.ProtobufOutput +Required.JsonInput.OptionalInt64Wrapper.JsonOutput +Required.JsonInput.OptionalInt64Wrapper.ProtobufOutput +Required.JsonInput.OptionalStringWrapper.JsonOutput +Required.JsonInput.OptionalStringWrapper.ProtobufOutput +Required.JsonInput.OptionalUint32Wrapper.JsonOutput +Required.JsonInput.OptionalUint32Wrapper.ProtobufOutput +Required.JsonInput.OptionalUint64Wrapper.JsonOutput +Required.JsonInput.OptionalUint64Wrapper.ProtobufOutput +Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput +Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput +Required.JsonInput.PrimitiveRepeatedField.JsonOutput +Required.JsonInput.PrimitiveRepeatedField.ProtobufOutput +Required.JsonInput.RepeatedBoolWrapper.JsonOutput +Required.JsonInput.RepeatedBoolWrapper.ProtobufOutput +Required.JsonInput.RepeatedBytesWrapper.JsonOutput +Required.JsonInput.RepeatedBytesWrapper.ProtobufOutput +Required.JsonInput.RepeatedDoubleWrapper.JsonOutput +Required.JsonInput.RepeatedDoubleWrapper.ProtobufOutput +Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt +Required.JsonInput.RepeatedFloatWrapper.JsonOutput +Required.JsonInput.RepeatedFloatWrapper.ProtobufOutput +Required.JsonInput.RepeatedInt32Wrapper.JsonOutput +Required.JsonInput.RepeatedInt32Wrapper.ProtobufOutput +Required.JsonInput.RepeatedInt64Wrapper.JsonOutput +Required.JsonInput.RepeatedInt64Wrapper.ProtobufOutput +Required.JsonInput.RepeatedStringWrapper.JsonOutput +Required.JsonInput.RepeatedStringWrapper.ProtobufOutput +Required.JsonInput.RepeatedUint32Wrapper.JsonOutput +Required.JsonInput.RepeatedUint32Wrapper.ProtobufOutput +Required.JsonInput.RepeatedUint64Wrapper.JsonOutput +Required.JsonInput.RepeatedUint64Wrapper.ProtobufOutput +Required.JsonInput.StringFieldEscape.JsonOutput +Required.JsonInput.StringFieldEscape.ProtobufOutput +Required.JsonInput.StringFieldNotAString +Required.JsonInput.StringFieldSurrogatePair.JsonOutput +Required.JsonInput.StringFieldSurrogatePair.ProtobufOutput +Required.JsonInput.StringFieldUnicodeEscape.JsonOutput +Required.JsonInput.StringFieldUnicodeEscape.ProtobufOutput +Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.JsonOutput +Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.ProtobufOutput +Required.JsonInput.Struct.JsonOutput +Required.JsonInput.Struct.ProtobufOutput +Required.JsonInput.TimestampMaxValue.JsonOutput +Required.JsonInput.TimestampMaxValue.ProtobufOutput +Required.JsonInput.TimestampMinValue.JsonOutput +Required.JsonInput.TimestampMinValue.ProtobufOutput +Required.JsonInput.TimestampRepeatedValue.JsonOutput +Required.JsonInput.TimestampRepeatedValue.ProtobufOutput +Required.JsonInput.TimestampWithNegativeOffset.JsonOutput +Required.JsonInput.TimestampWithNegativeOffset.ProtobufOutput +Required.JsonInput.TimestampWithPositiveOffset.JsonOutput +Required.JsonInput.TimestampWithPositiveOffset.ProtobufOutput +Required.JsonInput.Uint32FieldMaxFloatValue.JsonOutput +Required.JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput +Required.JsonInput.Uint32MapField.JsonOutput +Required.JsonInput.Uint32MapField.ProtobufOutput +Required.JsonInput.Uint64FieldMaxValue.JsonOutput +Required.JsonInput.Uint64FieldMaxValue.ProtobufOutput +Required.JsonInput.Uint64MapField.JsonOutput +Required.JsonInput.Uint64MapField.ProtobufOutput +Required.JsonInput.ValueAcceptBool.JsonOutput +Required.JsonInput.ValueAcceptBool.ProtobufOutput +Required.JsonInput.ValueAcceptFloat.JsonOutput +Required.JsonInput.ValueAcceptFloat.ProtobufOutput +Required.JsonInput.ValueAcceptInteger.JsonOutput +Required.JsonInput.ValueAcceptInteger.ProtobufOutput +Required.JsonInput.ValueAcceptList.JsonOutput +Required.JsonInput.ValueAcceptList.ProtobufOutput +Required.JsonInput.ValueAcceptNull.JsonOutput +Required.JsonInput.ValueAcceptNull.ProtobufOutput +Required.JsonInput.ValueAcceptObject.JsonOutput +Required.JsonInput.ValueAcceptObject.ProtobufOutput +Required.JsonInput.ValueAcceptString.JsonOutput +Required.JsonInput.ValueAcceptString.ProtobufOutput +Required.JsonInput.WrapperTypesWithNullValue.ProtobufOutput +Required.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput +Required.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput +Required.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput +Required.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput +Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED32.ProtobufOutput +Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.ProtobufOutput +Required.ProtobufInput.RepeatedScalarSelectsLast.UINT64.ProtobufOutput +Required.TimestampProtoInputTooLarge.JsonOutput +Required.TimestampProtoInputTooSmall.JsonOutput diff --git a/third_party/protobuf/conformance/failure_list_python.txt b/third_party/protobuf/conformance/failure_list_python.txt index d2e52637bdb8..e3ce7af75906 100644 --- a/third_party/protobuf/conformance/failure_list_python.txt +++ b/third_party/protobuf/conformance/failure_list_python.txt @@ -1,85 +1,21 @@ -DurationProtoInputTooLarge.JsonOutput -DurationProtoInputTooSmall.JsonOutput -FieldMaskNumbersDontRoundTrip.JsonOutput -FieldMaskPathsDontRoundTrip.JsonOutput -FieldMaskTooManyUnderscore.JsonOutput -JsonInput.Any.JsonOutput -JsonInput.Any.ProtobufOutput -JsonInput.AnyNested.JsonOutput -JsonInput.AnyNested.ProtobufOutput -JsonInput.AnyUnorderedTypeTag.JsonOutput -JsonInput.AnyUnorderedTypeTag.ProtobufOutput -JsonInput.AnyWithDuration.JsonOutput -JsonInput.AnyWithDuration.ProtobufOutput -JsonInput.AnyWithFieldMask.JsonOutput -JsonInput.AnyWithFieldMask.ProtobufOutput -JsonInput.AnyWithInt32ValueWrapper.JsonOutput -JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput -JsonInput.AnyWithStruct.JsonOutput -JsonInput.AnyWithStruct.ProtobufOutput -JsonInput.AnyWithTimestamp.JsonOutput -JsonInput.AnyWithTimestamp.ProtobufOutput -JsonInput.AnyWithValueForInteger.JsonOutput -JsonInput.AnyWithValueForInteger.ProtobufOutput -JsonInput.AnyWithValueForJsonObject.JsonOutput -JsonInput.AnyWithValueForJsonObject.ProtobufOutput -JsonInput.BytesFieldInvalidBase64Characters -JsonInput.DoubleFieldInfinityNotQuoted -JsonInput.DoubleFieldNanNotQuoted -JsonInput.DoubleFieldNegativeInfinityNotQuoted -JsonInput.DoubleFieldTooSmall -JsonInput.DurationJsonInputTooLarge -JsonInput.DurationJsonInputTooSmall -JsonInput.DurationMissingS -JsonInput.EnumFieldNumericValueNonZero.JsonOutput -JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput -JsonInput.EnumFieldNumericValueZero.JsonOutput -JsonInput.EnumFieldNumericValueZero.ProtobufOutput -JsonInput.EnumFieldUnknownValue.Validator -JsonInput.FieldMask.ProtobufOutput -JsonInput.FieldMaskInvalidCharacter -JsonInput.FieldNameInLowerCamelCase.Validator -JsonInput.FieldNameInSnakeCase.JsonOutput -JsonInput.FieldNameInSnakeCase.ProtobufOutput -JsonInput.FloatFieldInfinityNotQuoted -JsonInput.FloatFieldNanNotQuoted -JsonInput.FloatFieldNegativeInfinityNotQuoted -JsonInput.FloatFieldTooLarge -JsonInput.FloatFieldTooSmall -JsonInput.Int32FieldExponentialFormat.JsonOutput -JsonInput.Int32FieldExponentialFormat.ProtobufOutput -JsonInput.Int32FieldFloatTrailingZero.JsonOutput -JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput -JsonInput.Int32FieldMaxFloatValue.JsonOutput -JsonInput.Int32FieldMaxFloatValue.ProtobufOutput -JsonInput.Int32FieldMinFloatValue.JsonOutput -JsonInput.Int32FieldMinFloatValue.ProtobufOutput -JsonInput.Int32FieldMinValue.JsonOutput -JsonInput.OriginalProtoFieldName.JsonOutput -JsonInput.OriginalProtoFieldName.ProtobufOutput -JsonInput.RepeatedFieldMessageElementIsNull -JsonInput.RepeatedFieldPrimitiveElementIsNull -JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool -JsonInput.StringFieldSurrogatePair.JsonOutput -JsonInput.StringFieldUnpairedLowSurrogate -JsonInput.Struct.JsonOutput -JsonInput.Struct.ProtobufOutput -JsonInput.TimestampJsonInputLowercaseT -JsonInput.Uint32FieldMaxFloatValue.JsonOutput -JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput -JsonInput.ValueAcceptBool.JsonOutput -JsonInput.ValueAcceptBool.ProtobufOutput -JsonInput.ValueAcceptFloat.JsonOutput -JsonInput.ValueAcceptFloat.ProtobufOutput -JsonInput.ValueAcceptInteger.JsonOutput -JsonInput.ValueAcceptInteger.ProtobufOutput -JsonInput.ValueAcceptList.JsonOutput -JsonInput.ValueAcceptList.ProtobufOutput -JsonInput.ValueAcceptNull.JsonOutput -JsonInput.ValueAcceptNull.ProtobufOutput -JsonInput.ValueAcceptObject.JsonOutput -JsonInput.ValueAcceptObject.ProtobufOutput -JsonInput.ValueAcceptString.JsonOutput -JsonInput.ValueAcceptString.ProtobufOutput -TimestampProtoInputTooLarge.JsonOutput -TimestampProtoInputTooSmall.JsonOutput +Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput +Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput +Recommended.Proto3.JsonInput.DoubleFieldInfinityNotQuoted +Recommended.Proto3.JsonInput.DoubleFieldNanNotQuoted +Recommended.Proto3.JsonInput.DoubleFieldNegativeInfinityNotQuoted +Recommended.Proto3.JsonInput.FloatFieldInfinityNotQuoted +Recommended.Proto3.JsonInput.FloatFieldNanNotQuoted +Recommended.Proto3.JsonInput.FloatFieldNegativeInfinityNotQuoted +Required.Proto3.JsonInput.DoubleFieldTooSmall +Required.Proto3.JsonInput.FloatFieldTooLarge +Required.Proto3.JsonInput.FloatFieldTooSmall +Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool +Required.Proto3.JsonInput.TimestampJsonInputLowercaseT +Required.Proto2.ProtobufInput.IllegalZeroFieldNum_Case_0 +Required.Proto2.ProtobufInput.IllegalZeroFieldNum_Case_1 +Required.Proto2.ProtobufInput.IllegalZeroFieldNum_Case_2 +Required.Proto2.ProtobufInput.IllegalZeroFieldNum_Case_3 +Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_0 +Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_1 +Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_2 +Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_3 diff --git a/third_party/protobuf/conformance/failure_list_python_cpp.txt b/third_party/protobuf/conformance/failure_list_python_cpp.txt index 7b5e45f9ff7e..59a969d2f590 100644 --- a/third_party/protobuf/conformance/failure_list_python_cpp.txt +++ b/third_party/protobuf/conformance/failure_list_python_cpp.txt @@ -7,104 +7,16 @@ # TODO(haberman): insert links to corresponding bugs tracking the issue. # Should we use GitHub issues or the Google-internal bug tracker? -DurationProtoInputTooLarge.JsonOutput -DurationProtoInputTooSmall.JsonOutput -FieldMaskNumbersDontRoundTrip.JsonOutput -FieldMaskPathsDontRoundTrip.JsonOutput -FieldMaskTooManyUnderscore.JsonOutput -JsonInput.Any.JsonOutput -JsonInput.Any.ProtobufOutput -JsonInput.AnyNested.JsonOutput -JsonInput.AnyNested.ProtobufOutput -JsonInput.AnyUnorderedTypeTag.JsonOutput -JsonInput.AnyUnorderedTypeTag.ProtobufOutput -JsonInput.AnyWithDuration.JsonOutput -JsonInput.AnyWithDuration.ProtobufOutput -JsonInput.AnyWithFieldMask.JsonOutput -JsonInput.AnyWithFieldMask.ProtobufOutput -JsonInput.AnyWithInt32ValueWrapper.JsonOutput -JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput -JsonInput.AnyWithStruct.JsonOutput -JsonInput.AnyWithStruct.ProtobufOutput -JsonInput.AnyWithTimestamp.JsonOutput -JsonInput.AnyWithTimestamp.ProtobufOutput -JsonInput.AnyWithValueForInteger.JsonOutput -JsonInput.AnyWithValueForInteger.ProtobufOutput -JsonInput.AnyWithValueForJsonObject.JsonOutput -JsonInput.AnyWithValueForJsonObject.ProtobufOutput -JsonInput.BytesFieldInvalidBase64Characters -JsonInput.DoubleFieldInfinityNotQuoted -JsonInput.DoubleFieldNanNotQuoted -JsonInput.DoubleFieldNegativeInfinityNotQuoted -JsonInput.DoubleFieldTooSmall -JsonInput.DurationJsonInputTooLarge -JsonInput.DurationJsonInputTooSmall -JsonInput.DurationMissingS -JsonInput.EnumFieldNumericValueNonZero.JsonOutput -JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput -JsonInput.EnumFieldNumericValueZero.JsonOutput -JsonInput.EnumFieldNumericValueZero.ProtobufOutput -JsonInput.EnumFieldUnknownValue.Validator -JsonInput.FieldMask.ProtobufOutput -JsonInput.FieldMaskInvalidCharacter -JsonInput.FieldNameInLowerCamelCase.Validator -JsonInput.FieldNameInSnakeCase.JsonOutput -JsonInput.FieldNameInSnakeCase.ProtobufOutput -JsonInput.FloatFieldInfinityNotQuoted -JsonInput.FloatFieldNanNotQuoted -JsonInput.FloatFieldNegativeInfinityNotQuoted -JsonInput.FloatFieldTooLarge -JsonInput.FloatFieldTooSmall -JsonInput.Int32FieldExponentialFormat.JsonOutput -JsonInput.Int32FieldExponentialFormat.ProtobufOutput -JsonInput.Int32FieldFloatTrailingZero.JsonOutput -JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput -JsonInput.Int32FieldMaxFloatValue.JsonOutput -JsonInput.Int32FieldMaxFloatValue.ProtobufOutput -JsonInput.Int32FieldMinFloatValue.JsonOutput -JsonInput.Int32FieldMinFloatValue.ProtobufOutput -JsonInput.Int32FieldMinValue.JsonOutput -JsonInput.OriginalProtoFieldName.JsonOutput -JsonInput.OriginalProtoFieldName.ProtobufOutput -JsonInput.RepeatedFieldMessageElementIsNull -JsonInput.RepeatedFieldPrimitiveElementIsNull -JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool -JsonInput.StringFieldSurrogatePair.JsonOutput -JsonInput.StringFieldUnpairedLowSurrogate -JsonInput.Struct.JsonOutput -JsonInput.Struct.ProtobufOutput -JsonInput.TimestampJsonInputLowercaseT -JsonInput.Uint32FieldMaxFloatValue.JsonOutput -JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput -JsonInput.ValueAcceptBool.JsonOutput -JsonInput.ValueAcceptBool.ProtobufOutput -JsonInput.ValueAcceptFloat.JsonOutput -JsonInput.ValueAcceptFloat.ProtobufOutput -JsonInput.ValueAcceptInteger.JsonOutput -JsonInput.ValueAcceptInteger.ProtobufOutput -JsonInput.ValueAcceptList.JsonOutput -JsonInput.ValueAcceptList.ProtobufOutput -JsonInput.ValueAcceptNull.JsonOutput -JsonInput.ValueAcceptNull.ProtobufOutput -JsonInput.ValueAcceptObject.JsonOutput -JsonInput.ValueAcceptObject.ProtobufOutput -JsonInput.ValueAcceptString.JsonOutput -JsonInput.ValueAcceptString.ProtobufOutput -ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE -ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE -ProtobufInput.PrematureEofInPackedField.BOOL -ProtobufInput.PrematureEofInPackedField.DOUBLE -ProtobufInput.PrematureEofInPackedField.ENUM -ProtobufInput.PrematureEofInPackedField.FIXED32 -ProtobufInput.PrematureEofInPackedField.FIXED64 -ProtobufInput.PrematureEofInPackedField.FLOAT -ProtobufInput.PrematureEofInPackedField.INT32 -ProtobufInput.PrematureEofInPackedField.INT64 -ProtobufInput.PrematureEofInPackedField.SFIXED32 -ProtobufInput.PrematureEofInPackedField.SFIXED64 -ProtobufInput.PrematureEofInPackedField.SINT32 -ProtobufInput.PrematureEofInPackedField.SINT64 -ProtobufInput.PrematureEofInPackedField.UINT32 -ProtobufInput.PrematureEofInPackedField.UINT64 -TimestampProtoInputTooLarge.JsonOutput -TimestampProtoInputTooSmall.JsonOutput +Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput +Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput +Recommended.Proto3.JsonInput.DoubleFieldInfinityNotQuoted +Recommended.Proto3.JsonInput.DoubleFieldNanNotQuoted +Recommended.Proto3.JsonInput.DoubleFieldNegativeInfinityNotQuoted +Recommended.Proto3.JsonInput.FloatFieldInfinityNotQuoted +Recommended.Proto3.JsonInput.FloatFieldNanNotQuoted +Recommended.Proto3.JsonInput.FloatFieldNegativeInfinityNotQuoted +Required.Proto3.JsonInput.DoubleFieldTooSmall +Required.Proto3.JsonInput.FloatFieldTooLarge +Required.Proto3.JsonInput.FloatFieldTooSmall +Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool +Required.Proto3.JsonInput.TimestampJsonInputLowercaseT diff --git a/third_party/protobuf/conformance/failure_list_ruby.txt b/third_party/protobuf/conformance/failure_list_ruby.txt index 7c12da0611ff..fc6455d8e44e 100644 --- a/third_party/protobuf/conformance/failure_list_ruby.txt +++ b/third_party/protobuf/conformance/failure_list_ruby.txt @@ -1,199 +1,66 @@ -DurationProtoInputTooLarge.JsonOutput -DurationProtoInputTooSmall.JsonOutput -FieldMaskNumbersDontRoundTrip.JsonOutput -FieldMaskPathsDontRoundTrip.JsonOutput -FieldMaskTooManyUnderscore.JsonOutput -JsonInput.Any.JsonOutput -JsonInput.Any.ProtobufOutput -JsonInput.AnyNested.JsonOutput -JsonInput.AnyNested.ProtobufOutput -JsonInput.AnyUnorderedTypeTag.JsonOutput -JsonInput.AnyUnorderedTypeTag.ProtobufOutput -JsonInput.AnyWithDuration.JsonOutput -JsonInput.AnyWithDuration.ProtobufOutput -JsonInput.AnyWithFieldMask.JsonOutput -JsonInput.AnyWithFieldMask.ProtobufOutput -JsonInput.AnyWithInt32ValueWrapper.JsonOutput -JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput -JsonInput.AnyWithStruct.JsonOutput -JsonInput.AnyWithStruct.ProtobufOutput -JsonInput.AnyWithTimestamp.JsonOutput -JsonInput.AnyWithTimestamp.ProtobufOutput -JsonInput.AnyWithValueForInteger.JsonOutput -JsonInput.AnyWithValueForInteger.ProtobufOutput -JsonInput.AnyWithValueForJsonObject.JsonOutput -JsonInput.AnyWithValueForJsonObject.ProtobufOutput -JsonInput.BoolFieldIntegerOne -JsonInput.BoolFieldIntegerZero -JsonInput.DoubleFieldInfinity.JsonOutput -JsonInput.DoubleFieldInfinity.ProtobufOutput -JsonInput.DoubleFieldMaxNegativeValue.JsonOutput -JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput -JsonInput.DoubleFieldMaxPositiveValue.JsonOutput -JsonInput.DoubleFieldMaxPositiveValue.ProtobufOutput -JsonInput.DoubleFieldMinNegativeValue.JsonOutput -JsonInput.DoubleFieldMinNegativeValue.ProtobufOutput -JsonInput.DoubleFieldMinPositiveValue.JsonOutput -JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput -JsonInput.DoubleFieldNan.JsonOutput -JsonInput.DoubleFieldNan.ProtobufOutput -JsonInput.DoubleFieldNegativeInfinity.JsonOutput -JsonInput.DoubleFieldNegativeInfinity.ProtobufOutput -JsonInput.DoubleFieldQuotedValue.JsonOutput -JsonInput.DoubleFieldQuotedValue.ProtobufOutput -JsonInput.DurationHas3FractionalDigits.Validator -JsonInput.DurationHas6FractionalDigits.Validator -JsonInput.DurationHas9FractionalDigits.Validator -JsonInput.DurationHasZeroFractionalDigit.Validator -JsonInput.DurationMaxValue.JsonOutput -JsonInput.DurationMaxValue.ProtobufOutput -JsonInput.DurationMinValue.JsonOutput -JsonInput.DurationMinValue.ProtobufOutput -JsonInput.DurationRepeatedValue.JsonOutput -JsonInput.DurationRepeatedValue.ProtobufOutput -JsonInput.EnumFieldNumericValueNonZero.JsonOutput -JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput -JsonInput.EnumFieldNumericValueZero.JsonOutput -JsonInput.EnumFieldNumericValueZero.ProtobufOutput -JsonInput.EnumFieldUnknownValue.Validator -JsonInput.FieldMask.JsonOutput -JsonInput.FieldMask.ProtobufOutput -JsonInput.FieldNameInSnakeCase.JsonOutput -JsonInput.FieldNameWithMixedCases.JsonOutput -JsonInput.FieldNameWithMixedCases.ProtobufOutput -JsonInput.FieldNameWithMixedCases.Validator -JsonInput.FloatFieldInfinity.JsonOutput -JsonInput.FloatFieldInfinity.ProtobufOutput -JsonInput.FloatFieldNan.JsonOutput -JsonInput.FloatFieldNan.ProtobufOutput -JsonInput.FloatFieldNegativeInfinity.JsonOutput -JsonInput.FloatFieldNegativeInfinity.ProtobufOutput -JsonInput.FloatFieldQuotedValue.JsonOutput -JsonInput.FloatFieldQuotedValue.ProtobufOutput -JsonInput.FloatFieldTooLarge -JsonInput.FloatFieldTooSmall -JsonInput.Int32FieldExponentialFormat.JsonOutput -JsonInput.Int32FieldExponentialFormat.ProtobufOutput -JsonInput.Int32FieldFloatTrailingZero.JsonOutput -JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput -JsonInput.Int32FieldMaxFloatValue.JsonOutput -JsonInput.Int32FieldMaxFloatValue.ProtobufOutput -JsonInput.Int32FieldMinFloatValue.JsonOutput -JsonInput.Int32FieldMinFloatValue.ProtobufOutput -JsonInput.Int32FieldStringValue.JsonOutput -JsonInput.Int32FieldStringValue.ProtobufOutput -JsonInput.Int32FieldStringValueEscaped.JsonOutput -JsonInput.Int32FieldStringValueEscaped.ProtobufOutput -JsonInput.Int32MapEscapedKey.JsonOutput -JsonInput.Int32MapEscapedKey.ProtobufOutput -JsonInput.Int32MapField.JsonOutput -JsonInput.Int32MapField.ProtobufOutput -JsonInput.Int64FieldBeString.Validator -JsonInput.Int64FieldMaxValue.JsonOutput -JsonInput.Int64FieldMaxValue.ProtobufOutput -JsonInput.Int64FieldMinValue.JsonOutput -JsonInput.Int64FieldMinValue.ProtobufOutput -JsonInput.Int64MapEscapedKey.JsonOutput -JsonInput.Int64MapEscapedKey.ProtobufOutput -JsonInput.Int64MapField.JsonOutput -JsonInput.Int64MapField.ProtobufOutput -JsonInput.MessageField.JsonOutput -JsonInput.MessageField.ProtobufOutput -JsonInput.MessageMapField.JsonOutput -JsonInput.MessageMapField.ProtobufOutput -JsonInput.MessageRepeatedField.JsonOutput -JsonInput.MessageRepeatedField.ProtobufOutput -JsonInput.OptionalBoolWrapper.JsonOutput -JsonInput.OptionalBoolWrapper.ProtobufOutput -JsonInput.OptionalBytesWrapper.JsonOutput -JsonInput.OptionalBytesWrapper.ProtobufOutput -JsonInput.OptionalDoubleWrapper.JsonOutput -JsonInput.OptionalDoubleWrapper.ProtobufOutput -JsonInput.OptionalFloatWrapper.JsonOutput -JsonInput.OptionalFloatWrapper.ProtobufOutput -JsonInput.OptionalInt32Wrapper.JsonOutput -JsonInput.OptionalInt32Wrapper.ProtobufOutput -JsonInput.OptionalInt64Wrapper.JsonOutput -JsonInput.OptionalInt64Wrapper.ProtobufOutput -JsonInput.OptionalStringWrapper.JsonOutput -JsonInput.OptionalStringWrapper.ProtobufOutput -JsonInput.OptionalUint32Wrapper.JsonOutput -JsonInput.OptionalUint32Wrapper.ProtobufOutput -JsonInput.OptionalUint64Wrapper.JsonOutput -JsonInput.OptionalUint64Wrapper.ProtobufOutput -JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput -JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput -JsonInput.OriginalProtoFieldName.JsonOutput -JsonInput.PrimitiveRepeatedField.JsonOutput -JsonInput.PrimitiveRepeatedField.ProtobufOutput -JsonInput.RepeatedBoolWrapper.JsonOutput -JsonInput.RepeatedBoolWrapper.ProtobufOutput -JsonInput.RepeatedBytesWrapper.JsonOutput -JsonInput.RepeatedBytesWrapper.ProtobufOutput -JsonInput.RepeatedDoubleWrapper.JsonOutput -JsonInput.RepeatedDoubleWrapper.ProtobufOutput -JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt -JsonInput.RepeatedFloatWrapper.JsonOutput -JsonInput.RepeatedFloatWrapper.ProtobufOutput -JsonInput.RepeatedInt32Wrapper.JsonOutput -JsonInput.RepeatedInt32Wrapper.ProtobufOutput -JsonInput.RepeatedInt64Wrapper.JsonOutput -JsonInput.RepeatedInt64Wrapper.ProtobufOutput -JsonInput.RepeatedStringWrapper.JsonOutput -JsonInput.RepeatedStringWrapper.ProtobufOutput -JsonInput.RepeatedUint32Wrapper.JsonOutput -JsonInput.RepeatedUint32Wrapper.ProtobufOutput -JsonInput.RepeatedUint64Wrapper.JsonOutput -JsonInput.RepeatedUint64Wrapper.ProtobufOutput -JsonInput.StringFieldNotAString -JsonInput.StringFieldSurrogateInWrongOrder -JsonInput.StringFieldSurrogatePair.JsonOutput -JsonInput.StringFieldSurrogatePair.ProtobufOutput -JsonInput.StringFieldUnpairedHighSurrogate -JsonInput.StringFieldUnpairedLowSurrogate -JsonInput.Struct.JsonOutput -JsonInput.Struct.ProtobufOutput -JsonInput.TimestampHas3FractionalDigits.Validator -JsonInput.TimestampHas6FractionalDigits.Validator -JsonInput.TimestampHas9FractionalDigits.Validator -JsonInput.TimestampHasZeroFractionalDigit.Validator -JsonInput.TimestampMaxValue.JsonOutput -JsonInput.TimestampMaxValue.ProtobufOutput -JsonInput.TimestampMinValue.JsonOutput -JsonInput.TimestampMinValue.ProtobufOutput -JsonInput.TimestampRepeatedValue.JsonOutput -JsonInput.TimestampRepeatedValue.ProtobufOutput -JsonInput.TimestampWithNegativeOffset.JsonOutput -JsonInput.TimestampWithNegativeOffset.ProtobufOutput -JsonInput.TimestampWithPositiveOffset.JsonOutput -JsonInput.TimestampWithPositiveOffset.ProtobufOutput -JsonInput.TimestampZeroNormalized.Validator -JsonInput.Uint32FieldMaxFloatValue.JsonOutput -JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput -JsonInput.Uint32MapField.JsonOutput -JsonInput.Uint32MapField.ProtobufOutput -JsonInput.Uint64FieldBeString.Validator -JsonInput.Uint64FieldMaxValue.JsonOutput -JsonInput.Uint64FieldMaxValue.ProtobufOutput -JsonInput.Uint64MapField.JsonOutput -JsonInput.Uint64MapField.ProtobufOutput -JsonInput.ValueAcceptBool.JsonOutput -JsonInput.ValueAcceptBool.ProtobufOutput -JsonInput.ValueAcceptFloat.JsonOutput -JsonInput.ValueAcceptFloat.ProtobufOutput -JsonInput.ValueAcceptInteger.JsonOutput -JsonInput.ValueAcceptInteger.ProtobufOutput -JsonInput.ValueAcceptList.JsonOutput -JsonInput.ValueAcceptList.ProtobufOutput -JsonInput.ValueAcceptNull.JsonOutput -JsonInput.ValueAcceptNull.ProtobufOutput -JsonInput.ValueAcceptObject.JsonOutput -JsonInput.ValueAcceptObject.ProtobufOutput -JsonInput.ValueAcceptString.JsonOutput -JsonInput.ValueAcceptString.ProtobufOutput -ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput -ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput -ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput -ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput -TimestampProtoInputTooLarge.JsonOutput -TimestampProtoInputTooSmall.JsonOutput +Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput +Recommended.FieldMaskPathsDontRoundTrip.JsonOutput +Recommended.FieldMaskTooManyUnderscore.JsonOutput +Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput +Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput +Recommended.Proto3.JsonInput.DurationHas3FractionalDigits.Validator +Recommended.Proto3.JsonInput.DurationHas6FractionalDigits.Validator +Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter +Recommended.Proto3.JsonInput.MapFieldValueIsNull +Recommended.Proto3.JsonInput.RepeatedFieldMessageElementIsNull +Recommended.Proto3.JsonInput.RepeatedFieldPrimitiveElementIsNull +Recommended.Proto3.JsonInput.StringEndsWithEscapeChar +Recommended.Proto3.JsonInput.StringFieldSurrogateInWrongOrder +Recommended.Proto3.JsonInput.StringFieldUnpairedHighSurrogate +Recommended.Proto3.JsonInput.StringFieldUnpairedLowSurrogate +Recommended.Proto3.JsonInput.TimestampHas3FractionalDigits.Validator +Recommended.Proto3.JsonInput.TimestampHas6FractionalDigits.Validator +Required.DurationProtoInputTooLarge.JsonOutput +Required.DurationProtoInputTooSmall.JsonOutput +Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput +Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput +Required.Proto3.JsonInput.DoubleFieldMinPositiveValue.JsonOutput +Required.Proto3.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput +Required.Proto3.JsonInput.DoubleFieldNan.JsonOutput +Required.Proto3.JsonInput.DurationMinValue.JsonOutput +Required.Proto3.JsonInput.DurationRepeatedValue.JsonOutput +Required.Proto3.JsonInput.FloatFieldInfinity.JsonOutput +Required.Proto3.JsonInput.FloatFieldNan.JsonOutput +Required.Proto3.JsonInput.FloatFieldNegativeInfinity.JsonOutput +Required.Proto3.JsonInput.OneofFieldDuplicate +Required.Proto3.JsonInput.OptionalBoolWrapper.JsonOutput +Required.Proto3.JsonInput.OptionalBytesWrapper.JsonOutput +Required.Proto3.JsonInput.OptionalDoubleWrapper.JsonOutput +Required.Proto3.JsonInput.OptionalFloatWrapper.JsonOutput +Required.Proto3.JsonInput.OptionalInt32Wrapper.JsonOutput +Required.Proto3.JsonInput.OptionalInt64Wrapper.JsonOutput +Required.Proto3.JsonInput.OptionalStringWrapper.JsonOutput +Required.Proto3.JsonInput.OptionalUint32Wrapper.JsonOutput +Required.Proto3.JsonInput.OptionalUint64Wrapper.JsonOutput +Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput +Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput +Required.Proto3.JsonInput.RepeatedBoolWrapper.JsonOutput +Required.Proto3.JsonInput.RepeatedBytesWrapper.JsonOutput +Required.Proto3.JsonInput.RepeatedDoubleWrapper.JsonOutput +Required.Proto3.JsonInput.RepeatedFloatWrapper.JsonOutput +Required.Proto3.JsonInput.RepeatedInt32Wrapper.JsonOutput +Required.Proto3.JsonInput.RepeatedInt64Wrapper.JsonOutput +Required.Proto3.JsonInput.RepeatedStringWrapper.JsonOutput +Required.Proto3.JsonInput.RepeatedUint32Wrapper.JsonOutput +Required.Proto3.JsonInput.RepeatedUint64Wrapper.JsonOutput +Required.Proto3.JsonInput.StringFieldSurrogatePair.JsonOutput +Required.Proto3.JsonInput.StringFieldSurrogatePair.ProtobufOutput +Required.Proto3.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput +Required.Proto3.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput +Required.Proto3.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput +Required.Proto3.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput +Required.TimestampProtoInputTooLarge.JsonOutput +Required.TimestampProtoInputTooSmall.JsonOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonFalse.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonNull.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonNumber.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonObject.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonString.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonTrue.ProtobufOutput +Required.Proto3.JsonInput.RejectTopLevelNull diff --git a/third_party/protobuf/conformance/failure_list_ruby_mac.txt b/third_party/protobuf/conformance/failure_list_ruby_mac.txt new file mode 100644 index 000000000000..153b0a201947 --- /dev/null +++ b/third_party/protobuf/conformance/failure_list_ruby_mac.txt @@ -0,0 +1,66 @@ +Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput +Recommended.FieldMaskPathsDontRoundTrip.JsonOutput +Recommended.FieldMaskTooManyUnderscore.JsonOutput +Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput +Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput +Recommended.Proto3.JsonInput.DurationHas3FractionalDigits.Validator +Recommended.Proto3.JsonInput.DurationHas6FractionalDigits.Validator +Recommended.Proto3.JsonInput.MapFieldValueIsNull +Recommended.Proto3.JsonInput.RepeatedFieldMessageElementIsNull +Recommended.Proto3.JsonInput.RepeatedFieldPrimitiveElementIsNull +Recommended.Proto3.JsonInput.StringEndsWithEscapeChar +Recommended.Proto3.JsonInput.StringFieldSurrogateInWrongOrder +Recommended.Proto3.JsonInput.StringFieldUnpairedHighSurrogate +Recommended.Proto3.JsonInput.StringFieldUnpairedLowSurrogate +Recommended.Proto3.JsonInput.TimestampHas3FractionalDigits.Validator +Recommended.Proto3.JsonInput.TimestampHas6FractionalDigits.Validator +Required.DurationProtoInputTooLarge.JsonOutput +Required.DurationProtoInputTooSmall.JsonOutput +Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput +Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput +Required.Proto3.JsonInput.DoubleFieldMinPositiveValue.JsonOutput +Required.Proto3.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput +Required.Proto3.JsonInput.DoubleFieldNan.JsonOutput +Required.Proto3.JsonInput.DurationMinValue.JsonOutput +Required.Proto3.JsonInput.DurationRepeatedValue.JsonOutput +Required.Proto3.JsonInput.FloatFieldInfinity.JsonOutput +Required.Proto3.JsonInput.FloatFieldNan.JsonOutput +Required.Proto3.JsonInput.FloatFieldNegativeInfinity.JsonOutput +Required.Proto3.JsonInput.OneofFieldDuplicate +Required.Proto3.JsonInput.OptionalBoolWrapper.JsonOutput +Required.Proto3.JsonInput.OptionalBytesWrapper.JsonOutput +Required.Proto3.JsonInput.OptionalDoubleWrapper.JsonOutput +Required.Proto3.JsonInput.OptionalFloatWrapper.JsonOutput +Required.Proto3.JsonInput.OptionalInt32Wrapper.JsonOutput +Required.Proto3.JsonInput.OptionalInt64Wrapper.JsonOutput +Required.Proto3.JsonInput.OptionalStringWrapper.JsonOutput +Required.Proto3.JsonInput.OptionalUint32Wrapper.JsonOutput +Required.Proto3.JsonInput.OptionalUint64Wrapper.JsonOutput +Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput +Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput +Required.Proto3.JsonInput.RepeatedBoolWrapper.JsonOutput +Required.Proto3.JsonInput.RepeatedBytesWrapper.JsonOutput +Required.Proto3.JsonInput.RepeatedDoubleWrapper.JsonOutput +Required.Proto3.JsonInput.RepeatedFloatWrapper.JsonOutput +Required.Proto3.JsonInput.RepeatedInt32Wrapper.JsonOutput +Required.Proto3.JsonInput.RepeatedInt64Wrapper.JsonOutput +Required.Proto3.JsonInput.RepeatedStringWrapper.JsonOutput +Required.Proto3.JsonInput.RepeatedUint32Wrapper.JsonOutput +Required.Proto3.JsonInput.RepeatedUint64Wrapper.JsonOutput +Required.Proto3.JsonInput.StringFieldSurrogatePair.JsonOutput +Required.Proto3.JsonInput.StringFieldSurrogatePair.ProtobufOutput +Required.Proto3.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput +Required.Proto3.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput +Required.Proto3.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput +Required.Proto3.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput +Required.TimestampProtoInputTooLarge.JsonOutput +Required.TimestampProtoInputTooSmall.JsonOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonFalse.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonNull.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonNumber.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonObject.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonString.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonTrue.ProtobufOutput +Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter +Required.Proto3.JsonInput.RejectTopLevelNull diff --git a/third_party/protobuf/conformance/text_format_conformance_suite.cc b/third_party/protobuf/conformance/text_format_conformance_suite.cc new file mode 100644 index 000000000000..97b7b9072736 --- /dev/null +++ b/third_party/protobuf/conformance/text_format_conformance_suite.cc @@ -0,0 +1,317 @@ +// 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 "text_format_conformance_suite.h" + +#include "conformance_test.h" + +#include +#include +#include +#include + +using conformance::ConformanceRequest; +using conformance::ConformanceResponse; +using conformance::WireFormat; +using google::protobuf::Message; +using google::protobuf::TextFormat; +using protobuf_test_messages::proto2::TestAllTypesProto2; +using protobuf_test_messages::proto2::UnknownToTestAllTypes; +using protobuf_test_messages::proto3::TestAllTypesProto3; +using std::string; + +namespace google { +namespace protobuf { + +TextFormatConformanceTestSuite::TextFormatConformanceTestSuite() { + SetFailureListFlagName("--text_format_failure_list"); +} + +bool TextFormatConformanceTestSuite::ParseTextFormatResponse( + const ConformanceResponse& response, + const ConformanceRequestSetting& setting, Message* test_message) { + TextFormat::Parser parser; + const ConformanceRequest& request = setting.GetRequest(); + if (request.print_unknown_fields()) { + parser.AllowFieldNumber(true); + } + if (!parser.ParseFromString(response.text_payload(), test_message)) { + GOOGLE_LOG(ERROR) << "INTERNAL ERROR: internal text->protobuf transcode " + << "yielded unparseable proto. Text payload: " + << response.text_payload(); + return false; + } + + return true; +} + +bool TextFormatConformanceTestSuite::ParseResponse( + const ConformanceResponse& response, + const ConformanceRequestSetting& setting, Message* test_message) { + const ConformanceRequest& request = setting.GetRequest(); + WireFormat requested_output = request.requested_output_format(); + const string& test_name = setting.GetTestName(); + ConformanceLevel level = setting.GetLevel(); + + switch (response.result_case()) { + case ConformanceResponse::kProtobufPayload: { + if (requested_output != conformance::PROTOBUF) { + ReportFailure( + test_name, level, request, response, + StrCat("Test was asked for ", WireFormatToString(requested_output), + " output but provided PROTOBUF instead.") + .c_str()); + return false; + } + + if (!test_message->ParseFromString(response.protobuf_payload())) { + ReportFailure(test_name, level, request, response, + "Protobuf output we received from test was unparseable."); + return false; + } + + break; + } + + case ConformanceResponse::kTextPayload: { + if (requested_output != conformance::TEXT_FORMAT) { + ReportFailure( + test_name, level, request, response, + StrCat("Test was asked for ", WireFormatToString(requested_output), + " output but provided TEXT_FORMAT instead.") + .c_str()); + return false; + } + + if (!ParseTextFormatResponse(response, setting, test_message)) { + ReportFailure( + test_name, level, request, response, + "TEXT_FORMAT output we received from test was unparseable."); + return false; + } + + break; + } + + default: + GOOGLE_LOG(FATAL) << test_name + << ": unknown payload type: " << response.result_case(); + } + + return true; +} + +void TextFormatConformanceTestSuite::ExpectParseFailure(const string& test_name, + ConformanceLevel level, + const string& input) { + TestAllTypesProto3 prototype; + // We don't expect output, but if the program erroneously accepts the protobuf + // we let it send its response as this. We must not leave it unspecified. + ConformanceRequestSetting setting( + level, conformance::TEXT_FORMAT, conformance::TEXT_FORMAT, + conformance::TEXT_FORMAT_TEST, prototype, test_name, input); + const ConformanceRequest& request = setting.GetRequest(); + ConformanceResponse response; + string effective_test_name = StrCat(setting.ConformanceLevelToString(level), + ".Proto3.TextFormatInput.", test_name); + + RunTest(effective_test_name, request, &response); + if (response.result_case() == ConformanceResponse::kParseError) { + ReportSuccess(effective_test_name); + } else if (response.result_case() == ConformanceResponse::kSkipped) { + ReportSkip(effective_test_name, request, response); + } else { + ReportFailure(effective_test_name, level, request, response, + "Should have failed to parse, but didn't."); + } +} + +void TextFormatConformanceTestSuite::RunValidTextFormatTest( + const string& test_name, ConformanceLevel level, const string& input_text) { + TestAllTypesProto3 prototype; + RunValidTextFormatTestWithMessage(test_name, level, input_text, prototype); +} + +void TextFormatConformanceTestSuite::RunValidTextFormatTestProto2( + const string& test_name, ConformanceLevel level, const string& input_text) { + TestAllTypesProto2 prototype; + RunValidTextFormatTestWithMessage(test_name, level, input_text, prototype); +} + +void TextFormatConformanceTestSuite::RunValidTextFormatTestWithMessage( + const string& test_name, ConformanceLevel level, const string& input_text, + const Message& prototype) { + ConformanceRequestSetting setting1( + level, conformance::TEXT_FORMAT, conformance::PROTOBUF, + conformance::TEXT_FORMAT_TEST, prototype, test_name, input_text); + RunValidInputTest(setting1, input_text); + ConformanceRequestSetting setting2( + level, conformance::TEXT_FORMAT, conformance::TEXT_FORMAT, + conformance::TEXT_FORMAT_TEST, prototype, test_name, input_text); + RunValidInputTest(setting2, input_text); +} + +void TextFormatConformanceTestSuite::RunValidUnknownTextFormatTest( + const string& test_name, const Message& message) { + string serialized_input; + message.SerializeToString(&serialized_input); + TestAllTypesProto3 prototype; + ConformanceRequestSetting setting1( + RECOMMENDED, conformance::PROTOBUF, conformance::TEXT_FORMAT, + conformance::TEXT_FORMAT_TEST, prototype, test_name + "_Drop", + serialized_input); + setting1.SetPrototypeMessageForCompare(message); + RunValidBinaryInputTest(setting1, ""); + + ConformanceRequestSetting setting2( + RECOMMENDED, conformance::PROTOBUF, conformance::TEXT_FORMAT, + conformance::TEXT_FORMAT_TEST, prototype, test_name + "_Print", + serialized_input); + setting2.SetPrototypeMessageForCompare(message); + setting2.SetPrintUnknownFields(true); + RunValidBinaryInputTest(setting2, serialized_input); +} + +void TextFormatConformanceTestSuite::RunSuiteImpl() { + RunValidTextFormatTest("HelloWorld", REQUIRED, + "optional_string: 'Hello, World!'"); + // Integer fields. + RunValidTextFormatTest("Int32FieldMaxValue", REQUIRED, + "optional_int32: 2147483647"); + RunValidTextFormatTest("Int32FieldMinValue", REQUIRED, + "optional_int32: -2147483648"); + RunValidTextFormatTest("Uint32FieldMaxValue", REQUIRED, + "optional_uint32: 4294967295"); + RunValidTextFormatTest("Int64FieldMaxValue", REQUIRED, + "optional_int64: 9223372036854775807"); + RunValidTextFormatTest("Int64FieldMinValue", REQUIRED, + "optional_int64: -9223372036854775808"); + RunValidTextFormatTest("Uint64FieldMaxValue", REQUIRED, + "optional_uint64: 18446744073709551615"); + + // Parsers reject out-of-bound integer values. + ExpectParseFailure("Int32FieldTooLarge", REQUIRED, + "optional_int32: 2147483648"); + ExpectParseFailure("Int32FieldTooSmall", REQUIRED, + "optional_int32: -2147483649"); + ExpectParseFailure("Uint32FieldTooLarge", REQUIRED, + "optional_uint32: 4294967296"); + ExpectParseFailure("Int64FieldTooLarge", REQUIRED, + "optional_int64: 9223372036854775808"); + ExpectParseFailure("Int64FieldTooSmall", REQUIRED, + "optional_int64: -9223372036854775809"); + ExpectParseFailure("Uint64FieldTooLarge", REQUIRED, + "optional_uint64: 18446744073709551616"); + + // Floating point fields + RunValidTextFormatTest("FloatField", REQUIRED, + "optional_float: 3.192837"); + RunValidTextFormatTest("FloatFieldWithVeryPreciseNumber", REQUIRED, + "optional_float: 3.123456789123456789"); + RunValidTextFormatTest("FloatFieldMaxValue", REQUIRED, + "optional_float: 3.4028235e+38"); + RunValidTextFormatTest("FloatFieldMinValue", REQUIRED, + "optional_float: 1.17549e-38"); + RunValidTextFormatTest("FloatFieldNaNValue", REQUIRED, + "optional_float: NaN"); + RunValidTextFormatTest("FloatFieldPosInfValue", REQUIRED, + "optional_float: inf"); + RunValidTextFormatTest("FloatFieldNegInfValue", REQUIRED, + "optional_float: -inf"); + RunValidTextFormatTest("FloatFieldWithInt32Max", REQUIRED, + "optional_float: 4294967296"); + RunValidTextFormatTest("FloatFieldLargerThanInt64", REQUIRED, + "optional_float: 9223372036854775808"); + RunValidTextFormatTest("FloatFieldTooLarge", REQUIRED, + "optional_float: 3.4028235e+39"); + RunValidTextFormatTest("FloatFieldTooSmall", REQUIRED, + "optional_float: 1.17549e-39"); + RunValidTextFormatTest("FloatFieldLargerThanUint64", REQUIRED, + "optional_float: 18446744073709551616"); + + // Group fields + RunValidTextFormatTestProto2("GroupFieldNoColon", REQUIRED, + "Data { group_int32: 1 }"); + RunValidTextFormatTestProto2("GroupFieldWithColon", REQUIRED, + "Data: { group_int32: 1 }"); + RunValidTextFormatTestProto2("GroupFieldEmpty", REQUIRED, + "Data {}"); + + + // Unknown Fields + UnknownToTestAllTypes message; + // Unable to print unknown Fixed32/Fixed64 fields as if they are known. + // Fixed32/Fixed64 fields are not added in the tests. + message.set_optional_int32(123); + message.set_optional_string("hello"); + message.set_optional_bool(true); + RunValidUnknownTextFormatTest("ScalarUnknownFields", message); + + message.Clear(); + message.mutable_nested_message()->set_c(111); + RunValidUnknownTextFormatTest("MessageUnknownFields", message); + + message.Clear(); + message.mutable_optionalgroup()->set_a(321); + RunValidUnknownTextFormatTest("GroupUnknownFields", message); + + message.add_repeated_int32(1); + message.add_repeated_int32(2); + message.add_repeated_int32(3); + RunValidUnknownTextFormatTest("RepeatedUnknownFields", message); + + // Any fields + RunValidTextFormatTest("AnyField", REQUIRED, + R"( + optional_any: { + [type.googleapis.com/protobuf_test_messages.proto3.TestAllTypesProto3] { + optional_int32: 12345 + } + } + )"); + RunValidTextFormatTest("AnyFieldWithRawBytes", REQUIRED, + R"( + optional_any: { + type_url: "type.googleapis.com/protobuf_test_messages.proto3.TestAllTypesProto3" + value: "\b\271`" + } + )"); + ExpectParseFailure("AnyFieldWithInvalidType", REQUIRED, + R"( + optional_any: { + [type.googleapis.com/unknown] { + optional_int32: 12345 + } + } + )"); +} + +} // namespace protobuf +} // namespace google diff --git a/third_party/protobuf/conformance/text_format_conformance_suite.h b/third_party/protobuf/conformance/text_format_conformance_suite.h new file mode 100644 index 000000000000..dd258f50b8ab --- /dev/null +++ b/third_party/protobuf/conformance/text_format_conformance_suite.h @@ -0,0 +1,69 @@ +// 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 TEXT_FORMAT_CONFORMANCE_SUITE_H_ +#define TEXT_FORMAT_CONFORMANCE_SUITE_H_ + +#include "conformance_test.h" + +namespace google { +namespace protobuf { + +class TextFormatConformanceTestSuite : public ConformanceTestSuite { + public: + TextFormatConformanceTestSuite(); + + private: + void RunSuiteImpl(); + void RunValidTextFormatTest(const string& test_name, ConformanceLevel level, + const string& input); + void RunValidTextFormatTestProto2(const string& test_name, + ConformanceLevel level, + const string& input); + void RunValidTextFormatTestWithMessage(const string& test_name, + ConformanceLevel level, + const string& input_text, + const Message& prototype); + void RunValidUnknownTextFormatTest(const string& test_name, + const Message& message); + void ExpectParseFailure(const string& test_name, ConformanceLevel level, + const string& input); + bool ParseTextFormatResponse(const conformance::ConformanceResponse& response, + const ConformanceRequestSetting& setting, + Message* test_message); + bool ParseResponse(const conformance::ConformanceResponse& response, + const ConformanceRequestSetting& setting, + Message* test_message) override; +}; + +} // namespace protobuf +} // namespace google + +#endif // TEXT_FORMAT_CONFORMANCE_SUITE_H_ diff --git a/third_party/protobuf/conformance/text_format_failure_list_csharp.txt b/third_party/protobuf/conformance/text_format_failure_list_csharp.txt new file mode 100644 index 000000000000..404b64a58431 --- /dev/null +++ b/third_party/protobuf/conformance/text_format_failure_list_csharp.txt @@ -0,0 +1,8 @@ +Recommended.Proto3.ProtobufInput.GroupUnknownFields_Drop.TextFormatOutput +Recommended.Proto3.ProtobufInput.GroupUnknownFields_Print.TextFormatOutput +Recommended.Proto3.ProtobufInput.MessageUnknownFields_Drop.TextFormatOutput +Recommended.Proto3.ProtobufInput.MessageUnknownFields_Print.TextFormatOutput +Recommended.Proto3.ProtobufInput.RepeatedUnknownFields_Drop.TextFormatOutput +Recommended.Proto3.ProtobufInput.RepeatedUnknownFields_Print.TextFormatOutput +Recommended.Proto3.ProtobufInput.ScalarUnknownFields_Drop.TextFormatOutput +Recommended.Proto3.ProtobufInput.ScalarUnknownFields_Print.TextFormatOutput diff --git a/third_party/protobuf/conformance/text_format_failure_list_java.txt b/third_party/protobuf/conformance/text_format_failure_list_java.txt new file mode 100755 index 000000000000..81433b441a4e --- /dev/null +++ b/third_party/protobuf/conformance/text_format_failure_list_java.txt @@ -0,0 +1,6 @@ +Recommended.Proto3.ProtobufInput.GroupUnknownFields_Drop.TextFormatOutput +Recommended.Proto3.ProtobufInput.MessageUnknownFields_Drop.TextFormatOutput +Recommended.Proto3.ProtobufInput.RepeatedUnknownFields_Drop.TextFormatOutput +Recommended.Proto3.ProtobufInput.ScalarUnknownFields_Drop.TextFormatOutput +Required.Proto3.TextFormatInput.AnyField.ProtobufOutput +Required.Proto3.TextFormatInput.AnyField.TextFormatOutput diff --git a/third_party/protobuf/conformance/text_format_failure_list_php.txt b/third_party/protobuf/conformance/text_format_failure_list_php.txt new file mode 100644 index 000000000000..404b64a58431 --- /dev/null +++ b/third_party/protobuf/conformance/text_format_failure_list_php.txt @@ -0,0 +1,8 @@ +Recommended.Proto3.ProtobufInput.GroupUnknownFields_Drop.TextFormatOutput +Recommended.Proto3.ProtobufInput.GroupUnknownFields_Print.TextFormatOutput +Recommended.Proto3.ProtobufInput.MessageUnknownFields_Drop.TextFormatOutput +Recommended.Proto3.ProtobufInput.MessageUnknownFields_Print.TextFormatOutput +Recommended.Proto3.ProtobufInput.RepeatedUnknownFields_Drop.TextFormatOutput +Recommended.Proto3.ProtobufInput.RepeatedUnknownFields_Print.TextFormatOutput +Recommended.Proto3.ProtobufInput.ScalarUnknownFields_Drop.TextFormatOutput +Recommended.Proto3.ProtobufInput.ScalarUnknownFields_Print.TextFormatOutput diff --git a/third_party/protobuf/conformance/text_format_failure_list_python.txt b/third_party/protobuf/conformance/text_format_failure_list_python.txt new file mode 100644 index 000000000000..b2db95e7de3f --- /dev/null +++ b/third_party/protobuf/conformance/text_format_failure_list_python.txt @@ -0,0 +1,5 @@ +# This is the list of text format conformance tests that are known to fail right +# now. +# TODO: These should be fixed. +Required.Proto3.TextFormatInput.FloatFieldMaxValue.ProtobufOutput +Required.Proto3.TextFormatInput.FloatFieldMaxValue.TextFormatOutput diff --git a/third_party/protobuf/conformance/text_format_failure_list_ruby.txt b/third_party/protobuf/conformance/text_format_failure_list_ruby.txt new file mode 100644 index 000000000000..404b64a58431 --- /dev/null +++ b/third_party/protobuf/conformance/text_format_failure_list_ruby.txt @@ -0,0 +1,8 @@ +Recommended.Proto3.ProtobufInput.GroupUnknownFields_Drop.TextFormatOutput +Recommended.Proto3.ProtobufInput.GroupUnknownFields_Print.TextFormatOutput +Recommended.Proto3.ProtobufInput.MessageUnknownFields_Drop.TextFormatOutput +Recommended.Proto3.ProtobufInput.MessageUnknownFields_Print.TextFormatOutput +Recommended.Proto3.ProtobufInput.RepeatedUnknownFields_Drop.TextFormatOutput +Recommended.Proto3.ProtobufInput.RepeatedUnknownFields_Print.TextFormatOutput +Recommended.Proto3.ProtobufInput.ScalarUnknownFields_Drop.TextFormatOutput +Recommended.Proto3.ProtobufInput.ScalarUnknownFields_Print.TextFormatOutput diff --git a/third_party/protobuf/conformance/third_party/jsoncpp/json.h b/third_party/protobuf/conformance/third_party/jsoncpp/json.h index 42e7e7f4ad03..32fd0720d4f3 100644 --- a/third_party/protobuf/conformance/third_party/jsoncpp/json.h +++ b/third_party/protobuf/conformance/third_party/jsoncpp/json.h @@ -6,28 +6,28 @@ // ////////////////////////////////////////////////////////////////////// /* -The JsonCpp library's source code, including accompanying documentation, +The JsonCpp library's source code, including accompanying documentation, tests and demonstration applications, are licensed under the following conditions... -The author (Baptiste Lepilleur) explicitly disclaims copyright in all -jurisdictions which recognize such a disclaimer. In such jurisdictions, +The author (Baptiste Lepilleur) explicitly disclaims copyright in all +jurisdictions which recognize such a disclaimer. In such jurisdictions, this software is released into the Public Domain. In jurisdictions which do not recognize Public Domain property (e.g. Germany as of 2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is released under the terms of the MIT License (see below). -In jurisdictions which recognize Public Domain property, the user of this -software may choose to accept it either as 1) Public Domain, 2) under the -conditions of the MIT License (see below), or 3) under the terms of dual +In jurisdictions which recognize Public Domain property, the user of this +software may choose to accept it either as 1) Public Domain, 2) under the +conditions of the MIT License (see below), or 3) under the terms of dual Public Domain/MIT License conditions described here, as they choose. The MIT License is about as close to Public Domain as a license can get, and is described in clear, concise terms at: http://en.wikipedia.org/wiki/MIT_License - + The full text of the MIT License follows: ======================================================================== @@ -434,7 +434,7 @@ class JSON_API Exception : public std::exception { /** Exceptions which the user cannot easily avoid. * * E.g. out-of-memory (when we use malloc), stack-overflow, malicious input - * + * * \remark derived from Json::Exception */ class JSON_API RuntimeError : public Exception { @@ -445,7 +445,7 @@ class JSON_API RuntimeError : public Exception { /** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros. * * These are precondition-violations (user bugs) and internal errors (our bugs). - * + * * \remark derived from Json::Exception */ class JSON_API LogicError : public Exception { @@ -1570,7 +1570,7 @@ class JSON_API CharReaderBuilder : public CharReader::Factory { - `"rejectDupKeys": false or true` - If true, `parse()` returns false when a key is duplicated within an object. - `"allowSpecialFloats": false or true` - - If true, special float values (NaNs and infinities) are allowed + - If true, special float values (NaNs and infinities) are allowed and their values are lossfree restorable. You can examine 'settings_` yourself diff --git a/third_party/protobuf/conformance/third_party/jsoncpp/jsoncpp.cpp b/third_party/protobuf/conformance/third_party/jsoncpp/jsoncpp.cpp index f803962adeaa..4d3e0f2f3155 100644 --- a/third_party/protobuf/conformance/third_party/jsoncpp/jsoncpp.cpp +++ b/third_party/protobuf/conformance/third_party/jsoncpp/jsoncpp.cpp @@ -6,28 +6,28 @@ // ////////////////////////////////////////////////////////////////////// /* -The JsonCpp library's source code, including accompanying documentation, +The JsonCpp library's source code, including accompanying documentation, tests and demonstration applications, are licensed under the following conditions... -The author (Baptiste Lepilleur) explicitly disclaims copyright in all -jurisdictions which recognize such a disclaimer. In such jurisdictions, +The author (Baptiste Lepilleur) explicitly disclaims copyright in all +jurisdictions which recognize such a disclaimer. In such jurisdictions, this software is released into the Public Domain. In jurisdictions which do not recognize Public Domain property (e.g. Germany as of 2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is released under the terms of the MIT License (see below). -In jurisdictions which recognize Public Domain property, the user of this -software may choose to accept it either as 1) Public Domain, 2) under the -conditions of the MIT License (see below), or 3) under the terms of dual +In jurisdictions which recognize Public Domain property, the user of this +software may choose to accept it either as 1) Public Domain, 2) under the +conditions of the MIT License (see below), or 3) under the terms of dual Public Domain/MIT License conditions described here, as they choose. The MIT License is about as close to Public Domain as a license can get, and is described in clear, concise terms at: http://en.wikipedia.org/wiki/MIT_License - + The full text of the MIT License follows: ======================================================================== @@ -207,7 +207,7 @@ static inline void fixNumericLocale(char* begin, char* end) { #include #if defined(_MSC_VER) -#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above +#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above #define snprintf sprintf_s #elif _MSC_VER >= 1900 // VC++ 14.0 and above #define snprintf std::snprintf @@ -4029,7 +4029,7 @@ Value& Path::make(Value& root) const { #define snprintf std::snprintf #endif -#if defined(__BORLANDC__) +#if defined(__BORLANDC__) #include #define isfinite _finite #define snprintf _snprintf @@ -5096,7 +5096,7 @@ StreamWriter* StreamWriterBuilder::newStreamWriter() const std::string cs_str = settings_["commentStyle"].asString(); bool eyc = settings_["enableYAMLCompatibility"].asBool(); bool dnp = settings_["dropNullPlaceholders"].asBool(); - bool usf = settings_["useSpecialFloats"].asBool(); + bool usf = settings_["useSpecialFloats"].asBool(); unsigned int pre = settings_["precision"].asUInt(); CommentStyle::Enum cs = CommentStyle::All; if (cs_str == "All") { diff --git a/third_party/protobuf/conformance/update_failure_list.py b/third_party/protobuf/conformance/update_failure_list.py new file mode 100755 index 000000000000..ad42ed3c187a --- /dev/null +++ b/third_party/protobuf/conformance/update_failure_list.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python +# 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. + +"""Script to update a failure list file to add/remove failures. + +This is sort of like comm(1), except it recognizes comments and ignores them. +""" + +import argparse + +parser = argparse.ArgumentParser( + description='Adds/removes failures from the failure list.') +parser.add_argument('filename', type=str, help='failure list file to update') +parser.add_argument('--add', dest='add_list', action='append') +parser.add_argument('--remove', dest='remove_list', action='append') + +args = parser.parse_args() + +add_set = set() +remove_set = set() + +for add_file in (args.add_list or []): + with open(add_file) as f: + for line in f: + add_set.add(line) + +for remove_file in (args.remove_list or []): + with open(remove_file) as f: + for line in f: + if line in add_set: + raise Exception("Asked to both add and remove test: " + line) + remove_set.add(line.strip()) + +add_list = sorted(add_set, reverse=True) + +with open(args.filename) as in_file: + existing_list = in_file.read() + +with open(args.filename, "w") as f: + for line in existing_list.splitlines(True): + test = line.split("#")[0].strip() + while len(add_list) > 0 and test > add_list[-1]: + f.write(add_list.pop()) + if test not in remove_set: + f.write(line) diff --git a/third_party/protobuf/csharp/.gitignore b/third_party/protobuf/csharp/.gitignore index c88f741e37a1..d0d7ae04f73b 100644 --- a/third_party/protobuf/csharp/.gitignore +++ b/third_party/protobuf/csharp/.gitignore @@ -1,16 +1,10 @@ -# -# Untracked directories -# -src/AddressBook/bin -src/AddressBook/obj -src/Google.Protobuf/bin/ -src/Google.Protobuf/obj/ -src/Google.Protobuf.Conformance/bin/ -src/Google.Protobuf.Conformance/obj/ -src/Google.Protobuf.Test/bin/ -src/Google.Protobuf.Test/obj/ -src/Google.Protobuf.JsonDump/bin/ -src/Google.Protobuf.JsonDump/obj/ +# Output +bin +obj +project.lock.json +TestResult.xml + +# Possibly legacy now? mono/bin mono/tmp mono/protoc @@ -23,6 +17,7 @@ lib/NUnit # # Untracked files # +.vs *.user *.suo *.nupkg @@ -34,3 +29,6 @@ mono/*.exe mono/*.dll lib/protoc.exe *.ncrunch* + +# Benchmark output +BenchmarkDotNet.Artifacts/ diff --git a/third_party/protobuf/csharp/CHANGES.txt b/third_party/protobuf/csharp/CHANGES.txt index a87cd4d5dfcf..8574b7c4a35d 100644 --- a/third_party/protobuf/csharp/CHANGES.txt +++ b/third_party/protobuf/csharp/CHANGES.txt @@ -26,7 +26,7 @@ Changes: - Optimized enum parsing. Fixes: -- Fix for bug in limited input stream's Position, Introduced Position on +- Fix for bug in limited input stream's Position, Introduced Position on output stream - Fix for writing a character to a JSON output overflows allocated buffer - Optimize FromBase64String to return Empty when presented with empty string. @@ -47,14 +47,14 @@ Changes: - Added 'Unsafe' static type in ByteString to allow direct buffer access Fixes: -- Issue 50: The XML serializer will fail to deserialize a message with empty +- Issue 50: The XML serializer will fail to deserialize a message with empty child message - Issue 45: Use of 'item' as a field name causes AmbiguousMatchException - Issue 49: Generated nested static Types class should be partial - Issue 38: Disable CLSCompliant warnings (3021) - Issue 40: proto_path does not work for command-line file names - Issue 54: should retire all bytes in buffer (bufferSize) -- Issue 43: Fix to correct identical 'umbrella_classname' options from trying +- Issue 43: Fix to correct identical 'umbrella_classname' options from trying to write to the same filename. =============================================================================== @@ -66,7 +66,7 @@ Features: NONE, GENERIC, INTERFACE, or IRPCDISPATCH - Added interfaces IRpcDispatch and IRpcServerStub to provide for blocking services and implementations. -- Added ProtoGen.exe command-line argument "--protoc_dir=" to specify the +- Added ProtoGen.exe command-line argument "--protoc_dir=" to specify the location of protoc.exe. - Extracted interfaces for ICodedInputStream and ICodedOutputStream to allow custom implementation of writers with both speed and size optimizations. @@ -86,9 +86,9 @@ Fixes: - Issue 16: Does not integrate well with other tooling - Issue 19: Support for negative enum values - Issue 26: AddRange in GeneratedBuilder iterates twice. -- Issue 27: Remove XML documentation output from test projects to clear +- Issue 27: Remove XML documentation output from test projects to clear warnings/errors. -- Issue 28: Circular message dependencies result in null default values for +- Issue 28: Circular message dependencies result in null default values for Message fields. - Issue 29: Message classes generated have a public default constructor. You can disable private ctor generation with the option generate_private_ctor. @@ -109,14 +109,14 @@ RELEASE NOTES - Version 2.3.0.277 =============================================================================== Features: -- Added cls_compliance option to generate attributes indicating +- Added cls_compliance option to generate attributes indicating non-CLS-compliance. - Added file_extension option to control the generated output file's extension. - Added umbrella_namespace option to place the umbrella class into a nested - namespace to address issues with proto files having the same name as a + namespace to address issues with proto files having the same name as a message it contains. - Added output_directory option to set the output path for the source file(s). -- Added ignore_google_protobuf option to avoid generating code for includes +- Added ignore_google_protobuf option to avoid generating code for includes from the google.protobuf package. - Added the LITE framework (Google.ProtoBuffersLite.dll) and the ability to generate code with "option optimize_for = LITE_RUNTIME;". diff --git a/third_party/protobuf/csharp/Google.Protobuf.Tools.nuspec b/third_party/protobuf/csharp/Google.Protobuf.Tools.nuspec index e4240dae8756..237a7e831f37 100644 --- a/third_party/protobuf/csharp/Google.Protobuf.Tools.nuspec +++ b/third_party/protobuf/csharp/Google.Protobuf.Tools.nuspec @@ -1,37 +1,39 @@ - + Google.Protobuf.Tools Google Protocol Buffers tools Tools for Protocol Buffers - Google's data interchange format. See project site for more info. - 3.0.0-beta3 + 3.9.0 Google Inc. protobuf-packages - https://github.com/google/protobuf/blob/master/LICENSE - https://github.com/google/protobuf + https://github.com/protocolbuffers/protobuf/blob/master/LICENSE + https://github.com/protocolbuffers/protobuf false Tools for Protocol Buffers Copyright 2015, Google Inc. Protocol Buffers Binary Serialization Format Google proto proto3 - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/third_party/protobuf/csharp/README.md b/third_party/protobuf/csharp/README.md index 8c3993e0149d..9aab782da19a 100644 --- a/third_party/protobuf/csharp/README.md +++ b/third_party/protobuf/csharp/README.md @@ -1,19 +1,16 @@ This directory contains the C# Protocol Buffers runtime library. -Status: Beta - ready for external testing -========================================= - Usage ===== The easiest way how to use C# protobufs is via the `Google.Protobuf` NuGet package. Just add the NuGet package to your VS project. -Besides C# runtime library, the NuGet package also contains -precompiled version of `protoc.exe` and a copy of well known `.proto` +You will also want to install the `Google.Protobuf.Tools` NuGet package, which +contains precompiled version of `protoc.exe` and a copy of well known `.proto` files under the package's `tools` directory. -To generate C# files from your `.proto` files, invoke `protoc` with the +To generate C# files from your `.proto` files, invoke `protoc` with the `--csharp_out` option. Supported platforms @@ -34,16 +31,45 @@ which only uses features from C# 3 and earlier. Building ======== -Open the `src/Google.Protobuf.sln` solution in Visual Studio 2015 or -later. You should be able to run the NUnit test from Test Explorer -(you might need to install NUnit Visual Studio add-in). +Open the `src/Google.Protobuf.sln` solution in Visual Studio 2017 or +later. Although *users* of this project are only expected to have Visual Studio 2012 or later, *developers* of the library are required to -have Visual Studio 2015 or later, as the library uses C# 6 features -in its implementation. These features have no impact when using the -compiled code - they're only relevant when building the -`Google.Protobuf` assembly. +have Visual Studio 2017 or later, as the library uses C# 6 features +in its implementation, as well as the new Visual Studio 2017 csproj +format. These features have no impact when using the compiled code - +they're only relevant when building the `Google.Protobuf` assembly. + +In order to run and debug the AddressBook example in the IDE, you must +install the optional component, ".Net Core 1.0 - 1.1 development tools +for Web" (as it's labelled in current versions of the VS2017 +installer), above and beyond the main .NET Core cross-platform +development feature. + +Testing +======= + +The unit tests use [NUnit 3](https://github.com/nunit/nunit). Tests can be +run using the Visual Studio Test Explorer or `dotnet test`. + +.NET 3.5 +======== + +We don't officially support .NET 3.5. However, there has been some effort +to make enabling .NET 3.5 support relatively painless in case you require it. +There's no guarantee that this will continue in the future, so rely on .NET +3.5 support at your peril. + +To enable .NET 3.5 support, you must edit the `TargetFrameworks` elements of +[src/Google.Protobuf/Google.Protobuf.csproj](src/Google.Protobuf/Google.Protobuf.csproj) +(and [src/Google.Protobuf.Test/Google.Protobuf.Test.csproj](src/Google.Protobuf.Test/Google.Protobuf.Test.csproj) +if you want to run the unit tests): + +Open the .csproj file in a text editor and simply add `net35` to the list of +target frameworks, noting that the `TargetFrameworks` element appears twice in +the file (once in the first `PropertyGroup` element, and again in the second +`PropertyGroup` element, i.e., the one with the conditional). History of C# protobufs ======================= @@ -51,7 +77,7 @@ History of C# protobufs This subtree was originally imported from https://github.com/jskeet/protobuf-csharp-port and represents the latest development version of C# protobufs, that will now be developed and maintained by Google. All the development will be done in open, under this repository -(https://github.com/google/protobuf). +(https://github.com/protocolbuffers/protobuf). The previous project differs from this project in a number of ways: diff --git a/third_party/protobuf/csharp/build_packages.bat b/third_party/protobuf/csharp/build_packages.bat index 1502f0634b78..d7205659f103 100644 --- a/third_party/protobuf/csharp/build_packages.bat +++ b/third_party/protobuf/csharp/build_packages.bat @@ -1,10 +1,7 @@ @rem Builds Google.Protobuf NuGet packages -@rem Adjust the location of nuget.exe -set NUGET=C:\nuget\nuget.exe - -@rem Build src/Google.Protobuf.sln solution in Release configuration first. -%NUGET% pack src\Google.Protobuf\Google.Protobuf.nuspec -Symbols || goto :error +dotnet restore src/Google.Protobuf.sln +dotnet pack -c Release src/Google.Protobuf.sln || goto :error goto :EOF diff --git a/third_party/protobuf/csharp/build_tools.sh b/third_party/protobuf/csharp/build_tools.sh new file mode 100755 index 000000000000..182c5c5c82ea --- /dev/null +++ b/third_party/protobuf/csharp/build_tools.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +if [ $# -ne 1 ]; then + cat < + +Example: + $ $0 3.0.0 + +This script will download pre-built protoc binaries from maven repository and +create the Google.Protobuf.Tools package. Well-known type .proto files will also +be included. +EOF + exit 1 +fi + +VERSION_NUMBER=$1 +# pairs. +declare -a FILE_NAMES=( \ + windows_x86 windows-x86_32.exe \ + windows_x64 windows-x86_64.exe \ + macosx_x86 osx-x86_32.exe \ + macosx_x64 osx-x86_64.exe \ + linux_x86 linux-x86_32.exe \ + linux_x64 linux-x86_64.exe \ +) + +set -e + +mkdir -p protoc +# Create a zip file for each binary. +for((i=0;i<${#FILE_NAMES[@]};i+=2));do + DIR_NAME=${FILE_NAMES[$i]} + mkdir -p protoc/$DIR_NAME + + if [ ${DIR_NAME:0:3} = "win" ]; then + TARGET_BINARY="protoc.exe" + else + TARGET_BINARY="protoc" + fi + + BINARY_NAME=${FILE_NAMES[$(($i+1))]} + BINARY_URL=http://repo1.maven.org/maven2/com/google/protobuf/protoc/${VERSION_NUMBER}/protoc-${VERSION_NUMBER}-${BINARY_NAME} + + if ! wget ${BINARY_URL} -O protoc/$DIR_NAME/$TARGET_BINARY &> /dev/null; then + echo "[ERROR] Failed to download ${BINARY_URL}" >&2 + echo "[ERROR] Skipped $protoc-${VERSION_NAME}-${DIR_NAME}" >&2 + continue + fi +done + +nuget pack Google.Protobuf.Tools.nuspec diff --git a/third_party/protobuf/csharp/buildall.bat b/third_party/protobuf/csharp/buildall.bat new file mode 100644 index 000000000000..821ffb3102be --- /dev/null +++ b/third_party/protobuf/csharp/buildall.bat @@ -0,0 +1,13 @@ +@rem Builds Google.Protobuf and runs the tests + +dotnet build src/Google.Protobuf.sln || goto :error + +echo Running tests. + +dotnet test src/Google.Protobuf.Test/Google.Protobuf.Test.csproj || goto :error + +goto :EOF + +:error +echo Failed! +exit /b %errorlevel% diff --git a/third_party/protobuf/csharp/buildall.sh b/third_party/protobuf/csharp/buildall.sh index 45af705f3857..43b5ac3ffb29 100755 --- a/third_party/protobuf/csharp/buildall.sh +++ b/third_party/protobuf/csharp/buildall.sh @@ -1,17 +1,17 @@ #!/bin/bash -# Use mono to build solution and run all tests. -# Adjust these to reflect the location of nunit-console in your system. -NUNIT_CONSOLE=nunit-console - -# The rest you can leave intact CONFIG=Release SRC=$(dirname $0)/src set -ex -echo Building the solution. -xbuild /p:Configuration=$CONFIG $SRC/Google.Protobuf.sln +echo Building relevant projects. +dotnet restore $SRC/Google.Protobuf.sln +dotnet build -c $CONFIG $SRC/Google.Protobuf.sln echo Running tests. -$NUNIT_CONSOLE $SRC/Google.Protobuf.Test/bin/$CONFIG/Google.Protobuf.Test.dll +# Only test netcoreapp2.1, which uses the .NET Core runtime. +# If we want to test the .NET 4.5 version separately, we could +# run Mono explicitly. However, we don't have any differences between +# the .NET 4.5 and netstandard2.1 assemblies. +dotnet test -c $CONFIG -f netcoreapp2.1 $SRC/Google.Protobuf.Test/Google.Protobuf.Test.csproj diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/protos/csharp/protos/unittest_issues.proto b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/protos/csharp/protos/unittest_issues.proto new file mode 100644 index 000000000000..b6178bf1af69 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/protos/csharp/protos/unittest_issues.proto @@ -0,0 +1,126 @@ +syntax = "proto3"; + +// These proto descriptors have at one time been reported as an issue or defect. +// They are kept here to replicate the issue, and continue to verify the fix. + +// Issue: Non-"Google.Protobuffers" namespace will ensure that protobuffer library types are qualified +option csharp_namespace = "UnitTest.Issues.TestProtos"; + +package unittest_issues; +option optimize_for = SPEED; + +// Issue 307: when generating doubly-nested types, any references +// should be of the form A.Types.B.Types.C. +message Issue307 { + message NestedOnce { + message NestedTwice { + } + } +} + +// Old issue 13: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=13 +// New issue 309: https://github.com/protocolbuffers/protobuf/issues/309 + +// message A { +// optional int32 _A = 1; +// } + +// message B { +// optional int32 B_ = 1; +// } + +//message AB { +// optional int32 a_b = 1; +//} + +// Similar issue with numeric names +// Java code failed too, so probably best for this to be a restriction. +// See https://github.com/protocolbuffers/protobuf/issues/308 +// message NumberField { +// optional int32 _01 = 1; +// } + +// issue 19 - negative enum values + +enum NegativeEnum { + NEGATIVE_ENUM_ZERO = 0; + FiveBelow = -5; + MinusOne = -1; +} + +message NegativeEnumMessage { + NegativeEnum value = 1; + repeated NegativeEnum values = 2 [packed = false]; + repeated NegativeEnum packed_values = 3 [packed=true]; +} + +// Issue 21: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=21 +// Decorate fields with [deprecated=true] as [System.Obsolete] + +message DeprecatedChild { +} + +enum DeprecatedEnum { + DEPRECATED_ZERO = 0; + one = 1; +} + +message DeprecatedFieldsMessage { + int32 PrimitiveValue = 1 [deprecated = true]; + repeated int32 PrimitiveArray = 2 [deprecated = true]; + + DeprecatedChild MessageValue = 3 [deprecated = true]; + repeated DeprecatedChild MessageArray = 4 [deprecated = true]; + + DeprecatedEnum EnumValue = 5 [deprecated = true]; + repeated DeprecatedEnum EnumArray = 6 [deprecated = true]; +} + +// Issue 45: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=45 +message ItemField { + int32 item = 1; +} + +message ReservedNames { + // Force a nested type called Types + message SomeNestedType { + } + + int32 types = 1; + int32 descriptor = 2; +} + +message TestJsonFieldOrdering { + // These fields are deliberately not declared in numeric + // order, and the oneof fields aren't contiguous either. + // This allows for reasonably robust tests of JSON output + // ordering. + // TestFieldOrderings in unittest_proto3.proto is similar, + // but doesn't include oneofs. + // TODO: Consider adding oneofs to TestFieldOrderings, although + // that will require fixing other tests in multiple platforms. + // Alternatively, consider just adding this to + // unittest_proto3.proto if multiple platforms want it. + + int32 plain_int32 = 4; + + oneof o1 { + string o1_string = 2; + int32 o1_int32 = 5; + } + + string plain_string = 1; + + oneof o2 { + int32 o2_int32 = 6; + string o2_string = 3; + } + +} + +message TestJsonName { + // Message for testing the effects for of the json_name option + string name = 1; + string description = 2 [json_name = "desc"]; + string guid = 3 [json_name = "exid"]; +} diff --git a/third_party/protobuf/src/google/protobuf/map_unittest_proto3.proto b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/map_unittest_proto3.proto similarity index 100% rename from third_party/protobuf/src/google/protobuf/map_unittest_proto3.proto rename to third_party/protobuf/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/map_unittest_proto3.proto diff --git a/third_party/protobuf/src/google/protobuf/unittest_import_proto3.proto b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_import_proto3.proto similarity index 100% rename from third_party/protobuf/src/google/protobuf/unittest_import_proto3.proto rename to third_party/protobuf/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_import_proto3.proto diff --git a/third_party/protobuf/src/google/protobuf/unittest_import_public_proto3.proto b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_import_public_proto3.proto similarity index 100% rename from third_party/protobuf/src/google/protobuf/unittest_import_public_proto3.proto rename to third_party/protobuf/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_import_public_proto3.proto diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_proto3.proto b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_proto3.proto new file mode 100644 index 000000000000..f59d21786453 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_proto3.proto @@ -0,0 +1,388 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Author: kenton@google.com (Kenton Varda) +// Based on original Protocol Buffers design by +// Sanjay Ghemawat, Jeff Dean, and others. +// +// A proto file we will use for unit testing. + +syntax = "proto3"; + +// Some generic_services option(s) added automatically. +// See: http://go/proto2-generic-services-default +option cc_generic_services = true; // auto-added +option java_generic_services = true; // auto-added +option py_generic_services = true; // auto-added +option cc_enable_arenas = true; +option csharp_namespace = "Google.Protobuf.TestProtos"; + +import "google/protobuf/unittest_import_proto3.proto"; + +// We don't put this in a package within proto2 because we need to make sure +// that the generated code doesn't depend on being in the proto2 namespace. +// In test_util.h we do "using namespace unittest = protobuf_unittest". +package protobuf_unittest; + +// Protos optimized for SPEED use a strict superset of the generated code +// of equivalent ones optimized for CODE_SIZE, so we should optimize all our +// tests for speed unless explicitly testing code size optimization. +option optimize_for = SPEED; + +option java_outer_classname = "UnittestProto"; + +// This proto includes every type of field in both singular and repeated +// forms. +message TestAllTypes { + message NestedMessage { + // The field name "b" fails to compile in proto1 because it conflicts with + // a local variable named "b" in one of the generated methods. Doh. + // This file needs to compile in proto1 to test backwards-compatibility. + int32 bb = 1; + } + + enum NestedEnum { + NESTED_ENUM_UNSPECIFIED = 0; + FOO = 1; + BAR = 2; + BAZ = 3; + NEG = -1; // Intentionally negative. + } + + // Singular + int32 single_int32 = 1; + int64 single_int64 = 2; + uint32 single_uint32 = 3; + uint64 single_uint64 = 4; + sint32 single_sint32 = 5; + sint64 single_sint64 = 6; + fixed32 single_fixed32 = 7; + fixed64 single_fixed64 = 8; + sfixed32 single_sfixed32 = 9; + sfixed64 single_sfixed64 = 10; + float single_float = 11; + double single_double = 12; + bool single_bool = 13; + string single_string = 14; + bytes single_bytes = 15; + + NestedMessage single_nested_message = 18; + ForeignMessage single_foreign_message = 19; + protobuf_unittest_import.ImportMessage single_import_message = 20; + + NestedEnum single_nested_enum = 21; + ForeignEnum single_foreign_enum = 22; + protobuf_unittest_import.ImportEnum single_import_enum = 23; + + // Defined in unittest_import_public.proto + protobuf_unittest_import.PublicImportMessage + single_public_import_message = 26; + + // Repeated + repeated int32 repeated_int32 = 31; + repeated int64 repeated_int64 = 32; + repeated uint32 repeated_uint32 = 33; + repeated uint64 repeated_uint64 = 34; + repeated sint32 repeated_sint32 = 35; + repeated sint64 repeated_sint64 = 36; + repeated fixed32 repeated_fixed32 = 37; + repeated fixed64 repeated_fixed64 = 38; + repeated sfixed32 repeated_sfixed32 = 39; + repeated sfixed64 repeated_sfixed64 = 40; + repeated float repeated_float = 41; + repeated double repeated_double = 42; + repeated bool repeated_bool = 43; + repeated string repeated_string = 44; + repeated bytes repeated_bytes = 45; + + repeated NestedMessage repeated_nested_message = 48; + repeated ForeignMessage repeated_foreign_message = 49; + repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50; + + repeated NestedEnum repeated_nested_enum = 51; + repeated ForeignEnum repeated_foreign_enum = 52; + repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53; + // Defined in unittest_import_public.proto + repeated protobuf_unittest_import.PublicImportMessage + repeated_public_import_message = 54; + + // For oneof test + oneof oneof_field { + uint32 oneof_uint32 = 111; + NestedMessage oneof_nested_message = 112; + string oneof_string = 113; + bytes oneof_bytes = 114; + } +} + +// This proto includes a recusively nested message. +message NestedTestAllTypes { + NestedTestAllTypes child = 1; + TestAllTypes payload = 2; + repeated NestedTestAllTypes repeated_child = 3; +} + +message TestDeprecatedFields { + int32 deprecated_int32 = 1 [deprecated=true]; +} + +// Define these after TestAllTypes to make sure the compiler can handle +// that. +message ForeignMessage { + int32 c = 1; +} + +enum ForeignEnum { + FOREIGN_UNSPECIFIED = 0; + FOREIGN_FOO = 4; + FOREIGN_BAR = 5; + FOREIGN_BAZ = 6; +} + +message TestReservedFields { + reserved 2, 15, 9 to 11; + reserved "bar", "baz"; +} + + +// Test that we can use NestedMessage from outside TestAllTypes. +message TestForeignNested { + TestAllTypes.NestedMessage foreign_nested = 1; +} + +// Test that really large tag numbers don't break anything. +message TestReallyLargeTagNumber { + // The largest possible tag number is 2^28 - 1, since the wire format uses + // three bits to communicate wire type. + int32 a = 1; + int32 bb = 268435455; +} + +message TestRecursiveMessage { + TestRecursiveMessage a = 1; + int32 i = 2; +} + +// Test that mutual recursion works. +message TestMutualRecursionA { + TestMutualRecursionB bb = 1; +} + +message TestMutualRecursionB { + TestMutualRecursionA a = 1; + int32 optional_int32 = 2; +} + + +// Test an enum that has multiple values with the same number. +enum TestEnumWithDupValue { + TEST_ENUM_WITH_DUP_VALUE_UNSPECIFIED = 0; + option allow_alias = true; + + FOO1 = 1; + BAR1 = 2; + BAZ = 3; + FOO2 = 1; + BAR2 = 2; +} + +// Test an enum with large, unordered values. +enum TestSparseEnum { + TEST_SPARSE_ENUM_UNSPECIFIED = 0; + SPARSE_A = 123; + SPARSE_B = 62374; + SPARSE_C = 12589234; + SPARSE_D = -15; + SPARSE_E = -53452; + // In proto3, value 0 must be the first one specified + // SPARSE_F = 0; + SPARSE_G = 2; +} + +// Test message with CamelCase field names. This violates Protocol Buffer +// standard style. +message TestCamelCaseFieldNames { + int32 PrimitiveField = 1; + string StringField = 2; + ForeignEnum EnumField = 3; + ForeignMessage MessageField = 4; + + repeated int32 RepeatedPrimitiveField = 7; + repeated string RepeatedStringField = 8; + repeated ForeignEnum RepeatedEnumField = 9; + repeated ForeignMessage RepeatedMessageField = 10; +} + + +// We list fields out of order, to ensure that we're using field number and not +// field index to determine serialization order. +message TestFieldOrderings { + string my_string = 11; + int64 my_int = 1; + float my_float = 101; + message NestedMessage { + int64 oo = 2; + // The field name "b" fails to compile in proto1 because it conflicts with + // a local variable named "b" in one of the generated methods. Doh. + // This file needs to compile in proto1 to test backwards-compatibility. + int32 bb = 1; + } + + NestedMessage single_nested_message = 200; +} + +message SparseEnumMessage { + TestSparseEnum sparse_enum = 1; +} + +// Test String and Bytes: string is for valid UTF-8 strings +message OneString { + string data = 1; +} + +message MoreString { + repeated string data = 1; +} + +message OneBytes { + bytes data = 1; +} + +message MoreBytes { + bytes data = 1; +} + +// Test int32, uint32, int64, uint64, and bool are all compatible +message Int32Message { + int32 data = 1; +} + +message Uint32Message { + uint32 data = 1; +} + +message Int64Message { + int64 data = 1; +} + +message Uint64Message { + uint64 data = 1; +} + +message BoolMessage { + bool data = 1; +} + +// Test oneofs. +message TestOneof { + oneof foo { + int32 foo_int = 1; + string foo_string = 2; + TestAllTypes foo_message = 3; + } +} + +// Test messages for packed fields + +message TestPackedTypes { + repeated int32 packed_int32 = 90 [packed = true]; + repeated int64 packed_int64 = 91 [packed = true]; + repeated uint32 packed_uint32 = 92 [packed = true]; + repeated uint64 packed_uint64 = 93 [packed = true]; + repeated sint32 packed_sint32 = 94 [packed = true]; + repeated sint64 packed_sint64 = 95 [packed = true]; + repeated fixed32 packed_fixed32 = 96 [packed = true]; + repeated fixed64 packed_fixed64 = 97 [packed = true]; + repeated sfixed32 packed_sfixed32 = 98 [packed = true]; + repeated sfixed64 packed_sfixed64 = 99 [packed = true]; + repeated float packed_float = 100 [packed = true]; + repeated double packed_double = 101 [packed = true]; + repeated bool packed_bool = 102 [packed = true]; + repeated ForeignEnum packed_enum = 103 [packed = true]; +} + +// A message with the same fields as TestPackedTypes, but without packing. Used +// to test packed <-> unpacked wire compatibility. +message TestUnpackedTypes { + repeated int32 unpacked_int32 = 90 [packed = false]; + repeated int64 unpacked_int64 = 91 [packed = false]; + repeated uint32 unpacked_uint32 = 92 [packed = false]; + repeated uint64 unpacked_uint64 = 93 [packed = false]; + repeated sint32 unpacked_sint32 = 94 [packed = false]; + repeated sint64 unpacked_sint64 = 95 [packed = false]; + repeated fixed32 unpacked_fixed32 = 96 [packed = false]; + repeated fixed64 unpacked_fixed64 = 97 [packed = false]; + repeated sfixed32 unpacked_sfixed32 = 98 [packed = false]; + repeated sfixed64 unpacked_sfixed64 = 99 [packed = false]; + repeated float unpacked_float = 100 [packed = false]; + repeated double unpacked_double = 101 [packed = false]; + repeated bool unpacked_bool = 102 [packed = false]; + repeated ForeignEnum unpacked_enum = 103 [packed = false]; +} + +message TestRepeatedScalarDifferentTagSizes { + // Parsing repeated fixed size values used to fail. This message needs to be + // used in order to get a tag of the right size; all of the repeated fields + // in TestAllTypes didn't trigger the check. + repeated fixed32 repeated_fixed32 = 12; + // Check for a varint type, just for good measure. + repeated int32 repeated_int32 = 13; + + // These have two-byte tags. + repeated fixed64 repeated_fixed64 = 2046; + repeated int64 repeated_int64 = 2047; + + // Three byte tags. + repeated float repeated_float = 262142; + repeated uint64 repeated_uint64 = 262143; +} + +message TestCommentInjectionMessage { + // */ <- This should not close the generated doc comment + string a = 1; +} + + +// Test that RPC services work. +message FooRequest {} +message FooResponse {} + +message FooClientMessage {} +message FooServerMessage{} + +service TestService { + rpc Foo(FooRequest) returns (FooResponse); + rpc Bar(BarRequest) returns (BarResponse); +} + + +message BarRequest {} +message BarResponse {} + diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_well_known_types.proto b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_well_known_types.proto new file mode 100644 index 000000000000..c90752440b28 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_well_known_types.proto @@ -0,0 +1,114 @@ +syntax = "proto3"; + +package protobuf_unittest; + +option csharp_namespace = "Google.Protobuf.TestProtos"; +option java_multiple_files = true; +option java_package = "com.google.protobuf.test"; + +import "google/protobuf/any.proto"; +import "google/protobuf/api.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/source_context.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/type.proto"; +import "google/protobuf/wrappers.proto"; + +// Test that we can include all well-known types. +// Each wrapper type is included separately, as languages +// map handle different wrappers in different ways. +message TestWellKnownTypes { + google.protobuf.Any any_field = 1; + google.protobuf.Api api_field = 2; + google.protobuf.Duration duration_field = 3; + google.protobuf.Empty empty_field = 4; + google.protobuf.FieldMask field_mask_field = 5; + google.protobuf.SourceContext source_context_field = 6; + google.protobuf.Struct struct_field = 7; + google.protobuf.Timestamp timestamp_field = 8; + google.protobuf.Type type_field = 9; + google.protobuf.DoubleValue double_field = 10; + google.protobuf.FloatValue float_field = 11; + google.protobuf.Int64Value int64_field = 12; + google.protobuf.UInt64Value uint64_field = 13; + google.protobuf.Int32Value int32_field = 14; + google.protobuf.UInt32Value uint32_field = 15; + google.protobuf.BoolValue bool_field = 16; + google.protobuf.StringValue string_field = 17; + google.protobuf.BytesValue bytes_field = 18; + // Part of struct, but useful to be able to test separately + google.protobuf.Value value_field = 19; +} + +// A repeated field for each well-known type. +message RepeatedWellKnownTypes { + repeated google.protobuf.Any any_field = 1; + repeated google.protobuf.Api api_field = 2; + repeated google.protobuf.Duration duration_field = 3; + repeated google.protobuf.Empty empty_field = 4; + repeated google.protobuf.FieldMask field_mask_field = 5; + repeated google.protobuf.SourceContext source_context_field = 6; + repeated google.protobuf.Struct struct_field = 7; + repeated google.protobuf.Timestamp timestamp_field = 8; + repeated google.protobuf.Type type_field = 9; + // These don't actually make a lot of sense, but they're not prohibited... + repeated google.protobuf.DoubleValue double_field = 10; + repeated google.protobuf.FloatValue float_field = 11; + repeated google.protobuf.Int64Value int64_field = 12; + repeated google.protobuf.UInt64Value uint64_field = 13; + repeated google.protobuf.Int32Value int32_field = 14; + repeated google.protobuf.UInt32Value uint32_field = 15; + repeated google.protobuf.BoolValue bool_field = 16; + repeated google.protobuf.StringValue string_field = 17; + repeated google.protobuf.BytesValue bytes_field = 18; +} + +message OneofWellKnownTypes { + oneof oneof_field { + google.protobuf.Any any_field = 1; + google.protobuf.Api api_field = 2; + google.protobuf.Duration duration_field = 3; + google.protobuf.Empty empty_field = 4; + google.protobuf.FieldMask field_mask_field = 5; + google.protobuf.SourceContext source_context_field = 6; + google.protobuf.Struct struct_field = 7; + google.protobuf.Timestamp timestamp_field = 8; + google.protobuf.Type type_field = 9; + google.protobuf.DoubleValue double_field = 10; + google.protobuf.FloatValue float_field = 11; + google.protobuf.Int64Value int64_field = 12; + google.protobuf.UInt64Value uint64_field = 13; + google.protobuf.Int32Value int32_field = 14; + google.protobuf.UInt32Value uint32_field = 15; + google.protobuf.BoolValue bool_field = 16; + google.protobuf.StringValue string_field = 17; + google.protobuf.BytesValue bytes_field = 18; + } +} + +// A map field for each well-known type. We only +// need to worry about the value part of the map being the +// well-known types, as messages can't be map keys. +message MapWellKnownTypes { + map any_field = 1; + map api_field = 2; + map duration_field = 3; + map empty_field = 4; + map field_mask_field = 5; + map source_context_field = 6; + map struct_field = 7; + map timestamp_field = 8; + map type_field = 9; + map double_field = 10; + map float_field = 11; + map int64_field = 12; + map uint64_field = 13; + map int32_field = 14; + map uint32_field = 15; + map bool_field = 16; + map string_field = 17; + map bytes_field = 18; +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/ByteStringTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/ByteStringTest.cs new file mode 100644 index 000000000000..685e130a748c --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/ByteStringTest.cs @@ -0,0 +1,171 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Text; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class ByteStringTest + { + [Test] + public void Equality() + { + ByteString b1 = ByteString.CopyFrom(1, 2, 3); + ByteString b2 = ByteString.CopyFrom(1, 2, 3); + ByteString b3 = ByteString.CopyFrom(1, 2, 4); + ByteString b4 = ByteString.CopyFrom(1, 2, 3, 4); + EqualityTester.AssertEquality(b1, b1); + EqualityTester.AssertEquality(b1, b2); + EqualityTester.AssertInequality(b1, b3); + EqualityTester.AssertInequality(b1, b4); + EqualityTester.AssertInequality(b1, null); +#pragma warning disable 1718 // Deliberately calling ==(b1, b1) and !=(b1, b1) + Assert.IsTrue(b1 == b1); + Assert.IsTrue(b1 == b2); + Assert.IsFalse(b1 == b3); + Assert.IsFalse(b1 == b4); + Assert.IsFalse(b1 == null); + Assert.IsTrue((ByteString) null == null); + Assert.IsFalse(b1 != b1); + Assert.IsFalse(b1 != b2); +#pragma warning disable 1718 + Assert.IsTrue(b1 != b3); + Assert.IsTrue(b1 != b4); + Assert.IsTrue(b1 != null); + Assert.IsFalse((ByteString) null != null); + } + + [Test] + public void EmptyByteStringHasZeroSize() + { + Assert.AreEqual(0, ByteString.Empty.Length); + } + + [Test] + public void CopyFromStringWithExplicitEncoding() + { + ByteString bs = ByteString.CopyFrom("AB", Encoding.Unicode); + Assert.AreEqual(4, bs.Length); + Assert.AreEqual(65, bs[0]); + Assert.AreEqual(0, bs[1]); + Assert.AreEqual(66, bs[2]); + Assert.AreEqual(0, bs[3]); + } + + [Test] + public void IsEmptyWhenEmpty() + { + Assert.IsTrue(ByteString.CopyFromUtf8("").IsEmpty); + } + + [Test] + public void IsEmptyWhenNotEmpty() + { + Assert.IsFalse(ByteString.CopyFromUtf8("X").IsEmpty); + } + + [Test] + public void CopyFromByteArrayCopiesContents() + { + byte[] data = new byte[1]; + data[0] = 10; + ByteString bs = ByteString.CopyFrom(data); + Assert.AreEqual(10, bs[0]); + data[0] = 5; + Assert.AreEqual(10, bs[0]); + } + + [Test] + public void ToByteArrayCopiesContents() + { + ByteString bs = ByteString.CopyFromUtf8("Hello"); + byte[] data = bs.ToByteArray(); + Assert.AreEqual((byte)'H', data[0]); + Assert.AreEqual((byte)'H', bs[0]); + data[0] = 0; + Assert.AreEqual(0, data[0]); + Assert.AreEqual((byte)'H', bs[0]); + } + + [Test] + public void CopyFromUtf8UsesUtf8() + { + ByteString bs = ByteString.CopyFromUtf8("\u20ac"); + Assert.AreEqual(3, bs.Length); + Assert.AreEqual(0xe2, bs[0]); + Assert.AreEqual(0x82, bs[1]); + Assert.AreEqual(0xac, bs[2]); + } + + [Test] + public void CopyFromPortion() + { + byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6}; + ByteString bs = ByteString.CopyFrom(data, 2, 3); + Assert.AreEqual(3, bs.Length); + Assert.AreEqual(2, bs[0]); + Assert.AreEqual(3, bs[1]); + } + + [Test] + public void ToStringUtf8() + { + ByteString bs = ByteString.CopyFromUtf8("\u20ac"); + Assert.AreEqual("\u20ac", bs.ToStringUtf8()); + } + + [Test] + public void ToStringWithExplicitEncoding() + { + ByteString bs = ByteString.CopyFrom("\u20ac", Encoding.Unicode); + Assert.AreEqual("\u20ac", bs.ToString(Encoding.Unicode)); + } + + [Test] + public void FromBase64_WithText() + { + byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6}; + string base64 = Convert.ToBase64String(data); + ByteString bs = ByteString.FromBase64(base64); + Assert.AreEqual(data, bs.ToByteArray()); + } + + [Test] + public void FromBase64_Empty() + { + // Optimization which also fixes issue 61. + Assert.AreSame(ByteString.Empty, ByteString.FromBase64("")); + } + } +} \ No newline at end of file diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs new file mode 100644 index 000000000000..23af28870ab4 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs @@ -0,0 +1,53 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using NUnit.Framework; + +namespace Google.Protobuf +{ + internal static class CodedInputStreamExtensions + { + public static void AssertNextTag(this CodedInputStream input, uint expectedTag) + { + uint tag = input.ReadTag(); + Assert.AreEqual(expectedTag, tag); + } + + public static T ReadMessage(this CodedInputStream stream, MessageParser parser) + where T : IMessage + { + var message = parser.CreateTemplate(); + stream.ReadMessage(message); + return message; + } + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamTest.cs new file mode 100644 index 000000000000..73a578d2b5a9 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamTest.cs @@ -0,0 +1,598 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.IO; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class CodedInputStreamTest + { + /// + /// Helper to construct a byte array from a bunch of bytes. The inputs are + /// actually ints so that I can use hex notation and not get stupid errors + /// about precision. + /// + private static byte[] Bytes(params int[] bytesAsInts) + { + byte[] bytes = new byte[bytesAsInts.Length]; + for (int i = 0; i < bytesAsInts.Length; i++) + { + bytes[i] = (byte) bytesAsInts[i]; + } + return bytes; + } + + /// + /// Parses the given bytes using ReadRawVarint32() and ReadRawVarint64() + /// + private static void AssertReadVarint(byte[] data, ulong value) + { + CodedInputStream input = new CodedInputStream(data); + Assert.AreEqual((uint) value, input.ReadRawVarint32()); + + input = new CodedInputStream(data); + Assert.AreEqual(value, input.ReadRawVarint64()); + Assert.IsTrue(input.IsAtEnd); + + // Try different block sizes. + for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2) + { + input = new CodedInputStream(new SmallBlockInputStream(data, bufferSize)); + Assert.AreEqual((uint) value, input.ReadRawVarint32()); + + input = new CodedInputStream(new SmallBlockInputStream(data, bufferSize)); + Assert.AreEqual(value, input.ReadRawVarint64()); + Assert.IsTrue(input.IsAtEnd); + } + + // Try reading directly from a MemoryStream. We want to verify that it + // doesn't read past the end of the input, so write an extra byte - this + // lets us test the position at the end. + MemoryStream memoryStream = new MemoryStream(); + memoryStream.Write(data, 0, data.Length); + memoryStream.WriteByte(0); + memoryStream.Position = 0; + Assert.AreEqual((uint) value, CodedInputStream.ReadRawVarint32(memoryStream)); + Assert.AreEqual(data.Length, memoryStream.Position); + } + + /// + /// Parses the given bytes using ReadRawVarint32() and ReadRawVarint64() and + /// expects them to fail with an InvalidProtocolBufferException whose + /// description matches the given one. + /// + private static void AssertReadVarintFailure(InvalidProtocolBufferException expected, byte[] data) + { + CodedInputStream input = new CodedInputStream(data); + var exception = Assert.Throws(() => input.ReadRawVarint32()); + Assert.AreEqual(expected.Message, exception.Message); + + input = new CodedInputStream(data); + exception = Assert.Throws(() => input.ReadRawVarint64()); + Assert.AreEqual(expected.Message, exception.Message); + + // Make sure we get the same error when reading directly from a Stream. + exception = Assert.Throws(() => CodedInputStream.ReadRawVarint32(new MemoryStream(data))); + Assert.AreEqual(expected.Message, exception.Message); + } + + [Test] + public void ReadVarint() + { + AssertReadVarint(Bytes(0x00), 0); + AssertReadVarint(Bytes(0x01), 1); + AssertReadVarint(Bytes(0x7f), 127); + // 14882 + AssertReadVarint(Bytes(0xa2, 0x74), (0x22 << 0) | (0x74 << 7)); + // 2961488830 + AssertReadVarint(Bytes(0xbe, 0xf7, 0x92, 0x84, 0x0b), + (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | + (0x0bL << 28)); + + // 64-bit + // 7256456126 + AssertReadVarint(Bytes(0xbe, 0xf7, 0x92, 0x84, 0x1b), + (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | + (0x1bL << 28)); + // 41256202580718336 + AssertReadVarint(Bytes(0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49), + (0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) | + (0x43L << 28) | (0x49L << 35) | (0x24L << 42) | (0x49L << 49)); + // 11964378330978735131 + AssertReadVarint(Bytes(0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01), + (0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) | + (0x3bUL << 28) | (0x56UL << 35) | (0x00UL << 42) | + (0x05UL << 49) | (0x26UL << 56) | (0x01UL << 63)); + + // Failures + AssertReadVarintFailure( + InvalidProtocolBufferException.MalformedVarint(), + Bytes(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x00)); + AssertReadVarintFailure( + InvalidProtocolBufferException.TruncatedMessage(), + Bytes(0x80)); + } + + /// + /// Parses the given bytes using ReadRawLittleEndian32() and checks + /// that the result matches the given value. + /// + private static void AssertReadLittleEndian32(byte[] data, uint value) + { + CodedInputStream input = new CodedInputStream(data); + Assert.AreEqual(value, input.ReadRawLittleEndian32()); + Assert.IsTrue(input.IsAtEnd); + + // Try different block sizes. + for (int blockSize = 1; blockSize <= 16; blockSize *= 2) + { + input = new CodedInputStream( + new SmallBlockInputStream(data, blockSize)); + Assert.AreEqual(value, input.ReadRawLittleEndian32()); + Assert.IsTrue(input.IsAtEnd); + } + } + + /// + /// Parses the given bytes using ReadRawLittleEndian64() and checks + /// that the result matches the given value. + /// + private static void AssertReadLittleEndian64(byte[] data, ulong value) + { + CodedInputStream input = new CodedInputStream(data); + Assert.AreEqual(value, input.ReadRawLittleEndian64()); + Assert.IsTrue(input.IsAtEnd); + + // Try different block sizes. + for (int blockSize = 1; blockSize <= 16; blockSize *= 2) + { + input = new CodedInputStream( + new SmallBlockInputStream(data, blockSize)); + Assert.AreEqual(value, input.ReadRawLittleEndian64()); + Assert.IsTrue(input.IsAtEnd); + } + } + + [Test] + public void ReadLittleEndian() + { + AssertReadLittleEndian32(Bytes(0x78, 0x56, 0x34, 0x12), 0x12345678); + AssertReadLittleEndian32(Bytes(0xf0, 0xde, 0xbc, 0x9a), 0x9abcdef0); + + AssertReadLittleEndian64(Bytes(0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12), + 0x123456789abcdef0L); + AssertReadLittleEndian64( + Bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a), 0x9abcdef012345678UL); + } + + [Test] + public void DecodeZigZag32() + { + Assert.AreEqual(0, CodedInputStream.DecodeZigZag32(0)); + Assert.AreEqual(-1, CodedInputStream.DecodeZigZag32(1)); + Assert.AreEqual(1, CodedInputStream.DecodeZigZag32(2)); + Assert.AreEqual(-2, CodedInputStream.DecodeZigZag32(3)); + Assert.AreEqual(0x3FFFFFFF, CodedInputStream.DecodeZigZag32(0x7FFFFFFE)); + Assert.AreEqual(unchecked((int) 0xC0000000), CodedInputStream.DecodeZigZag32(0x7FFFFFFF)); + Assert.AreEqual(0x7FFFFFFF, CodedInputStream.DecodeZigZag32(0xFFFFFFFE)); + Assert.AreEqual(unchecked((int) 0x80000000), CodedInputStream.DecodeZigZag32(0xFFFFFFFF)); + } + + [Test] + public void DecodeZigZag64() + { + Assert.AreEqual(0, CodedInputStream.DecodeZigZag64(0)); + Assert.AreEqual(-1, CodedInputStream.DecodeZigZag64(1)); + Assert.AreEqual(1, CodedInputStream.DecodeZigZag64(2)); + Assert.AreEqual(-2, CodedInputStream.DecodeZigZag64(3)); + Assert.AreEqual(0x000000003FFFFFFFL, CodedInputStream.DecodeZigZag64(0x000000007FFFFFFEL)); + Assert.AreEqual(unchecked((long) 0xFFFFFFFFC0000000L), CodedInputStream.DecodeZigZag64(0x000000007FFFFFFFL)); + Assert.AreEqual(0x000000007FFFFFFFL, CodedInputStream.DecodeZigZag64(0x00000000FFFFFFFEL)); + Assert.AreEqual(unchecked((long) 0xFFFFFFFF80000000L), CodedInputStream.DecodeZigZag64(0x00000000FFFFFFFFL)); + Assert.AreEqual(0x7FFFFFFFFFFFFFFFL, CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFEL)); + Assert.AreEqual(unchecked((long) 0x8000000000000000L), CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFFL)); + } + + [Test] + public void ReadWholeMessage_VaryingBlockSizes() + { + TestAllTypes message = SampleMessages.CreateFullTestAllTypes(); + + byte[] rawBytes = message.ToByteArray(); + Assert.AreEqual(rawBytes.Length, message.CalculateSize()); + TestAllTypes message2 = TestAllTypes.Parser.ParseFrom(rawBytes); + Assert.AreEqual(message, message2); + + // Try different block sizes. + for (int blockSize = 1; blockSize < 256; blockSize *= 2) + { + message2 = TestAllTypes.Parser.ParseFrom(new SmallBlockInputStream(rawBytes, blockSize)); + Assert.AreEqual(message, message2); + } + } + + [Test] + public void ReadHugeBlob() + { + // Allocate and initialize a 1MB blob. + byte[] blob = new byte[1 << 20]; + for (int i = 0; i < blob.Length; i++) + { + blob[i] = (byte) i; + } + + // Make a message containing it. + var message = new TestAllTypes { SingleBytes = ByteString.CopyFrom(blob) }; + + // Serialize and parse it. Make sure to parse from an InputStream, not + // directly from a ByteString, so that CodedInputStream uses buffered + // reading. + TestAllTypes message2 = TestAllTypes.Parser.ParseFrom(message.ToByteString()); + + Assert.AreEqual(message, message2); + } + + [Test] + public void ReadMaliciouslyLargeBlob() + { + MemoryStream ms = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(ms); + + uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); + output.WriteRawVarint32(tag); + output.WriteRawVarint32(0x7FFFFFFF); + output.WriteRawBytes(new byte[32]); // Pad with a few random bytes. + output.Flush(); + ms.Position = 0; + + CodedInputStream input = new CodedInputStream(ms); + Assert.AreEqual(tag, input.ReadTag()); + + Assert.Throws(() => input.ReadBytes()); + } + + internal static TestRecursiveMessage MakeRecursiveMessage(int depth) + { + if (depth == 0) + { + return new TestRecursiveMessage { I = 5 }; + } + else + { + return new TestRecursiveMessage { A = MakeRecursiveMessage(depth - 1) }; + } + } + + internal static void AssertMessageDepth(TestRecursiveMessage message, int depth) + { + if (depth == 0) + { + Assert.IsNull(message.A); + Assert.AreEqual(5, message.I); + } + else + { + Assert.IsNotNull(message.A); + AssertMessageDepth(message.A, depth - 1); + } + } + + [Test] + public void MaliciousRecursion() + { + ByteString atRecursiveLimit = MakeRecursiveMessage(CodedInputStream.DefaultRecursionLimit).ToByteString(); + ByteString beyondRecursiveLimit = MakeRecursiveMessage(CodedInputStream.DefaultRecursionLimit + 1).ToByteString(); + + AssertMessageDepth(TestRecursiveMessage.Parser.ParseFrom(atRecursiveLimit), CodedInputStream.DefaultRecursionLimit); + + Assert.Throws(() => TestRecursiveMessage.Parser.ParseFrom(beyondRecursiveLimit)); + + CodedInputStream input = CodedInputStream.CreateWithLimits(new MemoryStream(atRecursiveLimit.ToByteArray()), 1000000, CodedInputStream.DefaultRecursionLimit - 1); + Assert.Throws(() => TestRecursiveMessage.Parser.ParseFrom(input)); + } + + [Test] + public void SizeLimit() + { + // Have to use a Stream rather than ByteString.CreateCodedInput as SizeLimit doesn't + // apply to the latter case. + MemoryStream ms = new MemoryStream(SampleMessages.CreateFullTestAllTypes().ToByteArray()); + CodedInputStream input = CodedInputStream.CreateWithLimits(ms, 16, 100); + Assert.Throws(() => TestAllTypes.Parser.ParseFrom(input)); + } + + /// + /// Tests that if we read an string that contains invalid UTF-8, no exception + /// is thrown. Instead, the invalid bytes are replaced with the Unicode + /// "replacement character" U+FFFD. + /// + [Test] + public void ReadInvalidUtf8() + { + MemoryStream ms = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(ms); + + uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); + output.WriteRawVarint32(tag); + output.WriteRawVarint32(1); + output.WriteRawBytes(new byte[] {0x80}); + output.Flush(); + ms.Position = 0; + + CodedInputStream input = new CodedInputStream(ms); + + Assert.AreEqual(tag, input.ReadTag()); + string text = input.ReadString(); + Assert.AreEqual('\ufffd', text[0]); + } + + /// + /// A stream which limits the number of bytes it reads at a time. + /// We use this to make sure that CodedInputStream doesn't screw up when + /// reading in small blocks. + /// + private sealed class SmallBlockInputStream : MemoryStream + { + private readonly int blockSize; + + public SmallBlockInputStream(byte[] data, int blockSize) + : base(data) + { + this.blockSize = blockSize; + } + + public override int Read(byte[] buffer, int offset, int count) + { + return base.Read(buffer, offset, Math.Min(count, blockSize)); + } + } + + [Test] + public void TestNegativeEnum() + { + byte[] bytes = { 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01 }; + CodedInputStream input = new CodedInputStream(bytes); + Assert.AreEqual((int)SampleEnum.NegativeValue, input.ReadEnum()); + Assert.IsTrue(input.IsAtEnd); + } + + //Issue 71: CodedInputStream.ReadBytes go to slow path unnecessarily + [Test] + public void TestSlowPathAvoidance() + { + using (var ms = new MemoryStream()) + { + CodedOutputStream output = new CodedOutputStream(ms); + output.WriteTag(1, WireFormat.WireType.LengthDelimited); + output.WriteBytes(ByteString.CopyFrom(new byte[100])); + output.WriteTag(2, WireFormat.WireType.LengthDelimited); + output.WriteBytes(ByteString.CopyFrom(new byte[100])); + output.Flush(); + + ms.Position = 0; + CodedInputStream input = new CodedInputStream(ms, new byte[ms.Length / 2], 0, 0, false); + + uint tag = input.ReadTag(); + Assert.AreEqual(1, WireFormat.GetTagFieldNumber(tag)); + Assert.AreEqual(100, input.ReadBytes().Length); + + tag = input.ReadTag(); + Assert.AreEqual(2, WireFormat.GetTagFieldNumber(tag)); + Assert.AreEqual(100, input.ReadBytes().Length); + } + } + + [Test] + public void Tag0Throws() + { + var input = new CodedInputStream(new byte[] { 0 }); + Assert.Throws(() => input.ReadTag()); + } + + [Test] + public void SkipGroup() + { + // Create an output stream with a group in: + // Field 1: string "field 1" + // Field 2: group containing: + // Field 1: fixed int32 value 100 + // Field 2: string "ignore me" + // Field 3: nested group containing + // Field 1: fixed int64 value 1000 + // Field 3: string "field 3" + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + output.WriteTag(1, WireFormat.WireType.LengthDelimited); + output.WriteString("field 1"); + + // The outer group... + output.WriteTag(2, WireFormat.WireType.StartGroup); + output.WriteTag(1, WireFormat.WireType.Fixed32); + output.WriteFixed32(100); + output.WriteTag(2, WireFormat.WireType.LengthDelimited); + output.WriteString("ignore me"); + // The nested group... + output.WriteTag(3, WireFormat.WireType.StartGroup); + output.WriteTag(1, WireFormat.WireType.Fixed64); + output.WriteFixed64(1000); + // Note: Not sure the field number is relevant for end group... + output.WriteTag(3, WireFormat.WireType.EndGroup); + + // End the outer group + output.WriteTag(2, WireFormat.WireType.EndGroup); + + output.WriteTag(3, WireFormat.WireType.LengthDelimited); + output.WriteString("field 3"); + output.Flush(); + stream.Position = 0; + + // Now act like a generated client + var input = new CodedInputStream(stream); + Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited), input.ReadTag()); + Assert.AreEqual("field 1", input.ReadString()); + Assert.AreEqual(WireFormat.MakeTag(2, WireFormat.WireType.StartGroup), input.ReadTag()); + input.SkipLastField(); // Should consume the whole group, including the nested one. + Assert.AreEqual(WireFormat.MakeTag(3, WireFormat.WireType.LengthDelimited), input.ReadTag()); + Assert.AreEqual("field 3", input.ReadString()); + } + + [Test] + public void SkipGroup_WrongEndGroupTag() + { + // Create an output stream with: + // Field 1: string "field 1" + // Start group 2 + // Field 3: fixed int32 + // End group 4 (should give an error) + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + output.WriteTag(1, WireFormat.WireType.LengthDelimited); + output.WriteString("field 1"); + + // The outer group... + output.WriteTag(2, WireFormat.WireType.StartGroup); + output.WriteTag(3, WireFormat.WireType.Fixed32); + output.WriteFixed32(100); + output.WriteTag(4, WireFormat.WireType.EndGroup); + output.Flush(); + stream.Position = 0; + + // Now act like a generated client + var input = new CodedInputStream(stream); + Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited), input.ReadTag()); + Assert.AreEqual("field 1", input.ReadString()); + Assert.AreEqual(WireFormat.MakeTag(2, WireFormat.WireType.StartGroup), input.ReadTag()); + Assert.Throws(input.SkipLastField); + } + + [Test] + public void RogueEndGroupTag() + { + // If we have an end-group tag without a leading start-group tag, generated + // code will just call SkipLastField... so that should fail. + + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + output.WriteTag(1, WireFormat.WireType.EndGroup); + output.Flush(); + stream.Position = 0; + + var input = new CodedInputStream(stream); + Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.EndGroup), input.ReadTag()); + Assert.Throws(input.SkipLastField); + } + + [Test] + public void EndOfStreamReachedWhileSkippingGroup() + { + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + output.WriteTag(1, WireFormat.WireType.StartGroup); + output.WriteTag(2, WireFormat.WireType.StartGroup); + output.WriteTag(2, WireFormat.WireType.EndGroup); + + output.Flush(); + stream.Position = 0; + + // Now act like a generated client + var input = new CodedInputStream(stream); + input.ReadTag(); + Assert.Throws(input.SkipLastField); + } + + [Test] + public void RecursionLimitAppliedWhileSkippingGroup() + { + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + for (int i = 0; i < CodedInputStream.DefaultRecursionLimit + 1; i++) + { + output.WriteTag(1, WireFormat.WireType.StartGroup); + } + for (int i = 0; i < CodedInputStream.DefaultRecursionLimit + 1; i++) + { + output.WriteTag(1, WireFormat.WireType.EndGroup); + } + output.Flush(); + stream.Position = 0; + + // Now act like a generated client + var input = new CodedInputStream(stream); + Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.StartGroup), input.ReadTag()); + Assert.Throws(input.SkipLastField); + } + + [Test] + public void Construction_Invalid() + { + Assert.Throws(() => new CodedInputStream((byte[]) null)); + Assert.Throws(() => new CodedInputStream(null, 0, 0)); + Assert.Throws(() => new CodedInputStream((Stream) null)); + Assert.Throws(() => new CodedInputStream(new byte[10], 100, 0)); + Assert.Throws(() => new CodedInputStream(new byte[10], 5, 10)); + } + + [Test] + public void CreateWithLimits_InvalidLimits() + { + var stream = new MemoryStream(); + Assert.Throws(() => CodedInputStream.CreateWithLimits(stream, 0, 1)); + Assert.Throws(() => CodedInputStream.CreateWithLimits(stream, 1, 0)); + } + + [Test] + public void Dispose_DisposesUnderlyingStream() + { + var memoryStream = new MemoryStream(); + Assert.IsTrue(memoryStream.CanRead); + using (var cis = new CodedInputStream(memoryStream)) + { + } + Assert.IsFalse(memoryStream.CanRead); // Disposed + } + + [Test] + public void Dispose_WithLeaveOpen() + { + var memoryStream = new MemoryStream(); + Assert.IsTrue(memoryStream.CanRead); + using (var cis = new CodedInputStream(memoryStream, true)) + { + } + Assert.IsTrue(memoryStream.CanRead); // We left the stream open + } + } +} \ No newline at end of file diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedOutputStreamTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedOutputStreamTest.cs new file mode 100644 index 000000000000..01bd3218f337 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedOutputStreamTest.cs @@ -0,0 +1,419 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.IO; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class CodedOutputStreamTest + { + /// + /// Writes the given value using WriteRawVarint32() and WriteRawVarint64() and + /// checks that the result matches the given bytes + /// + private static void AssertWriteVarint(byte[] data, ulong value) + { + // Only do 32-bit write if the value fits in 32 bits. + if ((value >> 32) == 0) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput); + output.WriteRawVarint32((uint) value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + // Also try computing size. + Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint32Size((uint) value)); + } + + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput); + output.WriteRawVarint64(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + + // Also try computing size. + Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint64Size(value)); + } + + // Try different buffer sizes. + for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2) + { + // Only do 32-bit write if the value fits in 32 bits. + if ((value >> 32) == 0) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = + new CodedOutputStream(rawOutput, bufferSize); + output.WriteRawVarint32((uint) value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + } + + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput, bufferSize); + output.WriteRawVarint64(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + } + } + } + + /// + /// Tests WriteRawVarint32() and WriteRawVarint64() + /// + [Test] + public void WriteVarint() + { + AssertWriteVarint(new byte[] {0x00}, 0); + AssertWriteVarint(new byte[] {0x01}, 1); + AssertWriteVarint(new byte[] {0x7f}, 127); + // 14882 + AssertWriteVarint(new byte[] {0xa2, 0x74}, (0x22 << 0) | (0x74 << 7)); + // 2961488830 + AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x0b}, + (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | + (0x0bL << 28)); + + // 64-bit + // 7256456126 + AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x1b}, + (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | + (0x1bL << 28)); + // 41256202580718336 + AssertWriteVarint( + new byte[] {0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49}, + (0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) | + (0x43UL << 28) | (0x49L << 35) | (0x24UL << 42) | (0x49UL << 49)); + // 11964378330978735131 + AssertWriteVarint( + new byte[] {0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01}, + unchecked((ulong) + ((0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) | + (0x3bL << 28) | (0x56L << 35) | (0x00L << 42) | + (0x05L << 49) | (0x26L << 56) | (0x01L << 63)))); + } + + /// + /// Parses the given bytes using WriteRawLittleEndian32() and checks + /// that the result matches the given value. + /// + private static void AssertWriteLittleEndian32(byte[] data, uint value) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput); + output.WriteRawLittleEndian32(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + + // Try different buffer sizes. + for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2) + { + rawOutput = new MemoryStream(); + output = new CodedOutputStream(rawOutput, bufferSize); + output.WriteRawLittleEndian32(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + } + } + + /// + /// Parses the given bytes using WriteRawLittleEndian64() and checks + /// that the result matches the given value. + /// + private static void AssertWriteLittleEndian64(byte[] data, ulong value) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput); + output.WriteRawLittleEndian64(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + + // Try different block sizes. + for (int blockSize = 1; blockSize <= 16; blockSize *= 2) + { + rawOutput = new MemoryStream(); + output = new CodedOutputStream(rawOutput, blockSize); + output.WriteRawLittleEndian64(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + } + } + + /// + /// Tests writeRawLittleEndian32() and writeRawLittleEndian64(). + /// + [Test] + public void WriteLittleEndian() + { + AssertWriteLittleEndian32(new byte[] {0x78, 0x56, 0x34, 0x12}, 0x12345678); + AssertWriteLittleEndian32(new byte[] {0xf0, 0xde, 0xbc, 0x9a}, 0x9abcdef0); + + AssertWriteLittleEndian64( + new byte[] {0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12}, + 0x123456789abcdef0L); + AssertWriteLittleEndian64( + new byte[] {0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a}, + 0x9abcdef012345678UL); + } + + [Test] + public void WriteWholeMessage_VaryingBlockSizes() + { + TestAllTypes message = SampleMessages.CreateFullTestAllTypes(); + + byte[] rawBytes = message.ToByteArray(); + + // Try different block sizes. + for (int blockSize = 1; blockSize < 256; blockSize *= 2) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput, blockSize); + message.WriteTo(output); + output.Flush(); + Assert.AreEqual(rawBytes, rawOutput.ToArray()); + } + } + + [Test] + public void EncodeZigZag32() + { + Assert.AreEqual(0u, CodedOutputStream.EncodeZigZag32(0)); + Assert.AreEqual(1u, CodedOutputStream.EncodeZigZag32(-1)); + Assert.AreEqual(2u, CodedOutputStream.EncodeZigZag32(1)); + Assert.AreEqual(3u, CodedOutputStream.EncodeZigZag32(-2)); + Assert.AreEqual(0x7FFFFFFEu, CodedOutputStream.EncodeZigZag32(0x3FFFFFFF)); + Assert.AreEqual(0x7FFFFFFFu, CodedOutputStream.EncodeZigZag32(unchecked((int) 0xC0000000))); + Assert.AreEqual(0xFFFFFFFEu, CodedOutputStream.EncodeZigZag32(0x7FFFFFFF)); + Assert.AreEqual(0xFFFFFFFFu, CodedOutputStream.EncodeZigZag32(unchecked((int) 0x80000000))); + } + + [Test] + public void EncodeZigZag64() + { + Assert.AreEqual(0u, CodedOutputStream.EncodeZigZag64(0)); + Assert.AreEqual(1u, CodedOutputStream.EncodeZigZag64(-1)); + Assert.AreEqual(2u, CodedOutputStream.EncodeZigZag64(1)); + Assert.AreEqual(3u, CodedOutputStream.EncodeZigZag64(-2)); + Assert.AreEqual(0x000000007FFFFFFEuL, + CodedOutputStream.EncodeZigZag64(unchecked((long) 0x000000003FFFFFFFUL))); + Assert.AreEqual(0x000000007FFFFFFFuL, + CodedOutputStream.EncodeZigZag64(unchecked((long) 0xFFFFFFFFC0000000UL))); + Assert.AreEqual(0x00000000FFFFFFFEuL, + CodedOutputStream.EncodeZigZag64(unchecked((long) 0x000000007FFFFFFFUL))); + Assert.AreEqual(0x00000000FFFFFFFFuL, + CodedOutputStream.EncodeZigZag64(unchecked((long) 0xFFFFFFFF80000000UL))); + Assert.AreEqual(0xFFFFFFFFFFFFFFFEL, + CodedOutputStream.EncodeZigZag64(unchecked((long) 0x7FFFFFFFFFFFFFFFUL))); + Assert.AreEqual(0xFFFFFFFFFFFFFFFFL, + CodedOutputStream.EncodeZigZag64(unchecked((long) 0x8000000000000000UL))); + } + + [Test] + public void RoundTripZigZag32() + { + // Some easier-to-verify round-trip tests. The inputs (other than 0, 1, -1) + // were chosen semi-randomly via keyboard bashing. + Assert.AreEqual(0, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(0))); + Assert.AreEqual(1, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(1))); + Assert.AreEqual(-1, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-1))); + Assert.AreEqual(14927, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(14927))); + Assert.AreEqual(-3612, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-3612))); + } + + [Test] + public void RoundTripZigZag64() + { + Assert.AreEqual(0, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(0))); + Assert.AreEqual(1, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(1))); + Assert.AreEqual(-1, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-1))); + Assert.AreEqual(14927, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(14927))); + Assert.AreEqual(-3612, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-3612))); + + Assert.AreEqual(856912304801416L, + CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(856912304801416L))); + Assert.AreEqual(-75123905439571256L, + CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-75123905439571256L))); + } + + [Test] + public void TestNegativeEnumNoTag() + { + Assert.AreEqual(10, CodedOutputStream.ComputeInt32Size(-2)); + Assert.AreEqual(10, CodedOutputStream.ComputeEnumSize((int) SampleEnum.NegativeValue)); + + byte[] bytes = new byte[10]; + CodedOutputStream output = new CodedOutputStream(bytes); + output.WriteEnum((int) SampleEnum.NegativeValue); + + Assert.AreEqual(0, output.SpaceLeft); + Assert.AreEqual("FE-FF-FF-FF-FF-FF-FF-FF-FF-01", BitConverter.ToString(bytes)); + } + + [Test] + public void TestCodedInputOutputPosition() + { + byte[] content = new byte[110]; + for (int i = 0; i < content.Length; i++) + content[i] = (byte)i; + + byte[] child = new byte[120]; + { + MemoryStream ms = new MemoryStream(child); + CodedOutputStream cout = new CodedOutputStream(ms, 20); + // Field 11: numeric value: 500 + cout.WriteTag(11, WireFormat.WireType.Varint); + Assert.AreEqual(1, cout.Position); + cout.WriteInt32(500); + Assert.AreEqual(3, cout.Position); + //Field 12: length delimited 120 bytes + cout.WriteTag(12, WireFormat.WireType.LengthDelimited); + Assert.AreEqual(4, cout.Position); + cout.WriteBytes(ByteString.CopyFrom(content)); + Assert.AreEqual(115, cout.Position); + // Field 13: fixed numeric value: 501 + cout.WriteTag(13, WireFormat.WireType.Fixed32); + Assert.AreEqual(116, cout.Position); + cout.WriteSFixed32(501); + Assert.AreEqual(120, cout.Position); + cout.Flush(); + } + + byte[] bytes = new byte[130]; + { + CodedOutputStream cout = new CodedOutputStream(bytes); + // Field 1: numeric value: 500 + cout.WriteTag(1, WireFormat.WireType.Varint); + Assert.AreEqual(1, cout.Position); + cout.WriteInt32(500); + Assert.AreEqual(3, cout.Position); + //Field 2: length delimited 120 bytes + cout.WriteTag(2, WireFormat.WireType.LengthDelimited); + Assert.AreEqual(4, cout.Position); + cout.WriteBytes(ByteString.CopyFrom(child)); + Assert.AreEqual(125, cout.Position); + // Field 3: fixed numeric value: 500 + cout.WriteTag(3, WireFormat.WireType.Fixed32); + Assert.AreEqual(126, cout.Position); + cout.WriteSFixed32(501); + Assert.AreEqual(130, cout.Position); + cout.Flush(); + } + // Now test Input stream: + { + CodedInputStream cin = new CodedInputStream(new MemoryStream(bytes), new byte[50], 0, 0, false); + Assert.AreEqual(0, cin.Position); + // Field 1: + uint tag = cin.ReadTag(); + Assert.AreEqual(1, tag >> 3); + Assert.AreEqual(1, cin.Position); + Assert.AreEqual(500, cin.ReadInt32()); + Assert.AreEqual(3, cin.Position); + //Field 2: + tag = cin.ReadTag(); + Assert.AreEqual(2, tag >> 3); + Assert.AreEqual(4, cin.Position); + int childlen = cin.ReadLength(); + Assert.AreEqual(120, childlen); + Assert.AreEqual(5, cin.Position); + int oldlimit = cin.PushLimit((int)childlen); + Assert.AreEqual(5, cin.Position); + // Now we are reading child message + { + // Field 11: numeric value: 500 + tag = cin.ReadTag(); + Assert.AreEqual(11, tag >> 3); + Assert.AreEqual(6, cin.Position); + Assert.AreEqual(500, cin.ReadInt32()); + Assert.AreEqual(8, cin.Position); + //Field 12: length delimited 120 bytes + tag = cin.ReadTag(); + Assert.AreEqual(12, tag >> 3); + Assert.AreEqual(9, cin.Position); + ByteString bstr = cin.ReadBytes(); + Assert.AreEqual(110, bstr.Length); + Assert.AreEqual((byte) 109, bstr[109]); + Assert.AreEqual(120, cin.Position); + // Field 13: fixed numeric value: 501 + tag = cin.ReadTag(); + Assert.AreEqual(13, tag >> 3); + // ROK - Previously broken here, this returned 126 failing to account for bufferSizeAfterLimit + Assert.AreEqual(121, cin.Position); + Assert.AreEqual(501, cin.ReadSFixed32()); + Assert.AreEqual(125, cin.Position); + Assert.IsTrue(cin.IsAtEnd); + } + cin.PopLimit(oldlimit); + Assert.AreEqual(125, cin.Position); + // Field 3: fixed numeric value: 501 + tag = cin.ReadTag(); + Assert.AreEqual(3, tag >> 3); + Assert.AreEqual(126, cin.Position); + Assert.AreEqual(501, cin.ReadSFixed32()); + Assert.AreEqual(130, cin.Position); + Assert.IsTrue(cin.IsAtEnd); + } + } + + [Test] + public void Dispose_DisposesUnderlyingStream() + { + var memoryStream = new MemoryStream(); + Assert.IsTrue(memoryStream.CanWrite); + using (var cos = new CodedOutputStream(memoryStream)) + { + cos.WriteRawByte(0); + Assert.AreEqual(0, memoryStream.Position); // Not flushed yet + } + Assert.AreEqual(1, memoryStream.ToArray().Length); // Flushed data from CodedOutputStream to MemoryStream + Assert.IsFalse(memoryStream.CanWrite); // Disposed + } + + [Test] + public void Dispose_WithLeaveOpen() + { + var memoryStream = new MemoryStream(); + Assert.IsTrue(memoryStream.CanWrite); + using (var cos = new CodedOutputStream(memoryStream, true)) + { + cos.WriteRawByte(0); + Assert.AreEqual(0, memoryStream.Position); // Not flushed yet + } + Assert.AreEqual(1, memoryStream.Position); // Flushed data from CodedOutputStream to MemoryStream + Assert.IsTrue(memoryStream.CanWrite); // We left the stream open + } + } +} \ No newline at end of file diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Collections/MapFieldTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Collections/MapFieldTest.cs new file mode 100644 index 000000000000..3b4e1d33b180 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Collections/MapFieldTest.cs @@ -0,0 +1,532 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections.Generic; +using Google.Protobuf.TestProtos; +using NUnit.Framework; +using System.Collections; +using System.Linq; + +namespace Google.Protobuf.Collections +{ + /// + /// Tests for MapField which aren't reliant on the encoded format - + /// tests for serialization/deserialization are part of GeneratedMessageTest. + /// + public class MapFieldTest + { + [Test] + public void Clone_ClonesMessages() + { + var message = new ForeignMessage { C = 20 }; + var map = new MapField { { "x", message } }; + var clone = map.Clone(); + map["x"].C = 30; + Assert.AreEqual(20, clone["x"].C); + } + + [Test] + public void NullValuesProhibited() + { + TestNullValues(0); + TestNullValues(""); + TestNullValues(new TestAllTypes()); + } + + private void TestNullValues(T nonNullValue) + { + var map = new MapField(); + var nullValue = (T) (object) null; + Assert.Throws(() => map.Add(0, nullValue)); + Assert.Throws(() => map[0] = nullValue); + map.Add(1, nonNullValue); + map[1] = nonNullValue; + } + + [Test] + public void Add_ForbidsNullKeys() + { + var map = new MapField(); + Assert.Throws(() => map.Add(null, new ForeignMessage())); + } + + [Test] + public void Indexer_ForbidsNullKeys() + { + var map = new MapField(); + Assert.Throws(() => map[null] = new ForeignMessage()); + } + + [Test] + public void AddPreservesInsertionOrder() + { + var map = new MapField(); + map.Add("a", "v1"); + map.Add("b", "v2"); + map.Add("c", "v3"); + map.Remove("b"); + map.Add("d", "v4"); + CollectionAssert.AreEqual(new[] { "a", "c", "d" }, map.Keys); + CollectionAssert.AreEqual(new[] { "v1", "v3", "v4" }, map.Values); + } + + [Test] + public void EqualityIsOrderInsensitive() + { + var map1 = new MapField(); + map1.Add("a", "v1"); + map1.Add("b", "v2"); + + var map2 = new MapField(); + map2.Add("b", "v2"); + map2.Add("a", "v1"); + + EqualityTester.AssertEquality(map1, map2); + } + + [Test] + public void EqualityIsKeySensitive() + { + var map1 = new MapField(); + map1.Add("first key", "v1"); + map1.Add("second key", "v2"); + + var map2 = new MapField(); + map2.Add("third key", "v1"); + map2.Add("fourth key", "v2"); + + EqualityTester.AssertInequality(map1, map2); + } + + [Test] + public void Equality_Simple() + { + var map = new MapField(); + EqualityTester.AssertEquality(map, map); + EqualityTester.AssertInequality(map, null); + Assert.IsFalse(map.Equals(new object())); + } + + [Test] + public void EqualityIsValueSensitive() + { + // Note: Without some care, it's a little easier than one might + // hope to see hash collisions, but only in some environments... + var map1 = new MapField(); + map1.Add("a", "first value"); + map1.Add("b", "second value"); + + var map2 = new MapField(); + map2.Add("a", "third value"); + map2.Add("b", "fourth value"); + + EqualityTester.AssertInequality(map1, map2); + } + + [Test] + public void Add_Dictionary() + { + var map1 = new MapField + { + { "x", "y" }, + { "a", "b" } + }; + var map2 = new MapField + { + { "before", "" }, + map1, + { "after", "" } + }; + var expected = new MapField + { + { "before", "" }, + { "x", "y" }, + { "a", "b" }, + { "after", "" } + }; + Assert.AreEqual(expected, map2); + CollectionAssert.AreEqual(new[] { "before", "x", "a", "after" }, map2.Keys); + } + + // General IDictionary behavior tests + [Test] + public void Add_KeyAlreadyExists() + { + var map = new MapField(); + map.Add("foo", "bar"); + Assert.Throws(() => map.Add("foo", "baz")); + } + + [Test] + public void Add_Pair() + { + var map = new MapField(); + ICollection> collection = map; + collection.Add(NewKeyValuePair("x", "y")); + Assert.AreEqual("y", map["x"]); + Assert.Throws(() => collection.Add(NewKeyValuePair("x", "z"))); + } + + [Test] + public void Contains_Pair() + { + var map = new MapField { { "x", "y" } }; + ICollection> collection = map; + Assert.IsTrue(collection.Contains(NewKeyValuePair("x", "y"))); + Assert.IsFalse(collection.Contains(NewKeyValuePair("x", "z"))); + Assert.IsFalse(collection.Contains(NewKeyValuePair("z", "y"))); + } + + [Test] + public void Remove_Key() + { + var map = new MapField(); + map.Add("foo", "bar"); + Assert.AreEqual(1, map.Count); + Assert.IsFalse(map.Remove("missing")); + Assert.AreEqual(1, map.Count); + Assert.IsTrue(map.Remove("foo")); + Assert.AreEqual(0, map.Count); + Assert.Throws(() => map.Remove(null)); + } + + [Test] + public void Remove_Pair() + { + var map = new MapField(); + map.Add("foo", "bar"); + ICollection> collection = map; + Assert.AreEqual(1, map.Count); + Assert.IsFalse(collection.Remove(NewKeyValuePair("wrong key", "bar"))); + Assert.AreEqual(1, map.Count); + Assert.IsFalse(collection.Remove(NewKeyValuePair("foo", "wrong value"))); + Assert.AreEqual(1, map.Count); + Assert.IsTrue(collection.Remove(NewKeyValuePair("foo", "bar"))); + Assert.AreEqual(0, map.Count); + Assert.Throws(() => collection.Remove(new KeyValuePair(null, ""))); + } + + [Test] + public void CopyTo_Pair() + { + var map = new MapField(); + map.Add("foo", "bar"); + ICollection> collection = map; + KeyValuePair[] array = new KeyValuePair[3]; + collection.CopyTo(array, 1); + Assert.AreEqual(NewKeyValuePair("foo", "bar"), array[1]); + } + + [Test] + public void Clear() + { + var map = new MapField { { "x", "y" } }; + Assert.AreEqual(1, map.Count); + map.Clear(); + Assert.AreEqual(0, map.Count); + map.Add("x", "y"); + Assert.AreEqual(1, map.Count); + } + + [Test] + public void Indexer_Get() + { + var map = new MapField { { "x", "y" } }; + Assert.AreEqual("y", map["x"]); + Assert.Throws(() => { var ignored = map["z"]; }); + } + + [Test] + public void Indexer_Set() + { + var map = new MapField(); + map["x"] = "y"; + Assert.AreEqual("y", map["x"]); + map["x"] = "z"; // This won't throw, unlike Add. + Assert.AreEqual("z", map["x"]); + } + + [Test] + public void GetEnumerator_NonGeneric() + { + IEnumerable map = new MapField { { "x", "y" } }; + CollectionAssert.AreEqual(new[] { new KeyValuePair("x", "y") }, + map.Cast().ToList()); + } + + // Test for the explicitly-implemented non-generic IDictionary interface + [Test] + public void IDictionary_GetEnumerator() + { + IDictionary map = new MapField { { "x", "y" } }; + var enumerator = map.GetEnumerator(); + + // Commented assertions show an ideal situation - it looks like + // the LinkedList enumerator doesn't throw when you ask for the current entry + // at an inappropriate time; fixing this would be more work than it's worth. + // Assert.Throws(() => enumerator.Current.GetHashCode()); + Assert.IsTrue(enumerator.MoveNext()); + Assert.AreEqual("x", enumerator.Key); + Assert.AreEqual("y", enumerator.Value); + Assert.AreEqual(new DictionaryEntry("x", "y"), enumerator.Current); + Assert.AreEqual(new DictionaryEntry("x", "y"), enumerator.Entry); + Assert.IsFalse(enumerator.MoveNext()); + // Assert.Throws(() => enumerator.Current.GetHashCode()); + enumerator.Reset(); + // Assert.Throws(() => enumerator.Current.GetHashCode()); + Assert.IsTrue(enumerator.MoveNext()); + Assert.AreEqual("x", enumerator.Key); // Assume the rest are okay + } + + [Test] + public void IDictionary_Add() + { + var map = new MapField { { "x", "y" } }; + IDictionary dictionary = map; + dictionary.Add("a", "b"); + Assert.AreEqual("b", map["a"]); + Assert.Throws(() => dictionary.Add("a", "duplicate")); + Assert.Throws(() => dictionary.Add(new object(), "key is bad")); + Assert.Throws(() => dictionary.Add("value is bad", new object())); + } + + [Test] + public void IDictionary_Contains() + { + var map = new MapField { { "x", "y" } }; + IDictionary dictionary = map; + + Assert.IsFalse(dictionary.Contains("a")); + Assert.IsFalse(dictionary.Contains(5)); + // Surprising, but IDictionary.Contains is only about keys. + Assert.IsFalse(dictionary.Contains(new DictionaryEntry("x", "y"))); + Assert.IsTrue(dictionary.Contains("x")); + } + + [Test] + public void IDictionary_Remove() + { + var map = new MapField { { "x", "y" } }; + IDictionary dictionary = map; + dictionary.Remove("a"); + Assert.AreEqual(1, dictionary.Count); + dictionary.Remove(5); + Assert.AreEqual(1, dictionary.Count); + dictionary.Remove(new DictionaryEntry("x", "y")); + Assert.AreEqual(1, dictionary.Count); + dictionary.Remove("x"); + Assert.AreEqual(0, dictionary.Count); + Assert.Throws(() => dictionary.Remove(null)); + } + + [Test] + public void IDictionary_CopyTo() + { + var map = new MapField { { "x", "y" } }; + IDictionary dictionary = map; + var array = new DictionaryEntry[3]; + dictionary.CopyTo(array, 1); + CollectionAssert.AreEqual(new[] { default(DictionaryEntry), new DictionaryEntry("x", "y"), default(DictionaryEntry) }, + array); + var objectArray = new object[3]; + dictionary.CopyTo(objectArray, 1); + CollectionAssert.AreEqual(new object[] { null, new DictionaryEntry("x", "y"), null }, + objectArray); + } + + [Test] + public void IDictionary_IsFixedSize() + { + var map = new MapField { { "x", "y" } }; + IDictionary dictionary = map; + Assert.IsFalse(dictionary.IsFixedSize); + } + + [Test] + public void IDictionary_Keys() + { + IDictionary dictionary = new MapField { { "x", "y" } }; + CollectionAssert.AreEqual(new[] { "x" }, dictionary.Keys); + } + + [Test] + public void IDictionary_Values() + { + IDictionary dictionary = new MapField { { "x", "y" } }; + CollectionAssert.AreEqual(new[] { "y" }, dictionary.Values); + } + + [Test] + public void IDictionary_IsSynchronized() + { + IDictionary dictionary = new MapField { { "x", "y" } }; + Assert.IsFalse(dictionary.IsSynchronized); + } + + [Test] + public void IDictionary_SyncRoot() + { + IDictionary dictionary = new MapField { { "x", "y" } }; + Assert.AreSame(dictionary, dictionary.SyncRoot); + } + + [Test] + public void IDictionary_Indexer_Get() + { + IDictionary dictionary = new MapField { { "x", "y" } }; + Assert.AreEqual("y", dictionary["x"]); + Assert.IsNull(dictionary["a"]); + Assert.IsNull(dictionary[5]); + Assert.Throws(() => dictionary[null].GetHashCode()); + } + + [Test] + public void IDictionary_Indexer_Set() + { + var map = new MapField { { "x", "y" } }; + IDictionary dictionary = map; + map["a"] = "b"; + Assert.AreEqual("b", map["a"]); + map["a"] = "c"; + Assert.AreEqual("c", map["a"]); + Assert.Throws(() => dictionary[5] = "x"); + Assert.Throws(() => dictionary["x"] = 5); + Assert.Throws(() => dictionary[null] = "z"); + Assert.Throws(() => dictionary["x"] = null); + } + + [Test] + public void KeysReturnsLiveView() + { + var map = new MapField(); + var keys = map.Keys; + CollectionAssert.AreEqual(new string[0], keys); + map["foo"] = "bar"; + map["x"] = "y"; + CollectionAssert.AreEqual(new[] { "foo", "x" }, keys); + } + + [Test] + public void ValuesReturnsLiveView() + { + var map = new MapField(); + var values = map.Values; + CollectionAssert.AreEqual(new string[0], values); + map["foo"] = "bar"; + map["x"] = "y"; + CollectionAssert.AreEqual(new[] { "bar", "y" }, values); + } + + // Just test keys - we know the implementation is the same for values + [Test] + public void ViewsAreReadOnly() + { + var map = new MapField(); + var keys = map.Keys; + Assert.IsTrue(keys.IsReadOnly); + Assert.Throws(() => keys.Clear()); + Assert.Throws(() => keys.Remove("a")); + Assert.Throws(() => keys.Add("a")); + } + + // Just test keys - we know the implementation is the same for values + [Test] + public void ViewCopyTo() + { + var map = new MapField { { "foo", "bar" }, { "x", "y" } }; + var keys = map.Keys; + var array = new string[4]; + Assert.Throws(() => keys.CopyTo(array, 3)); + Assert.Throws(() => keys.CopyTo(array, -1)); + keys.CopyTo(array, 1); + CollectionAssert.AreEqual(new[] { null, "foo", "x", null }, array); + } + + // Just test keys - we know the implementation is the same for values + [Test] + public void NonGenericViewCopyTo() + { + IDictionary map = new MapField { { "foo", "bar" }, { "x", "y" } }; + ICollection keys = map.Keys; + // Note the use of the Array type here rather than string[] + Array array = new string[4]; + Assert.Throws(() => keys.CopyTo(array, 3)); + Assert.Throws(() => keys.CopyTo(array, -1)); + keys.CopyTo(array, 1); + CollectionAssert.AreEqual(new[] { null, "foo", "x", null }, array); + } + + [Test] + public void KeysContains() + { + var map = new MapField { { "foo", "bar" }, { "x", "y" } }; + var keys = map.Keys; + Assert.IsTrue(keys.Contains("foo")); + Assert.IsFalse(keys.Contains("bar")); // It's a value! + Assert.IsFalse(keys.Contains("1")); + // Keys can't be null, so we should prevent contains check + Assert.Throws(() => keys.Contains(null)); + } + + [Test] + public void ValuesContains() + { + var map = new MapField { { "foo", "bar" }, { "x", "y" } }; + var values = map.Values; + Assert.IsTrue(values.Contains("bar")); + Assert.IsFalse(values.Contains("foo")); // It's a key! + Assert.IsFalse(values.Contains("1")); + // Values can be null, so this makes sense + Assert.IsFalse(values.Contains(null)); + } + + [Test] + public void ToString_StringToString() + { + var map = new MapField { { "foo", "bar" }, { "x", "y" } }; + Assert.AreEqual("{ \"foo\": \"bar\", \"x\": \"y\" }", map.ToString()); + } + + [Test] + public void ToString_UnsupportedKeyType() + { + var map = new MapField { { 10, "foo" } }; + Assert.Throws(() => map.ToString()); + } + + private static KeyValuePair NewKeyValuePair(TKey key, TValue value) + { + return new KeyValuePair(key, value); + } + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs new file mode 100644 index 000000000000..6852f75f8eb2 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs @@ -0,0 +1,746 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using Google.Protobuf.TestProtos; +using Google.Protobuf.WellKnownTypes; +using NUnit.Framework; + +namespace Google.Protobuf.Collections +{ + public class RepeatedFieldTest + { + [Test] + public void NullValuesRejected() + { + var list = new RepeatedField(); + Assert.Throws(() => list.Add((string)null)); + Assert.Throws(() => list.Add((IEnumerable)null)); + Assert.Throws(() => list.Add((RepeatedField)null)); + Assert.Throws(() => list.Contains(null)); + Assert.Throws(() => list.IndexOf(null)); + } + + [Test] + public void Add_SingleItem() + { + var list = new RepeatedField(); + list.Add("foo"); + Assert.AreEqual(1, list.Count); + Assert.AreEqual("foo", list[0]); + } + + [Test] + public void Add_Sequence() + { + var list = new RepeatedField(); + list.Add(new[] { "foo", "bar" }); + Assert.AreEqual(2, list.Count); + Assert.AreEqual("foo", list[0]); + Assert.AreEqual("bar", list[1]); + } + + [Test] + public void AddRange_SlowPath() + { + var list = new RepeatedField(); + list.AddRange(new[] { "foo", "bar" }.Select(x => x)); + Assert.AreEqual(2, list.Count); + Assert.AreEqual("foo", list[0]); + Assert.AreEqual("bar", list[1]); + } + + [Test] + public void AddRange_SlowPath_NullsProhibited_ReferenceType() + { + var list = new RepeatedField(); + // It's okay for this to throw ArgumentNullException if necessary. + // It's not ideal, but not awful. + Assert.Catch(() => list.AddRange(new[] { "foo", null }.Select(x => x))); + } + + [Test] + public void AddRange_SlowPath_NullsProhibited_NullableValueType() + { + var list = new RepeatedField(); + // It's okay for this to throw ArgumentNullException if necessary. + // It's not ideal, but not awful. + Assert.Catch(() => list.AddRange(new[] { 20, (int?)null }.Select(x => x))); + } + + [Test] + public void AddRange_Optimized_NonNullableValueType() + { + var list = new RepeatedField(); + list.AddRange(new List { 20, 30 }); + Assert.AreEqual(2, list.Count); + Assert.AreEqual(20, list[0]); + Assert.AreEqual(30, list[1]); + } + + [Test] + public void AddRange_Optimized_ReferenceType() + { + var list = new RepeatedField(); + list.AddRange(new List { "foo", "bar" }); + Assert.AreEqual(2, list.Count); + Assert.AreEqual("foo", list[0]); + Assert.AreEqual("bar", list[1]); + } + + [Test] + public void AddRange_Optimized_NullableValueType() + { + var list = new RepeatedField(); + list.AddRange(new List { 20, 30 }); + Assert.AreEqual(2, list.Count); + Assert.AreEqual((int?) 20, list[0]); + Assert.AreEqual((int?) 30, list[1]); + } + + [Test] + public void AddRange_Optimized_NullsProhibited_ReferenceType() + { + // We don't just trust that a collection with a nullable element type doesn't contain nulls + var list = new RepeatedField(); + // It's okay for this to throw ArgumentNullException if necessary. + // It's not ideal, but not awful. + Assert.Catch(() => list.AddRange(new List { "foo", null })); + } + + [Test] + public void AddRange_Optimized_NullsProhibited_NullableValueType() + { + // We don't just trust that a collection with a nullable element type doesn't contain nulls + var list = new RepeatedField(); + // It's okay for this to throw ArgumentNullException if necessary. + // It's not ideal, but not awful. + Assert.Catch(() => list.AddRange(new List { 20, null })); + } + + [Test] + public void AddRange_AlreadyNotEmpty() + { + var list = new RepeatedField { 1, 2, 3 }; + list.AddRange(new List { 4, 5, 6 }); + CollectionAssert.AreEqual(new[] { 1, 2, 3, 4, 5, 6 }, list); + } + + [Test] + public void AddRange_RepeatedField() + { + var list = new RepeatedField { "original" }; + list.AddRange(new RepeatedField { "foo", "bar" }); + Assert.AreEqual(3, list.Count); + Assert.AreEqual("original", list[0]); + Assert.AreEqual("foo", list[1]); + Assert.AreEqual("bar", list[2]); + } + + [Test] + public void RemoveAt_Valid() + { + var list = new RepeatedField { "first", "second", "third" }; + list.RemoveAt(1); + CollectionAssert.AreEqual(new[] { "first", "third" }, list); + // Just check that these don't throw... + list.RemoveAt(list.Count - 1); // Now the count will be 1... + list.RemoveAt(0); + Assert.AreEqual(0, list.Count); + } + + [Test] + public void RemoveAt_Invalid() + { + var list = new RepeatedField { "first", "second", "third" }; + Assert.Throws(() => list.RemoveAt(-1)); + Assert.Throws(() => list.RemoveAt(3)); + } + + [Test] + public void Insert_Valid() + { + var list = new RepeatedField { "first", "second" }; + list.Insert(1, "middle"); + CollectionAssert.AreEqual(new[] { "first", "middle", "second" }, list); + list.Insert(3, "end"); + CollectionAssert.AreEqual(new[] { "first", "middle", "second", "end" }, list); + list.Insert(0, "start"); + CollectionAssert.AreEqual(new[] { "start", "first", "middle", "second", "end" }, list); + } + + [Test] + public void Insert_Invalid() + { + var list = new RepeatedField { "first", "second" }; + Assert.Throws(() => list.Insert(-1, "foo")); + Assert.Throws(() => list.Insert(3, "foo")); + Assert.Throws(() => list.Insert(0, null)); + } + + [Test] + public void Equals_RepeatedField() + { + var list = new RepeatedField { "first", "second" }; + Assert.IsFalse(list.Equals((RepeatedField) null)); + Assert.IsTrue(list.Equals(list)); + Assert.IsFalse(list.Equals(new RepeatedField { "first", "third" })); + Assert.IsFalse(list.Equals(new RepeatedField { "first" })); + Assert.IsTrue(list.Equals(new RepeatedField { "first", "second" })); + } + + [Test] + public void Equals_Object() + { + var list = new RepeatedField { "first", "second" }; + Assert.IsFalse(list.Equals((object) null)); + Assert.IsTrue(list.Equals((object) list)); + Assert.IsFalse(list.Equals((object) new RepeatedField { "first", "third" })); + Assert.IsFalse(list.Equals((object) new RepeatedField { "first" })); + Assert.IsTrue(list.Equals((object) new RepeatedField { "first", "second" })); + Assert.IsFalse(list.Equals(new object())); + } + + [Test] + public void GetEnumerator_GenericInterface() + { + IEnumerable list = new RepeatedField { "first", "second" }; + // Select gets rid of the optimizations in ToList... + CollectionAssert.AreEqual(new[] { "first", "second" }, list.Select(x => x).ToList()); + } + + [Test] + public void GetEnumerator_NonGenericInterface() + { + IEnumerable list = new RepeatedField { "first", "second" }; + CollectionAssert.AreEqual(new[] { "first", "second" }, list.Cast().ToList()); + } + + [Test] + public void CopyTo() + { + var list = new RepeatedField { "first", "second" }; + string[] stringArray = new string[4]; + list.CopyTo(stringArray, 1); + CollectionAssert.AreEqual(new[] { null, "first", "second", null }, stringArray); + } + + [Test] + public void Indexer_Get() + { + var list = new RepeatedField { "first", "second" }; + Assert.AreEqual("first", list[0]); + Assert.AreEqual("second", list[1]); + Assert.Throws(() => list[-1].GetHashCode()); + Assert.Throws(() => list[2].GetHashCode()); + } + + [Test] + public void Indexer_Set() + { + var list = new RepeatedField { "first", "second" }; + list[0] = "changed"; + Assert.AreEqual("changed", list[0]); + Assert.Throws(() => list[0] = null); + Assert.Throws(() => list[-1] = "bad"); + Assert.Throws(() => list[2] = "bad"); + } + + [Test] + public void Clone_ReturnsMutable() + { + var list = new RepeatedField { 0 }; + var clone = list.Clone(); + clone[0] = 1; + } + + [Test] + public void Enumerator() + { + var list = new RepeatedField { "first", "second" }; + using (var enumerator = list.GetEnumerator()) + { + Assert.IsTrue(enumerator.MoveNext()); + Assert.AreEqual("first", enumerator.Current); + Assert.IsTrue(enumerator.MoveNext()); + Assert.AreEqual("second", enumerator.Current); + Assert.IsFalse(enumerator.MoveNext()); + Assert.IsFalse(enumerator.MoveNext()); + } + } + + [Test] + public void AddEntriesFrom_PackedInt32() + { + uint packedTag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + var length = CodedOutputStream.ComputeInt32Size(10) + + CodedOutputStream.ComputeInt32Size(999) + + CodedOutputStream.ComputeInt32Size(-1000); + output.WriteTag(packedTag); + output.WriteRawVarint32((uint) length); + output.WriteInt32(10); + output.WriteInt32(999); + output.WriteInt32(-1000); + output.Flush(); + stream.Position = 0; + + // Deliberately "expecting" a non-packed tag, but we detect that the data is + // actually packed. + uint nonPackedTag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var field = new RepeatedField(); + var input = new CodedInputStream(stream); + input.AssertNextTag(packedTag); + field.AddEntriesFrom(input, FieldCodec.ForInt32(nonPackedTag)); + CollectionAssert.AreEqual(new[] { 10, 999, -1000 }, field); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void AddEntriesFrom_NonPackedInt32() + { + uint nonPackedTag = WireFormat.MakeTag(10, WireFormat.WireType.Varint); + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + output.WriteTag(nonPackedTag); + output.WriteInt32(10); + output.WriteTag(nonPackedTag); + output.WriteInt32(999); + output.WriteTag(nonPackedTag); + output.WriteInt32(-1000); // Just for variety... + output.Flush(); + stream.Position = 0; + + // Deliberately "expecting" a packed tag, but we detect that the data is + // actually not packed. + uint packedTag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var field = new RepeatedField(); + var input = new CodedInputStream(stream); + input.AssertNextTag(nonPackedTag); + field.AddEntriesFrom(input, FieldCodec.ForInt32(packedTag)); + CollectionAssert.AreEqual(new[] { 10, 999, -1000 }, field); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void AddEntriesFrom_String() + { + uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + output.WriteTag(tag); + output.WriteString("Foo"); + output.WriteTag(tag); + output.WriteString(""); + output.WriteTag(tag); + output.WriteString("Bar"); + output.Flush(); + stream.Position = 0; + + var field = new RepeatedField(); + var input = new CodedInputStream(stream); + input.AssertNextTag(tag); + field.AddEntriesFrom(input, FieldCodec.ForString(tag)); + CollectionAssert.AreEqual(new[] { "Foo", "", "Bar" }, field); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void AddEntriesFrom_Message() + { + var message1 = new ForeignMessage { C = 2000 }; + var message2 = new ForeignMessage { C = -250 }; + + uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + output.WriteTag(tag); + output.WriteMessage(message1); + output.WriteTag(tag); + output.WriteMessage(message2); + output.Flush(); + stream.Position = 0; + + var field = new RepeatedField(); + var input = new CodedInputStream(stream); + input.AssertNextTag(tag); + field.AddEntriesFrom(input, FieldCodec.ForMessage(tag, ForeignMessage.Parser)); + CollectionAssert.AreEqual(new[] { message1, message2}, field); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void WriteTo_PackedInt32() + { + uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var field = new RepeatedField { 10, 1000, 1000000 }; + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + field.WriteTo(output, FieldCodec.ForInt32(tag)); + output.Flush(); + stream.Position = 0; + + var input = new CodedInputStream(stream); + input.AssertNextTag(tag); + var length = input.ReadLength(); + Assert.AreEqual(10, input.ReadInt32()); + Assert.AreEqual(1000, input.ReadInt32()); + Assert.AreEqual(1000000, input.ReadInt32()); + Assert.IsTrue(input.IsAtEnd); + Assert.AreEqual(1 + CodedOutputStream.ComputeLengthSize(length) + length, stream.Length); + } + + [Test] + public void WriteTo_NonPackedInt32() + { + uint tag = WireFormat.MakeTag(10, WireFormat.WireType.Varint); + var field = new RepeatedField { 10, 1000, 1000000}; + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + field.WriteTo(output, FieldCodec.ForInt32(tag)); + output.Flush(); + stream.Position = 0; + + var input = new CodedInputStream(stream); + input.AssertNextTag(tag); + Assert.AreEqual(10, input.ReadInt32()); + input.AssertNextTag(tag); + Assert.AreEqual(1000, input.ReadInt32()); + input.AssertNextTag(tag); + Assert.AreEqual(1000000, input.ReadInt32()); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void WriteTo_String() + { + uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var field = new RepeatedField { "Foo", "", "Bar" }; + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + field.WriteTo(output, FieldCodec.ForString(tag)); + output.Flush(); + stream.Position = 0; + + var input = new CodedInputStream(stream); + input.AssertNextTag(tag); + Assert.AreEqual("Foo", input.ReadString()); + input.AssertNextTag(tag); + Assert.AreEqual("", input.ReadString()); + input.AssertNextTag(tag); + Assert.AreEqual("Bar", input.ReadString()); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void WriteTo_Message() + { + var message1 = new ForeignMessage { C = 20 }; + var message2 = new ForeignMessage { C = 25 }; + uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var field = new RepeatedField { message1, message2 }; + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + field.WriteTo(output, FieldCodec.ForMessage(tag, ForeignMessage.Parser)); + output.Flush(); + stream.Position = 0; + + var input = new CodedInputStream(stream); + input.AssertNextTag(tag); + Assert.AreEqual(message1, input.ReadMessage(ForeignMessage.Parser)); + input.AssertNextTag(tag); + Assert.AreEqual(message2, input.ReadMessage(ForeignMessage.Parser)); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void CalculateSize_VariableSizeNonPacked() + { + var list = new RepeatedField { 1, 500, 1 }; + var tag = WireFormat.MakeTag(1, WireFormat.WireType.Varint); + // 2 bytes for the first entry, 3 bytes for the second, 2 bytes for the third + Assert.AreEqual(7, list.CalculateSize(FieldCodec.ForInt32(tag))); + } + + [Test] + public void CalculateSize_FixedSizeNonPacked() + { + var list = new RepeatedField { 1, 500, 1 }; + var tag = WireFormat.MakeTag(1, WireFormat.WireType.Fixed32); + // 5 bytes for the each entry + Assert.AreEqual(15, list.CalculateSize(FieldCodec.ForSFixed32(tag))); + } + + [Test] + public void CalculateSize_VariableSizePacked() + { + var list = new RepeatedField { 1, 500, 1}; + var tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); + // 1 byte for the tag, 1 byte for the length, + // 1 byte for the first entry, 2 bytes for the second, 1 byte for the third + Assert.AreEqual(6, list.CalculateSize(FieldCodec.ForInt32(tag))); + } + + [Test] + public void CalculateSize_FixedSizePacked() + { + var list = new RepeatedField { 1, 500, 1 }; + var tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); + // 1 byte for the tag, 1 byte for the length, 4 bytes per entry + Assert.AreEqual(14, list.CalculateSize(FieldCodec.ForSFixed32(tag))); + } + + [Test] + public void TestNegativeEnumArray() + { + int arraySize = 1 + 1 + (11 * 5); + int msgSize = arraySize; + byte[] bytes = new byte[msgSize]; + CodedOutputStream output = new CodedOutputStream(bytes); + uint tag = WireFormat.MakeTag(8, WireFormat.WireType.Varint); + for (int i = 0; i >= -5; i--) + { + output.WriteTag(tag); + output.WriteEnum(i); + } + + Assert.AreEqual(0, output.SpaceLeft); + + CodedInputStream input = new CodedInputStream(bytes); + tag = input.ReadTag(); + + RepeatedField values = new RepeatedField(); + values.AddEntriesFrom(input, FieldCodec.ForEnum(tag, x => (int)x, x => (SampleEnum)x)); + + Assert.AreEqual(6, values.Count); + Assert.AreEqual(SampleEnum.None, values[0]); + Assert.AreEqual(((SampleEnum)(-1)), values[1]); + Assert.AreEqual(SampleEnum.NegativeValue, values[2]); + Assert.AreEqual(((SampleEnum)(-3)), values[3]); + Assert.AreEqual(((SampleEnum)(-4)), values[4]); + Assert.AreEqual(((SampleEnum)(-5)), values[5]); + } + + + [Test] + public void TestNegativeEnumPackedArray() + { + int arraySize = 1 + (10 * 5); + int msgSize = 1 + 1 + arraySize; + byte[] bytes = new byte[msgSize]; + CodedOutputStream output = new CodedOutputStream(bytes); + // Length-delimited to show we want the packed representation + uint tag = WireFormat.MakeTag(8, WireFormat.WireType.LengthDelimited); + output.WriteTag(tag); + int size = 0; + for (int i = 0; i >= -5; i--) + { + size += CodedOutputStream.ComputeEnumSize(i); + } + output.WriteRawVarint32((uint)size); + for (int i = 0; i >= -5; i--) + { + output.WriteEnum(i); + } + Assert.AreEqual(0, output.SpaceLeft); + + CodedInputStream input = new CodedInputStream(bytes); + tag = input.ReadTag(); + + RepeatedField values = new RepeatedField(); + values.AddEntriesFrom(input, FieldCodec.ForEnum(tag, x => (int)x, x => (SampleEnum)x)); + + Assert.AreEqual(6, values.Count); + Assert.AreEqual(SampleEnum.None, values[0]); + Assert.AreEqual(((SampleEnum)(-1)), values[1]); + Assert.AreEqual(SampleEnum.NegativeValue, values[2]); + Assert.AreEqual(((SampleEnum)(-3)), values[3]); + Assert.AreEqual(((SampleEnum)(-4)), values[4]); + Assert.AreEqual(((SampleEnum)(-5)), values[5]); + } + + // Fairly perfunctory tests for the non-generic IList implementation + [Test] + public void IList_Indexer() + { + var field = new RepeatedField { "first", "second" }; + IList list = field; + Assert.AreEqual("first", list[0]); + list[1] = "changed"; + Assert.AreEqual("changed", field[1]); + } + + [Test] + public void IList_Contains() + { + IList list = new RepeatedField { "first", "second" }; + Assert.IsTrue(list.Contains("second")); + Assert.IsFalse(list.Contains("third")); + Assert.IsFalse(list.Contains(new object())); + } + + [Test] + public void IList_Add() + { + IList list = new RepeatedField { "first", "second" }; + list.Add("third"); + CollectionAssert.AreEqual(new[] { "first", "second", "third" }, list); + } + + [Test] + public void IList_Remove() + { + IList list = new RepeatedField { "first", "second" }; + list.Remove("third"); // No-op, no exception + list.Remove(new object()); // No-op, no exception + list.Remove("first"); + CollectionAssert.AreEqual(new[] { "second" }, list); + } + + [Test] + public void IList_IsFixedSize() + { + var field = new RepeatedField { "first", "second" }; + IList list = field; + Assert.IsFalse(list.IsFixedSize); + } + + [Test] + public void IList_IndexOf() + { + IList list = new RepeatedField { "first", "second" }; + Assert.AreEqual(1, list.IndexOf("second")); + Assert.AreEqual(-1, list.IndexOf("third")); + Assert.AreEqual(-1, list.IndexOf(new object())); + } + + [Test] + public void IList_SyncRoot() + { + IList list = new RepeatedField { "first", "second" }; + Assert.AreSame(list, list.SyncRoot); + } + + [Test] + public void IList_CopyTo() + { + IList list = new RepeatedField { "first", "second" }; + string[] stringArray = new string[4]; + list.CopyTo(stringArray, 1); + CollectionAssert.AreEqual(new[] { null, "first", "second", null }, stringArray); + + object[] objectArray = new object[4]; + list.CopyTo(objectArray, 1); + CollectionAssert.AreEqual(new[] { null, "first", "second", null }, objectArray); + + Assert.Throws(() => list.CopyTo(new StringBuilder[4], 1)); + Assert.Throws(() => list.CopyTo(new int[4], 1)); + } + + [Test] + public void IList_IsSynchronized() + { + IList list = new RepeatedField { "first", "second" }; + Assert.IsFalse(list.IsSynchronized); + } + + [Test] + public void IList_Insert() + { + IList list = new RepeatedField { "first", "second" }; + list.Insert(1, "middle"); + CollectionAssert.AreEqual(new[] { "first", "middle", "second" }, list); + } + + [Test] + public void ToString_Integers() + { + var list = new RepeatedField { 5, 10, 20 }; + var text = list.ToString(); + Assert.AreEqual("[ 5, 10, 20 ]", text); + } + + [Test] + public void ToString_Strings() + { + var list = new RepeatedField { "x", "y", "z" }; + var text = list.ToString(); + Assert.AreEqual("[ \"x\", \"y\", \"z\" ]", text); + } + + [Test] + public void ToString_Messages() + { + var list = new RepeatedField { new TestAllTypes { SingleDouble = 1.5 }, new TestAllTypes { SingleInt32 = 10 } }; + var text = list.ToString(); + Assert.AreEqual("[ { \"singleDouble\": 1.5 }, { \"singleInt32\": 10 } ]", text); + } + + [Test] + public void ToString_Empty() + { + var list = new RepeatedField { }; + var text = list.ToString(); + Assert.AreEqual("[ ]", text); + } + + [Test] + public void ToString_InvalidElementType() + { + var list = new RepeatedField { 15m }; + Assert.Throws(() => list.ToString()); + } + + [Test] + public void ToString_Timestamp() + { + var list = new RepeatedField { Timestamp.FromDateTime(new DateTime(2015, 10, 1, 12, 34, 56, DateTimeKind.Utc)) }; + var text = list.ToString(); + Assert.AreEqual("[ \"2015-10-01T12:34:56Z\" ]", text); + } + + [Test] + public void ToString_Struct() + { + var message = new Struct { Fields = { { "foo", new Value { NumberValue = 20 } } } }; + var list = new RepeatedField { message }; + var text = list.ToString(); + Assert.AreEqual(text, "[ { \"foo\": 20 } ]", message.ToString()); + } + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Compatibility/PropertyInfoExtensionsTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Compatibility/PropertyInfoExtensionsTest.cs new file mode 100644 index 000000000000..df23a09cd4c4 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Compatibility/PropertyInfoExtensionsTest.cs @@ -0,0 +1,98 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using NUnit.Framework; +using System.Reflection; + +namespace Google.Protobuf.Compatibility +{ + public class PropertyInfoExtensionsTest + { + public string PublicReadWrite { get; set; } + private string PrivateReadWrite { get; set; } + public string PublicReadPrivateWrite { get; private set; } + public string PrivateReadPublicWrite { private get; set; } + public string PublicReadOnly { get { return null; } } + private string PrivateReadOnly { get { return null; } } + public string PublicWriteOnly { set { } } + private string PrivateWriteOnly { set { } } + + [Test] + [TestCase("PublicReadWrite")] + [TestCase("PublicReadPrivateWrite")] + [TestCase("PublicReadOnly")] + public void GetGetMethod_Success(string name) + { + var propertyInfo = typeof(PropertyInfoExtensionsTest) + .GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); + Assert.IsNotNull(PropertyInfoExtensions.GetGetMethod(propertyInfo)); + } + + [Test] + [TestCase("PrivateReadWrite")] + [TestCase("PrivateReadPublicWrite")] + [TestCase("PrivateReadOnly")] + [TestCase("PublicWriteOnly")] + [TestCase("PrivateWriteOnly")] + public void GetGetMethod_NoAccessibleGetter(string name) + { + var propertyInfo = typeof(PropertyInfoExtensionsTest) + .GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); + Assert.IsNull(PropertyInfoExtensions.GetGetMethod(propertyInfo)); + } + + [Test] + [TestCase("PublicReadWrite")] + [TestCase("PrivateReadPublicWrite")] + [TestCase("PublicWriteOnly")] + public void GetSetMethod_Success(string name) + { + var propertyInfo = typeof(PropertyInfoExtensionsTest) + .GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); + Assert.IsNotNull(PropertyInfoExtensions.GetSetMethod(propertyInfo)); + } + + [Test] + [TestCase("PublicReadPrivateWrite")] + [TestCase("PrivateReadWrite")] + [TestCase("PrivateReadOnly")] + [TestCase("PublicReadOnly")] + [TestCase("PrivateWriteOnly")] + public void GetSetMethod_NoAccessibleGetter(string name) + { + var propertyInfo = typeof(PropertyInfoExtensionsTest) + .GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); + Assert.IsNull(PropertyInfoExtensions.GetSetMethod(propertyInfo)); + } + } + +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs new file mode 100644 index 000000000000..e8a3d360c219 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs @@ -0,0 +1,117 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Reflection; + +#if !DOTNET35 +namespace Google.Protobuf.Compatibility +{ + public class TypeExtensionsTest + { + public class DerivedList : List { } + public string PublicProperty { get; set; } + private string PrivateProperty { get; set; } + + public void PublicMethod() + { + } + + private void PrivateMethod() + { + } + + [Test] + [TestCase(typeof(object), typeof(string), true)] + [TestCase(typeof(object), typeof(int), true)] + [TestCase(typeof(string), typeof(string), true)] + [TestCase(typeof(string), typeof(object), false)] + [TestCase(typeof(string), typeof(int), false)] + [TestCase(typeof(int), typeof(int), true)] + [TestCase(typeof(ValueType), typeof(int), true)] + [TestCase(typeof(long), typeof(int), false)] // + public void IsAssignableFrom(Type target, Type argument, bool expected) + { + Assert.AreEqual(expected, TypeExtensions.IsAssignableFrom(target, argument)); + } + + [Test] + [TestCase(typeof(DerivedList), "Count")] // Go up the type hierarchy + [TestCase(typeof(List), "Count")] + [TestCase(typeof(List<>), "Count")] + [TestCase(typeof(TypeExtensionsTest), "PublicProperty")] + public void GetProperty_Success(Type type, string name) + { + var property = TypeExtensions.GetProperty(type, name); + Assert.IsNotNull(property); + Assert.AreEqual(name, property.Name); + } + + [Test] + [TestCase(typeof(TypeExtensionsTest), "PrivateProperty")] + [TestCase(typeof(TypeExtensionsTest), "Garbage")] + public void GetProperty_NoSuchProperty(Type type, string name) + { + var property = TypeExtensions.GetProperty(type, name); + Assert.IsNull(property); + } + + [Test] + [TestCase(typeof(DerivedList), "RemoveAt")] // Go up the type hierarchy + [TestCase(typeof(List<>), "RemoveAt")] + [TestCase(typeof(TypeExtensionsTest), "PublicMethod")] + public void GetMethod_Success(Type type, string name) + { + var method = TypeExtensions.GetMethod(type, name); + Assert.IsNotNull(method); + Assert.AreEqual(name, method.Name); + } + + [Test] + [TestCase(typeof(TypeExtensionsTest), "PrivateMethod")] + [TestCase(typeof(TypeExtensionsTest), "GarbageMethod")] + public void GetMethod_NoSuchMethod(Type type, string name) + { + var method = TypeExtensions.GetMethod(type, name); + Assert.IsNull(method); + } + + [Test] + [TestCase(typeof(List), "IndexOf")] + public void GetMethod_Ambiguous(Type type, string name) + { + Assert.Throws(() => TypeExtensions.GetMethod(type, name)); + } + } +} +#endif diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Properties/AssemblyInfo.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/DeprecatedMemberTest.cs similarity index 73% rename from third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Properties/AssemblyInfo.cs rename to third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/DeprecatedMemberTest.cs index d22e90fd8f26..34d5b9f98cbb 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Properties/AssemblyInfo.cs +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/DeprecatedMemberTest.cs @@ -1,48 +1,55 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2015 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System.Reflection; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Google.Protobuf.Conformance")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Google.Protobuf.Conformance")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -[assembly: AssemblyVersion("3.0.0.0")] -[assembly: AssemblyFileVersion("3.0.0.0")] +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Reflection; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class DeprecatedMemberTest + { + private static void AssertIsDeprecated(MemberInfo member) + { + Assert.NotNull(member); + Assert.IsTrue(member.IsDefined(typeof(ObsoleteAttribute), false), "Member not obsolete: " + member); + } + + [Test] + public void TestDepreatedPrimitiveValue() + { + AssertIsDeprecated(typeof(TestDeprecatedFields).GetProperty("DeprecatedInt32")); + } + + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/EqualityTester.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/EqualityTester.cs new file mode 100644 index 000000000000..a669baba17bf --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/EqualityTester.cs @@ -0,0 +1,64 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using NUnit.Framework; + +namespace Google.Protobuf +{ + /// + /// Helper methods when testing equality. NUnit's Assert.AreEqual and + /// Assert.AreNotEqual methods try to be clever with collections, which can + /// be annoying... + /// + internal static class EqualityTester + { + public static void AssertEquality(T first, T second) where T : IEquatable + { + Assert.IsTrue(first.Equals(second)); + Assert.IsTrue(first.Equals((object) second)); + Assert.AreEqual(first.GetHashCode(), second.GetHashCode()); + } + + public static void AssertInequality(T first, T second) where T : IEquatable + { + Assert.IsFalse(first.Equals(second)); + Assert.IsFalse(first.Equals((object) second)); + // While this isn't a requirement, the chances of this test failing due to + // coincidence rather than a bug are very small. + if (first != null && second != null) + { + Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode()); + } + } + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/FieldCodecTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/FieldCodecTest.cs new file mode 100644 index 000000000000..390766682797 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/FieldCodecTest.cs @@ -0,0 +1,196 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class FieldCodecTest + { +#pragma warning disable 0414 // Used by tests via reflection - do not remove! + private static readonly List Codecs = new List + { + new FieldCodecTestData(FieldCodec.ForBool(100), true, "FixedBool"), + new FieldCodecTestData(FieldCodec.ForString(100), "sample", "String"), + new FieldCodecTestData(FieldCodec.ForBytes(100), ByteString.CopyFrom(1, 2, 3), "Bytes"), + new FieldCodecTestData(FieldCodec.ForInt32(100), -1000, "Int32"), + new FieldCodecTestData(FieldCodec.ForSInt32(100), -1000, "SInt32"), + new FieldCodecTestData(FieldCodec.ForSFixed32(100), -1000, "SFixed32"), + new FieldCodecTestData(FieldCodec.ForUInt32(100), 1234, "UInt32"), + new FieldCodecTestData(FieldCodec.ForFixed32(100), 1234, "Fixed32"), + new FieldCodecTestData(FieldCodec.ForInt64(100), -1000, "Int64"), + new FieldCodecTestData(FieldCodec.ForSInt64(100), -1000, "SInt64"), + new FieldCodecTestData(FieldCodec.ForSFixed64(100), -1000, "SFixed64"), + new FieldCodecTestData(FieldCodec.ForUInt64(100), 1234, "UInt64"), + new FieldCodecTestData(FieldCodec.ForFixed64(100), 1234, "Fixed64"), + new FieldCodecTestData(FieldCodec.ForFloat(100), 1234.5f, "FixedFloat"), + new FieldCodecTestData(FieldCodec.ForDouble(100), 1234567890.5d, "FixedDouble"), + new FieldCodecTestData( + FieldCodec.ForEnum(100, t => (int) t, t => (ForeignEnum) t), ForeignEnum.ForeignBaz, "Enum"), + new FieldCodecTestData( + FieldCodec.ForMessage(100, ForeignMessage.Parser), new ForeignMessage { C = 10 }, "Message"), + }; +#pragma warning restore 0414 + + [Test, TestCaseSource("Codecs")] + public void RoundTripWithTag(ICodecTestData codec) + { + codec.TestRoundTripWithTag(); + } + + [Test, TestCaseSource("Codecs")] + public void RoundTripRaw(ICodecTestData codec) + { + codec.TestRoundTripRaw(); + } + + [Test, TestCaseSource("Codecs")] + public void CalculateSize(ICodecTestData codec) + { + codec.TestCalculateSizeWithTag(); + } + + [Test, TestCaseSource("Codecs")] + public void DefaultValue(ICodecTestData codec) + { + codec.TestDefaultValue(); + } + + [Test, TestCaseSource("Codecs")] + public void FixedSize(ICodecTestData codec) + { + codec.TestFixedSize(); + } + + // This is ugly, but it means we can have a non-generic interface. + // It feels like NUnit should support this better, but I don't know + // of any better ways right now. + public interface ICodecTestData + { + void TestRoundTripRaw(); + void TestRoundTripWithTag(); + void TestCalculateSizeWithTag(); + void TestDefaultValue(); + void TestFixedSize(); + } + + public class FieldCodecTestData : ICodecTestData + { + private readonly FieldCodec codec; + private readonly T sampleValue; + private readonly string name; + + public FieldCodecTestData(FieldCodec codec, T sampleValue, string name) + { + this.codec = codec; + this.sampleValue = sampleValue; + this.name = name; + } + + public void TestRoundTripRaw() + { + var stream = new MemoryStream(); + var codedOutput = new CodedOutputStream(stream); + codec.ValueWriter(codedOutput, sampleValue); + codedOutput.Flush(); + stream.Position = 0; + var codedInput = new CodedInputStream(stream); + Assert.AreEqual(sampleValue, codec.ValueReader(codedInput)); + Assert.IsTrue(codedInput.IsAtEnd); + } + + public void TestRoundTripWithTag() + { + var stream = new MemoryStream(); + var codedOutput = new CodedOutputStream(stream); + codec.WriteTagAndValue(codedOutput, sampleValue); + codedOutput.Flush(); + stream.Position = 0; + var codedInput = new CodedInputStream(stream); + codedInput.AssertNextTag(codec.Tag); + Assert.AreEqual(sampleValue, codec.Read(codedInput)); + Assert.IsTrue(codedInput.IsAtEnd); + } + + public void TestCalculateSizeWithTag() + { + var stream = new MemoryStream(); + var codedOutput = new CodedOutputStream(stream); + codec.WriteTagAndValue(codedOutput, sampleValue); + codedOutput.Flush(); + Assert.AreEqual(stream.Position, codec.CalculateSizeWithTag(sampleValue)); + } + + public void TestDefaultValue() + { + // WriteTagAndValue ignores default values + var stream = new MemoryStream(); + var codedOutput = new CodedOutputStream(stream); + codec.WriteTagAndValue(codedOutput, codec.DefaultValue); + codedOutput.Flush(); + Assert.AreEqual(0, stream.Position); + Assert.AreEqual(0, codec.CalculateSizeWithTag(codec.DefaultValue)); + if (typeof(T).GetTypeInfo().IsValueType) + { + Assert.AreEqual(default(T), codec.DefaultValue); + } + + // The plain ValueWriter/ValueReader delegates don't. + if (codec.DefaultValue != null) // This part isn't appropriate for message types. + { + codedOutput = new CodedOutputStream(stream); + codec.ValueWriter(codedOutput, codec.DefaultValue); + codedOutput.Flush(); + Assert.AreNotEqual(0, stream.Position); + Assert.AreEqual(stream.Position, codec.ValueSizeCalculator(codec.DefaultValue)); + stream.Position = 0; + var codedInput = new CodedInputStream(stream); + Assert.AreEqual(codec.DefaultValue, codec.ValueReader(codedInput)); + } + } + + public void TestFixedSize() + { + Assert.AreEqual(name.Contains("Fixed"), codec.FixedSize != 0); + } + + public override string ToString() + { + return name; + } + } + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/GeneratedMessageTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/GeneratedMessageTest.cs new file mode 100644 index 000000000000..429c51ff91d3 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/GeneratedMessageTest.cs @@ -0,0 +1,725 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.IO; +using Google.Protobuf.TestProtos; +using NUnit.Framework; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using Google.Protobuf.WellKnownTypes; + +namespace Google.Protobuf +{ + /// + /// Tests around the generated TestAllTypes message. + /// + public class GeneratedMessageTest + { + [Test] + public void EmptyMessageFieldDistinctFromMissingMessageField() + { + // This demonstrates what we're really interested in... + var message1 = new TestAllTypes { SingleForeignMessage = new ForeignMessage() }; + var message2 = new TestAllTypes(); // SingleForeignMessage is null + EqualityTester.AssertInequality(message1, message2); + } + + [Test] + public void DefaultValues() + { + // Single fields + var message = new TestAllTypes(); + Assert.AreEqual(false, message.SingleBool); + Assert.AreEqual(ByteString.Empty, message.SingleBytes); + Assert.AreEqual(0.0, message.SingleDouble); + Assert.AreEqual(0, message.SingleFixed32); + Assert.AreEqual(0L, message.SingleFixed64); + Assert.AreEqual(0.0f, message.SingleFloat); + Assert.AreEqual(ForeignEnum.ForeignUnspecified, message.SingleForeignEnum); + Assert.IsNull(message.SingleForeignMessage); + Assert.AreEqual(ImportEnum.Unspecified, message.SingleImportEnum); + Assert.IsNull(message.SingleImportMessage); + Assert.AreEqual(0, message.SingleInt32); + Assert.AreEqual(0L, message.SingleInt64); + Assert.AreEqual(TestAllTypes.Types.NestedEnum.Unspecified, message.SingleNestedEnum); + Assert.IsNull(message.SingleNestedMessage); + Assert.IsNull(message.SinglePublicImportMessage); + Assert.AreEqual(0, message.SingleSfixed32); + Assert.AreEqual(0L, message.SingleSfixed64); + Assert.AreEqual(0, message.SingleSint32); + Assert.AreEqual(0L, message.SingleSint64); + Assert.AreEqual("", message.SingleString); + Assert.AreEqual(0U, message.SingleUint32); + Assert.AreEqual(0UL, message.SingleUint64); + + // Repeated fields + Assert.AreEqual(0, message.RepeatedBool.Count); + Assert.AreEqual(0, message.RepeatedBytes.Count); + Assert.AreEqual(0, message.RepeatedDouble.Count); + Assert.AreEqual(0, message.RepeatedFixed32.Count); + Assert.AreEqual(0, message.RepeatedFixed64.Count); + Assert.AreEqual(0, message.RepeatedFloat.Count); + Assert.AreEqual(0, message.RepeatedForeignEnum.Count); + Assert.AreEqual(0, message.RepeatedForeignMessage.Count); + Assert.AreEqual(0, message.RepeatedImportEnum.Count); + Assert.AreEqual(0, message.RepeatedImportMessage.Count); + Assert.AreEqual(0, message.RepeatedNestedEnum.Count); + Assert.AreEqual(0, message.RepeatedNestedMessage.Count); + Assert.AreEqual(0, message.RepeatedPublicImportMessage.Count); + Assert.AreEqual(0, message.RepeatedSfixed32.Count); + Assert.AreEqual(0, message.RepeatedSfixed64.Count); + Assert.AreEqual(0, message.RepeatedSint32.Count); + Assert.AreEqual(0, message.RepeatedSint64.Count); + Assert.AreEqual(0, message.RepeatedString.Count); + Assert.AreEqual(0, message.RepeatedUint32.Count); + Assert.AreEqual(0, message.RepeatedUint64.Count); + + // Oneof fields + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + } + + [Test] + public void NullStringAndBytesRejected() + { + var message = new TestAllTypes(); + Assert.Throws(() => message.SingleString = null); + Assert.Throws(() => message.OneofString = null); + Assert.Throws(() => message.SingleBytes = null); + Assert.Throws(() => message.OneofBytes = null); + } + + [Test] + public void RoundTrip_Empty() + { + var message = new TestAllTypes(); + // Without setting any values, there's nothing to write. + byte[] bytes = message.ToByteArray(); + Assert.AreEqual(0, bytes.Length); + TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes); + Assert.AreEqual(message, parsed); + } + + [Test] + public void RoundTrip_SingleValues() + { + var message = new TestAllTypes + { + SingleBool = true, + SingleBytes = ByteString.CopyFrom(1, 2, 3, 4), + SingleDouble = 23.5, + SingleFixed32 = 23, + SingleFixed64 = 1234567890123, + SingleFloat = 12.25f, + SingleForeignEnum = ForeignEnum.ForeignBar, + SingleForeignMessage = new ForeignMessage { C = 10 }, + SingleImportEnum = ImportEnum.ImportBaz, + SingleImportMessage = new ImportMessage { D = 20 }, + SingleInt32 = 100, + SingleInt64 = 3210987654321, + SingleNestedEnum = TestAllTypes.Types.NestedEnum.Foo, + SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 }, + SinglePublicImportMessage = new PublicImportMessage { E = 54 }, + SingleSfixed32 = -123, + SingleSfixed64 = -12345678901234, + SingleSint32 = -456, + SingleSint64 = -12345678901235, + SingleString = "test", + SingleUint32 = uint.MaxValue, + SingleUint64 = ulong.MaxValue + }; + + byte[] bytes = message.ToByteArray(); + TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes); + Assert.AreEqual(message, parsed); + } + + [Test] + public void RoundTrip_RepeatedValues() + { + var message = new TestAllTypes + { + RepeatedBool = { true, false }, + RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6) }, + RepeatedDouble = { -12.25, 23.5 }, + RepeatedFixed32 = { uint.MaxValue, 23 }, + RepeatedFixed64 = { ulong.MaxValue, 1234567890123 }, + RepeatedFloat = { 100f, 12.25f }, + RepeatedForeignEnum = { ForeignEnum.ForeignFoo, ForeignEnum.ForeignBar }, + RepeatedForeignMessage = { new ForeignMessage(), new ForeignMessage { C = 10 } }, + RepeatedImportEnum = { ImportEnum.ImportBaz, ImportEnum.Unspecified }, + RepeatedImportMessage = { new ImportMessage { D = 20 }, new ImportMessage { D = 25 } }, + RepeatedInt32 = { 100, 200 }, + RepeatedInt64 = { 3210987654321, long.MaxValue }, + RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.Foo, TestAllTypes.Types.NestedEnum.Neg }, + RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 35 }, new TestAllTypes.Types.NestedMessage { Bb = 10 } }, + RepeatedPublicImportMessage = { new PublicImportMessage { E = 54 }, new PublicImportMessage { E = -1 } }, + RepeatedSfixed32 = { -123, 123 }, + RepeatedSfixed64 = { -12345678901234, 12345678901234 }, + RepeatedSint32 = { -456, 100 }, + RepeatedSint64 = { -12345678901235, 123 }, + RepeatedString = { "foo", "bar" }, + RepeatedUint32 = { uint.MaxValue, uint.MinValue }, + RepeatedUint64 = { ulong.MaxValue, uint.MinValue } + }; + + byte[] bytes = message.ToByteArray(); + TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes); + Assert.AreEqual(message, parsed); + } + + // Note that not every map within map_unittest_proto3 is used. They all go through very + // similar code paths. The fact that all maps are present is validation that we have codecs + // for every type. + [Test] + public void RoundTrip_Maps() + { + var message = new TestMap + { + MapBoolBool = { + { false, true }, + { true, false } + }, + MapInt32Bytes = { + { 5, ByteString.CopyFrom(6, 7, 8) }, + { 25, ByteString.CopyFrom(1, 2, 3, 4, 5) }, + { 10, ByteString.Empty } + }, + MapInt32ForeignMessage = { + { 0, new ForeignMessage { C = 10 } }, + { 5, new ForeignMessage() }, + }, + MapInt32Enum = { + { 1, MapEnum.Bar }, + { 2000, MapEnum.Foo } + } + }; + + byte[] bytes = message.ToByteArray(); + TestMap parsed = TestMap.Parser.ParseFrom(bytes); + Assert.AreEqual(message, parsed); + } + + [Test] + public void MapWithEmptyEntry() + { + var message = new TestMap + { + MapInt32Bytes = { { 0, ByteString.Empty } } + }; + + byte[] bytes = message.ToByteArray(); + Assert.AreEqual(2, bytes.Length); // Tag for field entry (1 byte), length of entry (0; 1 byte) + + var parsed = TestMap.Parser.ParseFrom(bytes); + Assert.AreEqual(1, parsed.MapInt32Bytes.Count); + Assert.AreEqual(ByteString.Empty, parsed.MapInt32Bytes[0]); + } + + [Test] + public void MapWithOnlyValue() + { + // Hand-craft the stream to contain a single entry with just a value. + var memoryStream = new MemoryStream(); + var output = new CodedOutputStream(memoryStream); + output.WriteTag(TestMap.MapInt32ForeignMessageFieldNumber, WireFormat.WireType.LengthDelimited); + var nestedMessage = new ForeignMessage { C = 20 }; + // Size of the entry (tag, size written by WriteMessage, data written by WriteMessage) + output.WriteLength(2 + nestedMessage.CalculateSize()); + output.WriteTag(2, WireFormat.WireType.LengthDelimited); + output.WriteMessage(nestedMessage); + output.Flush(); + + var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); + Assert.AreEqual(nestedMessage, parsed.MapInt32ForeignMessage[0]); + } + + [Test] + public void MapWithOnlyKey_PrimitiveValue() + { + // Hand-craft the stream to contain a single entry with just a key. + var memoryStream = new MemoryStream(); + var output = new CodedOutputStream(memoryStream); + output.WriteTag(TestMap.MapInt32DoubleFieldNumber, WireFormat.WireType.LengthDelimited); + int key = 10; + output.WriteLength(1 + CodedOutputStream.ComputeInt32Size(key)); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key); + output.Flush(); + + var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); + Assert.AreEqual(0.0, parsed.MapInt32Double[key]); + } + + [Test] + public void MapWithOnlyKey_MessageValue() + { + // Hand-craft the stream to contain a single entry with just a key. + var memoryStream = new MemoryStream(); + var output = new CodedOutputStream(memoryStream); + output.WriteTag(TestMap.MapInt32ForeignMessageFieldNumber, WireFormat.WireType.LengthDelimited); + int key = 10; + output.WriteLength(1 + CodedOutputStream.ComputeInt32Size(key)); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key); + output.Flush(); + + var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); + Assert.AreEqual(new ForeignMessage(), parsed.MapInt32ForeignMessage[key]); + } + + [Test] + public void MapIgnoresExtraFieldsWithinEntryMessages() + { + // Hand-craft the stream to contain a single entry with three fields + var memoryStream = new MemoryStream(); + var output = new CodedOutputStream(memoryStream); + + output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); + + var key = 10; // Field 1 + var value = 20; // Field 2 + var extra = 30; // Field 3 + + // Each field can be represented in a single byte, with a single byte tag. + // Total message size: 6 bytes. + output.WriteLength(6); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key); + output.WriteTag(2, WireFormat.WireType.Varint); + output.WriteInt32(value); + output.WriteTag(3, WireFormat.WireType.Varint); + output.WriteInt32(extra); + output.Flush(); + + var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); + Assert.AreEqual(value, parsed.MapInt32Int32[key]); + } + + [Test] + public void MapFieldOrderIsIrrelevant() + { + var memoryStream = new MemoryStream(); + var output = new CodedOutputStream(memoryStream); + + output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); + + var key = 10; + var value = 20; + + // Each field can be represented in a single byte, with a single byte tag. + // Total message size: 4 bytes. + output.WriteLength(4); + output.WriteTag(2, WireFormat.WireType.Varint); + output.WriteInt32(value); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key); + output.Flush(); + + var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); + Assert.AreEqual(value, parsed.MapInt32Int32[key]); + } + + [Test] + public void MapNonContiguousEntries() + { + var memoryStream = new MemoryStream(); + var output = new CodedOutputStream(memoryStream); + + // Message structure: + // Entry for MapInt32Int32 + // Entry for MapStringString + // Entry for MapInt32Int32 + + // First entry + var key1 = 10; + var value1 = 20; + output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteLength(4); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key1); + output.WriteTag(2, WireFormat.WireType.Varint); + output.WriteInt32(value1); + + // Second entry + var key2 = "a"; + var value2 = "b"; + output.WriteTag(TestMap.MapStringStringFieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteLength(6); // 3 bytes per entry: tag, size, character + output.WriteTag(1, WireFormat.WireType.LengthDelimited); + output.WriteString(key2); + output.WriteTag(2, WireFormat.WireType.LengthDelimited); + output.WriteString(value2); + + // Third entry + var key3 = 15; + var value3 = 25; + output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteLength(4); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key3); + output.WriteTag(2, WireFormat.WireType.Varint); + output.WriteInt32(value3); + + output.Flush(); + var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); + var expected = new TestMap + { + MapInt32Int32 = { { key1, value1 }, { key3, value3 } }, + MapStringString = { { key2, value2 } } + }; + Assert.AreEqual(expected, parsed); + } + + [Test] + public void DuplicateKeys_LastEntryWins() + { + var memoryStream = new MemoryStream(); + var output = new CodedOutputStream(memoryStream); + + var key = 10; + var value1 = 20; + var value2 = 30; + + // First entry + output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteLength(4); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key); + output.WriteTag(2, WireFormat.WireType.Varint); + output.WriteInt32(value1); + + // Second entry - same key, different value + output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteLength(4); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key); + output.WriteTag(2, WireFormat.WireType.Varint); + output.WriteInt32(value2); + output.Flush(); + + var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); + Assert.AreEqual(value2, parsed.MapInt32Int32[key]); + } + + [Test] + public void CloneSingleNonMessageValues() + { + var original = new TestAllTypes + { + SingleBool = true, + SingleBytes = ByteString.CopyFrom(1, 2, 3, 4), + SingleDouble = 23.5, + SingleFixed32 = 23, + SingleFixed64 = 1234567890123, + SingleFloat = 12.25f, + SingleInt32 = 100, + SingleInt64 = 3210987654321, + SingleNestedEnum = TestAllTypes.Types.NestedEnum.Foo, + SingleSfixed32 = -123, + SingleSfixed64 = -12345678901234, + SingleSint32 = -456, + SingleSint64 = -12345678901235, + SingleString = "test", + SingleUint32 = uint.MaxValue, + SingleUint64 = ulong.MaxValue + }; + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreEqual(original, clone); + // Just as a single example + clone.SingleInt32 = 150; + Assert.AreNotEqual(original, clone); + } + + [Test] + public void CloneRepeatedNonMessageValues() + { + var original = new TestAllTypes + { + RepeatedBool = { true, false }, + RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6) }, + RepeatedDouble = { -12.25, 23.5 }, + RepeatedFixed32 = { uint.MaxValue, 23 }, + RepeatedFixed64 = { ulong.MaxValue, 1234567890123 }, + RepeatedFloat = { 100f, 12.25f }, + RepeatedInt32 = { 100, 200 }, + RepeatedInt64 = { 3210987654321, long.MaxValue }, + RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.Foo, TestAllTypes.Types.NestedEnum.Neg }, + RepeatedSfixed32 = { -123, 123 }, + RepeatedSfixed64 = { -12345678901234, 12345678901234 }, + RepeatedSint32 = { -456, 100 }, + RepeatedSint64 = { -12345678901235, 123 }, + RepeatedString = { "foo", "bar" }, + RepeatedUint32 = { uint.MaxValue, uint.MinValue }, + RepeatedUint64 = { ulong.MaxValue, uint.MinValue } + }; + + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreEqual(original, clone); + // Just as a single example + clone.RepeatedDouble.Add(25.5); + Assert.AreNotEqual(original, clone); + } + + [Test] + public void CloneSingleMessageField() + { + var original = new TestAllTypes + { + SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 } + }; + + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreNotSame(original.SingleNestedMessage, clone.SingleNestedMessage); + Assert.AreEqual(original, clone); + + clone.SingleNestedMessage.Bb = 30; + Assert.AreNotEqual(original, clone); + } + + [Test] + public void CloneRepeatedMessageField() + { + var original = new TestAllTypes + { + RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 20 } } + }; + + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreNotSame(original.RepeatedNestedMessage, clone.RepeatedNestedMessage); + Assert.AreNotSame(original.RepeatedNestedMessage[0], clone.RepeatedNestedMessage[0]); + Assert.AreEqual(original, clone); + + clone.RepeatedNestedMessage[0].Bb = 30; + Assert.AreNotEqual(original, clone); + } + + [Test] + public void CloneOneofField() + { + var original = new TestAllTypes + { + OneofNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 } + }; + + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreEqual(original, clone); + + // We should have cloned the message + original.OneofNestedMessage.Bb = 30; + Assert.AreNotEqual(original, clone); + } + + [Test] + public void OneofProperties() + { + // Switch the oneof case between each of the different options, and check everything behaves + // as expected in each case. + var message = new TestAllTypes(); + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); + + message.OneofString = "sample"; + Assert.AreEqual("sample", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofString, message.OneofFieldCase); + + var bytes = ByteString.CopyFrom(1, 2, 3); + message.OneofBytes = bytes; + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(bytes, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofBytes, message.OneofFieldCase); + + message.OneofUint32 = 20; + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(20, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message.OneofFieldCase); + + var nestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 25 }; + message.OneofNestedMessage = nestedMessage; + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.AreEqual(nestedMessage, message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofNestedMessage, message.OneofFieldCase); + + message.ClearOneofField(); + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); + } + + [Test] + public void Oneof_DefaultValuesNotEqual() + { + var message1 = new TestAllTypes { OneofString = "" }; + var message2 = new TestAllTypes { OneofUint32 = 0 }; + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofString, message1.OneofFieldCase); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase); + Assert.AreNotEqual(message1, message2); + } + + [Test] + public void OneofSerialization_NonDefaultValue() + { + var message = new TestAllTypes(); + message.OneofString = "this would take a bit of space"; + message.OneofUint32 = 10; + var bytes = message.ToByteArray(); + Assert.AreEqual(3, bytes.Length); // 2 bytes for the tag + 1 for the value - no string! + + var message2 = TestAllTypes.Parser.ParseFrom(bytes); + Assert.AreEqual(message, message2); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase); + } + + [Test] + public void OneofSerialization_DefaultValue() + { + var message = new TestAllTypes(); + message.OneofString = "this would take a bit of space"; + message.OneofUint32 = 0; // This is the default value for UInt32; normally wouldn't be serialized + var bytes = message.ToByteArray(); + Assert.AreEqual(3, bytes.Length); // 2 bytes for the tag + 1 for the value - it's still serialized + + var message2 = TestAllTypes.Parser.ParseFrom(bytes); + Assert.AreEqual(message, message2); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase); + } + + [Test] + public void DiscardUnknownFields_RealDataStillRead() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + var unusedFieldNumber = 23456; + Assert.IsFalse(TestAllTypes.Descriptor.Fields.InDeclarationOrder().Select(x => x.FieldNumber).Contains(unusedFieldNumber)); + output.WriteTag(unusedFieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteString("ignore me"); + message.WriteTo(output); + output.Flush(); + + stream.Position = 0; + var parsed = TestAllTypes.Parser.ParseFrom(stream); + // TODO(jieluo): Add test back after DiscardUnknownFields is supported + // Assert.AreEqual(message, parsed); + } + + [Test] + public void DiscardUnknownFields_AllTypes() + { + // Simple way of ensuring we can skip all kinds of fields. + var data = SampleMessages.CreateFullTestAllTypes().ToByteArray(); + var empty = Empty.Parser.ParseFrom(data); + // TODO(jieluo): Add test back after DiscardUnknownField is supported. + // Assert.AreEqual(new Empty(), empty); + } + + // This was originally seen as a conformance test failure. + [Test] + public void TruncatedMessageFieldThrows() + { + // 130, 3 is the message tag + // 1 is the data length - but there's no data. + var data = new byte[] { 130, 3, 1 }; + Assert.Throws(() => TestAllTypes.Parser.ParseFrom(data)); + } + + /// + /// Demonstrates current behaviour with an extraneous end group tag - see issue 688 + /// for details; we may want to change this. + /// + [Test] + public void ExtraEndGroupThrows() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + + output.WriteTag(TestAllTypes.SingleFixed32FieldNumber, WireFormat.WireType.Fixed32); + output.WriteFixed32(123); + output.WriteTag(100, WireFormat.WireType.EndGroup); + + output.Flush(); + + stream.Position = 0; + Assert.Throws(() => TestAllTypes.Parser.ParseFrom(stream)); + } + + [Test] + public void CustomDiagnosticMessage_DirectToStringCall() + { + var message = new ForeignMessage { C = 31 }; + Assert.AreEqual("{ \"c\": 31, \"@cInHex\": \"1f\" }", message.ToString()); + Assert.AreEqual("{ \"c\": 31 }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void CustomDiagnosticMessage_Nested() + { + var message = new TestAllTypes { SingleForeignMessage = new ForeignMessage { C = 16 } }; + Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16, \"@cInHex\": \"10\" } }", message.ToString()); + Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16 } }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void CustomDiagnosticMessage_DirectToTextWriterCall() + { + var message = new ForeignMessage { C = 31 }; + var writer = new StringWriter(); + JsonFormatter.Default.Format(message, writer); + Assert.AreEqual("{ \"c\": 31 }", writer.ToString()); + } + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj new file mode 100644 index 000000000000..1ef5bf8637ad --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj @@ -0,0 +1,30 @@ + + + + Exe + net451;netcoreapp2.1 + ../../keys/Google.Protobuf.snk + true + true + False + + + + + + + + + + + + + + netcoreapp2.1 + + + diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/IssuesTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/IssuesTest.cs new file mode 100644 index 000000000000..a38d6b08b568 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/IssuesTest.cs @@ -0,0 +1,82 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using Google.Protobuf.Reflection; +using UnitTest.Issues.TestProtos; +using NUnit.Framework; + + +namespace Google.Protobuf +{ + /// + /// Tests for issues which aren't easily compartmentalized into other unit tests. + /// + public class IssuesTest + { + // Issue 45 + [Test] + public void FieldCalledItem() + { + ItemField message = new ItemField { Item = 3 }; + FieldDescriptor field = ItemField.Descriptor.FindFieldByName("item"); + Assert.NotNull(field); + Assert.AreEqual(3, (int)field.Accessor.GetValue(message)); + } + + [Test] + public void ReservedNames() + { + var message = new ReservedNames { Types_ = 10, Descriptor_ = 20 }; + // Underscores aren't reflected in the JSON. + Assert.AreEqual("{ \"types\": 10, \"descriptor\": 20 }", message.ToString()); + } + + [Test] + public void JsonNameParseTest() + { + var settings = new JsonParser.Settings(10, TypeRegistry.FromFiles(UnittestIssuesReflection.Descriptor)); + var parser = new JsonParser(settings); + + // It is safe to use either original field name or explicitly specified json_name + Assert.AreEqual(new TestJsonName { Name = "test", Description = "test2", Guid = "test3" }, + parser.Parse("{ \"name\": \"test\", \"desc\": \"test2\", \"guid\": \"test3\" }")); + } + + [Test] + public void JsonNameFormatTest() + { + var message = new TestJsonName { Name = "test", Description = "test2", Guid = "test3" }; + Assert.AreEqual("{ \"name\": \"test\", \"desc\": \"test2\", \"exid\": \"test3\" }", + JsonFormatter.Default.Format(message)); + } + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/JsonParserTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/JsonParserTest.cs new file mode 100644 index 000000000000..f595455aa161 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/JsonParserTest.cs @@ -0,0 +1,939 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using Google.Protobuf.Reflection; +using Google.Protobuf.TestProtos; +using Google.Protobuf.WellKnownTypes; +using NUnit.Framework; +using System; + +namespace Google.Protobuf +{ + /// + /// Unit tests for JSON parsing. + /// + public class JsonParserTest + { + // Sanity smoke test + [Test] + public void AllTypesRoundtrip() + { + AssertRoundtrip(SampleMessages.CreateFullTestAllTypes()); + } + + [Test] + public void Maps() + { + AssertRoundtrip(new TestMap { MapStringString = { { "with spaces", "bar" }, { "a", "b" } } }); + AssertRoundtrip(new TestMap { MapInt32Int32 = { { 0, 1 }, { 2, 3 } } }); + AssertRoundtrip(new TestMap { MapBoolBool = { { false, true }, { true, false } } }); + } + + [Test] + [TestCase(" 1 ")] + [TestCase("+1")] + [TestCase("1,000")] + [TestCase("1.5")] + public void IntegerMapKeysAreStrict(string keyText) + { + // Test that integer parsing is strict. We assume that if this is correct for int32, + // it's correct for other numeric key types. + var json = "{ \"mapInt32Int32\": { \"" + keyText + "\" : \"1\" } }"; + Assert.Throws(() => JsonParser.Default.Parse(json)); + } + + [Test] + public void OriginalFieldNameAccepted() + { + var json = "{ \"single_int32\": 10 }"; + var expected = new TestAllTypes { SingleInt32 = 10 }; + Assert.AreEqual(expected, TestAllTypes.Parser.ParseJson(json)); + } + + [Test] + public void SourceContextRoundtrip() + { + AssertRoundtrip(new SourceContext { FileName = "foo.proto" }); + } + + [Test] + public void SingularWrappers_DefaultNonNullValues() + { + var message = new TestWellKnownTypes + { + StringField = "", + BytesField = ByteString.Empty, + BoolField = false, + FloatField = 0f, + DoubleField = 0d, + Int32Field = 0, + Int64Field = 0, + Uint32Field = 0, + Uint64Field = 0 + }; + AssertRoundtrip(message); + } + + [Test] + public void SingularWrappers_NonDefaultValues() + { + var message = new TestWellKnownTypes + { + StringField = "x", + BytesField = ByteString.CopyFrom(1, 2, 3), + BoolField = true, + FloatField = 12.5f, + DoubleField = 12.25d, + Int32Field = 1, + Int64Field = 2, + Uint32Field = 3, + Uint64Field = 4 + }; + AssertRoundtrip(message); + } + + [Test] + public void SingularWrappers_ExplicitNulls() + { + // When we parse the "valueField": null part, we remember it... basically, it's one case + // where explicit default values don't fully roundtrip. + var message = new TestWellKnownTypes { ValueField = Value.ForNull() }; + var json = new JsonFormatter(new JsonFormatter.Settings(true)).Format(message); + var parsed = JsonParser.Default.Parse(json); + Assert.AreEqual(message, parsed); + } + + [Test] + [TestCase(typeof(BoolValue), "true", true)] + [TestCase(typeof(Int32Value), "32", 32)] + [TestCase(typeof(Int64Value), "32", 32L)] + [TestCase(typeof(Int64Value), "\"32\"", 32L)] + [TestCase(typeof(UInt32Value), "32", 32U)] + [TestCase(typeof(UInt64Value), "\"32\"", 32UL)] + [TestCase(typeof(UInt64Value), "32", 32UL)] + [TestCase(typeof(StringValue), "\"foo\"", "foo")] + [TestCase(typeof(FloatValue), "1.5", 1.5f)] + [TestCase(typeof(DoubleValue), "1.5", 1.5d)] + public void Wrappers_Standalone(System.Type wrapperType, string json, object expectedValue) + { + IMessage parsed = (IMessage)Activator.CreateInstance(wrapperType); + IMessage expected = (IMessage)Activator.CreateInstance(wrapperType); + JsonParser.Default.Merge(parsed, "null"); + Assert.AreEqual(expected, parsed); + + JsonParser.Default.Merge(parsed, json); + expected.Descriptor.Fields[WrappersReflection.WrapperValueFieldNumber].Accessor.SetValue(expected, expectedValue); + Assert.AreEqual(expected, parsed); + } + + [Test] + public void ExplicitNullValue() + { + string json = "{\"valueField\": null}"; + var message = JsonParser.Default.Parse(json); + Assert.AreEqual(new TestWellKnownTypes { ValueField = Value.ForNull() }, message); + } + + [Test] + public void BytesWrapper_Standalone() + { + ByteString data = ByteString.CopyFrom(1, 2, 3); + // Can't do this with attributes... + var parsed = JsonParser.Default.Parse(WrapInQuotes(data.ToBase64())); + var expected = new BytesValue { Value = data }; + Assert.AreEqual(expected, parsed); + } + + [Test] + public void RepeatedWrappers() + { + var message = new RepeatedWellKnownTypes + { + BoolField = { true, false }, + BytesField = { ByteString.CopyFrom(1, 2, 3), ByteString.CopyFrom(4, 5, 6), ByteString.Empty }, + DoubleField = { 12.5, -1.5, 0d }, + FloatField = { 123.25f, -20f, 0f }, + Int32Field = { int.MaxValue, int.MinValue, 0 }, + Int64Field = { long.MaxValue, long.MinValue, 0L }, + StringField = { "First", "Second", "" }, + Uint32Field = { uint.MaxValue, uint.MinValue, 0U }, + Uint64Field = { ulong.MaxValue, ulong.MinValue, 0UL }, + }; + AssertRoundtrip(message); + } + + [Test] + public void RepeatedField_NullElementProhibited() + { + string json = "{ \"repeated_foreign_message\": [null] }"; + Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); + } + + [Test] + public void RepeatedField_NullOverallValueAllowed() + { + string json = "{ \"repeated_foreign_message\": null }"; + Assert.AreEqual(new TestAllTypes(), TestAllTypes.Parser.ParseJson(json)); + } + + [Test] + [TestCase("{ \"mapInt32Int32\": { \"10\": null }")] + [TestCase("{ \"mapStringString\": { \"abc\": null }")] + [TestCase("{ \"mapInt32ForeignMessage\": { \"10\": null }")] + public void MapField_NullValueProhibited(string json) + { + Assert.Throws(() => TestMap.Parser.ParseJson(json)); + } + + [Test] + public void MapField_NullOverallValueAllowed() + { + string json = "{ \"mapInt32Int32\": null }"; + Assert.AreEqual(new TestMap(), TestMap.Parser.ParseJson(json)); + } + + [Test] + public void IndividualWrapperTypes() + { + Assert.AreEqual(new StringValue { Value = "foo" }, StringValue.Parser.ParseJson("\"foo\"")); + Assert.AreEqual(new Int32Value { Value = 1 }, Int32Value.Parser.ParseJson("1")); + // Can parse strings directly too + Assert.AreEqual(new Int32Value { Value = 1 }, Int32Value.Parser.ParseJson("\"1\"")); + } + + private static void AssertRoundtrip(T message) where T : IMessage, new() + { + var clone = message.Clone(); + var json = JsonFormatter.Default.Format(message); + var parsed = JsonParser.Default.Parse(json); + Assert.AreEqual(clone, parsed); + } + + [Test] + [TestCase("0", 0)] + [TestCase("-0", 0)] // Not entirely clear whether we intend to allow this... + [TestCase("1", 1)] + [TestCase("-1", -1)] + [TestCase("2147483647", 2147483647)] + [TestCase("-2147483648", -2147483648)] + public void StringToInt32_Valid(string jsonValue, int expectedParsedValue) + { + string json = "{ \"singleInt32\": \"" + jsonValue + "\"}"; + var parsed = TestAllTypes.Parser.ParseJson(json); + Assert.AreEqual(expectedParsedValue, parsed.SingleInt32); + } + + [Test] + [TestCase("+0")] + [TestCase(" 1")] + [TestCase("1 ")] + [TestCase("00")] + [TestCase("-00")] + [TestCase("--1")] + [TestCase("+1")] + [TestCase("1.5")] + [TestCase("1e10")] + [TestCase("2147483648")] + [TestCase("-2147483649")] + public void StringToInt32_Invalid(string jsonValue) + { + string json = "{ \"singleInt32\": \"" + jsonValue + "\"}"; + Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); + } + + [Test] + [TestCase("0", 0U)] + [TestCase("1", 1U)] + [TestCase("4294967295", 4294967295U)] + public void StringToUInt32_Valid(string jsonValue, uint expectedParsedValue) + { + string json = "{ \"singleUint32\": \"" + jsonValue + "\"}"; + var parsed = TestAllTypes.Parser.ParseJson(json); + Assert.AreEqual(expectedParsedValue, parsed.SingleUint32); + } + + // Assume that anything non-bounds-related is covered in the Int32 case + [Test] + [TestCase("-1")] + [TestCase("4294967296")] + public void StringToUInt32_Invalid(string jsonValue) + { + string json = "{ \"singleUint32\": \"" + jsonValue + "\"}"; + Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); + } + + [Test] + [TestCase("0", 0L)] + [TestCase("1", 1L)] + [TestCase("-1", -1L)] + [TestCase("9223372036854775807", 9223372036854775807)] + [TestCase("-9223372036854775808", -9223372036854775808)] + public void StringToInt64_Valid(string jsonValue, long expectedParsedValue) + { + string json = "{ \"singleInt64\": \"" + jsonValue + "\"}"; + var parsed = TestAllTypes.Parser.ParseJson(json); + Assert.AreEqual(expectedParsedValue, parsed.SingleInt64); + } + + // Assume that anything non-bounds-related is covered in the Int32 case + [Test] + [TestCase("-9223372036854775809")] + [TestCase("9223372036854775808")] + public void StringToInt64_Invalid(string jsonValue) + { + string json = "{ \"singleInt64\": \"" + jsonValue + "\"}"; + Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); + } + + [Test] + [TestCase("0", 0UL)] + [TestCase("1", 1UL)] + [TestCase("18446744073709551615", 18446744073709551615)] + public void StringToUInt64_Valid(string jsonValue, ulong expectedParsedValue) + { + string json = "{ \"singleUint64\": \"" + jsonValue + "\"}"; + var parsed = TestAllTypes.Parser.ParseJson(json); + Assert.AreEqual(expectedParsedValue, parsed.SingleUint64); + } + + // Assume that anything non-bounds-related is covered in the Int32 case + [Test] + [TestCase("-1")] + [TestCase("18446744073709551616")] + public void StringToUInt64_Invalid(string jsonValue) + { + string json = "{ \"singleUint64\": \"" + jsonValue + "\"}"; + Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); + } + + [Test] + [TestCase("0", 0d)] + [TestCase("1", 1d)] + [TestCase("1.000000", 1d)] + [TestCase("1.0000000000000000000000001", 1d)] // We don't notice that we haven't preserved the exact value + [TestCase("-1", -1d)] + [TestCase("1e1", 10d)] + [TestCase("1e01", 10d)] // Leading decimals are allowed in exponents + [TestCase("1E1", 10d)] // Either case is fine + [TestCase("-1e1", -10d)] + [TestCase("1.5e1", 15d)] + [TestCase("-1.5e1", -15d)] + [TestCase("15e-1", 1.5d)] + [TestCase("-15e-1", -1.5d)] + [TestCase("1.79769e308", 1.79769e308)] + [TestCase("-1.79769e308", -1.79769e308)] + [TestCase("Infinity", double.PositiveInfinity)] + [TestCase("-Infinity", double.NegativeInfinity)] + [TestCase("NaN", double.NaN)] + public void StringToDouble_Valid(string jsonValue, double expectedParsedValue) + { + string json = "{ \"singleDouble\": \"" + jsonValue + "\"}"; + var parsed = TestAllTypes.Parser.ParseJson(json); + Assert.AreEqual(expectedParsedValue, parsed.SingleDouble); + } + + [Test] + [TestCase("1.7977e308")] + [TestCase("-1.7977e308")] + [TestCase("1e309")] + [TestCase("1,0")] + [TestCase("1.0.0")] + [TestCase("+1")] + [TestCase("00")] + [TestCase("01")] + [TestCase("-00")] + [TestCase("-01")] + [TestCase("--1")] + [TestCase(" Infinity")] + [TestCase(" -Infinity")] + [TestCase("NaN ")] + [TestCase("Infinity ")] + [TestCase("-Infinity ")] + [TestCase(" NaN")] + [TestCase("INFINITY")] + [TestCase("nan")] + [TestCase("\u00BD")] // 1/2 as a single Unicode character. Just sanity checking... + public void StringToDouble_Invalid(string jsonValue) + { + string json = "{ \"singleDouble\": \"" + jsonValue + "\"}"; + Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); + } + + [Test] + [TestCase("0", 0f)] + [TestCase("1", 1f)] + [TestCase("1.000000", 1f)] + [TestCase("-1", -1f)] + [TestCase("3.402823e38", 3.402823e38f)] + [TestCase("-3.402823e38", -3.402823e38f)] + [TestCase("1.5e1", 15f)] + [TestCase("15e-1", 1.5f)] + public void StringToFloat_Valid(string jsonValue, float expectedParsedValue) + { + string json = "{ \"singleFloat\": \"" + jsonValue + "\"}"; + var parsed = TestAllTypes.Parser.ParseJson(json); + Assert.AreEqual(expectedParsedValue, parsed.SingleFloat); + } + + [Test] + [TestCase("3.402824e38")] + [TestCase("-3.402824e38")] + [TestCase("1,0")] + [TestCase("1.0.0")] + [TestCase("+1")] + [TestCase("00")] + [TestCase("--1")] + public void StringToFloat_Invalid(string jsonValue) + { + string json = "{ \"singleFloat\": \"" + jsonValue + "\"}"; + Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); + } + + [Test] + [TestCase("0", 0)] + [TestCase("-0", 0)] // Not entirely clear whether we intend to allow this... + [TestCase("1", 1)] + [TestCase("-1", -1)] + [TestCase("2147483647", 2147483647)] + [TestCase("-2147483648", -2147483648)] + [TestCase("1e1", 10)] + [TestCase("-1e1", -10)] + [TestCase("10.00", 10)] + [TestCase("-10.00", -10)] + public void NumberToInt32_Valid(string jsonValue, int expectedParsedValue) + { + string json = "{ \"singleInt32\": " + jsonValue + "}"; + var parsed = TestAllTypes.Parser.ParseJson(json); + Assert.AreEqual(expectedParsedValue, parsed.SingleInt32); + } + + [Test] + [TestCase("+0", typeof(InvalidJsonException))] + [TestCase("00", typeof(InvalidJsonException))] + [TestCase("-00", typeof(InvalidJsonException))] + [TestCase("--1", typeof(InvalidJsonException))] + [TestCase("+1", typeof(InvalidJsonException))] + [TestCase("1.5", typeof(InvalidProtocolBufferException))] + // Value is out of range + [TestCase("1e10", typeof(InvalidProtocolBufferException))] + [TestCase("2147483648", typeof(InvalidProtocolBufferException))] + [TestCase("-2147483649", typeof(InvalidProtocolBufferException))] + public void NumberToInt32_Invalid(string jsonValue, System.Type expectedExceptionType) + { + string json = "{ \"singleInt32\": " + jsonValue + "}"; + Assert.Throws(expectedExceptionType, () => TestAllTypes.Parser.ParseJson(json)); + } + + [Test] + [TestCase("0", 0U)] + [TestCase("1", 1U)] + [TestCase("4294967295", 4294967295U)] + public void NumberToUInt32_Valid(string jsonValue, uint expectedParsedValue) + { + string json = "{ \"singleUint32\": " + jsonValue + "}"; + var parsed = TestAllTypes.Parser.ParseJson(json); + Assert.AreEqual(expectedParsedValue, parsed.SingleUint32); + } + + // Assume that anything non-bounds-related is covered in the Int32 case + [Test] + [TestCase("-1")] + [TestCase("4294967296")] + public void NumberToUInt32_Invalid(string jsonValue) + { + string json = "{ \"singleUint32\": " + jsonValue + "}"; + Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); + } + + [Test] + [TestCase("0", 0L)] + [TestCase("1", 1L)] + [TestCase("-1", -1L)] + // long.MaxValue isn't actually representable as a double. This string value is the highest + // representable value which isn't greater than long.MaxValue. + [TestCase("9223372036854774784", 9223372036854774784)] + [TestCase("-9223372036854775808", -9223372036854775808)] + public void NumberToInt64_Valid(string jsonValue, long expectedParsedValue) + { + string json = "{ \"singleInt64\": " + jsonValue + "}"; + var parsed = TestAllTypes.Parser.ParseJson(json); + Assert.AreEqual(expectedParsedValue, parsed.SingleInt64); + } + + // Assume that anything non-bounds-related is covered in the Int32 case + [Test] + [TestCase("9223372036854775808")] + // Theoretical bound would be -9223372036854775809, but when that is parsed to a double + // we end up with the exact value of long.MinValue due to lack of precision. The value here + // is the "next double down". + [TestCase("-9223372036854780000")] + public void NumberToInt64_Invalid(string jsonValue) + { + string json = "{ \"singleInt64\": " + jsonValue + "}"; + Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); + } + + [Test] + [TestCase("0", 0UL)] + [TestCase("1", 1UL)] + // ulong.MaxValue isn't representable as a double. This value is the largest double within + // the range of ulong. + [TestCase("18446744073709549568", 18446744073709549568UL)] + public void NumberToUInt64_Valid(string jsonValue, ulong expectedParsedValue) + { + string json = "{ \"singleUint64\": " + jsonValue + "}"; + var parsed = TestAllTypes.Parser.ParseJson(json); + Assert.AreEqual(expectedParsedValue, parsed.SingleUint64); + } + + // Assume that anything non-bounds-related is covered in the Int32 case + [Test] + [TestCase("-1")] + [TestCase("18446744073709551616")] + public void NumberToUInt64_Invalid(string jsonValue) + { + string json = "{ \"singleUint64\": " + jsonValue + "}"; + Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); + } + + [Test] + [TestCase("0", 0d)] + [TestCase("1", 1d)] + [TestCase("1.000000", 1d)] + [TestCase("1.0000000000000000000000001", 1d)] // We don't notice that we haven't preserved the exact value + [TestCase("-1", -1d)] + [TestCase("1e1", 10d)] + [TestCase("1e01", 10d)] // Leading decimals are allowed in exponents + [TestCase("1E1", 10d)] // Either case is fine + [TestCase("-1e1", -10d)] + [TestCase("1.5e1", 15d)] + [TestCase("-1.5e1", -15d)] + [TestCase("15e-1", 1.5d)] + [TestCase("-15e-1", -1.5d)] + [TestCase("1.79769e308", 1.79769e308)] + [TestCase("-1.79769e308", -1.79769e308)] + public void NumberToDouble_Valid(string jsonValue, double expectedParsedValue) + { + string json = "{ \"singleDouble\": " + jsonValue + "}"; + var parsed = TestAllTypes.Parser.ParseJson(json); + Assert.AreEqual(expectedParsedValue, parsed.SingleDouble); + } + + [Test] + [TestCase("1.7977e308")] + [TestCase("-1.7977e308")] + [TestCase("1e309")] + [TestCase("1,0")] + [TestCase("1.0.0")] + [TestCase("+1")] + [TestCase("00")] + [TestCase("--1")] + [TestCase("\u00BD")] // 1/2 as a single Unicode character. Just sanity checking... + public void NumberToDouble_Invalid(string jsonValue) + { + string json = "{ \"singleDouble\": " + jsonValue + "}"; + Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); + } + + [Test] + [TestCase("0", 0f)] + [TestCase("1", 1f)] + [TestCase("1.000000", 1f)] + [TestCase("-1", -1f)] + [TestCase("3.402823e38", 3.402823e38f)] + [TestCase("-3.402823e38", -3.402823e38f)] + [TestCase("1.5e1", 15f)] + [TestCase("15e-1", 1.5f)] + public void NumberToFloat_Valid(string jsonValue, float expectedParsedValue) + { + string json = "{ \"singleFloat\": " + jsonValue + "}"; + var parsed = TestAllTypes.Parser.ParseJson(json); + Assert.AreEqual(expectedParsedValue, parsed.SingleFloat); + } + + [Test] + [TestCase("3.402824e38", typeof(InvalidProtocolBufferException))] + [TestCase("-3.402824e38", typeof(InvalidProtocolBufferException))] + [TestCase("1,0", typeof(InvalidJsonException))] + [TestCase("1.0.0", typeof(InvalidJsonException))] + [TestCase("+1", typeof(InvalidJsonException))] + [TestCase("00", typeof(InvalidJsonException))] + [TestCase("--1", typeof(InvalidJsonException))] + public void NumberToFloat_Invalid(string jsonValue, System.Type expectedExceptionType) + { + string json = "{ \"singleFloat\": " + jsonValue + "}"; + Assert.Throws(expectedExceptionType, () => TestAllTypes.Parser.ParseJson(json)); + } + + // The simplest way of testing that the value has parsed correctly is to reformat it, + // as we trust the formatting. In many cases that will give the same result as the input, + // so in those cases we accept an expectedFormatted value of null. Sometimes the results + // will be different though, due to a different number of digits being provided. + [Test] + // Z offset + [TestCase("2015-10-09T14:46:23.123456789Z", null)] + [TestCase("2015-10-09T14:46:23.123456Z", null)] + [TestCase("2015-10-09T14:46:23.123Z", null)] + [TestCase("2015-10-09T14:46:23Z", null)] + [TestCase("2015-10-09T14:46:23.123456000Z", "2015-10-09T14:46:23.123456Z")] + [TestCase("2015-10-09T14:46:23.1234560Z", "2015-10-09T14:46:23.123456Z")] + [TestCase("2015-10-09T14:46:23.123000000Z", "2015-10-09T14:46:23.123Z")] + [TestCase("2015-10-09T14:46:23.1230Z", "2015-10-09T14:46:23.123Z")] + [TestCase("2015-10-09T14:46:23.00Z", "2015-10-09T14:46:23Z")] + + // +00:00 offset + [TestCase("2015-10-09T14:46:23.123456789+00:00", "2015-10-09T14:46:23.123456789Z")] + [TestCase("2015-10-09T14:46:23.123456+00:00", "2015-10-09T14:46:23.123456Z")] + [TestCase("2015-10-09T14:46:23.123+00:00", "2015-10-09T14:46:23.123Z")] + [TestCase("2015-10-09T14:46:23+00:00", "2015-10-09T14:46:23Z")] + [TestCase("2015-10-09T14:46:23.123456000+00:00", "2015-10-09T14:46:23.123456Z")] + [TestCase("2015-10-09T14:46:23.1234560+00:00", "2015-10-09T14:46:23.123456Z")] + [TestCase("2015-10-09T14:46:23.123000000+00:00", "2015-10-09T14:46:23.123Z")] + [TestCase("2015-10-09T14:46:23.1230+00:00", "2015-10-09T14:46:23.123Z")] + [TestCase("2015-10-09T14:46:23.00+00:00", "2015-10-09T14:46:23Z")] + + // Other offsets (assume by now that the subsecond handling is okay) + [TestCase("2015-10-09T15:46:23.123456789+01:00", "2015-10-09T14:46:23.123456789Z")] + [TestCase("2015-10-09T13:46:23.123456789-01:00", "2015-10-09T14:46:23.123456789Z")] + [TestCase("2015-10-09T15:16:23.123456789+00:30", "2015-10-09T14:46:23.123456789Z")] + [TestCase("2015-10-09T14:16:23.123456789-00:30", "2015-10-09T14:46:23.123456789Z")] + [TestCase("2015-10-09T16:31:23.123456789+01:45", "2015-10-09T14:46:23.123456789Z")] + [TestCase("2015-10-09T13:01:23.123456789-01:45", "2015-10-09T14:46:23.123456789Z")] + [TestCase("2015-10-10T08:46:23.123456789+18:00", "2015-10-09T14:46:23.123456789Z")] + [TestCase("2015-10-08T20:46:23.123456789-18:00", "2015-10-09T14:46:23.123456789Z")] + + // Leap years and min/max + [TestCase("2016-02-29T14:46:23.123456789Z", null)] + [TestCase("2000-02-29T14:46:23.123456789Z", null)] + [TestCase("0001-01-01T00:00:00Z", null)] + [TestCase("9999-12-31T23:59:59.999999999Z", null)] + public void Timestamp_Valid(string jsonValue, string expectedFormatted) + { + expectedFormatted = expectedFormatted ?? jsonValue; + string json = WrapInQuotes(jsonValue); + var parsed = Timestamp.Parser.ParseJson(json); + Assert.AreEqual(WrapInQuotes(expectedFormatted), parsed.ToString()); + } + + [Test] + [TestCase("2015-10-09 14:46:23.123456789Z", Description = "No T between date and time")] + [TestCase("2015/10/09T14:46:23.123456789Z", Description = "Wrong date separators")] + [TestCase("2015-10-09T14.46.23.123456789Z", Description = "Wrong time separators")] + [TestCase("2015-10-09T14:46:23,123456789Z", Description = "Wrong fractional second separators (valid ISO-8601 though)")] + [TestCase(" 2015-10-09T14:46:23.123456789Z", Description = "Whitespace at start")] + [TestCase("2015-10-09T14:46:23.123456789Z ", Description = "Whitespace at end")] + [TestCase("2015-10-09T14:46:23.1234567890", Description = "Too many digits")] + [TestCase("2015-10-09T14:46:23.123456789", Description = "No offset")] + [TestCase("2015-13-09T14:46:23.123456789Z", Description = "Invalid month")] + [TestCase("2015-10-32T14:46:23.123456789Z", Description = "Invalid day")] + [TestCase("2015-10-09T24:00:00.000000000Z", Description = "Invalid hour (valid ISO-8601 though)")] + [TestCase("2015-10-09T14:60:23.123456789Z", Description = "Invalid minutes")] + [TestCase("2015-10-09T14:46:60.123456789Z", Description = "Invalid seconds")] + [TestCase("2015-10-09T14:46:23.123456789+18:01", Description = "Offset too large (positive)")] + [TestCase("2015-10-09T14:46:23.123456789-18:01", Description = "Offset too large (negative)")] + [TestCase("2015-10-09T14:46:23.123456789-00:00", Description = "Local offset (-00:00) makes no sense here")] + [TestCase("0001-01-01T00:00:00+00:01", Description = "Value before earliest when offset applied")] + [TestCase("9999-12-31T23:59:59.999999999-00:01", Description = "Value after latest when offset applied")] + [TestCase("2100-02-29T14:46:23.123456789Z", Description = "Feb 29th on a non-leap-year")] + public void Timestamp_Invalid(string jsonValue) + { + string json = WrapInQuotes(jsonValue); + Assert.Throws(() => Timestamp.Parser.ParseJson(json)); + } + + [Test] + public void StructValue_Null() + { + Assert.AreEqual(new Value { NullValue = 0 }, Value.Parser.ParseJson("null")); + } + + [Test] + public void StructValue_String() + { + Assert.AreEqual(new Value { StringValue = "hi" }, Value.Parser.ParseJson("\"hi\"")); + } + + [Test] + public void StructValue_Bool() + { + Assert.AreEqual(new Value { BoolValue = true }, Value.Parser.ParseJson("true")); + Assert.AreEqual(new Value { BoolValue = false }, Value.Parser.ParseJson("false")); + } + + [Test] + public void StructValue_List() + { + Assert.AreEqual(Value.ForList(Value.ForNumber(1), Value.ForString("x")), Value.Parser.ParseJson("[1, \"x\"]")); + } + + [Test] + public void ParseListValue() + { + Assert.AreEqual(new ListValue { Values = { Value.ForNumber(1), Value.ForString("x") } }, ListValue.Parser.ParseJson("[1, \"x\"]")); + } + + [Test] + public void StructValue_Struct() + { + Assert.AreEqual( + Value.ForStruct(new Struct { Fields = { { "x", Value.ForNumber(1) }, { "y", Value.ForString("z") } } }), + Value.Parser.ParseJson("{ \"x\": 1, \"y\": \"z\" }")); + } + + [Test] + public void ParseStruct() + { + Assert.AreEqual(new Struct { Fields = { { "x", Value.ForNumber(1) }, { "y", Value.ForString("z") } } }, + Struct.Parser.ParseJson("{ \"x\": 1, \"y\": \"z\" }")); + } + + // TODO for duration parsing: upper and lower bounds. + // +/- 315576000000 seconds + + [Test] + [TestCase("1.123456789s", null)] + [TestCase("1.123456s", null)] + [TestCase("1.123s", null)] + [TestCase("1.12300s", "1.123s")] + [TestCase("1.12345s", "1.123450s")] + [TestCase("1s", null)] + [TestCase("-1.123456789s", null)] + [TestCase("-1.123456s", null)] + [TestCase("-1.123s", null)] + [TestCase("-1s", null)] + [TestCase("0.123s", null)] + [TestCase("-0.123s", null)] + [TestCase("123456.123s", null)] + [TestCase("-123456.123s", null)] + // Upper and lower bounds + [TestCase("315576000000s", null)] + [TestCase("-315576000000s", null)] + public void Duration_Valid(string jsonValue, string expectedFormatted) + { + expectedFormatted = expectedFormatted ?? jsonValue; + string json = WrapInQuotes(jsonValue); + var parsed = Duration.Parser.ParseJson(json); + Assert.AreEqual(WrapInQuotes(expectedFormatted), parsed.ToString()); + } + + // The simplest way of testing that the value has parsed correctly is to reformat it, + // as we trust the formatting. In many cases that will give the same result as the input, + // so in those cases we accept an expectedFormatted value of null. Sometimes the results + // will be different though, due to a different number of digits being provided. + [Test] + [TestCase("1.1234567890s", Description = "Too many digits")] + [TestCase("1.123456789", Description = "No suffix")] + [TestCase("1.123456789ss", Description = "Too much suffix")] + [TestCase("1.123456789S", Description = "Upper case suffix")] + [TestCase("+1.123456789s", Description = "Leading +")] + [TestCase(".123456789s", Description = "No integer before the fraction")] + [TestCase("1,123456789s", Description = "Comma as decimal separator")] + [TestCase("1x1.123456789s", Description = "Non-digit in integer part")] + [TestCase("1.1x3456789s", Description = "Non-digit in fractional part")] + [TestCase(" 1.123456789s", Description = "Whitespace before fraction")] + [TestCase("1.123456789s ", Description = "Whitespace after value")] + [TestCase("01.123456789s", Description = "Leading zero (positive)")] + [TestCase("-01.123456789s", Description = "Leading zero (negative)")] + [TestCase("--0.123456789s", Description = "Double minus sign")] + // Violate upper/lower bounds in various ways + [TestCase("315576000001s", Description = "Integer part too large")] + [TestCase("3155760000000s", Description = "Integer part too long (positive)")] + [TestCase("-3155760000000s", Description = "Integer part too long (negative)")] + public void Duration_Invalid(string jsonValue) + { + string json = WrapInQuotes(jsonValue); + Assert.Throws(() => Duration.Parser.ParseJson(json)); + } + + // Not as many tests for field masks as I'd like; more to be added when we have more + // detailed specifications. + + [Test] + [TestCase("")] + [TestCase("foo", "foo")] + [TestCase("foo,bar", "foo", "bar")] + [TestCase("foo.bar", "foo.bar")] + [TestCase("fooBar", "foo_bar")] + [TestCase("fooBar.bazQux", "foo_bar.baz_qux")] + public void FieldMask_Valid(string jsonValue, params string[] expectedPaths) + { + string json = WrapInQuotes(jsonValue); + var parsed = FieldMask.Parser.ParseJson(json); + CollectionAssert.AreEqual(expectedPaths, parsed.Paths); + } + + [Test] + [TestCase("foo_bar")] + public void FieldMask_Invalid(string jsonValue) + { + string json = WrapInQuotes(jsonValue); + Assert.Throws(() => FieldMask.Parser.ParseJson(json)); + } + + [Test] + public void Any_RegularMessage() + { + var registry = TypeRegistry.FromMessages(TestAllTypes.Descriptor); + var formatter = new JsonFormatter(new JsonFormatter.Settings(false, TypeRegistry.FromMessages(TestAllTypes.Descriptor))); + var message = new TestAllTypes { SingleInt32 = 10, SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 } }; + var original = Any.Pack(message); + var json = formatter.Format(original); // This is tested in JsonFormatterTest + var parser = new JsonParser(new JsonParser.Settings(10, registry)); + Assert.AreEqual(original, parser.Parse(json)); + string valueFirstJson = "{ \"singleInt32\": 10, \"singleNestedMessage\": { \"bb\": 20 }, \"@type\": \"type.googleapis.com/protobuf_unittest.TestAllTypes\" }"; + Assert.AreEqual(original, parser.Parse(valueFirstJson)); + } + + [Test] + public void Any_CustomPrefix() + { + var registry = TypeRegistry.FromMessages(TestAllTypes.Descriptor); + var message = new TestAllTypes { SingleInt32 = 10 }; + var original = Any.Pack(message, "custom.prefix/middle-part"); + var parser = new JsonParser(new JsonParser.Settings(10, registry)); + string json = "{ \"@type\": \"custom.prefix/middle-part/protobuf_unittest.TestAllTypes\", \"singleInt32\": 10 }"; + Assert.AreEqual(original, parser.Parse(json)); + } + + [Test] + public void Any_UnknownType() + { + string json = "{ \"@type\": \"type.googleapis.com/bogus\" }"; + Assert.Throws(() => Any.Parser.ParseJson(json)); + } + + [Test] + public void Any_NoTypeUrl() + { + string json = "{ \"foo\": \"bar\" }"; + Assert.Throws(() => Any.Parser.ParseJson(json)); + } + + [Test] + public void Any_WellKnownType() + { + var registry = TypeRegistry.FromMessages(Timestamp.Descriptor); + var formatter = new JsonFormatter(new JsonFormatter.Settings(false, registry)); + var timestamp = new DateTime(1673, 6, 19, 12, 34, 56, DateTimeKind.Utc).ToTimestamp(); + var original = Any.Pack(timestamp); + var json = formatter.Format(original); // This is tested in JsonFormatterTest + var parser = new JsonParser(new JsonParser.Settings(10, registry)); + Assert.AreEqual(original, parser.Parse(json)); + string valueFirstJson = "{ \"value\": \"1673-06-19T12:34:56Z\", \"@type\": \"type.googleapis.com/google.protobuf.Timestamp\" }"; + Assert.AreEqual(original, parser.Parse(valueFirstJson)); + } + + [Test] + public void Any_Nested() + { + var registry = TypeRegistry.FromMessages(TestWellKnownTypes.Descriptor, TestAllTypes.Descriptor); + var formatter = new JsonFormatter(new JsonFormatter.Settings(false, registry)); + var parser = new JsonParser(new JsonParser.Settings(10, registry)); + var doubleNestedMessage = new TestAllTypes { SingleInt32 = 20 }; + var nestedMessage = Any.Pack(doubleNestedMessage); + var message = new TestWellKnownTypes { AnyField = Any.Pack(nestedMessage) }; + var json = formatter.Format(message); + // Use the descriptor-based parser just for a change. + Assert.AreEqual(message, parser.Parse(json, TestWellKnownTypes.Descriptor)); + } + + [Test] + public void DataAfterObject() + { + string json = "{} 10"; + Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); + } + + /// + /// JSON equivalent to + /// + [Test] + public void MaliciousRecursion() + { + string data64 = CodedInputStreamTest.MakeRecursiveMessage(64).ToString(); + string data65 = CodedInputStreamTest.MakeRecursiveMessage(65).ToString(); + + var parser64 = new JsonParser(new JsonParser.Settings(64)); + CodedInputStreamTest.AssertMessageDepth(parser64.Parse(data64), 64); + Assert.Throws(() => parser64.Parse(data65)); + + var parser63 = new JsonParser(new JsonParser.Settings(63)); + Assert.Throws(() => parser63.Parse(data64)); + } + + [Test] + [TestCase("AQI")] + [TestCase("_-==")] + public void Bytes_InvalidBase64(string badBase64) + { + string json = "{ \"singleBytes\": \"" + badBase64 + "\" }"; + Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); + } + + [Test] + [TestCase("\"FOREIGN_BAR\"", ForeignEnum.ForeignBar)] + [TestCase("5", ForeignEnum.ForeignBar)] + [TestCase("100", (ForeignEnum)100)] + public void EnumValid(string value, ForeignEnum expectedValue) + { + string json = "{ \"singleForeignEnum\": " + value + " }"; + var parsed = TestAllTypes.Parser.ParseJson(json); + Assert.AreEqual(new TestAllTypes { SingleForeignEnum = expectedValue }, parsed); + } + + [Test] + [TestCase("\"NOT_A_VALID_VALUE\"")] + [TestCase("5.5")] + public void Enum_Invalid(string value) + { + string json = "{ \"singleForeignEnum\": " + value + " }"; + Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); + } + + [Test] + public void OneofDuplicate_Invalid() + { + string json = "{ \"oneofString\": \"x\", \"oneofUint32\": 10 }"; + Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); + } + + /// + /// Various tests use strings which have quotes round them for parsing or as the result + /// of formatting, but without those quotes being specified in the tests (for the sake of readability). + /// This method simply returns the input, wrapped in double quotes. + /// + internal static string WrapInQuotes(string text) + { + return '"' + text + '"'; + } + } +} \ No newline at end of file diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/JsonTokenizerTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/JsonTokenizerTest.cs new file mode 100644 index 000000000000..2e690c182dfe --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/JsonTokenizerTest.cs @@ -0,0 +1,408 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion +using NUnit.Framework; +using System; +using System.IO; + +namespace Google.Protobuf +{ + public class JsonTokenizerTest + { + [Test] + public void EmptyObjectValue() + { + AssertTokens("{}", JsonToken.StartObject, JsonToken.EndObject); + } + + [Test] + public void EmptyArrayValue() + { + AssertTokens("[]", JsonToken.StartArray, JsonToken.EndArray); + } + + [Test] + [TestCase("foo", "foo")] + [TestCase("tab\\t", "tab\t")] + [TestCase("line\\nfeed", "line\nfeed")] + [TestCase("carriage\\rreturn", "carriage\rreturn")] + [TestCase("back\\bspace", "back\bspace")] + [TestCase("form\\ffeed", "form\ffeed")] + [TestCase("escaped\\/slash", "escaped/slash")] + [TestCase("escaped\\\\backslash", "escaped\\backslash")] + [TestCase("escaped\\\"quote", "escaped\"quote")] + [TestCase("foo {}[] bar", "foo {}[] bar")] + [TestCase("foo\\u09aFbar", "foo\u09afbar")] // Digits, upper hex, lower hex + [TestCase("ab\ud800\udc00cd", "ab\ud800\udc00cd")] + [TestCase("ab\\ud800\\udc00cd", "ab\ud800\udc00cd")] + public void StringValue(string json, string expectedValue) + { + AssertTokensNoReplacement("\"" + json + "\"", JsonToken.Value(expectedValue)); + } + + // Valid surrogate pairs, with mixed escaping. These test cases can't be expressed + // using TestCase as they have no valid UTF-8 representation. + // It's unclear exactly how we should handle a mixture of escaped or not: that can't + // come from UTF-8 text, but could come from a .NET string. For the moment, + // treat it as valid in the obvious way. + [Test] + public void MixedSurrogatePairs() + { + string expected = "\ud800\udc00"; + AssertTokens("'\\ud800\udc00'", JsonToken.Value(expected)); + AssertTokens("'\ud800\\udc00'", JsonToken.Value(expected)); + } + + [Test] + public void ObjectDepth() + { + string json = "{ \"foo\": { \"x\": 1, \"y\": [ 0 ] } }"; + var tokenizer = JsonTokenizer.FromTextReader(new StringReader(json)); + // If we had more tests like this, I'd introduce a helper method... but for one test, it's not worth it. + Assert.AreEqual(0, tokenizer.ObjectDepth); + Assert.AreEqual(JsonToken.StartObject, tokenizer.Next()); + Assert.AreEqual(1, tokenizer.ObjectDepth); + Assert.AreEqual(JsonToken.Name("foo"), tokenizer.Next()); + Assert.AreEqual(1, tokenizer.ObjectDepth); + Assert.AreEqual(JsonToken.StartObject, tokenizer.Next()); + Assert.AreEqual(2, tokenizer.ObjectDepth); + Assert.AreEqual(JsonToken.Name("x"), tokenizer.Next()); + Assert.AreEqual(2, tokenizer.ObjectDepth); + Assert.AreEqual(JsonToken.Value(1), tokenizer.Next()); + Assert.AreEqual(2, tokenizer.ObjectDepth); + Assert.AreEqual(JsonToken.Name("y"), tokenizer.Next()); + Assert.AreEqual(2, tokenizer.ObjectDepth); + Assert.AreEqual(JsonToken.StartArray, tokenizer.Next()); + Assert.AreEqual(2, tokenizer.ObjectDepth); // Depth hasn't changed in array + Assert.AreEqual(JsonToken.Value(0), tokenizer.Next()); + Assert.AreEqual(2, tokenizer.ObjectDepth); + Assert.AreEqual(JsonToken.EndArray, tokenizer.Next()); + Assert.AreEqual(2, tokenizer.ObjectDepth); + Assert.AreEqual(JsonToken.EndObject, tokenizer.Next()); + Assert.AreEqual(1, tokenizer.ObjectDepth); + Assert.AreEqual(JsonToken.EndObject, tokenizer.Next()); + Assert.AreEqual(0, tokenizer.ObjectDepth); + Assert.AreEqual(JsonToken.EndDocument, tokenizer.Next()); + Assert.AreEqual(0, tokenizer.ObjectDepth); + } + + [Test] + public void ObjectDepth_WithPushBack() + { + string json = "{}"; + var tokenizer = JsonTokenizer.FromTextReader(new StringReader(json)); + Assert.AreEqual(0, tokenizer.ObjectDepth); + var token = tokenizer.Next(); + Assert.AreEqual(1, tokenizer.ObjectDepth); + // When we push back a "start object", we should effectively be back to the previous depth. + tokenizer.PushBack(token); + Assert.AreEqual(0, tokenizer.ObjectDepth); + // Read the same token again, and get back to depth 1 + token = tokenizer.Next(); + Assert.AreEqual(1, tokenizer.ObjectDepth); + + // Now the same in reverse, with EndObject + token = tokenizer.Next(); + Assert.AreEqual(0, tokenizer.ObjectDepth); + tokenizer.PushBack(token); + Assert.AreEqual(1, tokenizer.ObjectDepth); + tokenizer.Next(); + Assert.AreEqual(0, tokenizer.ObjectDepth); + } + + [Test] + [TestCase("embedded tab\t")] + [TestCase("embedded CR\r")] + [TestCase("embedded LF\n")] + [TestCase("embedded bell\u0007")] + [TestCase("bad escape\\a")] + [TestCase("incomplete escape\\")] + [TestCase("incomplete Unicode escape\\u000")] + [TestCase("invalid Unicode escape\\u000H")] + // Surrogate pair handling, both in raw .NET strings and escaped. We only need + // to detect this in strings, as non-ASCII characters anywhere other than in strings + // will already lead to parsing errors. + [TestCase("\\ud800")] + [TestCase("\\udc00")] + [TestCase("\\ud800x")] + [TestCase("\\udc00x")] + [TestCase("\\udc00\\ud800y")] + public void InvalidStringValue(string json) + { + AssertThrowsAfter("\"" + json + "\""); + } + + // Tests for invalid strings that can't be expressed in attributes, + // as the constants can't be expressed as UTF-8 strings. + [Test] + public void InvalidSurrogatePairs() + { + AssertThrowsAfter("\"\ud800x\""); + AssertThrowsAfter("\"\udc00y\""); + AssertThrowsAfter("\"\udc00\ud800y\""); + } + + [Test] + [TestCase("0", 0)] + [TestCase("-0", 0)] // We don't distinguish between positive and negative 0 + [TestCase("1", 1)] + [TestCase("-1", -1)] + // From here on, assume leading sign is okay... + [TestCase("1.125", 1.125)] + [TestCase("1.0", 1)] + [TestCase("1e5", 100000)] + [TestCase("1e000000", 1)] // Weird, but not prohibited by the spec + [TestCase("1E5", 100000)] + [TestCase("1e+5", 100000)] + [TestCase("1E-5", 0.00001)] + [TestCase("123E-2", 1.23)] + [TestCase("123.45E3", 123450)] + [TestCase(" 1 ", 1)] + public void NumberValue(string json, double expectedValue) + { + AssertTokens(json, JsonToken.Value(expectedValue)); + } + + [Test] + [TestCase("00")] + [TestCase(".5")] + [TestCase("1.")] + [TestCase("1e")] + [TestCase("1e-")] + [TestCase("--")] + [TestCase("--1")] + [TestCase("-1.7977e308")] + [TestCase("1.7977e308")] + public void InvalidNumberValue(string json) + { + AssertThrowsAfter(json); + } + + [Test] + [TestCase("nul")] + [TestCase("nothing")] + [TestCase("truth")] + [TestCase("fALSEhood")] + public void InvalidLiterals(string json) + { + AssertThrowsAfter(json); + } + + [Test] + public void NullValue() + { + AssertTokens("null", JsonToken.Null); + } + + [Test] + public void TrueValue() + { + AssertTokens("true", JsonToken.True); + } + + [Test] + public void FalseValue() + { + AssertTokens("false", JsonToken.False); + } + + [Test] + public void SimpleObject() + { + AssertTokens("{'x': 'y'}", + JsonToken.StartObject, JsonToken.Name("x"), JsonToken.Value("y"), JsonToken.EndObject); + } + + [Test] + [TestCase("[10, 20", 3)] + [TestCase("[10,", 2)] + [TestCase("[10:20]", 2)] + [TestCase("[", 1)] + [TestCase("[,", 1)] + [TestCase("{", 1)] + [TestCase("{,", 1)] + [TestCase("{[", 1)] + [TestCase("{{", 1)] + [TestCase("{0", 1)] + [TestCase("{null", 1)] + [TestCase("{false", 1)] + [TestCase("{true", 1)] + [TestCase("}", 0)] + [TestCase("]", 0)] + [TestCase(",", 0)] + [TestCase("'foo' 'bar'", 1)] + [TestCase(":", 0)] + [TestCase("'foo", 0)] // Incomplete string + [TestCase("{ 'foo' }", 2)] + [TestCase("{ x:1", 1)] // Property names must be quoted + [TestCase("{]", 1)] + [TestCase("[}", 1)] + [TestCase("[1,", 2)] + [TestCase("{'x':0]", 3)] + [TestCase("{ 'foo': }", 2)] + [TestCase("{ 'foo':'bar', }", 3)] + public void InvalidStructure(string json, int expectedValidTokens) + { + // Note: we don't test that the earlier tokens are exactly as expected, + // partly because that's hard to parameterize. + var reader = new StringReader(json.Replace('\'', '"')); + var tokenizer = JsonTokenizer.FromTextReader(reader); + for (int i = 0; i < expectedValidTokens; i++) + { + Assert.IsNotNull(tokenizer.Next()); + } + Assert.Throws(() => tokenizer.Next()); + } + + [Test] + public void ArrayMixedType() + { + AssertTokens("[1, 'foo', null, false, true, [2], {'x':'y' }]", + JsonToken.StartArray, + JsonToken.Value(1), + JsonToken.Value("foo"), + JsonToken.Null, + JsonToken.False, + JsonToken.True, + JsonToken.StartArray, + JsonToken.Value(2), + JsonToken.EndArray, + JsonToken.StartObject, + JsonToken.Name("x"), + JsonToken.Value("y"), + JsonToken.EndObject, + JsonToken.EndArray); + } + + [Test] + public void ObjectMixedType() + { + AssertTokens(@"{'a': 1, 'b': 'bar', 'c': null, 'd': false, 'e': true, + 'f': [2], 'g': {'x':'y' }}", + JsonToken.StartObject, + JsonToken.Name("a"), + JsonToken.Value(1), + JsonToken.Name("b"), + JsonToken.Value("bar"), + JsonToken.Name("c"), + JsonToken.Null, + JsonToken.Name("d"), + JsonToken.False, + JsonToken.Name("e"), + JsonToken.True, + JsonToken.Name("f"), + JsonToken.StartArray, + JsonToken.Value(2), + JsonToken.EndArray, + JsonToken.Name("g"), + JsonToken.StartObject, + JsonToken.Name("x"), + JsonToken.Value("y"), + JsonToken.EndObject, + JsonToken.EndObject); + } + + [Test] + public void NextAfterEndDocumentThrows() + { + var tokenizer = JsonTokenizer.FromTextReader(new StringReader("null")); + Assert.AreEqual(JsonToken.Null, tokenizer.Next()); + Assert.AreEqual(JsonToken.EndDocument, tokenizer.Next()); + Assert.Throws(() => tokenizer.Next()); + } + + [Test] + public void CanPushBackEndDocument() + { + var tokenizer = JsonTokenizer.FromTextReader(new StringReader("null")); + Assert.AreEqual(JsonToken.Null, tokenizer.Next()); + Assert.AreEqual(JsonToken.EndDocument, tokenizer.Next()); + tokenizer.PushBack(JsonToken.EndDocument); + Assert.AreEqual(JsonToken.EndDocument, tokenizer.Next()); + Assert.Throws(() => tokenizer.Next()); + } + + /// + /// Asserts that the specified JSON is tokenized into the given sequence of tokens. + /// All apostrophes are first converted to double quotes, allowing any tests + /// that don't need to check actual apostrophe handling to use apostrophes in the JSON, avoiding + /// messy string literal escaping. The "end document" token is not specified in the list of + /// expected tokens, but is implicit. + /// + private static void AssertTokens(string json, params JsonToken[] expectedTokens) + { + AssertTokensNoReplacement(json.Replace('\'', '"'), expectedTokens); + } + + /// + /// Asserts that the specified JSON is tokenized into the given sequence of tokens. + /// Unlike , this does not perform any character + /// replacement on the specified JSON, and should be used when the text contains apostrophes which + /// are expected to be used *as* apostrophes. The "end document" token is not specified in the list of + /// expected tokens, but is implicit. + /// + private static void AssertTokensNoReplacement(string json, params JsonToken[] expectedTokens) + { + var reader = new StringReader(json); + var tokenizer = JsonTokenizer.FromTextReader(reader); + for (int i = 0; i < expectedTokens.Length; i++) + { + var actualToken = tokenizer.Next(); + if (actualToken == JsonToken.EndDocument) + { + Assert.Fail("Expected {0} but reached end of token stream", expectedTokens[i]); + } + Assert.AreEqual(expectedTokens[i], actualToken); + } + var finalToken = tokenizer.Next(); + if (finalToken != JsonToken.EndDocument) + { + Assert.Fail("Expected token stream to be exhausted; received {0}", finalToken); + } + } + + private static void AssertThrowsAfter(string json, params JsonToken[] expectedTokens) + { + var reader = new StringReader(json); + var tokenizer = JsonTokenizer.FromTextReader(reader); + for (int i = 0; i < expectedTokens.Length; i++) + { + var actualToken = tokenizer.Next(); + if (actualToken == JsonToken.EndDocument) + { + Assert.Fail("Expected {0} but reached end of document", expectedTokens[i]); + } + Assert.AreEqual(expectedTokens[i], actualToken); + } + Assert.Throws(() => tokenizer.Next()); + } + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Program.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Program.cs new file mode 100644 index 000000000000..9078e59b1da9 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Program.cs @@ -0,0 +1,47 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2017 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion +using NUnitLite; +using System.Reflection; + +// Note: this file wasn't in the actual 3.0, but is required due to build +// system changes + +namespace Google.Protobuf.Test +{ + class Program + { + public static int Main(string[] args) + { + return new AutoRun(typeof(Program).GetTypeInfo().Assembly).Execute(args); + } + } +} \ No newline at end of file diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs new file mode 100644 index 000000000000..0520ada30aa8 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs @@ -0,0 +1,259 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System.Linq; +using Google.Protobuf.TestProtos; +using NUnit.Framework; +using UnitTest.Issues.TestProtos; + +namespace Google.Protobuf.Reflection +{ + /// + /// Tests for descriptors. (Not in its own namespace or broken up into individual classes as the + /// size doesn't warrant it. On the other hand, this makes me feel a bit dirty...) + /// + public class DescriptorsTest + { + [Test] + public void FileDescriptor() + { + FileDescriptor file = UnittestProto3Reflection.Descriptor; + + Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Name); + Assert.AreEqual("protobuf_unittest", file.Package); + + Assert.AreEqual("UnittestProto", file.Proto.Options.JavaOuterClassname); + Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Proto.Name); + + // unittest.proto doesn't have any public imports, but unittest_import.proto does. + Assert.AreEqual(0, file.PublicDependencies.Count); + Assert.AreEqual(1, UnittestImportProto3Reflection.Descriptor.PublicDependencies.Count); + Assert.AreEqual(UnittestImportPublicProto3Reflection.Descriptor, UnittestImportProto3Reflection.Descriptor.PublicDependencies[0]); + + Assert.AreEqual(1, file.Dependencies.Count); + Assert.AreEqual(UnittestImportProto3Reflection.Descriptor, file.Dependencies[0]); + + MessageDescriptor messageType = TestAllTypes.Descriptor; + Assert.AreSame(typeof(TestAllTypes), messageType.ClrType); + Assert.AreSame(TestAllTypes.Parser, messageType.Parser); + Assert.AreEqual(messageType, file.MessageTypes[0]); + Assert.AreEqual(messageType, file.FindTypeByName("TestAllTypes")); + Assert.Null(file.FindTypeByName("NoSuchType")); + Assert.Null(file.FindTypeByName("protobuf_unittest.TestAllTypes")); + for (int i = 0; i < file.MessageTypes.Count; i++) + { + Assert.AreEqual(i, file.MessageTypes[i].Index); + } + + Assert.AreEqual(file.EnumTypes[0], file.FindTypeByName("ForeignEnum")); + Assert.Null(file.FindTypeByName("NoSuchType")); + Assert.Null(file.FindTypeByName("protobuf_unittest.ForeignEnum")); + Assert.AreEqual(1, UnittestImportProto3Reflection.Descriptor.EnumTypes.Count); + Assert.AreEqual("ImportEnum", UnittestImportProto3Reflection.Descriptor.EnumTypes[0].Name); + for (int i = 0; i < file.EnumTypes.Count; i++) + { + Assert.AreEqual(i, file.EnumTypes[i].Index); + } + + Assert.AreEqual(10, file.SerializedData[0]); + } + + [Test] + public void MessageDescriptor() + { + MessageDescriptor messageType = TestAllTypes.Descriptor; + MessageDescriptor nestedType = TestAllTypes.Types.NestedMessage.Descriptor; + + Assert.AreEqual("TestAllTypes", messageType.Name); + Assert.AreEqual("protobuf_unittest.TestAllTypes", messageType.FullName); + Assert.AreEqual(UnittestProto3Reflection.Descriptor, messageType.File); + Assert.IsNull(messageType.ContainingType); + Assert.IsNull(messageType.Proto.Options); + + Assert.AreEqual("TestAllTypes", messageType.Name); + + Assert.AreEqual("NestedMessage", nestedType.Name); + Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedMessage", nestedType.FullName); + Assert.AreEqual(UnittestProto3Reflection.Descriptor, nestedType.File); + Assert.AreEqual(messageType, nestedType.ContainingType); + + FieldDescriptor field = messageType.Fields.InDeclarationOrder()[0]; + Assert.AreEqual("single_int32", field.Name); + Assert.AreEqual(field, messageType.FindDescriptor("single_int32")); + Assert.Null(messageType.FindDescriptor("no_such_field")); + Assert.AreEqual(field, messageType.FindFieldByNumber(1)); + Assert.Null(messageType.FindFieldByNumber(571283)); + var fieldsInDeclarationOrder = messageType.Fields.InDeclarationOrder(); + for (int i = 0; i < fieldsInDeclarationOrder.Count; i++) + { + Assert.AreEqual(i, fieldsInDeclarationOrder[i].Index); + } + + Assert.AreEqual(nestedType, messageType.NestedTypes[0]); + Assert.AreEqual(nestedType, messageType.FindDescriptor("NestedMessage")); + Assert.Null(messageType.FindDescriptor("NoSuchType")); + for (int i = 0; i < messageType.NestedTypes.Count; i++) + { + Assert.AreEqual(i, messageType.NestedTypes[i].Index); + } + + Assert.AreEqual(messageType.EnumTypes[0], messageType.FindDescriptor("NestedEnum")); + Assert.Null(messageType.FindDescriptor("NoSuchType")); + for (int i = 0; i < messageType.EnumTypes.Count; i++) + { + Assert.AreEqual(i, messageType.EnumTypes[i].Index); + } + } + + [Test] + public void FieldDescriptor() + { + MessageDescriptor messageType = TestAllTypes.Descriptor; + FieldDescriptor primitiveField = messageType.FindDescriptor("single_int32"); + FieldDescriptor enumField = messageType.FindDescriptor("single_nested_enum"); + FieldDescriptor messageField = messageType.FindDescriptor("single_foreign_message"); + + Assert.AreEqual("single_int32", primitiveField.Name); + Assert.AreEqual("protobuf_unittest.TestAllTypes.single_int32", + primitiveField.FullName); + Assert.AreEqual(1, primitiveField.FieldNumber); + Assert.AreEqual(messageType, primitiveField.ContainingType); + Assert.AreEqual(UnittestProto3Reflection.Descriptor, primitiveField.File); + Assert.AreEqual(FieldType.Int32, primitiveField.FieldType); + Assert.IsNull(primitiveField.Proto.Options); + + Assert.AreEqual("single_nested_enum", enumField.Name); + Assert.AreEqual(FieldType.Enum, enumField.FieldType); + // Assert.AreEqual(TestAllTypes.Types.NestedEnum.DescriptorProtoFile, enumField.EnumType); + + Assert.AreEqual("single_foreign_message", messageField.Name); + Assert.AreEqual(FieldType.Message, messageField.FieldType); + Assert.AreEqual(ForeignMessage.Descriptor, messageField.MessageType); + } + + [Test] + public void FieldDescriptorLabel() + { + FieldDescriptor singleField = + TestAllTypes.Descriptor.FindDescriptor("single_int32"); + FieldDescriptor repeatedField = + TestAllTypes.Descriptor.FindDescriptor("repeated_int32"); + + Assert.IsFalse(singleField.IsRepeated); + Assert.IsTrue(repeatedField.IsRepeated); + } + + [Test] + public void EnumDescriptor() + { + // Note: this test is a bit different to the Java version because there's no static way of getting to the descriptor + EnumDescriptor enumType = UnittestProto3Reflection.Descriptor.FindTypeByName("ForeignEnum"); + EnumDescriptor nestedType = TestAllTypes.Descriptor.FindDescriptor("NestedEnum"); + + Assert.AreEqual("ForeignEnum", enumType.Name); + Assert.AreEqual("protobuf_unittest.ForeignEnum", enumType.FullName); + Assert.AreEqual(UnittestProto3Reflection.Descriptor, enumType.File); + Assert.Null(enumType.ContainingType); + Assert.Null(enumType.Proto.Options); + + Assert.AreEqual("NestedEnum", nestedType.Name); + Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedEnum", + nestedType.FullName); + Assert.AreEqual(UnittestProto3Reflection.Descriptor, nestedType.File); + Assert.AreEqual(TestAllTypes.Descriptor, nestedType.ContainingType); + + EnumValueDescriptor value = enumType.FindValueByName("FOREIGN_FOO"); + Assert.AreEqual(value, enumType.Values[1]); + Assert.AreEqual("FOREIGN_FOO", value.Name); + Assert.AreEqual(4, value.Number); + Assert.AreEqual((int) ForeignEnum.ForeignFoo, value.Number); + Assert.AreEqual(value, enumType.FindValueByNumber(4)); + Assert.Null(enumType.FindValueByName("NO_SUCH_VALUE")); + for (int i = 0; i < enumType.Values.Count; i++) + { + Assert.AreEqual(i, enumType.Values[i].Index); + } + } + + [Test] + public void OneofDescriptor() + { + OneofDescriptor descriptor = TestAllTypes.Descriptor.FindDescriptor("oneof_field"); + Assert.AreEqual("oneof_field", descriptor.Name); + Assert.AreEqual("protobuf_unittest.TestAllTypes.oneof_field", descriptor.FullName); + + var expectedFields = new[] { + TestAllTypes.OneofBytesFieldNumber, + TestAllTypes.OneofNestedMessageFieldNumber, + TestAllTypes.OneofStringFieldNumber, + TestAllTypes.OneofUint32FieldNumber } + .Select(fieldNumber => TestAllTypes.Descriptor.FindFieldByNumber(fieldNumber)) + .ToList(); + foreach (var field in expectedFields) + { + Assert.AreSame(descriptor, field.ContainingOneof); + } + + CollectionAssert.AreEquivalent(expectedFields, descriptor.Fields); + } + + [Test] + public void MapEntryMessageDescriptor() + { + var descriptor = MapWellKnownTypes.Descriptor.NestedTypes[0]; + Assert.IsNull(descriptor.Parser); + Assert.IsNull(descriptor.ClrType); + Assert.IsNull(descriptor.Fields[1].Accessor); + } + + // From TestFieldOrdering: + // string my_string = 11; + // int64 my_int = 1; + // float my_float = 101; + // NestedMessage single_nested_message = 200; + [Test] + public void FieldListOrderings() + { + var fields = TestFieldOrderings.Descriptor.Fields; + Assert.AreEqual(new[] { 11, 1, 101, 200 }, fields.InDeclarationOrder().Select(x => x.FieldNumber)); + Assert.AreEqual(new[] { 1, 11, 101, 200 }, fields.InFieldNumberOrder().Select(x => x.FieldNumber)); + } + + + [Test] + public void DescriptorProtoFileDescriptor() + { + var descriptor = Google.Protobuf.Reflection.FileDescriptor.DescriptorProtoFileDescriptor; + Assert.AreEqual("google/protobuf/descriptor.proto", descriptor.Name); + } + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs new file mode 100644 index 000000000000..46cb1afcd5fd --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs @@ -0,0 +1,218 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using Google.Protobuf.TestProtos; +using NUnit.Framework; +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Google.Protobuf.Reflection +{ + public class FieldAccessTest + { + [Test] + public void GetValue() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var fields = TestAllTypes.Descriptor.Fields; + Assert.AreEqual(message.SingleBool, fields[TestAllTypes.SingleBoolFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleBytes, fields[TestAllTypes.SingleBytesFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleDouble, fields[TestAllTypes.SingleDoubleFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleFixed32, fields[TestAllTypes.SingleFixed32FieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleFixed64, fields[TestAllTypes.SingleFixed64FieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleFloat, fields[TestAllTypes.SingleFloatFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleForeignEnum, fields[TestAllTypes.SingleForeignEnumFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleForeignMessage, fields[TestAllTypes.SingleForeignMessageFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleImportEnum, fields[TestAllTypes.SingleImportEnumFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleImportMessage, fields[TestAllTypes.SingleImportMessageFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleInt32, fields[TestAllTypes.SingleInt32FieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleInt64, fields[TestAllTypes.SingleInt64FieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleNestedEnum, fields[TestAllTypes.SingleNestedEnumFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleNestedMessage, fields[TestAllTypes.SingleNestedMessageFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SinglePublicImportMessage, fields[TestAllTypes.SinglePublicImportMessageFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleSint32, fields[TestAllTypes.SingleSint32FieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleSint64, fields[TestAllTypes.SingleSint64FieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleString, fields[TestAllTypes.SingleStringFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleSfixed32, fields[TestAllTypes.SingleSfixed32FieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleSfixed64, fields[TestAllTypes.SingleSfixed64FieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleUint32, fields[TestAllTypes.SingleUint32FieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.SingleUint64, fields[TestAllTypes.SingleUint64FieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.OneofBytes, fields[TestAllTypes.OneofBytesFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.OneofString, fields[TestAllTypes.OneofStringFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.OneofNestedMessage, fields[TestAllTypes.OneofNestedMessageFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(message.OneofUint32, fields[TestAllTypes.OneofUint32FieldNumber].Accessor.GetValue(message)); + + // Just one example for repeated fields - they're all just returning the list + var list = (IList) fields[TestAllTypes.RepeatedInt32FieldNumber].Accessor.GetValue(message); + Assert.AreEqual(message.RepeatedInt32, list); + Assert.AreEqual(message.RepeatedInt32[0], list[0]); // Just in case there was any doubt... + + // Just a single map field, for the same reason + var mapMessage = new TestMap { MapStringString = { { "key1", "value1" }, { "key2", "value2" } } }; + fields = TestMap.Descriptor.Fields; + var dictionary = (IDictionary) fields[TestMap.MapStringStringFieldNumber].Accessor.GetValue(mapMessage); + Assert.AreEqual(mapMessage.MapStringString, dictionary); + Assert.AreEqual("value1", dictionary["key1"]); + } + + [Test] + public void Clear() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var fields = TestAllTypes.Descriptor.Fields; + fields[TestAllTypes.SingleBoolFieldNumber].Accessor.Clear(message); + fields[TestAllTypes.SingleInt32FieldNumber].Accessor.Clear(message); + fields[TestAllTypes.SingleStringFieldNumber].Accessor.Clear(message); + fields[TestAllTypes.SingleBytesFieldNumber].Accessor.Clear(message); + fields[TestAllTypes.SingleForeignEnumFieldNumber].Accessor.Clear(message); + fields[TestAllTypes.SingleForeignMessageFieldNumber].Accessor.Clear(message); + fields[TestAllTypes.RepeatedDoubleFieldNumber].Accessor.Clear(message); + + var expected = new TestAllTypes(SampleMessages.CreateFullTestAllTypes()) + { + SingleBool = false, + SingleInt32 = 0, + SingleString = "", + SingleBytes = ByteString.Empty, + SingleForeignEnum = 0, + SingleForeignMessage = null, + }; + expected.RepeatedDouble.Clear(); + + Assert.AreEqual(expected, message); + + // Separately, maps. + var mapMessage = new TestMap { MapStringString = { { "key1", "value1" }, { "key2", "value2" } } }; + fields = TestMap.Descriptor.Fields; + fields[TestMap.MapStringStringFieldNumber].Accessor.Clear(mapMessage); + Assert.AreEqual(0, mapMessage.MapStringString.Count); + } + + [Test] + public void SetValue_SingleFields() + { + // Just a sample (primitives, messages, enums, strings, byte strings) + var message = SampleMessages.CreateFullTestAllTypes(); + var fields = TestAllTypes.Descriptor.Fields; + fields[TestAllTypes.SingleBoolFieldNumber].Accessor.SetValue(message, false); + fields[TestAllTypes.SingleInt32FieldNumber].Accessor.SetValue(message, 500); + fields[TestAllTypes.SingleStringFieldNumber].Accessor.SetValue(message, "It's a string"); + fields[TestAllTypes.SingleBytesFieldNumber].Accessor.SetValue(message, ByteString.CopyFrom(99, 98, 97)); + fields[TestAllTypes.SingleForeignEnumFieldNumber].Accessor.SetValue(message, ForeignEnum.ForeignFoo); + fields[TestAllTypes.SingleForeignMessageFieldNumber].Accessor.SetValue(message, new ForeignMessage { C = 12345 }); + fields[TestAllTypes.SingleDoubleFieldNumber].Accessor.SetValue(message, 20150701.5); + + var expected = new TestAllTypes(SampleMessages.CreateFullTestAllTypes()) + { + SingleBool = false, + SingleInt32 = 500, + SingleString = "It's a string", + SingleBytes = ByteString.CopyFrom(99, 98, 97), + SingleForeignEnum = ForeignEnum.ForeignFoo, + SingleForeignMessage = new ForeignMessage { C = 12345 }, + SingleDouble = 20150701.5 + }; + + Assert.AreEqual(expected, message); + } + + [Test] + public void SetValue_SingleFields_WrongType() + { + IMessage message = SampleMessages.CreateFullTestAllTypes(); + var fields = message.Descriptor.Fields; + Assert.Throws(() => fields[TestAllTypes.SingleBoolFieldNumber].Accessor.SetValue(message, "This isn't a bool")); + } + + [Test] + public void SetValue_MapFields() + { + IMessage message = new TestMap(); + var fields = message.Descriptor.Fields; + Assert.Throws(() => fields[TestMap.MapStringStringFieldNumber].Accessor.SetValue(message, new Dictionary())); + } + + [Test] + public void SetValue_RepeatedFields() + { + IMessage message = SampleMessages.CreateFullTestAllTypes(); + var fields = message.Descriptor.Fields; + Assert.Throws(() => fields[TestAllTypes.RepeatedDoubleFieldNumber].Accessor.SetValue(message, new double[10])); + } + + [Test] + public void GetValue_IncorrectType() + { + IMessage message = SampleMessages.CreateFullTestAllTypes(); + var fields = message.Descriptor.Fields; + Assert.Throws(() => fields[TestAllTypes.SingleBoolFieldNumber].Accessor.GetValue(new TestMap())); + } + + [Test] + public void Oneof() + { + var message = new TestAllTypes(); + var descriptor = TestAllTypes.Descriptor; + Assert.AreEqual(1, descriptor.Oneofs.Count); + var oneof = descriptor.Oneofs[0]; + Assert.AreEqual("oneof_field", oneof.Name); + Assert.IsNull(oneof.Accessor.GetCaseFieldDescriptor(message)); + + message.OneofString = "foo"; + Assert.AreSame(descriptor.Fields[TestAllTypes.OneofStringFieldNumber], oneof.Accessor.GetCaseFieldDescriptor(message)); + + message.OneofUint32 = 10; + Assert.AreSame(descriptor.Fields[TestAllTypes.OneofUint32FieldNumber], oneof.Accessor.GetCaseFieldDescriptor(message)); + + oneof.Accessor.Clear(message); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); + } + + [Test] + public void FieldDescriptor_ByName() + { + var descriptor = TestAllTypes.Descriptor; + Assert.AreSame( + descriptor.Fields[TestAllTypes.SingleBoolFieldNumber], + descriptor.Fields["single_bool"]); + } + + [Test] + public void FieldDescriptor_NotFound() + { + var descriptor = TestAllTypes.Descriptor; + Assert.Throws(() => descriptor.Fields[999999].ToString()); + Assert.Throws(() => descriptor.Fields["not found"].ToString()); + } + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/TypeRegistryTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/TypeRegistryTest.cs new file mode 100644 index 000000000000..5be7ca236117 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/TypeRegistryTest.cs @@ -0,0 +1,94 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using Google.Protobuf.TestProtos; +using Google.Protobuf.WellKnownTypes; +using NUnit.Framework; + +namespace Google.Protobuf.Reflection +{ + public class TypeRegistryTest + { + // Most of our tests use messages. Simple test that we really can use files... + [Test] + public void CreateWithFileDescriptor() + { + var registry = TypeRegistry.FromFiles(DurationReflection.Descriptor, StructReflection.Descriptor); + AssertDescriptorPresent(registry, Duration.Descriptor); + AssertDescriptorPresent(registry, ListValue.Descriptor); + AssertDescriptorAbsent(registry, Timestamp.Descriptor); + } + + [Test] + public void TypesFromSameFile() + { + // Just for kicks, let's start with a nested type + var registry = TypeRegistry.FromMessages(TestAllTypes.Types.NestedMessage.Descriptor); + // Top-level... + AssertDescriptorPresent(registry, TestFieldOrderings.Descriptor); + // ... and nested (not the same as the original NestedMessage!) + AssertDescriptorPresent(registry, TestFieldOrderings.Types.NestedMessage.Descriptor); + } + + [Test] + public void DependenciesAreIncluded() + { + var registry = TypeRegistry.FromMessages(TestAllTypes.Descriptor); + // Direct dependencies + AssertDescriptorPresent(registry, ImportMessage.Descriptor); + // Public dependencies + AssertDescriptorPresent(registry, PublicImportMessage.Descriptor); + } + + [Test] + public void DuplicateFiles() + { + // Duplicates via dependencies and simply via repetition + var registry = TypeRegistry.FromFiles( + UnittestProto3Reflection.Descriptor, UnittestImportProto3Reflection.Descriptor, + TimestampReflection.Descriptor, TimestampReflection.Descriptor); + AssertDescriptorPresent(registry, TestAllTypes.Descriptor); + AssertDescriptorPresent(registry, ImportMessage.Descriptor); + AssertDescriptorPresent(registry, Timestamp.Descriptor); + } + + private static void AssertDescriptorPresent(TypeRegistry registry, MessageDescriptor descriptor) + { + Assert.AreSame(descriptor, registry.Find(descriptor.FullName)); + } + + private static void AssertDescriptorAbsent(TypeRegistry registry, MessageDescriptor descriptor) + { + Assert.IsNull(registry.Find(descriptor.FullName)); + } + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/SampleEnum.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/SampleEnum.cs new file mode 100644 index 000000000000..44f232a53ef6 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/SampleEnum.cs @@ -0,0 +1,42 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +namespace Google.Protobuf +{ + // Just a sample enum with positive and negative values to be used in tests. + internal enum SampleEnum + { + NegativeValue = -2, + None = 0, + PositiveValue = 3 + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/SampleMessages.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/SampleMessages.cs new file mode 100644 index 000000000000..ffa4e2a7c27d --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/SampleMessages.cs @@ -0,0 +1,99 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using Google.Protobuf.TestProtos; + +namespace Google.Protobuf +{ + /// + /// Helper methods to create sample instances of types generated from unit test messages. + /// + public class SampleMessages + { + /// + /// Creates a new sample TestAllTypes message with all fields populated. + /// The "oneof" field is populated with the string property (OneofString). + /// + public static TestAllTypes CreateFullTestAllTypes() + { + return new TestAllTypes + { + SingleBool = true, + SingleBytes = ByteString.CopyFrom(1, 2, 3, 4), + SingleDouble = 23.5, + SingleFixed32 = 23, + SingleFixed64 = 1234567890123, + SingleFloat = 12.25f, + SingleForeignEnum = ForeignEnum.ForeignBar, + SingleForeignMessage = new ForeignMessage { C = 10 }, + SingleImportEnum = ImportEnum.ImportBaz, + SingleImportMessage = new ImportMessage { D = 20 }, + SingleInt32 = 100, + SingleInt64 = 3210987654321, + SingleNestedEnum = TestAllTypes.Types.NestedEnum.Foo, + SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 }, + SinglePublicImportMessage = new PublicImportMessage { E = 54 }, + SingleSfixed32 = -123, + SingleSfixed64 = -12345678901234, + SingleSint32 = -456, + SingleSint64 = -12345678901235, + SingleString = "test", + SingleUint32 = UInt32.MaxValue, + SingleUint64 = UInt64.MaxValue, + RepeatedBool = { true, false }, + RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6), ByteString.CopyFrom(new byte[1000]) }, + RepeatedDouble = { -12.25, 23.5 }, + RepeatedFixed32 = { UInt32.MaxValue, 23 }, + RepeatedFixed64 = { UInt64.MaxValue, 1234567890123 }, + RepeatedFloat = { 100f, 12.25f }, + RepeatedForeignEnum = { ForeignEnum.ForeignFoo, ForeignEnum.ForeignBar }, + RepeatedForeignMessage = { new ForeignMessage(), new ForeignMessage { C = 10 } }, + RepeatedImportEnum = { ImportEnum.ImportBaz, ImportEnum.Unspecified }, + RepeatedImportMessage = { new ImportMessage { D = 20 }, new ImportMessage { D = 25 } }, + RepeatedInt32 = { 100, 200 }, + RepeatedInt64 = { 3210987654321, Int64.MaxValue }, + RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.Foo, TestAllTypes.Types.NestedEnum.Neg }, + RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 35 }, new TestAllTypes.Types.NestedMessage { Bb = 10 } }, + RepeatedPublicImportMessage = { new PublicImportMessage { E = 54 }, new PublicImportMessage { E = -1 } }, + RepeatedSfixed32 = { -123, 123 }, + RepeatedSfixed64 = { -12345678901234, 12345678901234 }, + RepeatedSint32 = { -456, 100 }, + RepeatedSint64 = { -12345678901235, 123 }, + RepeatedString = { "foo", "bar" }, + RepeatedUint32 = { UInt32.MaxValue, UInt32.MinValue }, + RepeatedUint64 = { UInt64.MaxValue, UInt32.MinValue }, + OneofString = "Oneof string" + }; + } + } +} \ No newline at end of file diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/TestCornerCases.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/TestCornerCases.cs new file mode 100644 index 000000000000..248f5fa913f2 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/TestCornerCases.cs @@ -0,0 +1,62 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using UnitTest.Issues.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class TestCornerCases + { + [Test] + public void TestRoundTripNegativeEnums() + { + NegativeEnumMessage msg = new NegativeEnumMessage + { + Value = NegativeEnum.MinusOne, + Values = { NegativeEnum.Zero, NegativeEnum.MinusOne, NegativeEnum.FiveBelow }, + PackedValues = { NegativeEnum.Zero, NegativeEnum.MinusOne, NegativeEnum.FiveBelow } + }; + + Assert.AreEqual(58, msg.CalculateSize()); + + byte[] bytes = new byte[58]; + CodedOutputStream output = new CodedOutputStream(bytes); + + msg.WriteTo(output); + Assert.AreEqual(0, output.SpaceLeft); + + NegativeEnumMessage copy = NegativeEnumMessage.Parser.ParseFrom(bytes); + Assert.AreEqual(msg, copy); + } + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/TestProtos/ForeignMessagePartial.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/TestProtos/ForeignMessagePartial.cs new file mode 100644 index 000000000000..5663a69902e5 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/TestProtos/ForeignMessagePartial.cs @@ -0,0 +1,45 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2016 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +namespace Google.Protobuf.TestProtos +{ + /// + /// A message with custom diagnostics (to test that they work). + /// + public partial class ForeignMessage : ICustomDiagnosticMessage + { + public string ToDiagnosticString() + { + return $"{{ \"c\": {C}, \"@cInHex\": \"{C:x}\" }}"; + } + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs new file mode 100644 index 000000000000..4aecc998deba --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs @@ -0,0 +1,116 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf.WellKnownTypes +{ + public class AnyTest + { + [Test] + public void Pack() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var any = Any.Pack(message); + Assert.AreEqual("type.googleapis.com/protobuf_unittest.TestAllTypes", any.TypeUrl); + Assert.AreEqual(message.CalculateSize(), any.Value.Length); + } + + [Test] + public void Pack_WithCustomPrefix() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var any = Any.Pack(message, "foo.bar/baz"); + Assert.AreEqual("foo.bar/baz/protobuf_unittest.TestAllTypes", any.TypeUrl); + Assert.AreEqual(message.CalculateSize(), any.Value.Length); + } + + [Test] + public void Pack_WithCustomPrefixTrailingSlash() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var any = Any.Pack(message, "foo.bar/baz/"); + Assert.AreEqual("foo.bar/baz/protobuf_unittest.TestAllTypes", any.TypeUrl); + Assert.AreEqual(message.CalculateSize(), any.Value.Length); + } + + [Test] + public void Unpack_WrongType() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var any = Any.Pack(message); + Assert.Throws(() => any.Unpack()); + } + + [Test] + public void Unpack_Success() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var any = Any.Pack(message); + var unpacked = any.Unpack(); + Assert.AreEqual(message, unpacked); + } + + [Test] + public void Unpack_CustomPrefix_Success() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var any = Any.Pack(message, "foo.bar/baz"); + var unpacked = any.Unpack(); + Assert.AreEqual(message, unpacked); + } + + [Test] + public void ToString_WithValues() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var any = Any.Pack(message); + var text = any.ToString(); + Assert.That(text, Does.Contain("\"@value\": \"" + message.ToByteString().ToBase64() + "\"")); + } + + [Test] + public void ToString_Empty() + { + var any = new Any(); + Assert.AreEqual("{ \"@type\": \"\", \"@value\": \"\" }", any.ToString()); + } + + [Test] + public void ToString_MessageContainingAny() + { + var message = new TestWellKnownTypes { AnyField = new Any() }; + Assert.AreEqual("{ \"anyField\": { \"@type\": \"\", \"@value\": \"\" } }", message.ToString()); + } + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs new file mode 100644 index 000000000000..141faf80e096 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs @@ -0,0 +1,132 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using NUnit.Framework; +using System; + +namespace Google.Protobuf.WellKnownTypes +{ + public class DurationTest + { + [Test] + public void ToTimeSpan() + { + Assert.AreEqual(TimeSpan.FromSeconds(1), new Duration { Seconds = 1 }.ToTimeSpan()); + Assert.AreEqual(TimeSpan.FromSeconds(-1), new Duration { Seconds = -1 }.ToTimeSpan()); + Assert.AreEqual(TimeSpan.FromMilliseconds(1), new Duration { Nanos = 1000000 }.ToTimeSpan()); + Assert.AreEqual(TimeSpan.FromMilliseconds(-1), new Duration { Nanos = -1000000 }.ToTimeSpan()); + Assert.AreEqual(TimeSpan.FromTicks(1), new Duration { Nanos = 100 }.ToTimeSpan()); + Assert.AreEqual(TimeSpan.FromTicks(-1), new Duration { Nanos = -100 }.ToTimeSpan()); + + // Rounding is towards 0 + Assert.AreEqual(TimeSpan.FromTicks(2), new Duration { Nanos = 250 }.ToTimeSpan()); + Assert.AreEqual(TimeSpan.FromTicks(-2), new Duration { Nanos = -250 }.ToTimeSpan()); + } + + [Test] + public void Addition() + { + Assert.AreEqual(new Duration { Seconds = 2, Nanos = 100000000 }, + new Duration { Seconds = 1, Nanos = 600000000 } + new Duration { Nanos = 500000000 }); + Assert.AreEqual(new Duration { Seconds = -2, Nanos = -100000000 }, + new Duration { Seconds = -1, Nanos = -600000000 } + new Duration { Nanos = -500000000 }); + Assert.AreEqual(new Duration { Seconds = 1, Nanos = 100000000 }, + new Duration { Seconds = 1, Nanos = 600000000 } + new Duration { Nanos = -500000000 }); + + // Non-normalized durations, or non-normalized intermediate results + Assert.AreEqual(new Duration { Seconds = 1 }, + new Duration { Seconds = 1, Nanos = -500000000 } + new Duration { Nanos = 500000000 }); + + Assert.AreEqual(new Duration { Nanos = -900000000 }, + new Duration { Seconds = -1, Nanos = -100000000 } + new Duration { Nanos = 200000000 }); + Assert.AreEqual(new Duration { Nanos = 900000000 }, + new Duration { Seconds = 1, Nanos = 100000000 } + new Duration { Nanos = -200000000 }); + } + + [Test] + public void Subtraction() + { + Assert.AreEqual(new Duration { Seconds = 1, Nanos = 100000000 }, + new Duration { Seconds = 1, Nanos = 600000000 } - new Duration { Nanos = 500000000 }); + Assert.AreEqual(new Duration { Seconds = -1, Nanos = -100000000 }, + new Duration { Seconds = -1, Nanos = -600000000 } - new Duration { Nanos = -500000000 }); + Assert.AreEqual(new Duration { Seconds = 2, Nanos = 100000000 }, + new Duration { Seconds = 1, Nanos = 600000000 } - new Duration { Nanos = -500000000 }); + + // Non-normalized durations + Assert.AreEqual(new Duration(), + new Duration { Seconds = 1, Nanos = -500000000 } - new Duration { Nanos = 500000000 }); + Assert.AreEqual(new Duration { Seconds = 1 }, + new Duration { Nanos = 2000000000 } - new Duration { Nanos = 1000000000 }); + } + + [Test] + public void FromTimeSpan() + { + Assert.AreEqual(new Duration { Seconds = 1 }, Duration.FromTimeSpan(TimeSpan.FromSeconds(1))); + Assert.AreEqual(new Duration { Nanos = Duration.NanosecondsPerTick }, Duration.FromTimeSpan(TimeSpan.FromTicks(1))); + } + + [Test] + [TestCase(0, Duration.MaxNanoseconds + 1)] + [TestCase(0, Duration.MinNanoseconds - 1)] + [TestCase(Duration.MinSeconds - 1, 0)] + [TestCase(Duration.MaxSeconds + 1, 0)] + [TestCase(1, -1)] + [TestCase(-1, 1)] + public void ToTimeSpan_Invalid(long seconds, int nanoseconds) + { + var duration = new Duration { Seconds = seconds, Nanos = nanoseconds }; + Assert.Throws(() => duration.ToTimeSpan()); + } + + [Test] + [TestCase(0, Duration.MaxNanoseconds)] + [TestCase(0, Duration.MinNanoseconds)] + [TestCase(Duration.MinSeconds, Duration.MinNanoseconds)] + [TestCase(Duration.MaxSeconds, Duration.MaxNanoseconds)] + public void ToTimeSpan_Valid(long seconds, int nanoseconds) + { + // Only testing that these values don't throw, unlike their similar tests in ToTimeSpan_Invalid + var duration = new Duration { Seconds = seconds, Nanos = nanoseconds }; + duration.ToTimeSpan(); + } + + [Test] + public void ToString_NonNormalized() + { + // Just a single example should be sufficient... + var duration = new Duration { Seconds = 1, Nanos = -1 }; + Assert.AreEqual("{ \"@warning\": \"Invalid Duration\", \"seconds\": \"1\", \"nanos\": -1 }", duration.ToString()); + } + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs new file mode 100644 index 000000000000..1d9908b4d314 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs @@ -0,0 +1,62 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2016 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + + +using NUnit.Framework; + +namespace Google.Protobuf.WellKnownTypes +{ + public class FieldMaskTest + { + [Test] + [TestCase("foo__bar")] + [TestCase("foo_3_ar")] + [TestCase("fooBar")] + public void ToString_Invalid(string input) + { + var mask = new FieldMask { Paths = { input } }; + var text = mask.ToString(); + // More specific test below + Assert.That(text, Does.Contain("@warning")); + Assert.That(text, Does.Contain(input)); + } + + [Test] + public void ToString_Invalid_Precise() + { + var mask = new FieldMask { Paths = { "x", "foo__bar", @"x\y" } }; + Assert.AreEqual( + "{ \"@warning\": \"Invalid FieldMask\", \"paths\": [ \"x\", \"foo__bar\", \"x\\\\y\" ] }", + mask.ToString()); + } + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs new file mode 100644 index 000000000000..548c585a1c98 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs @@ -0,0 +1,115 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using NUnit.Framework; +using System; + +namespace Google.Protobuf.WellKnownTypes +{ + public class TimestampTest + { + [Test] + public void FromAndToDateTime() + { + DateTime utcMin = DateTime.SpecifyKind(DateTime.MinValue, DateTimeKind.Utc); + DateTime utcMax = DateTime.SpecifyKind(DateTime.MaxValue, DateTimeKind.Utc); + AssertRoundtrip(new Timestamp { Seconds = -62135596800 }, utcMin); + AssertRoundtrip(new Timestamp { Seconds = 253402300799, Nanos = 999999900 }, utcMax); + AssertRoundtrip(new Timestamp(), new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)); + AssertRoundtrip(new Timestamp { Nanos = 1000000}, new DateTime(1970, 1, 1, 0, 0, 0, 1, DateTimeKind.Utc)); + AssertRoundtrip(new Timestamp { Seconds = -1, Nanos = 999000000 }, new DateTime(1969, 12, 31, 23, 59, 59, 999, DateTimeKind.Utc)); + AssertRoundtrip(new Timestamp { Seconds = 3600 }, new DateTime(1970, 1, 1, 1, 0, 0, DateTimeKind.Utc)); + AssertRoundtrip(new Timestamp { Seconds = -3600 }, new DateTime(1969, 12, 31, 23, 0, 0, DateTimeKind.Utc)); + } + + [Test] + public void ToDateTimeTruncation() + { + var t1 = new Timestamp { Seconds = 1, Nanos = 1000000 + Duration.NanosecondsPerTick - 1 }; + Assert.AreEqual(new DateTime(1970, 1, 1, 0, 0, 1, DateTimeKind.Utc).AddMilliseconds(1), t1.ToDateTime()); + + var t2 = new Timestamp { Seconds = -1, Nanos = 1000000 + Duration.NanosecondsPerTick - 1 }; + Assert.AreEqual(new DateTime(1969, 12, 31, 23, 59, 59).AddMilliseconds(1), t2.ToDateTime()); + } + + [Test] + [TestCase(Timestamp.UnixSecondsAtBclMinValue - 1, Timestamp.MaxNanos)] + [TestCase(Timestamp.UnixSecondsAtBclMaxValue + 1, 0)] + [TestCase(0, -1)] + [TestCase(0, Timestamp.MaxNanos + 1)] + public void ToDateTime_OutOfRange(long seconds, int nanoseconds) + { + var value = new Timestamp { Seconds = seconds, Nanos = nanoseconds }; + Assert.Throws(() => value.ToDateTime()); + } + + // 1ns larger or smaller than the above values + [Test] + [TestCase(Timestamp.UnixSecondsAtBclMinValue, 0)] + [TestCase(Timestamp.UnixSecondsAtBclMaxValue, Timestamp.MaxNanos)] + [TestCase(0, 0)] + [TestCase(0, Timestamp.MaxNanos)] + public void ToDateTime_ValidBoundaries(long seconds, int nanoseconds) + { + var value = new Timestamp { Seconds = seconds, Nanos = nanoseconds }; + value.ToDateTime(); + } + + private static void AssertRoundtrip(Timestamp timestamp, DateTime dateTime) + { + Assert.AreEqual(timestamp, Timestamp.FromDateTime(dateTime)); + Assert.AreEqual(dateTime, timestamp.ToDateTime()); + Assert.AreEqual(DateTimeKind.Utc, timestamp.ToDateTime().Kind); + } + + [Test] + public void Arithmetic() + { + Timestamp t1 = new Timestamp { Seconds = 10000, Nanos = 5000 }; + Timestamp t2 = new Timestamp { Seconds = 8000, Nanos = 10000 }; + Duration difference = new Duration { Seconds = 1999, Nanos = Duration.NanosecondsPerSecond - 5000 }; + Assert.AreEqual(difference, t1 - t2); + Assert.AreEqual(-difference, t2 - t1); + + Assert.AreEqual(t1, t2 + difference); + Assert.AreEqual(t2, t1 - difference); + } + + [Test] + public void ToString_NonNormalized() + { + // Just a single example should be sufficient... + var duration = new Timestamp { Seconds = 1, Nanos = -1 }; + Assert.AreEqual("{ \"@warning\": \"Invalid Timestamp\", \"seconds\": \"1\", \"nanos\": -1 }", duration.ToString()); + } + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs new file mode 100644 index 000000000000..0df4ac4c7935 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs @@ -0,0 +1,421 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using Google.Protobuf.TestProtos; +using NUnit.Framework; +using System.Collections; +using System.IO; + +namespace Google.Protobuf.WellKnownTypes +{ + public class WrappersTest + { + [Test] + public void NullIsDefault() + { + var message = new TestWellKnownTypes(); + Assert.IsNull(message.StringField); + Assert.IsNull(message.BytesField); + Assert.IsNull(message.BoolField); + Assert.IsNull(message.FloatField); + Assert.IsNull(message.DoubleField); + Assert.IsNull(message.Int32Field); + Assert.IsNull(message.Int64Field); + Assert.IsNull(message.Uint32Field); + Assert.IsNull(message.Uint64Field); + } + + [Test] + public void NonDefaultSingleValues() + { + var message = new TestWellKnownTypes + { + StringField = "x", + BytesField = ByteString.CopyFrom(1, 2, 3), + BoolField = true, + FloatField = 12.5f, + DoubleField = 12.25d, + Int32Field = 1, + Int64Field = 2, + Uint32Field = 3, + Uint64Field = 4 + }; + + var bytes = message.ToByteArray(); + var parsed = TestWellKnownTypes.Parser.ParseFrom(bytes); + + Assert.AreEqual("x", parsed.StringField); + Assert.AreEqual(ByteString.CopyFrom(1, 2, 3), parsed.BytesField); + Assert.AreEqual(true, parsed.BoolField); + Assert.AreEqual(12.5f, parsed.FloatField); + Assert.AreEqual(12.25d, parsed.DoubleField); + Assert.AreEqual(1, parsed.Int32Field); + Assert.AreEqual(2L, parsed.Int64Field); + Assert.AreEqual(3U, parsed.Uint32Field); + Assert.AreEqual(4UL, parsed.Uint64Field); + } + + [Test] + public void NonNullDefaultIsPreservedThroughSerialization() + { + var message = new TestWellKnownTypes + { + StringField = "", + BytesField = ByteString.Empty, + BoolField = false, + FloatField = 0f, + DoubleField = 0d, + Int32Field = 0, + Int64Field = 0, + Uint32Field = 0, + Uint64Field = 0 + }; + + var bytes = message.ToByteArray(); + var parsed = TestWellKnownTypes.Parser.ParseFrom(bytes); + + Assert.AreEqual("", parsed.StringField); + Assert.AreEqual(ByteString.Empty, parsed.BytesField); + Assert.AreEqual(false, parsed.BoolField); + Assert.AreEqual(0f, parsed.FloatField); + Assert.AreEqual(0d, parsed.DoubleField); + Assert.AreEqual(0, parsed.Int32Field); + Assert.AreEqual(0L, parsed.Int64Field); + Assert.AreEqual(0U, parsed.Uint32Field); + Assert.AreEqual(0UL, parsed.Uint64Field); + } + + [Test] + public void RepeatedWrappersProhibitNullItems() + { + var message = new RepeatedWellKnownTypes(); + Assert.Throws(() => message.BoolField.Add((bool?) null)); + Assert.Throws(() => message.Int32Field.Add((int?) null)); + Assert.Throws(() => message.StringField.Add((string) null)); + Assert.Throws(() => message.BytesField.Add((ByteString) null)); + } + + [Test] + public void RepeatedWrappersSerializeDeserialize() + { + var message = new RepeatedWellKnownTypes + { + BoolField = { true, false }, + BytesField = { ByteString.CopyFrom(1, 2, 3), ByteString.CopyFrom(4, 5, 6), ByteString.Empty }, + DoubleField = { 12.5, -1.5, 0d }, + FloatField = { 123.25f, -20f, 0f }, + Int32Field = { int.MaxValue, int.MinValue, 0 }, + Int64Field = { long.MaxValue, long.MinValue, 0L }, + StringField = { "First", "Second", "" }, + Uint32Field = { uint.MaxValue, uint.MinValue, 0U }, + Uint64Field = { ulong.MaxValue, ulong.MinValue, 0UL }, + }; + var bytes = message.ToByteArray(); + var parsed = RepeatedWellKnownTypes.Parser.ParseFrom(bytes); + + Assert.AreEqual(message, parsed); + // Just to test a single value for sanity... + Assert.AreEqual("Second", message.StringField[1]); + } + + [Test] + public void RepeatedWrappersBinaryFormat() + { + // At one point we accidentally used a packed format for repeated wrappers, which is wrong (and weird). + // This test is just to prove that we use the right format. + + var rawOutput = new MemoryStream(); + var output = new CodedOutputStream(rawOutput); + // Write a value of 5 + output.WriteTag(RepeatedWellKnownTypes.Int32FieldFieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteLength(2); + output.WriteTag(WrappersReflection.WrapperValueFieldNumber, WireFormat.WireType.Varint); + output.WriteInt32(5); + // Write a value of 0 (empty message) + output.WriteTag(RepeatedWellKnownTypes.Int32FieldFieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteLength(0); + output.Flush(); + var expectedBytes = rawOutput.ToArray(); + + var message = new RepeatedWellKnownTypes { Int32Field = { 5, 0 } }; + var actualBytes = message.ToByteArray(); + Assert.AreEqual(expectedBytes, actualBytes); + } + + [Test] + public void MapWrappersSerializeDeserialize() + { + // Note: no null values here, as they are prohibited in map fields + // (despite being representable). + var message = new MapWellKnownTypes + { + BoolField = { { 10, false }, { 20, true } }, + BytesField = { + { -1, ByteString.CopyFrom(1, 2, 3) }, + { 10, ByteString.CopyFrom(4, 5, 6) }, + { 1000, ByteString.Empty }, + }, + DoubleField = { { 1, 12.5 }, { 10, -1.5 }, { 20, 0d } }, + FloatField = { { 2, 123.25f }, { 3, -20f }, { 4, 0f } }, + Int32Field = { { 5, int.MaxValue }, { 6, int.MinValue }, { 7, 0 } }, + Int64Field = { { 8, long.MaxValue }, { 9, long.MinValue }, { 10, 0L } }, + StringField = { { 11, "First" }, { 12, "Second" }, { 13, "" } }, + Uint32Field = { { 15, uint.MaxValue }, { 16, uint.MinValue }, { 17, 0U } }, + Uint64Field = { { 18, ulong.MaxValue }, { 19, ulong.MinValue }, { 20, 0UL } }, + }; + + var bytes = message.ToByteArray(); + var parsed = MapWellKnownTypes.Parser.ParseFrom(bytes); + + Assert.AreEqual(message, parsed); + // Just to test a single value for sanity... + Assert.AreEqual("Second", message.StringField[12]); + } + + [Test] + public void Reflection_SingleValues() + { + var message = new TestWellKnownTypes + { + StringField = "x", + BytesField = ByteString.CopyFrom(1, 2, 3), + BoolField = true, + FloatField = 12.5f, + DoubleField = 12.25d, + Int32Field = 1, + Int64Field = 2, + Uint32Field = 3, + Uint64Field = 4 + }; + var fields = TestWellKnownTypes.Descriptor.Fields; + + Assert.AreEqual("x", fields[TestWellKnownTypes.StringFieldFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(ByteString.CopyFrom(1, 2, 3), fields[TestWellKnownTypes.BytesFieldFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(true, fields[TestWellKnownTypes.BoolFieldFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(12.5f, fields[TestWellKnownTypes.FloatFieldFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(12.25d, fields[TestWellKnownTypes.DoubleFieldFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(1, fields[TestWellKnownTypes.Int32FieldFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(2L, fields[TestWellKnownTypes.Int64FieldFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(3U, fields[TestWellKnownTypes.Uint32FieldFieldNumber].Accessor.GetValue(message)); + Assert.AreEqual(4UL, fields[TestWellKnownTypes.Uint64FieldFieldNumber].Accessor.GetValue(message)); + + // And a couple of null fields... + message.StringField = null; + message.FloatField = null; + Assert.IsNull(fields[TestWellKnownTypes.StringFieldFieldNumber].Accessor.GetValue(message)); + Assert.IsNull(fields[TestWellKnownTypes.FloatFieldFieldNumber].Accessor.GetValue(message)); + } + + [Test] + public void Reflection_RepeatedFields() + { + // Just a single example... note that we can't have a null value here + var message = new RepeatedWellKnownTypes { Int32Field = { 1, 2 } }; + var fields = RepeatedWellKnownTypes.Descriptor.Fields; + var list = (IList) fields[RepeatedWellKnownTypes.Int32FieldFieldNumber].Accessor.GetValue(message); + CollectionAssert.AreEqual(new[] { 1, 2 }, list); + } + + [Test] + public void Reflection_MapFields() + { + // Just a single example... note that we can't have a null value here despite the value type being int? + var message = new MapWellKnownTypes { Int32Field = { { 1, 2 } } }; + var fields = MapWellKnownTypes.Descriptor.Fields; + var dictionary = (IDictionary) fields[MapWellKnownTypes.Int32FieldFieldNumber].Accessor.GetValue(message); + Assert.AreEqual(2, dictionary[1]); + } + + [Test] + public void Oneof() + { + var message = new OneofWellKnownTypes { EmptyField = new Empty() }; + // Start off with a non-wrapper + Assert.AreEqual(OneofWellKnownTypes.OneofFieldOneofCase.EmptyField, message.OneofFieldCase); + AssertOneofRoundTrip(message); + + message.StringField = "foo"; + Assert.AreEqual(OneofWellKnownTypes.OneofFieldOneofCase.StringField, message.OneofFieldCase); + AssertOneofRoundTrip(message); + + message.StringField = "foo"; + Assert.AreEqual(OneofWellKnownTypes.OneofFieldOneofCase.StringField, message.OneofFieldCase); + AssertOneofRoundTrip(message); + + message.DoubleField = 0.0f; + Assert.AreEqual(OneofWellKnownTypes.OneofFieldOneofCase.DoubleField, message.OneofFieldCase); + AssertOneofRoundTrip(message); + + message.DoubleField = 1.0f; + Assert.AreEqual(OneofWellKnownTypes.OneofFieldOneofCase.DoubleField, message.OneofFieldCase); + AssertOneofRoundTrip(message); + + message.ClearOneofField(); + Assert.AreEqual(OneofWellKnownTypes.OneofFieldOneofCase.None, message.OneofFieldCase); + AssertOneofRoundTrip(message); + } + + private void AssertOneofRoundTrip(OneofWellKnownTypes message) + { + // Normal roundtrip, but explicitly checking the case... + var bytes = message.ToByteArray(); + var parsed = OneofWellKnownTypes.Parser.ParseFrom(bytes); + Assert.AreEqual(message, parsed); + Assert.AreEqual(message.OneofFieldCase, parsed.OneofFieldCase); + } + + [Test] + [TestCase("x", "y", "y")] + [TestCase("x", "", "x")] + [TestCase("x", null, "x")] + [TestCase("", "y", "y")] + [TestCase("", "", "")] + [TestCase("", null, "")] + [TestCase(null, "y", "y")] + [TestCase(null, "", "")] + [TestCase(null, null, null)] + public void Merging(string original, string merged, string expected) + { + var originalMessage = new TestWellKnownTypes { StringField = original }; + var mergingMessage = new TestWellKnownTypes { StringField = merged }; + originalMessage.MergeFrom(mergingMessage); + Assert.AreEqual(expected, originalMessage.StringField); + + // Try it using MergeFrom(CodedInputStream) too... + originalMessage = new TestWellKnownTypes { StringField = original }; + originalMessage.MergeFrom(mergingMessage.ToByteArray()); + Assert.AreEqual(expected, originalMessage.StringField); + } + + // Merging is odd with wrapper types, due to the way that default values aren't emitted in + // the binary stream. In fact we cheat a little bit - a message with an explicitly present default + // value will have that default value ignored. See issue 615. Fixing this would require significant upheaval to + // the FieldCodec side of things. + [Test] + public void MergingStreamExplicitValue() + { + var message = new TestWellKnownTypes { Int32Field = 5 }; + + // Create a byte array which has the data of an Int32Value explicitly containing a value of 0. + // This wouldn't normally happen. + byte[] bytes; + var wrapperTag = WireFormat.MakeTag(TestWellKnownTypes.Int32FieldFieldNumber, WireFormat.WireType.LengthDelimited); + var valueTag = WireFormat.MakeTag(Int32Value.ValueFieldNumber, WireFormat.WireType.Varint); + using (var stream = new MemoryStream()) + { + var coded = new CodedOutputStream(stream); + coded.WriteTag(wrapperTag); + coded.WriteLength(2); // valueTag + a value 0, each one byte + coded.WriteTag(valueTag); + coded.WriteInt32(0); + coded.Flush(); + bytes = stream.ToArray(); + } + + message.MergeFrom(bytes); + // A normal implementation would have 0 now, as the explicit default would have been overwritten the 5. + // With the FieldCodec for Nullable, we can't tell the difference between an implicit 0 and an explicit 0. + Assert.AreEqual(5, message.Int32Field); + } + + [Test] + public void MergingStreamNoValue() + { + var message = new TestWellKnownTypes { Int32Field = 5 }; + + // Create a byte array which an Int32 field, but with no value. + var bytes = new TestWellKnownTypes { Int32Field = 0 }.ToByteArray(); + Assert.AreEqual(2, bytes.Length); // The tag for Int32Field is a single byte, then a byte indicating a 0-length message. + message.MergeFrom(bytes); + + // The "implicit" 0 did *not* overwrite the value. + // (This is the correct behaviour.) + Assert.AreEqual(5, message.Int32Field); + } + + // All permutations of origin/merging value being null, zero (default) or non-default. + // As this is the in-memory version, we don't need to worry about the difference between implicit and explicit 0. + [Test] + [TestCase(null, null, null)] + [TestCase(null, 0, 0)] + [TestCase(null, 5, 5)] + [TestCase(0, null, 0)] + [TestCase(0, 0, 0)] + [TestCase(0, 5, 5)] + [TestCase(5, null, 5)] + [TestCase(5, 0, 5)] + [TestCase(5, 10, 10)] + public void MergingMessageWithZero(int? originValue, int? mergingValue, int? expectedResult) + { + // This differs from the MergingStreamCornerCase because when we merge message *objects*, + // we ignore default values from the "source". + var message1 = new TestWellKnownTypes { Int32Field = originValue }; + var message2 = new TestWellKnownTypes { Int32Field = mergingValue }; + message1.MergeFrom(message2); + Assert.AreEqual(expectedResult, message1.Int32Field); + } + + [Test] + public void UnknownFieldInWrapper() + { + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + var wrapperTag = WireFormat.MakeTag(TestWellKnownTypes.Int32FieldFieldNumber, WireFormat.WireType.LengthDelimited); + var unknownTag = WireFormat.MakeTag(15, WireFormat.WireType.Varint); + var valueTag = WireFormat.MakeTag(Int32Value.ValueFieldNumber, WireFormat.WireType.Varint); + + output.WriteTag(wrapperTag); + output.WriteLength(4); // unknownTag + value 5 + valueType + value 6, each 1 byte + output.WriteTag(unknownTag); + output.WriteInt32((int) valueTag); // Sneakily "pretend" it's a tag when it's really a value + output.WriteTag(valueTag); + output.WriteInt32(6); + + output.Flush(); + stream.Position = 0; + + var message = TestWellKnownTypes.Parser.ParseFrom(stream); + Assert.AreEqual(6, message.Int32Field); + } + + [Test] + public void ClearWithReflection() + { + // String and Bytes are the tricky ones here, as the CLR type of the property + // is the same between the wrapper and non-wrapper types. + var message = new TestWellKnownTypes { StringField = "foo" }; + TestWellKnownTypes.Descriptor.Fields[TestWellKnownTypes.StringFieldFieldNumber].Accessor.Clear(message); + Assert.IsNull(message.StringField); + } + } +} diff --git a/third_party/protobuf/csharp/compatibility_tests/v3.0.0/test.sh b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/test.sh new file mode 100755 index 000000000000..9fcf406c25f8 --- /dev/null +++ b/third_party/protobuf/csharp/compatibility_tests/v3.0.0/test.sh @@ -0,0 +1,96 @@ +#!/bin/bash + +function run_test() { + # Generate test proto files. + $1 -Iprotos/src -I../../../src/ --csharp_out=src/Google.Protobuf.Test \ + --csharp_opt=base_namespace=Google.Protobuf \ + protos/src/google/protobuf/unittest_import_proto3.proto \ + protos/src/google/protobuf/unittest_import_public_proto3.proto \ + protos/src/google/protobuf/unittest_well_known_types.proto + + $1 -Iprotos/csharp --csharp_out=src/Google.Protobuf.Test \ + --csharp_opt=base_namespace=UnitTest.Issues \ + protos/csharp/protos/unittest_issues.proto + + $2 -Iprotos/src --csharp_out=src/Google.Protobuf.Test \ + --csharp_opt=base_namespace=Google.Protobuf \ + protos/src/google/protobuf/unittest_proto3.proto \ + protos/src/google/protobuf/map_unittest_proto3.proto + + # Build and test. + dotnet restore src/Google.Protobuf/Google.Protobuf.csproj + dotnet restore src/Google.Protobuf.Test/Google.Protobuf.Test.csproj + dotnet build -c Release src/Google.Protobuf/Google.Protobuf.csproj + dotnet build -c Release src/Google.Protobuf.Test/Google.Protobuf.Test.csproj + dotnet run -c Release -f netcoreapp2.1 -p src/Google.Protobuf.Test/Google.Protobuf.Test.csproj +} + +set -ex + +# Change to the script's directory. +cd $(dirname $0) + +# Version of the tests (i.e., the version of protobuf from where we extracted +# these tests). +TEST_VERSION=3.0.0 + +# The old version of protobuf that we are testing compatibility against. This +# is usually the same as TEST_VERSION (i.e., we use the tests extracted from +# that version to test compatibility of the newest runtime against it), but it +# is also possible to use this same test set to test the compatibiilty of the +# latest version against other versions. +case "$1" in + ""|3.0.0) + OLD_VERSION=3.0.0 + OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0/protoc-3.0.0-linux-x86_64.exe + ;; + 3.0.2) + OLD_VERSION=3.0.2 + OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.2/protoc-3.0.2-linux-x86_64.exe + ;; + 3.1.0) + OLD_VERSION=3.1.0 + OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.1.0/protoc-3.1.0-linux-x86_64.exe + ;; + *) + echo "[ERROR]: Unknown version number: $1" + exit 1 + ;; +esac + +echo "Running compatibility tests with $OLD_VERSION" + +# Check protoc +[ -f ../../../src/protoc ] || { + echo "[ERROR]: Please build protoc first." + exit 1 +} + +# Download old version protoc compiler (for linux). +wget $OLD_VERSION_PROTOC -O old_protoc +chmod +x old_protoc + +# Test source compatibility. In these tests we recompile everything against +# the new runtime (including old version generated code). +# Copy the new runtime and keys. +cp ../../src/Google.Protobuf src/Google.Protobuf -r +cp ../../keys . -r + +# Test A.1: +# proto set 1: use old version +# proto set 2 which may import protos in set 1: use old version +run_test "./old_protoc" "./old_protoc" + +# Test A.2: +# proto set 1: use new version +# proto set 2 which may import protos in set 1: use old version +run_test "../../../src/protoc" "./old_protoc" + +# Test A.3: +# proto set 1: use old version +# proto set 2 which may import protos in set 1: use new version +run_test "./old_protoc" "../../../src/protoc" + +rm old_protoc +rm keys -r +rm src/Google.Protobuf -r diff --git a/third_party/protobuf/csharp/generate_protos.sh b/third_party/protobuf/csharp/generate_protos.sh index d979aa52be70..5d3f5b7759ad 100755 --- a/third_party/protobuf/csharp/generate_protos.sh +++ b/third_party/protobuf/csharp/generate_protos.sh @@ -3,7 +3,7 @@ # You first need to make sure protoc has been built (see instructions on # building protoc in root of this repository) -set -ex +set -e # cd to repository root pushd $(dirname $0)/.. @@ -40,23 +40,30 @@ $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \ src/google/protobuf/type.proto \ src/google/protobuf/wrappers.proto -# Test protos where the namespace matches the target location -$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf.Test \ - --csharp_opt=base_namespace=Google.Protobuf \ - src/google/protobuf/map_unittest_proto3.proto \ - src/google/protobuf/unittest_proto3.proto \ - src/google/protobuf/unittest_import_proto3.proto \ - src/google/protobuf/unittest_import_public_proto3.proto \ - src/google/protobuf/unittest_well_known_types.proto - -# Different base namespace to the protos above -$PROTOC -Icsharp/protos --csharp_out=csharp/src/Google.Protobuf.Test \ - --csharp_opt=base_namespace=UnitTest.Issues \ - csharp/protos/unittest_issues.proto +# Test protos +$PROTOC -Isrc -Icsharp/protos \ + --csharp_out=csharp/src/Google.Protobuf.Test/TestProtos \ + --descriptor_set_out=csharp/src/Google.Protobuf.Test/testprotos.pb \ + --include_source_info \ + --include_imports \ + csharp/protos/map_unittest_proto3.proto \ + csharp/protos/unittest_issues.proto \ + csharp/protos/unittest_custom_options_proto3.proto \ + csharp/protos/unittest_proto3.proto \ + csharp/protos/unittest_import_proto3.proto \ + csharp/protos/unittest_import_public_proto3.proto \ + src/google/protobuf/unittest_well_known_types.proto \ + src/google/protobuf/test_messages_proto3.proto # AddressBook sample protos -$PROTOC -Iexamples --csharp_out=csharp/src/AddressBook \ +$PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \ examples/addressbook.proto $PROTOC -Iconformance -Isrc --csharp_out=csharp/src/Google.Protobuf.Conformance \ conformance/conformance.proto + +# Benchmark protos +$PROTOC -Ibenchmarks \ + benchmarks/datasets/google_message1/proto3/*.proto \ + benchmarks/benchmarks.proto \ + --csharp_out=csharp/src/Google.Protobuf.Benchmarks diff --git a/third_party/protobuf/csharp/install_dotnet_sdk.ps1 b/third_party/protobuf/csharp/install_dotnet_sdk.ps1 new file mode 100644 index 000000000000..b4132ab31fec --- /dev/null +++ b/third_party/protobuf/csharp/install_dotnet_sdk.ps1 @@ -0,0 +1,21 @@ +#!/usr/bin/env powershell +# Install dotnet SDK based on the SDK version from global.json + +Set-StrictMode -Version 2 +$ErrorActionPreference = 'Stop' + +# avoid "Unknown error on a send" in Invoke-WebRequest +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + +$InstallScriptUrl = 'https://dot.net/v1/dotnet-install.ps1' +$InstallScriptPath = Join-Path "$env:TEMP" 'dotnet-install.ps1' +$GlobalJsonPath = Join-Path $PSScriptRoot '..' | Join-Path -ChildPath 'global.json' + +# Resolve SDK version from global.json file +$GlobalJson = Get-Content -Raw $GlobalJsonPath | ConvertFrom-Json +$SDKVersion = $GlobalJson.sdk.version + +# Download install script +Write-Host "Downloading install script: $InstallScriptUrl => $InstallScriptPath" +Invoke-WebRequest -Uri $InstallScriptUrl -OutFile $InstallScriptPath +&$InstallScriptPath -Version $SDKVersion diff --git a/third_party/protobuf/csharp/protos/README.md b/third_party/protobuf/csharp/protos/README.md new file mode 100644 index 000000000000..bdd66fcf3958 --- /dev/null +++ b/third_party/protobuf/csharp/protos/README.md @@ -0,0 +1,3 @@ +This directory contains unit test protos adapted from those in +src/google/protobuf, and C#-specific test protos for regression +tests against bugs found in the C# codegen or library. diff --git a/third_party/protobuf/csharp/protos/map_unittest_proto3.proto b/third_party/protobuf/csharp/protos/map_unittest_proto3.proto new file mode 100644 index 000000000000..e43e858bc1fd --- /dev/null +++ b/third_party/protobuf/csharp/protos/map_unittest_proto3.proto @@ -0,0 +1,116 @@ +// 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. + +// This file is mostly equivalent to map_unittest.proto, but imports +// unittest_proto3.proto instead of unittest.proto, so that it only +// uses proto3 messages. This makes it suitable for testing +// implementations which only support proto3. +// The TestRequiredMessageMap message has been removed as there are no +// required fields in proto3. +syntax = "proto3"; + +option csharp_namespace = "Google.Protobuf.TestProtos"; + +import "unittest_proto3.proto"; + +package protobuf_unittest3; + +// Tests maps. +message TestMap { + map map_int32_int32 = 1; + map map_int64_int64 = 2; + map map_uint32_uint32 = 3; + map map_uint64_uint64 = 4; + map map_sint32_sint32 = 5; + map map_sint64_sint64 = 6; + map map_fixed32_fixed32 = 7; + map map_fixed64_fixed64 = 8; + map map_sfixed32_sfixed32 = 9; + map map_sfixed64_sfixed64 = 10; + map map_int32_float = 11; + map map_int32_double = 12; + map map_bool_bool = 13; + map map_string_string = 14; + map map_int32_bytes = 15; + map map_int32_enum = 16; + map map_int32_foreign_message = 17; +} + +message TestMapSubmessage { + TestMap test_map = 1; +} + +message TestMessageMap { + map map_int32_message = 1; +} + +// Two map fields share the same entry default instance. +message TestSameTypeMap { + map map1 = 1; + map map2 = 2; +} + +enum MapEnum { + MAP_ENUM_FOO = 0; + MAP_ENUM_BAR = 1; + MAP_ENUM_BAZ = 2; +} + +message TestArenaMap { + map map_int32_int32 = 1; + map map_int64_int64 = 2; + map map_uint32_uint32 = 3; + map map_uint64_uint64 = 4; + map map_sint32_sint32 = 5; + map map_sint64_sint64 = 6; + map map_fixed32_fixed32 = 7; + map map_fixed64_fixed64 = 8; + map map_sfixed32_sfixed32 = 9; + map map_sfixed64_sfixed64 = 10; + map map_int32_float = 11; + map map_int32_double = 12; + map map_bool_bool = 13; + map map_int32_enum = 14; + map map_int32_foreign_message = 15; +} + +// Previously, message containing enum called Type cannot be used as value of +// map field. +message MessageContainingEnumCalledType { + enum Type { + TYPE_FOO = 0; + } + map type = 1; +} + +// Previously, message cannot contain map field called "entry". +message MessageContainingMapCalledEntry { + map entry = 1; +} diff --git a/third_party/protobuf/csharp/protos/unittest_custom_options_proto3.proto b/third_party/protobuf/csharp/protos/unittest_custom_options_proto3.proto new file mode 100644 index 000000000000..87bd0f7a84dc --- /dev/null +++ b/third_party/protobuf/csharp/protos/unittest_custom_options_proto3.proto @@ -0,0 +1,336 @@ +// 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: benjy@google.com (Benjy Weinberger) +// Based on original Protocol Buffers design by +// Sanjay Ghemawat, Jeff Dean, and others. +// +// A proto file used to test the "custom options" feature of google.protobuf. + +// This file is based on unittest_custom_options.proto in +// src/google/protobuf, but is modified for proto3. It could +// potentially be moved into src/google/protobuf, but currently C# +// is the only language that really needs it, as we don't support +// proto2 syntax. It's cut down significantly as proto3 only supports +// extensions for options. + + +syntax = "proto3"; + +// A custom file option (defined below). +option (file_opt1) = 9876543210; + +import "google/protobuf/descriptor.proto"; + +// We don't put this in a package within proto2 because we need to make sure +// that the generated code doesn't depend on being in the proto2 namespace. +package protobuf_unittest; +option csharp_namespace = "UnitTest.Issues.TestProtos"; + +// Some simple test custom options of various types. + +extend google.protobuf.FileOptions { + uint64 file_opt1 = 7736974; +} + +extend google.protobuf.MessageOptions { + int32 message_opt1 = 7739036; +} + +extend google.protobuf.FieldOptions { + fixed64 field_opt1 = 7740936; +} + +extend google.protobuf.OneofOptions { + int32 oneof_opt1 = 7740111; +} + +extend google.protobuf.EnumOptions { + sfixed32 enum_opt1 = 7753576; +} + +extend google.protobuf.EnumValueOptions { + int32 enum_value_opt1 = 1560678; +} + +extend google.protobuf.ServiceOptions { + sint64 service_opt1 = 7887650; +} + +enum MethodOpt1 { + METHODOPT1_UNSPECIFIED = 0; + METHODOPT1_VAL1 = 1; + METHODOPT1_VAL2 = 2; +} + +extend google.protobuf.MethodOptions { + MethodOpt1 method_opt1 = 7890860; +} + +// A test message with custom options at all possible locations (and also some +// regular options, to make sure they interact nicely). +message TestMessageWithCustomOptions { + option message_set_wire_format = false; + + option (message_opt1) = -56; + + string field1 = 1 [ctype=CORD, + (field_opt1)=8765432109]; + + oneof AnOneof { + option (oneof_opt1) = -99; + int32 oneof_field = 2; + } + + enum AnEnum { + option (enum_opt1) = -789; + ANENUM_UNSPECIFIED = 0; + ANENUM_VAL1 = 1; + ANENUM_VAL2 = 2 [(enum_value_opt1) = 123]; + } +} + + +// A test RPC service with custom options at all possible locations (and also +// some regular options, to make sure they interact nicely). +message CustomOptionFooRequest { +} + +message CustomOptionFooResponse { +} + +message CustomOptionFooClientMessage { +} + +message CustomOptionFooServerMessage { +} + +service TestServiceWithCustomOptions { + option (service_opt1) = -9876543210; + + rpc Foo(CustomOptionFooRequest) returns (CustomOptionFooResponse) { + option (method_opt1) = METHODOPT1_VAL2; + } +} + + + +// Options of every possible field type, so we can test them all exhaustively. + +message DummyMessageContainingEnum { + enum TestEnumType { + TEST_OPTION_ENUM_UNSPECIFIED = 0; + TEST_OPTION_ENUM_TYPE1 = 22; + TEST_OPTION_ENUM_TYPE2 = -23; + } +} + +message DummyMessageInvalidAsOptionType { +} + +extend google.protobuf.MessageOptions { + bool bool_opt = 7706090; + int32 int32_opt = 7705709; + int64 int64_opt = 7705542; + uint32 uint32_opt = 7704880; + uint64 uint64_opt = 7702367; + sint32 sint32_opt = 7701568; + sint64 sint64_opt = 7700863; + fixed32 fixed32_opt = 7700307; + fixed64 fixed64_opt = 7700194; + sfixed32 sfixed32_opt = 7698645; + sfixed64 sfixed64_opt = 7685475; + float float_opt = 7675390; + double double_opt = 7673293; + string string_opt = 7673285; + bytes bytes_opt = 7673238; + DummyMessageContainingEnum.TestEnumType enum_opt = 7673233; + DummyMessageInvalidAsOptionType message_type_opt = 7665967; +} + +message CustomOptionMinIntegerValues { + option (bool_opt) = false; + option (int32_opt) = -0x80000000; + option (int64_opt) = -0x8000000000000000; + option (uint32_opt) = 0; + option (uint64_opt) = 0; + option (sint32_opt) = -0x80000000; + option (sint64_opt) = -0x8000000000000000; + option (fixed32_opt) = 0; + option (fixed64_opt) = 0; + option (sfixed32_opt) = -0x80000000; + option (sfixed64_opt) = -0x8000000000000000; +} + +message CustomOptionMaxIntegerValues { + option (bool_opt) = true; + option (int32_opt) = 0x7FFFFFFF; + option (int64_opt) = 0x7FFFFFFFFFFFFFFF; + option (uint32_opt) = 0xFFFFFFFF; + option (uint64_opt) = 0xFFFFFFFFFFFFFFFF; + option (sint32_opt) = 0x7FFFFFFF; + option (sint64_opt) = 0x7FFFFFFFFFFFFFFF; + option (fixed32_opt) = 0xFFFFFFFF; + option (fixed64_opt) = 0xFFFFFFFFFFFFFFFF; + option (sfixed32_opt) = 0x7FFFFFFF; + option (sfixed64_opt) = 0x7FFFFFFFFFFFFFFF; +} + +message CustomOptionOtherValues { + option (int32_opt) = -100; // To test sign-extension. + option (float_opt) = 12.3456789; + option (double_opt) = 1.234567890123456789; + option (string_opt) = "Hello, \"World\""; + option (bytes_opt) = "Hello\0World"; + option (enum_opt) = TEST_OPTION_ENUM_TYPE2; +} + +message SettingRealsFromPositiveInts { + option (float_opt) = 12; + option (double_opt) = 154; +} + +message SettingRealsFromNegativeInts { + option (float_opt) = -12; + option (double_opt) = -154; +} + +// Options of complex message types, themselves combined and extended in +// various ways. + +message ComplexOptionType1 { + int32 foo = 1; + int32 foo2 = 2; + int32 foo3 = 3; + repeated int32 foo4 = 4; +} + +message ComplexOptionType2 { + ComplexOptionType1 bar = 1; + int32 baz = 2; + + message ComplexOptionType4 { + int32 waldo = 1; + + extend google.protobuf.MessageOptions { + ComplexOptionType4 complex_opt4 = 7633546; + } + } + + ComplexOptionType4 fred = 3; + repeated ComplexOptionType4 barney = 4; +} + +message ComplexOptionType3 { + int32 qux = 1; +} + +extend google.protobuf.MessageOptions { + protobuf_unittest.ComplexOptionType1 complex_opt1 = 7646756; + ComplexOptionType2 complex_opt2 = 7636949; + ComplexOptionType3 complex_opt3 = 7636463; +} + +// Note that we try various different ways of naming the same extension. +message VariousComplexOptions { + option (.protobuf_unittest.complex_opt1).foo = 42; + option (protobuf_unittest.complex_opt1).foo4 = 99; + option (protobuf_unittest.complex_opt1).foo4 = 88; + option (complex_opt2).baz = 987; + option (complex_opt2).bar.foo = 743; + option (ComplexOptionType2.ComplexOptionType4.complex_opt4).waldo = 1971; + option (complex_opt2).fred.waldo = 321; + option (complex_opt2).barney = { waldo: 101 }; + option (complex_opt2).barney = { waldo: 212 }; + option (protobuf_unittest.complex_opt3).qux = 9; +} + +// ------------------------------------------------------ +// Definitions for testing aggregate option parsing. +// See descriptor_unittest.cc. + +// A helper type used to test aggregate option parsing +message Aggregate { + int32 i = 1; + string s = 2; + + // A nested object + Aggregate sub = 3; +} + +// Allow Aggregate to be used as an option at all possible locations +// in the .proto grammer. +extend google.protobuf.FileOptions { Aggregate fileopt = 15478479; } +extend google.protobuf.MessageOptions { Aggregate msgopt = 15480088; } +extend google.protobuf.FieldOptions { Aggregate fieldopt = 15481374; } +extend google.protobuf.EnumOptions { Aggregate enumopt = 15483218; } +extend google.protobuf.EnumValueOptions { Aggregate enumvalopt = 15486921; } +extend google.protobuf.ServiceOptions { Aggregate serviceopt = 15497145; } +extend google.protobuf.MethodOptions { Aggregate methodopt = 15512713; } + +// Try using AggregateOption at different points in the proto grammar +option (fileopt) = { + s: 'FileAnnotation' + // Also test the handling of comments + /* of both types */ i: 100 + + sub { s: 'NestedFileAnnotation' } +}; + +message AggregateMessage { + option (msgopt) = { i:101 s:'MessageAnnotation' }; + int32 fieldname = 1 [(fieldopt) = { s:'FieldAnnotation' }]; +} + +service AggregateService { + option (serviceopt) = { s:'ServiceAnnotation' }; + rpc Method (AggregateMessage) returns (AggregateMessage) { + option (methodopt) = { s:'MethodAnnotation' }; + } +} + +enum AggregateEnum { + option (enumopt) = { s:'EnumAnnotation' }; + UNSPECIFIED = 0; + VALUE = 1 [(enumvalopt) = { s:'EnumValueAnnotation' }]; +} + +// Test custom options for nested type. +message NestedOptionType { + message NestedMessage { + option (message_opt1) = 1001; + int32 nested_field = 1 [(field_opt1) = 1002]; + } + enum NestedEnum { + UNSPECIFIED = 0; + option (enum_opt1) = 1003; + NESTED_ENUM_VALUE = 1 [(enum_value_opt1) = 1004]; + } +} diff --git a/third_party/protobuf/javanano/src/test/java/com/google/protobuf/nano/unittest_simple_nano.proto b/third_party/protobuf/csharp/protos/unittest_import_proto3.proto similarity index 76% rename from third_party/protobuf/javanano/src/test/java/com/google/protobuf/nano/unittest_simple_nano.proto rename to third_party/protobuf/csharp/protos/unittest_import_proto3.proto index 25786cc227cb..2e6668228663 100644 --- a/third_party/protobuf/javanano/src/test/java/com/google/protobuf/nano/unittest_simple_nano.proto +++ b/third_party/protobuf/csharp/protos/unittest_import_proto3.proto @@ -28,27 +28,29 @@ // (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: wink@google.com (Wink Saville) +// Author: kenton@google.com (Kenton Varda) +// Based on original Protocol Buffers design by +// Sanjay Ghemawat, Jeff Dean, and others. // +// A proto file which is imported by unittest_proto3.proto to test importing. + +syntax = "proto3"; package protobuf_unittest_import; -option java_package = "com.google.protobuf"; -// Explicit outer classname to suppress legacy info. -option java_outer_classname = "UnittestSimpleNano"; +option csharp_namespace = "Google.Protobuf.TestProtos"; -message SimpleMessageNano { - message NestedMessage { - optional int32 bb = 1; - } +// Test public import +import public "unittest_import_public_proto3.proto"; - enum NestedEnum { - FOO = 1; - BAR = 2; - BAZ = 3; - } +message ImportMessage { + int32 d = 1; +} - optional int32 d = 1 [default = 123]; - optional NestedMessage nested_msg = 2; - optional NestedEnum default_nested_enum = 3 [default = BAZ]; +enum ImportEnum { + IMPORT_ENUM_UNSPECIFIED = 0; + IMPORT_FOO = 7; + IMPORT_BAR = 8; + IMPORT_BAZ = 9; } + diff --git a/third_party/protobuf/javanano/src/test/java/com/google/protobuf/nano/unittest_stringutf8_nano.proto b/third_party/protobuf/csharp/protos/unittest_import_public_proto3.proto similarity index 86% rename from third_party/protobuf/javanano/src/test/java/com/google/protobuf/nano/unittest_stringutf8_nano.proto rename to third_party/protobuf/csharp/protos/unittest_import_public_proto3.proto index bbd677cfd6f0..88c20799ae92 100644 --- a/third_party/protobuf/javanano/src/test/java/com/google/protobuf/nano/unittest_stringutf8_nano.proto +++ b/third_party/protobuf/csharp/protos/unittest_import_public_proto3.proto @@ -28,16 +28,14 @@ // (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: wink@google.com (Wink Saville) -// +// Author: liujisi@google.com (Pherl Liu) + +syntax = "proto3"; package protobuf_unittest_import; -option java_package = "com.google.protobuf"; -// Explicit outer classname to suppress legacy info. -option java_outer_classname = "UnittestStringutf8Nano"; +option csharp_namespace = "Google.Protobuf.TestProtos"; -message StringUtf8 { - optional string id = 1; - repeated string rs = 2; +message PublicImportMessage { + int32 e = 1; } diff --git a/third_party/protobuf/csharp/protos/unittest_issues.proto b/third_party/protobuf/csharp/protos/unittest_issues.proto index 6c9f76344abe..b4a88d86481b 100644 --- a/third_party/protobuf/csharp/protos/unittest_issues.proto +++ b/third_party/protobuf/csharp/protos/unittest_issues.proto @@ -7,7 +7,6 @@ syntax = "proto3"; option csharp_namespace = "UnitTest.Issues.TestProtos"; package unittest_issues; -option optimize_for = SPEED; // Issue 307: when generating doubly-nested types, any references // should be of the form A.Types.B.Types.C. @@ -19,8 +18,8 @@ message Issue307 { } // Old issue 13: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=13 -// New issue 309: https://github.com/google/protobuf/issues/309 - +// New issue 309: https://github.com/protocolbuffers/protobuf/issues/309 + // message A { // optional int32 _A = 1; // } @@ -35,7 +34,7 @@ message Issue307 { // Similar issue with numeric names // Java code failed too, so probably best for this to be a restriction. -// See https://github.com/google/protobuf/issues/308 +// See https://github.com/protocolbuffers/protobuf/issues/308 // message NumberField { // optional int32 _01 = 1; // } @@ -101,21 +100,21 @@ message TestJsonFieldOrdering { // that will require fixing other tests in multiple platforms. // Alternatively, consider just adding this to // unittest_proto3.proto if multiple platforms want it. - + int32 plain_int32 = 4; oneof o1 { string o1_string = 2; int32 o1_int32 = 5; } - + string plain_string = 1; - + oneof o2 { int32 o2_int32 = 6; string o2_string = 3; } - + } message TestJsonName { @@ -124,3 +123,18 @@ message TestJsonName { string description = 2 [json_name = "desc"]; string guid = 3 [json_name = "exid"]; } + +// Issue 3200: When merging two messages which use the same +// oneof case, which is itself a message type, the submessages should +// be merged. +message OneofMerging { + message Nested { + int32 x = 1; + int32 y = 2; + } + + oneof value { + string text = 1; + Nested nested = 2; + } +} \ No newline at end of file diff --git a/third_party/protobuf/csharp/protos/unittest_proto3.proto b/third_party/protobuf/csharp/protos/unittest_proto3.proto new file mode 100644 index 000000000000..884beae4e561 --- /dev/null +++ b/third_party/protobuf/csharp/protos/unittest_proto3.proto @@ -0,0 +1,410 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Author: kenton@google.com (Kenton Varda) +// Based on original Protocol Buffers design by +// Sanjay Ghemawat, Jeff Dean, and others. +// +// A proto file we will use for unit testing. + +syntax = "proto3"; + +option csharp_namespace = "Google.Protobuf.TestProtos"; + +// Only present so we can test that we can read it (as an example +// of a non-C# option) +option java_outer_classname = "UnittestProto"; + +import "unittest_import_proto3.proto"; + +package protobuf_unittest3; + +// This proto includes every type of field in both singular and repeated +// forms. +message TestAllTypes { + message NestedMessage { + // The field name "b" fails to compile in proto1 because it conflicts with + // a local variable named "b" in one of the generated methods. Doh. + // This file needs to compile in proto1 to test backwards-compatibility. + int32 bb = 1; + } + + enum NestedEnum { + NESTED_ENUM_UNSPECIFIED = 0; + FOO = 1; + BAR = 2; + BAZ = 3; + NEG = -1; // Intentionally negative. + } + + // Singular + int32 single_int32 = 1; + int64 single_int64 = 2; + uint32 single_uint32 = 3; + uint64 single_uint64 = 4; + sint32 single_sint32 = 5; + sint64 single_sint64 = 6; + fixed32 single_fixed32 = 7; + fixed64 single_fixed64 = 8; + sfixed32 single_sfixed32 = 9; + sfixed64 single_sfixed64 = 10; + float single_float = 11; + double single_double = 12; + bool single_bool = 13; + string single_string = 14; + bytes single_bytes = 15; + + NestedMessage single_nested_message = 18; + ForeignMessage single_foreign_message = 19; + protobuf_unittest_import.ImportMessage single_import_message = 20; + + NestedEnum single_nested_enum = 21; + ForeignEnum single_foreign_enum = 22; + protobuf_unittest_import.ImportEnum single_import_enum = 23; + + // Defined in unittest_import_public.proto + protobuf_unittest_import.PublicImportMessage + single_public_import_message = 26; + + // Repeated + repeated int32 repeated_int32 = 31; + repeated int64 repeated_int64 = 32; + repeated uint32 repeated_uint32 = 33; + repeated uint64 repeated_uint64 = 34; + repeated sint32 repeated_sint32 = 35; + repeated sint64 repeated_sint64 = 36; + repeated fixed32 repeated_fixed32 = 37; + repeated fixed64 repeated_fixed64 = 38; + repeated sfixed32 repeated_sfixed32 = 39; + repeated sfixed64 repeated_sfixed64 = 40; + repeated float repeated_float = 41; + repeated double repeated_double = 42; + repeated bool repeated_bool = 43; + repeated string repeated_string = 44; + repeated bytes repeated_bytes = 45; + + repeated NestedMessage repeated_nested_message = 48; + repeated ForeignMessage repeated_foreign_message = 49; + repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50; + + repeated NestedEnum repeated_nested_enum = 51; + repeated ForeignEnum repeated_foreign_enum = 52; + repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53; + // Defined in unittest_import_public.proto + repeated protobuf_unittest_import.PublicImportMessage + repeated_public_import_message = 54; + + // For oneof test + oneof oneof_field { + uint32 oneof_uint32 = 111; + NestedMessage oneof_nested_message = 112; + string oneof_string = 113; + bytes oneof_bytes = 114; + } +} + +// This proto includes a recusively nested message. +message NestedTestAllTypes { + NestedTestAllTypes child = 1; + TestAllTypes payload = 2; + repeated NestedTestAllTypes repeated_child = 3; +} + +message TestDeprecatedFields { + int32 deprecated_int32 = 1 [deprecated=true]; +} + +// Define these after TestAllTypes to make sure the compiler can handle +// that. +message ForeignMessage { + int32 c = 1; +} + +enum ForeignEnum { + FOREIGN_UNSPECIFIED = 0; + FOREIGN_FOO = 4; + FOREIGN_BAR = 5; + FOREIGN_BAZ = 6; +} + +message TestReservedFields { + reserved 2, 15, 9 to 11; + reserved "bar", "baz"; +} + + +// Test that we can use NestedMessage from outside TestAllTypes. +message TestForeignNested { + TestAllTypes.NestedMessage foreign_nested = 1; +} + +// Test that really large tag numbers don't break anything. +message TestReallyLargeTagNumber { + // The largest possible tag number is 2^28 - 1, since the wire format uses + // three bits to communicate wire type. + int32 a = 1; + int32 bb = 268435455; +} + +message TestRecursiveMessage { + TestRecursiveMessage a = 1; + int32 i = 2; +} + +// Test that mutual recursion works. +message TestMutualRecursionA { + TestMutualRecursionB bb = 1; +} + +message TestMutualRecursionB { + TestMutualRecursionA a = 1; + int32 optional_int32 = 2; +} + +message TestEnumAllowAlias { + TestEnumWithDupValue value = 1; +} + +// Test an enum that has multiple values with the same number. +enum TestEnumWithDupValue { + TEST_ENUM_WITH_DUP_VALUE_UNSPECIFIED = 0; + option allow_alias = true; + + FOO1 = 1; + BAR1 = 2; + BAZ = 3; + FOO2 = 1; + BAR2 = 2; +} + +// Test an enum with large, unordered values. +enum TestSparseEnum { + TEST_SPARSE_ENUM_UNSPECIFIED = 0; + SPARSE_A = 123; + SPARSE_B = 62374; + SPARSE_C = 12589234; + SPARSE_D = -15; + SPARSE_E = -53452; + // In proto3, value 0 must be the first one specified + // SPARSE_F = 0; + SPARSE_G = 2; +} + +// Test message with CamelCase field names. This violates Protocol Buffer +// standard style. +message TestCamelCaseFieldNames { + int32 PrimitiveField = 1; + string StringField = 2; + ForeignEnum EnumField = 3; + ForeignMessage MessageField = 4; + + repeated int32 RepeatedPrimitiveField = 7; + repeated string RepeatedStringField = 8; + repeated ForeignEnum RepeatedEnumField = 9; + repeated ForeignMessage RepeatedMessageField = 10; +} + + +// We list fields out of order, to ensure that we're using field number and not +// field index to determine serialization order. +message TestFieldOrderings { + string my_string = 11; + int64 my_int = 1; + float my_float = 101; + message NestedMessage { + int64 oo = 2; + // The field name "b" fails to compile in proto1 because it conflicts with + // a local variable named "b" in one of the generated methods. Doh. + // This file needs to compile in proto1 to test backwards-compatibility. + int32 bb = 1; + } + + NestedMessage single_nested_message = 200; +} + +message SparseEnumMessage { + TestSparseEnum sparse_enum = 1; +} + +// Test String and Bytes: string is for valid UTF-8 strings +message OneString { + string data = 1; +} + +message MoreString { + repeated string data = 1; +} + +message OneBytes { + bytes data = 1; +} + +message MoreBytes { + bytes data = 1; +} + +// Test int32, uint32, int64, uint64, and bool are all compatible +message Int32Message { + int32 data = 1; +} + +message Uint32Message { + uint32 data = 1; +} + +message Int64Message { + int64 data = 1; +} + +message Uint64Message { + uint64 data = 1; +} + +message BoolMessage { + bool data = 1; +} + +// Test oneofs. +message TestOneof { + oneof foo { + int32 foo_int = 1; + string foo_string = 2; + TestAllTypes foo_message = 3; + } +} + +// Test messages for packed fields + +message TestPackedTypes { + repeated int32 packed_int32 = 90 [packed = true]; + repeated int64 packed_int64 = 91 [packed = true]; + repeated uint32 packed_uint32 = 92 [packed = true]; + repeated uint64 packed_uint64 = 93 [packed = true]; + repeated sint32 packed_sint32 = 94 [packed = true]; + repeated sint64 packed_sint64 = 95 [packed = true]; + repeated fixed32 packed_fixed32 = 96 [packed = true]; + repeated fixed64 packed_fixed64 = 97 [packed = true]; + repeated sfixed32 packed_sfixed32 = 98 [packed = true]; + repeated sfixed64 packed_sfixed64 = 99 [packed = true]; + repeated float packed_float = 100 [packed = true]; + repeated double packed_double = 101 [packed = true]; + repeated bool packed_bool = 102 [packed = true]; + repeated ForeignEnum packed_enum = 103 [packed = true]; +} + +// A message with the same fields as TestPackedTypes, but without packing. Used +// to test packed <-> unpacked wire compatibility. +message TestUnpackedTypes { + repeated int32 unpacked_int32 = 90 [packed = false]; + repeated int64 unpacked_int64 = 91 [packed = false]; + repeated uint32 unpacked_uint32 = 92 [packed = false]; + repeated uint64 unpacked_uint64 = 93 [packed = false]; + repeated sint32 unpacked_sint32 = 94 [packed = false]; + repeated sint64 unpacked_sint64 = 95 [packed = false]; + repeated fixed32 unpacked_fixed32 = 96 [packed = false]; + repeated fixed64 unpacked_fixed64 = 97 [packed = false]; + repeated sfixed32 unpacked_sfixed32 = 98 [packed = false]; + repeated sfixed64 unpacked_sfixed64 = 99 [packed = false]; + repeated float unpacked_float = 100 [packed = false]; + repeated double unpacked_double = 101 [packed = false]; + repeated bool unpacked_bool = 102 [packed = false]; + repeated ForeignEnum unpacked_enum = 103 [packed = false]; +} + +message TestRepeatedScalarDifferentTagSizes { + // Parsing repeated fixed size values used to fail. This message needs to be + // used in order to get a tag of the right size; all of the repeated fields + // in TestAllTypes didn't trigger the check. + repeated fixed32 repeated_fixed32 = 12; + // Check for a varint type, just for good measure. + repeated int32 repeated_int32 = 13; + + // These have two-byte tags. + repeated fixed64 repeated_fixed64 = 2046; + repeated int64 repeated_int64 = 2047; + + // Three byte tags. + repeated float repeated_float = 262142; + repeated uint64 repeated_uint64 = 262143; +} + +message TestCommentInjectionMessage { + // */ <- This should not close the generated doc comment + string a = 1; +} + + +// Test that RPC services work. +message FooRequest {} +message FooResponse {} + +message FooClientMessage {} +message FooServerMessage{} + +// This is a test service +service TestService { + // This is a test method + rpc Foo(FooRequest) returns (FooResponse); + rpc Bar(BarRequest) returns (BarResponse); +} + + +message BarRequest {} +message BarResponse {} + +message TestEmptyMessage {} + +// This is leading detached comment 1 + +// This is leading detached comment 2 + +// This is a leading comment +message CommentMessage { + // Leading nested message comment + message NestedCommentMessage { + // Leading nested message field comment + string nested_text = 1; + } + + // Leading nested enum comment + enum NestedCommentEnum { + // Zero value comment + ZERO_VALUE = 0; + } + + // Leading field comment + string text = 1; // Trailing field comment +} + +// Leading enum comment +enum CommentEnum { + // Zero value comment + ZERO_VALUE = 0; +} diff --git a/third_party/protobuf/csharp/src/AddressBook/AddPerson.cs b/third_party/protobuf/csharp/src/AddressBook/AddPerson.cs index 484f1ea25df3..62d1788d55a7 100644 --- a/third_party/protobuf/csharp/src/AddressBook/AddPerson.cs +++ b/third_party/protobuf/csharp/src/AddressBook/AddPerson.cs @@ -1,132 +1,132 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; -using System.IO; - -namespace Google.Protobuf.Examples.AddressBook -{ - internal class AddPerson - { - /// - /// Builds a person based on user input - /// - private static Person PromptForAddress(TextReader input, TextWriter output) - { - Person person = new Person(); - - output.Write("Enter person ID: "); - person.Id = int.Parse(input.ReadLine()); - - output.Write("Enter name: "); - person.Name = input.ReadLine(); - - output.Write("Enter email address (blank for none): "); - string email = input.ReadLine(); - if (email.Length > 0) - { - person.Email = email; - } - - while (true) - { - output.Write("Enter a phone number (or leave blank to finish): "); - string number = input.ReadLine(); - if (number.Length == 0) - { - break; - } - - Person.Types.PhoneNumber phoneNumber = new Person.Types.PhoneNumber { Number = number }; - - output.Write("Is this a mobile, home, or work phone? "); - String type = input.ReadLine(); - switch (type) - { - case "mobile": - phoneNumber.Type = Person.Types.PhoneType.Mobile; - break; - case "home": - phoneNumber.Type = Person.Types.PhoneType.Home; - break; - case "work": - phoneNumber.Type = Person.Types.PhoneType.Work; - break; - default: - output.Write("Unknown phone type. Using default."); - break; - } - - person.Phones.Add(phoneNumber); - } - return person; - } - - /// - /// Entry point - loads an existing addressbook or creates a new one, - /// then writes it back to the file. - /// - public static int Main(string[] args) - { - if (args.Length != 1) - { - Console.Error.WriteLine("Usage: AddPerson ADDRESS_BOOK_FILE"); - return -1; - } - - AddressBook addressBook; - - if (File.Exists(args[0])) - { - using (Stream file = File.OpenRead(args[0])) - { - addressBook = AddressBook.Parser.ParseFrom(file); - } - } - else - { - Console.WriteLine("{0}: File not found. Creating a new file.", args[0]); - addressBook = new AddressBook(); - } - - // Add an address. - addressBook.People.Add(PromptForAddress(Console.In, Console.Out)); - - // Write the new address book back to disk. - using (Stream output = File.OpenWrite(args[0])) - { - addressBook.WriteTo(output); - } - return 0; - } - } +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.IO; + +namespace Google.Protobuf.Examples.AddressBook +{ + internal class AddPerson + { + /// + /// Builds a person based on user input + /// + private static Person PromptForAddress(TextReader input, TextWriter output) + { + Person person = new Person(); + + output.Write("Enter person ID: "); + person.Id = int.Parse(input.ReadLine()); + + output.Write("Enter name: "); + person.Name = input.ReadLine(); + + output.Write("Enter email address (blank for none): "); + string email = input.ReadLine(); + if (email.Length > 0) + { + person.Email = email; + } + + while (true) + { + output.Write("Enter a phone number (or leave blank to finish): "); + string number = input.ReadLine(); + if (number.Length == 0) + { + break; + } + + Person.Types.PhoneNumber phoneNumber = new Person.Types.PhoneNumber { Number = number }; + + output.Write("Is this a mobile, home, or work phone? "); + String type = input.ReadLine(); + switch (type) + { + case "mobile": + phoneNumber.Type = Person.Types.PhoneType.Mobile; + break; + case "home": + phoneNumber.Type = Person.Types.PhoneType.Home; + break; + case "work": + phoneNumber.Type = Person.Types.PhoneType.Work; + break; + default: + output.Write("Unknown phone type. Using default."); + break; + } + + person.Phones.Add(phoneNumber); + } + return person; + } + + /// + /// Entry point - loads an existing addressbook or creates a new one, + /// then writes it back to the file. + /// + public static int Main(string[] args) + { + if (args.Length != 1) + { + Console.Error.WriteLine("Usage: AddPerson ADDRESS_BOOK_FILE"); + return -1; + } + + AddressBook addressBook; + + if (File.Exists(args[0])) + { + using (Stream file = File.OpenRead(args[0])) + { + addressBook = AddressBook.Parser.ParseFrom(file); + } + } + else + { + Console.WriteLine("{0}: File not found. Creating a new file.", args[0]); + addressBook = new AddressBook(); + } + + // Add an address. + addressBook.People.Add(PromptForAddress(Console.In, Console.Out)); + + // Write the new address book back to disk. + using (Stream output = File.OpenWrite(args[0])) + { + addressBook.WriteTo(output); + } + return 0; + } + } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/AddressBook/AddressBook.csproj b/third_party/protobuf/csharp/src/AddressBook/AddressBook.csproj index 021647fc8c3a..f3268c0acf3e 100644 --- a/third_party/protobuf/csharp/src/AddressBook/AddressBook.csproj +++ b/third_party/protobuf/csharp/src/AddressBook/AddressBook.csproj @@ -1,75 +1,14 @@ - - + + - Debug - AnyCPU - 9.0.30729 - 2.0 - {A31F5FB2-4FF3-432A-B35B-5CD203606311} + netcoreapp2.1 Exe - Properties - Google.Protobuf.Examples.AddressBook - AddressBook - v4.5 - 512 Google.Protobuf.Examples.AddressBook.Program - - + False - - true - full - false - bin\Debug - obj\Debug\ - DEBUG;TRACE - prompt - 4 - true - Off - false - - - pdbonly - true - bin\Release - obj\Release\ - TRACE - prompt - 4 - true - Off - false - - - - - - - - - - - - - - - - - - {6908BDCE-D925-43F3-94AC-A531E6DF2591} - Google.Protobuf - - + - + - - - \ No newline at end of file + + diff --git a/third_party/protobuf/csharp/src/AddressBook/Addressbook.cs b/third_party/protobuf/csharp/src/AddressBook/Addressbook.cs index 362e1cb6a2c2..cbd977269620 100644 --- a/third_party/protobuf/csharp/src/AddressBook/Addressbook.cs +++ b/third_party/protobuf/csharp/src/AddressBook/Addressbook.cs @@ -1,5 +1,7 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: addressbook.proto +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: addressbook.proto +// #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -10,7 +12,6 @@ namespace Google.Protobuf.Examples.AddressBook { /// Holder for reflection information generated from addressbook.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class AddressbookReflection { #region Descriptor @@ -23,20 +24,22 @@ public static partial class AddressbookReflection { static AddressbookReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "ChFhZGRyZXNzYm9vay5wcm90bxIIdHV0b3JpYWwi1QEKBlBlcnNvbhIMCgRu", - "YW1lGAEgASgJEgoKAmlkGAIgASgFEg0KBWVtYWlsGAMgASgJEiwKBnBob25l", - "cxgEIAMoCzIcLnR1dG9yaWFsLlBlcnNvbi5QaG9uZU51bWJlchpHCgtQaG9u", - "ZU51bWJlchIOCgZudW1iZXIYASABKAkSKAoEdHlwZRgCIAEoDjIaLnR1dG9y", - "aWFsLlBlcnNvbi5QaG9uZVR5cGUiKwoJUGhvbmVUeXBlEgoKBk1PQklMRRAA", - "EggKBEhPTUUQARIICgRXT1JLEAIiLwoLQWRkcmVzc0Jvb2sSIAoGcGVvcGxl", - "GAEgAygLMhAudHV0b3JpYWwuUGVyc29uQlAKFGNvbS5leGFtcGxlLnR1dG9y", - "aWFsQhFBZGRyZXNzQm9va1Byb3Rvc6oCJEdvb2dsZS5Qcm90b2J1Zi5FeGFt", - "cGxlcy5BZGRyZXNzQm9va2IGcHJvdG8z")); + "ChFhZGRyZXNzYm9vay5wcm90bxIIdHV0b3JpYWwaH2dvb2dsZS9wcm90b2J1", + "Zi90aW1lc3RhbXAucHJvdG8ihwIKBlBlcnNvbhIMCgRuYW1lGAEgASgJEgoK", + "AmlkGAIgASgFEg0KBWVtYWlsGAMgASgJEiwKBnBob25lcxgEIAMoCzIcLnR1", + "dG9yaWFsLlBlcnNvbi5QaG9uZU51bWJlchIwCgxsYXN0X3VwZGF0ZWQYBSAB", + "KAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wGkcKC1Bob25lTnVtYmVy", + "Eg4KBm51bWJlchgBIAEoCRIoCgR0eXBlGAIgASgOMhoudHV0b3JpYWwuUGVy", + "c29uLlBob25lVHlwZSIrCglQaG9uZVR5cGUSCgoGTU9CSUxFEAASCAoESE9N", + "RRABEggKBFdPUksQAiIvCgtBZGRyZXNzQm9vaxIgCgZwZW9wbGUYASADKAsy", + "EC50dXRvcmlhbC5QZXJzb25CUAoUY29tLmV4YW1wbGUudHV0b3JpYWxCEUFk", + "ZHJlc3NCb29rUHJvdG9zqgIkR29vZ2xlLlByb3RvYnVmLkV4YW1wbGVzLkFk", + "ZHJlc3NCb29rYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Examples.AddressBook.Person), global::Google.Protobuf.Examples.AddressBook.Person.Parser, new[]{ "Name", "Id", "Email", "Phones" }, null, new[]{ typeof(global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType) }, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber), global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber.Parser, new[]{ "Number", "Type" }, null, null, null)}), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Examples.AddressBook.AddressBook), global::Google.Protobuf.Examples.AddressBook.AddressBook.Parser, new[]{ "People" }, null, null, null) + new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, }, + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Examples.AddressBook.Person), global::Google.Protobuf.Examples.AddressBook.Person.Parser, new[]{ "Name", "Id", "Email", "Phones", "LastUpdated" }, null, new[]{ typeof(global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType) }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber), global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber.Parser, new[]{ "Number", "Type" }, null, null, null, null)}), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Examples.AddressBook.AddressBook), global::Google.Protobuf.Examples.AddressBook.AddressBook.Parser, new[]{ "People" }, null, null, null, null) })); } #endregion @@ -44,34 +47,42 @@ static AddressbookReflection() { } #region Messages /// - /// [START messages] + /// [START messages] /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Person : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Person()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.Examples.AddressBook.AddressbookReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Person() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Person(Person other) : this() { name_ = other.name_; id_ = other.id_; email_ = other.email_; phones_ = other.phones_.Clone(); + lastUpdated_ = other.lastUpdated_ != null ? other.lastUpdated_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Person Clone() { return new Person(this); } @@ -79,6 +90,7 @@ public Person Clone() { /// Field number for the "name" field. public const int NameFieldNumber = 1; private string name_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -90,8 +102,9 @@ public string Name { public const int IdFieldNumber = 2; private int id_; /// - /// Unique ID number for this person. + /// Unique ID number for this person. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Id { get { return id_; } set { @@ -102,6 +115,7 @@ public int Id { /// Field number for the "email" field. public const int EmailFieldNumber = 3; private string email_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Email { get { return email_; } set { @@ -114,14 +128,28 @@ public string Email { private static readonly pb::FieldCodec _repeated_phones_codec = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber.Parser); private readonly pbc::RepeatedField phones_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Phones { get { return phones_; } } + /// Field number for the "last_updated" field. + public const int LastUpdatedFieldNumber = 5; + private global::Google.Protobuf.WellKnownTypes.Timestamp lastUpdated_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.WellKnownTypes.Timestamp LastUpdated { + get { return lastUpdated_; } + set { + lastUpdated_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Person); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Person other) { if (ReferenceEquals(other, null)) { return false; @@ -133,22 +161,30 @@ public bool Equals(Person other) { if (Id != other.Id) return false; if (Email != other.Email) return false; if(!phones_.Equals(other.phones_)) return false; - return true; + if (!object.Equals(LastUpdated, other.LastUpdated)) return false; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); if (Id != 0) hash ^= Id.GetHashCode(); if (Email.Length != 0) hash ^= Email.GetHashCode(); hash ^= phones_.GetHashCode(); + if (lastUpdated_ != null) hash ^= LastUpdated.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -163,8 +199,16 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteString(Email); } phones_.WriteTo(output, _repeated_phones_codec); + if (lastUpdated_ != null) { + output.WriteRawTag(42); + output.WriteMessage(LastUpdated); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -177,9 +221,16 @@ public int CalculateSize() { size += 1 + pb::CodedOutputStream.ComputeStringSize(Email); } size += phones_.CalculateSize(_repeated_phones_codec); + if (lastUpdated_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(LastUpdated); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Person other) { if (other == null) { return; @@ -194,14 +245,22 @@ public void MergeFrom(Person other) { Email = other.Email; } phones_.Add(other.phones_); + if (other.lastUpdated_ != null) { + if (lastUpdated_ == null) { + LastUpdated = new global::Google.Protobuf.WellKnownTypes.Timestamp(); + } + LastUpdated.MergeFrom(other.LastUpdated); + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Name = input.ReadString(); @@ -219,13 +278,20 @@ public void MergeFrom(pb::CodedInputStream input) { phones_.AddEntriesFrom(input, _repeated_phones_codec); break; } + case 42: { + if (lastUpdated_ == null) { + LastUpdated = new global::Google.Protobuf.WellKnownTypes.Timestamp(); + } + input.ReadMessage(LastUpdated); + break; + } } } } #region Nested types /// Container for nested types declared in the Person message type. - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { public enum PhoneType { [pbr::OriginalName("MOBILE")] Mobile = 0, @@ -233,30 +299,37 @@ public enum PhoneType { [pbr::OriginalName("WORK")] Work = 2, } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class PhoneNumber : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PhoneNumber()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.Examples.AddressBook.Person.Descriptor.NestedTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public PhoneNumber() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public PhoneNumber(PhoneNumber other) : this() { number_ = other.number_; type_ = other.type_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public PhoneNumber Clone() { return new PhoneNumber(this); } @@ -264,6 +337,7 @@ public PhoneNumber Clone() { /// Field number for the "number" field. public const int NumberFieldNumber = 1; private string number_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Number { get { return number_; } set { @@ -273,7 +347,8 @@ public string Number { /// Field number for the "type" field. public const int TypeFieldNumber = 2; - private global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType type_ = 0; + private global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType type_ = global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.Mobile; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType Type { get { return type_; } set { @@ -281,10 +356,12 @@ public string Number { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as PhoneNumber); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(PhoneNumber other) { if (ReferenceEquals(other, null)) { return false; @@ -294,42 +371,56 @@ public bool Equals(PhoneNumber other) { } if (Number != other.Number) return false; if (Type != other.Type) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Number.Length != 0) hash ^= Number.GetHashCode(); - if (Type != 0) hash ^= Type.GetHashCode(); + if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.Mobile) hash ^= Type.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Number.Length != 0) { output.WriteRawTag(10); output.WriteString(Number); } - if (Type != 0) { + if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.Mobile) { output.WriteRawTag(16); output.WriteEnum((int) Type); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Number.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Number); } - if (Type != 0) { + if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.Mobile) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(PhoneNumber other) { if (other == null) { return; @@ -337,24 +428,26 @@ public void MergeFrom(PhoneNumber other) { if (other.Number.Length != 0) { Number = other.Number; } - if (other.Type != 0) { + if (other.Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.Mobile) { Type = other.Type; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Number = input.ReadString(); break; } case 16: { - type_ = (global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType) input.ReadEnum(); + Type = (global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType) input.ReadEnum(); break; } } @@ -369,31 +462,38 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Our address book file is just one of these. + /// Our address book file is just one of these. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class AddressBook : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AddressBook()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.Examples.AddressBook.AddressbookReflection.Descriptor.MessageTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public AddressBook() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public AddressBook(AddressBook other) : this() { people_ = other.people_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public AddressBook Clone() { return new AddressBook(this); } @@ -403,14 +503,17 @@ public AddressBook Clone() { private static readonly pb::FieldCodec _repeated_people_codec = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.Examples.AddressBook.Person.Parser); private readonly pbc::RepeatedField people_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField People { get { return people_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as AddressBook); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(AddressBook other) { if (ReferenceEquals(other, null)) { return false; @@ -419,42 +522,58 @@ public bool Equals(AddressBook other) { return true; } if(!people_.Equals(other.people_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= people_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { people_.WriteTo(output, _repeated_people_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += people_.CalculateSize(_repeated_people_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(AddressBook other) { if (other == null) { return; } people_.Add(other.people_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { people_.AddEntriesFrom(input, _repeated_people_codec); diff --git a/third_party/protobuf/csharp/src/AddressBook/ListPeople.cs b/third_party/protobuf/csharp/src/AddressBook/ListPeople.cs index 71572289d4c8..3758c1bce5f8 100644 --- a/third_party/protobuf/csharp/src/AddressBook/ListPeople.cs +++ b/third_party/protobuf/csharp/src/AddressBook/ListPeople.cs @@ -1,99 +1,99 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; -using System.IO; - -namespace Google.Protobuf.Examples.AddressBook -{ - internal class ListPeople - { - /// - /// Iterates though all people in the AddressBook and prints info about them. - /// - private static void Print(AddressBook addressBook) - { - foreach (Person person in addressBook.People) - { - Console.WriteLine("Person ID: {0}", person.Id); - Console.WriteLine(" Name: {0}", person.Name); - if (person.Email != "") - { - Console.WriteLine(" E-mail address: {0}", person.Email); - } - - foreach (Person.Types.PhoneNumber phoneNumber in person.Phones) - { - switch (phoneNumber.Type) - { - case Person.Types.PhoneType.Mobile: - Console.Write(" Mobile phone #: "); - break; - case Person.Types.PhoneType.Home: - Console.Write(" Home phone #: "); - break; - case Person.Types.PhoneType.Work: - Console.Write(" Work phone #: "); - break; - } - Console.WriteLine(phoneNumber.Number); - } - } - } - - /// - /// Entry point - loads the addressbook and then displays it. - /// - public static int Main(string[] args) - { - if (args.Length != 1) - { - Console.Error.WriteLine("Usage: ListPeople ADDRESS_BOOK_FILE"); - return 1; - } - - if (!File.Exists(args[0])) - { - Console.WriteLine("{0} doesn't exist. Add a person to create the file first.", args[0]); - return 0; - } - - // Read the existing address book. - using (Stream stream = File.OpenRead(args[0])) - { - AddressBook addressBook = AddressBook.Parser.ParseFrom(stream); - Print(addressBook); - } - return 0; - } - } +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.IO; + +namespace Google.Protobuf.Examples.AddressBook +{ + internal class ListPeople + { + /// + /// Iterates though all people in the AddressBook and prints info about them. + /// + private static void Print(AddressBook addressBook) + { + foreach (Person person in addressBook.People) + { + Console.WriteLine("Person ID: {0}", person.Id); + Console.WriteLine(" Name: {0}", person.Name); + if (person.Email != "") + { + Console.WriteLine(" E-mail address: {0}", person.Email); + } + + foreach (Person.Types.PhoneNumber phoneNumber in person.Phones) + { + switch (phoneNumber.Type) + { + case Person.Types.PhoneType.Mobile: + Console.Write(" Mobile phone #: "); + break; + case Person.Types.PhoneType.Home: + Console.Write(" Home phone #: "); + break; + case Person.Types.PhoneType.Work: + Console.Write(" Work phone #: "); + break; + } + Console.WriteLine(phoneNumber.Number); + } + } + } + + /// + /// Entry point - loads the addressbook and then displays it. + /// + public static int Main(string[] args) + { + if (args.Length != 1) + { + Console.Error.WriteLine("Usage: ListPeople ADDRESS_BOOK_FILE"); + return 1; + } + + if (!File.Exists(args[0])) + { + Console.WriteLine("{0} doesn't exist. Add a person to create the file first.", args[0]); + return 0; + } + + // Read the existing address book. + using (Stream stream = File.OpenRead(args[0])) + { + AddressBook addressBook = AddressBook.Parser.ParseFrom(stream); + Print(addressBook); + } + return 0; + } + } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/AddressBook/Program.cs b/third_party/protobuf/csharp/src/AddressBook/Program.cs index 8164f4417949..ff7b9c085e07 100644 --- a/third_party/protobuf/csharp/src/AddressBook/Program.cs +++ b/third_party/protobuf/csharp/src/AddressBook/Program.cs @@ -1,95 +1,95 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; - -namespace Google.Protobuf.Examples.AddressBook -{ - /// - /// Entry point. Repeatedly prompts user for an action to take, delegating actual behaviour - /// to individual actions. Each action has its own Main method, so that it can be used as an - /// invidual complete program. - /// - internal class Program - { - private static int Main(string[] args) - { - if (args.Length > 1) - { - Console.Error.WriteLine("Usage: AddressBook [file]"); - Console.Error.WriteLine("If the filename isn't specified, \"addressbook.data\" is used instead."); - return 1; - } - string addressBookFile = args.Length > 0 ? args[0] : "addressbook.data"; - - bool stopping = false; - while (!stopping) - { - Console.WriteLine("Options:"); - Console.WriteLine(" L: List contents"); - Console.WriteLine(" A: Add new person"); - Console.WriteLine(" Q: Quit"); - Console.Write("Action? "); - Console.Out.Flush(); - char choice = Console.ReadKey().KeyChar; - Console.WriteLine(); - try - { - switch (choice) - { - case 'A': - case 'a': - AddPerson.Main(new string[] {addressBookFile}); - break; - case 'L': - case 'l': - ListPeople.Main(new string[] {addressBookFile}); - break; - case 'Q': - case 'q': - stopping = true; - break; - default: - Console.WriteLine("Unknown option: {0}", choice); - break; - } - } - catch (Exception e) - { - Console.WriteLine("Exception executing action: {0}", e); - } - Console.WriteLine(); - } - return 0; - } - } +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; + +namespace Google.Protobuf.Examples.AddressBook +{ + /// + /// Entry point. Repeatedly prompts user for an action to take, delegating actual behaviour + /// to individual actions. Each action has its own Main method, so that it can be used as an + /// invidual complete program. + /// + internal class Program + { + private static int Main(string[] args) + { + if (args.Length > 1) + { + Console.Error.WriteLine("Usage: AddressBook [file]"); + Console.Error.WriteLine("If the filename isn't specified, \"addressbook.data\" is used instead."); + return 1; + } + string addressBookFile = args.Length > 0 ? args[0] : "addressbook.data"; + + bool stopping = false; + while (!stopping) + { + Console.WriteLine("Options:"); + Console.WriteLine(" L: List contents"); + Console.WriteLine(" A: Add new person"); + Console.WriteLine(" Q: Quit"); + Console.Write("Action? "); + Console.Out.Flush(); + char choice = Console.ReadKey().KeyChar; + Console.WriteLine(); + try + { + switch (choice) + { + case 'A': + case 'a': + AddPerson.Main(new string[] {addressBookFile}); + break; + case 'L': + case 'l': + ListPeople.Main(new string[] {addressBookFile}); + break; + case 'Q': + case 'q': + stopping = true; + break; + default: + Console.WriteLine("Unknown option: {0}", choice); + break; + } + } + catch (Exception e) + { + Console.WriteLine("Exception executing action: {0}", e); + } + Console.WriteLine(); + } + return 0; + } + } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/AddressBook/Properties/AssemblyInfo.cs b/third_party/protobuf/csharp/src/AddressBook/Properties/AssemblyInfo.cs deleted file mode 100644 index 1452f7a41101..000000000000 --- a/third_party/protobuf/csharp/src/AddressBook/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("AddressBook")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("AddressBook")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -[assembly: AssemblyVersion("3.0.0.0")] -[assembly: AssemblyFileVersion("3.0.0.0")] diff --git a/third_party/protobuf/csharp/src/AddressBook/SampleUsage.cs b/third_party/protobuf/csharp/src/AddressBook/SampleUsage.cs index aad7d700278a..941d865aa48b 100644 --- a/third_party/protobuf/csharp/src/AddressBook/SampleUsage.cs +++ b/third_party/protobuf/csharp/src/AddressBook/SampleUsage.cs @@ -1,73 +1,73 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; -using System.IO; - -namespace Google.Protobuf.Examples.AddressBook -{ - internal class SampleUsage - { - private static void Main() - { - byte[] bytes; - // Create a new person - Person person = new Person - { - Id = 1, - Name = "Foo", - Email = "foo@bar", - Phones = { new Person.Types.PhoneNumber { Number = "555-1212" } } - }; - using (MemoryStream stream = new MemoryStream()) - { - // Save the person to a stream - person.WriteTo(stream); - bytes = stream.ToArray(); - } - Person copy = Person.Parser.ParseFrom(bytes); - - AddressBook book = new AddressBook - { - People = { copy } - }; - bytes = book.ToByteArray(); - // And read the address book back again - AddressBook restored = AddressBook.Parser.ParseFrom(bytes); - // The message performs a deep-comparison on equality: - if (restored.People.Count != 1 || !person.Equals(restored.People[0])) - { - throw new ApplicationException("There is a bad person in here!"); - } - } - } +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.IO; + +namespace Google.Protobuf.Examples.AddressBook +{ + internal class SampleUsage + { + private static void Main() + { + byte[] bytes; + // Create a new person + Person person = new Person + { + Id = 1, + Name = "Foo", + Email = "foo@bar", + Phones = { new Person.Types.PhoneNumber { Number = "555-1212" } } + }; + using (MemoryStream stream = new MemoryStream()) + { + // Save the person to a stream + person.WriteTo(stream); + bytes = stream.ToArray(); + } + Person copy = Person.Parser.ParseFrom(bytes); + + AddressBook book = new AddressBook + { + People = { copy } + }; + bytes = book.ToByteArray(); + // And read the address book back again + AddressBook restored = AddressBook.Parser.ParseFrom(bytes); + // The message performs a deep-comparison on equality: + if (restored.People.Count != 1 || !person.Equals(restored.People[0])) + { + throw new Exception("There is a bad person in here!"); + } + } + } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/AddressBook/app.config b/third_party/protobuf/csharp/src/AddressBook/app.config deleted file mode 100644 index a80813afe3fe..000000000000 --- a/third_party/protobuf/csharp/src/AddressBook/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs new file mode 100644 index 000000000000..9e8c330a2b63 --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs @@ -0,0 +1,1980 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: datasets/google_message1/proto3/benchmark_message1_proto3.proto +// +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Benchmarks.Proto3 { + + /// Holder for reflection information generated from datasets/google_message1/proto3/benchmark_message1_proto3.proto + public static partial class BenchmarkMessage1Proto3Reflection { + + #region Descriptor + /// File descriptor for datasets/google_message1/proto3/benchmark_message1_proto3.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static BenchmarkMessage1Proto3Reflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Cj9kYXRhc2V0cy9nb29nbGVfbWVzc2FnZTEvcHJvdG8zL2JlbmNobWFya19t", + "ZXNzYWdlMV9wcm90bzMucHJvdG8SEWJlbmNobWFya3MucHJvdG8zIoMGCg5H", + "b29nbGVNZXNzYWdlMRIOCgZmaWVsZDEYASABKAkSDgoGZmllbGQ5GAkgASgJ", + "Eg8KB2ZpZWxkMTgYEiABKAkSDwoHZmllbGQ4MBhQIAEoCBIPCgdmaWVsZDgx", + "GFEgASgIEg4KBmZpZWxkMhgCIAEoBRIOCgZmaWVsZDMYAyABKAUSEQoIZmll", + "bGQyODAYmAIgASgFEg4KBmZpZWxkNhgGIAEoBRIPCgdmaWVsZDIyGBYgASgD", + "Eg4KBmZpZWxkNBgEIAEoCRIOCgZmaWVsZDUYBSADKAYSDwoHZmllbGQ1ORg7", + "IAEoCBIOCgZmaWVsZDcYByABKAkSDwoHZmllbGQxNhgQIAEoBRIRCghmaWVs", + "ZDEzMBiCASABKAUSDwoHZmllbGQxMhgMIAEoCBIPCgdmaWVsZDE3GBEgASgI", + "Eg8KB2ZpZWxkMTMYDSABKAgSDwoHZmllbGQxNBgOIAEoCBIQCghmaWVsZDEw", + "NBhoIAEoBRIQCghmaWVsZDEwMBhkIAEoBRIQCghmaWVsZDEwMRhlIAEoBRIQ", + "CghmaWVsZDEwMhhmIAEoCRIQCghmaWVsZDEwMxhnIAEoCRIPCgdmaWVsZDI5", + "GB0gASgFEg8KB2ZpZWxkMzAYHiABKAgSDwoHZmllbGQ2MBg8IAEoBRIRCghm", + "aWVsZDI3MRiPAiABKAUSEQoIZmllbGQyNzIYkAIgASgFEhEKCGZpZWxkMTUw", + "GJYBIAEoBRIPCgdmaWVsZDIzGBcgASgFEg8KB2ZpZWxkMjQYGCABKAgSDwoH", + "ZmllbGQyNRgZIAEoBRI8CgdmaWVsZDE1GA8gASgLMisuYmVuY2htYXJrcy5w", + "cm90bzMuR29vZ2xlTWVzc2FnZTFTdWJNZXNzYWdlEg8KB2ZpZWxkNzgYTiAB", + "KAgSDwoHZmllbGQ2NxhDIAEoBRIPCgdmaWVsZDY4GEQgASgFEhEKCGZpZWxk", + "MTI4GIABIAEoBRIRCghmaWVsZDEyORiBASABKAkSEQoIZmllbGQxMzEYgwEg", + "ASgFIvcCChhHb29nbGVNZXNzYWdlMVN1Yk1lc3NhZ2USDgoGZmllbGQxGAEg", + "ASgFEg4KBmZpZWxkMhgCIAEoBRIOCgZmaWVsZDMYAyABKAUSDwoHZmllbGQx", + "NRgPIAEoCRIPCgdmaWVsZDEyGAwgASgIEg8KB2ZpZWxkMTMYDSABKAMSDwoH", + "ZmllbGQxNBgOIAEoAxIPCgdmaWVsZDE2GBAgASgFEg8KB2ZpZWxkMTkYEyAB", + "KAUSDwoHZmllbGQyMBgUIAEoCBIPCgdmaWVsZDI4GBwgASgIEg8KB2ZpZWxk", + "MjEYFSABKAYSDwoHZmllbGQyMhgWIAEoBRIPCgdmaWVsZDIzGBcgASgIEhEK", + "CGZpZWxkMjA2GM4BIAEoCBIRCghmaWVsZDIwMxjLASABKAcSEQoIZmllbGQy", + "MDQYzAEgASgFEhEKCGZpZWxkMjA1GM0BIAEoCRIRCghmaWVsZDIwNxjPASAB", + "KAQSEQoIZmllbGQzMDAYrAIgASgEQiUKHmNvbS5nb29nbGUucHJvdG9idWYu", + "YmVuY2htYXJrc0gB+AEBYgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Benchmarks.Proto3.GoogleMessage1), global::Benchmarks.Proto3.GoogleMessage1.Parser, new[]{ "Field1", "Field9", "Field18", "Field80", "Field81", "Field2", "Field3", "Field280", "Field6", "Field22", "Field4", "Field5", "Field59", "Field7", "Field16", "Field130", "Field12", "Field17", "Field13", "Field14", "Field104", "Field100", "Field101", "Field102", "Field103", "Field29", "Field30", "Field60", "Field271", "Field272", "Field150", "Field23", "Field24", "Field25", "Field15", "Field78", "Field67", "Field68", "Field128", "Field129", "Field131" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Benchmarks.Proto3.GoogleMessage1SubMessage), global::Benchmarks.Proto3.GoogleMessage1SubMessage.Parser, new[]{ "Field1", "Field2", "Field3", "Field15", "Field12", "Field13", "Field14", "Field16", "Field19", "Field20", "Field28", "Field21", "Field22", "Field23", "Field206", "Field203", "Field204", "Field205", "Field207", "Field300" }, null, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class GoogleMessage1 : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new GoogleMessage1()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Benchmarks.Proto3.BenchmarkMessage1Proto3Reflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public GoogleMessage1() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public GoogleMessage1(GoogleMessage1 other) : this() { + field1_ = other.field1_; + field9_ = other.field9_; + field18_ = other.field18_; + field80_ = other.field80_; + field81_ = other.field81_; + field2_ = other.field2_; + field3_ = other.field3_; + field280_ = other.field280_; + field6_ = other.field6_; + field22_ = other.field22_; + field4_ = other.field4_; + field5_ = other.field5_.Clone(); + field59_ = other.field59_; + field7_ = other.field7_; + field16_ = other.field16_; + field130_ = other.field130_; + field12_ = other.field12_; + field17_ = other.field17_; + field13_ = other.field13_; + field14_ = other.field14_; + field104_ = other.field104_; + field100_ = other.field100_; + field101_ = other.field101_; + field102_ = other.field102_; + field103_ = other.field103_; + field29_ = other.field29_; + field30_ = other.field30_; + field60_ = other.field60_; + field271_ = other.field271_; + field272_ = other.field272_; + field150_ = other.field150_; + field23_ = other.field23_; + field24_ = other.field24_; + field25_ = other.field25_; + field15_ = other.field15_ != null ? other.field15_.Clone() : null; + field78_ = other.field78_; + field67_ = other.field67_; + field68_ = other.field68_; + field128_ = other.field128_; + field129_ = other.field129_; + field131_ = other.field131_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public GoogleMessage1 Clone() { + return new GoogleMessage1(this); + } + + /// Field number for the "field1" field. + public const int Field1FieldNumber = 1; + private string field1_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Field1 { + get { return field1_; } + set { + field1_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "field9" field. + public const int Field9FieldNumber = 9; + private string field9_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Field9 { + get { return field9_; } + set { + field9_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "field18" field. + public const int Field18FieldNumber = 18; + private string field18_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Field18 { + get { return field18_; } + set { + field18_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "field80" field. + public const int Field80FieldNumber = 80; + private bool field80_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Field80 { + get { return field80_; } + set { + field80_ = value; + } + } + + /// Field number for the "field81" field. + public const int Field81FieldNumber = 81; + private bool field81_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Field81 { + get { return field81_; } + set { + field81_ = value; + } + } + + /// Field number for the "field2" field. + public const int Field2FieldNumber = 2; + private int field2_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field2 { + get { return field2_; } + set { + field2_ = value; + } + } + + /// Field number for the "field3" field. + public const int Field3FieldNumber = 3; + private int field3_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field3 { + get { return field3_; } + set { + field3_ = value; + } + } + + /// Field number for the "field280" field. + public const int Field280FieldNumber = 280; + private int field280_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field280 { + get { return field280_; } + set { + field280_ = value; + } + } + + /// Field number for the "field6" field. + public const int Field6FieldNumber = 6; + private int field6_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field6 { + get { return field6_; } + set { + field6_ = value; + } + } + + /// Field number for the "field22" field. + public const int Field22FieldNumber = 22; + private long field22_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Field22 { + get { return field22_; } + set { + field22_ = value; + } + } + + /// Field number for the "field4" field. + public const int Field4FieldNumber = 4; + private string field4_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Field4 { + get { return field4_; } + set { + field4_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "field5" field. + public const int Field5FieldNumber = 5; + private static readonly pb::FieldCodec _repeated_field5_codec + = pb::FieldCodec.ForFixed64(42); + private readonly pbc::RepeatedField field5_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Field5 { + get { return field5_; } + } + + /// Field number for the "field59" field. + public const int Field59FieldNumber = 59; + private bool field59_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Field59 { + get { return field59_; } + set { + field59_ = value; + } + } + + /// Field number for the "field7" field. + public const int Field7FieldNumber = 7; + private string field7_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Field7 { + get { return field7_; } + set { + field7_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "field16" field. + public const int Field16FieldNumber = 16; + private int field16_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field16 { + get { return field16_; } + set { + field16_ = value; + } + } + + /// Field number for the "field130" field. + public const int Field130FieldNumber = 130; + private int field130_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field130 { + get { return field130_; } + set { + field130_ = value; + } + } + + /// Field number for the "field12" field. + public const int Field12FieldNumber = 12; + private bool field12_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Field12 { + get { return field12_; } + set { + field12_ = value; + } + } + + /// Field number for the "field17" field. + public const int Field17FieldNumber = 17; + private bool field17_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Field17 { + get { return field17_; } + set { + field17_ = value; + } + } + + /// Field number for the "field13" field. + public const int Field13FieldNumber = 13; + private bool field13_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Field13 { + get { return field13_; } + set { + field13_ = value; + } + } + + /// Field number for the "field14" field. + public const int Field14FieldNumber = 14; + private bool field14_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Field14 { + get { return field14_; } + set { + field14_ = value; + } + } + + /// Field number for the "field104" field. + public const int Field104FieldNumber = 104; + private int field104_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field104 { + get { return field104_; } + set { + field104_ = value; + } + } + + /// Field number for the "field100" field. + public const int Field100FieldNumber = 100; + private int field100_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field100 { + get { return field100_; } + set { + field100_ = value; + } + } + + /// Field number for the "field101" field. + public const int Field101FieldNumber = 101; + private int field101_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field101 { + get { return field101_; } + set { + field101_ = value; + } + } + + /// Field number for the "field102" field. + public const int Field102FieldNumber = 102; + private string field102_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Field102 { + get { return field102_; } + set { + field102_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "field103" field. + public const int Field103FieldNumber = 103; + private string field103_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Field103 { + get { return field103_; } + set { + field103_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "field29" field. + public const int Field29FieldNumber = 29; + private int field29_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field29 { + get { return field29_; } + set { + field29_ = value; + } + } + + /// Field number for the "field30" field. + public const int Field30FieldNumber = 30; + private bool field30_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Field30 { + get { return field30_; } + set { + field30_ = value; + } + } + + /// Field number for the "field60" field. + public const int Field60FieldNumber = 60; + private int field60_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field60 { + get { return field60_; } + set { + field60_ = value; + } + } + + /// Field number for the "field271" field. + public const int Field271FieldNumber = 271; + private int field271_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field271 { + get { return field271_; } + set { + field271_ = value; + } + } + + /// Field number for the "field272" field. + public const int Field272FieldNumber = 272; + private int field272_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field272 { + get { return field272_; } + set { + field272_ = value; + } + } + + /// Field number for the "field150" field. + public const int Field150FieldNumber = 150; + private int field150_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field150 { + get { return field150_; } + set { + field150_ = value; + } + } + + /// Field number for the "field23" field. + public const int Field23FieldNumber = 23; + private int field23_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field23 { + get { return field23_; } + set { + field23_ = value; + } + } + + /// Field number for the "field24" field. + public const int Field24FieldNumber = 24; + private bool field24_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Field24 { + get { return field24_; } + set { + field24_ = value; + } + } + + /// Field number for the "field25" field. + public const int Field25FieldNumber = 25; + private int field25_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field25 { + get { return field25_; } + set { + field25_ = value; + } + } + + /// Field number for the "field15" field. + public const int Field15FieldNumber = 15; + private global::Benchmarks.Proto3.GoogleMessage1SubMessage field15_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Benchmarks.Proto3.GoogleMessage1SubMessage Field15 { + get { return field15_; } + set { + field15_ = value; + } + } + + /// Field number for the "field78" field. + public const int Field78FieldNumber = 78; + private bool field78_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Field78 { + get { return field78_; } + set { + field78_ = value; + } + } + + /// Field number for the "field67" field. + public const int Field67FieldNumber = 67; + private int field67_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field67 { + get { return field67_; } + set { + field67_ = value; + } + } + + /// Field number for the "field68" field. + public const int Field68FieldNumber = 68; + private int field68_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field68 { + get { return field68_; } + set { + field68_ = value; + } + } + + /// Field number for the "field128" field. + public const int Field128FieldNumber = 128; + private int field128_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field128 { + get { return field128_; } + set { + field128_ = value; + } + } + + /// Field number for the "field129" field. + public const int Field129FieldNumber = 129; + private string field129_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Field129 { + get { return field129_; } + set { + field129_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "field131" field. + public const int Field131FieldNumber = 131; + private int field131_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field131 { + get { return field131_; } + set { + field131_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as GoogleMessage1); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(GoogleMessage1 other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Field1 != other.Field1) return false; + if (Field9 != other.Field9) return false; + if (Field18 != other.Field18) return false; + if (Field80 != other.Field80) return false; + if (Field81 != other.Field81) return false; + if (Field2 != other.Field2) return false; + if (Field3 != other.Field3) return false; + if (Field280 != other.Field280) return false; + if (Field6 != other.Field6) return false; + if (Field22 != other.Field22) return false; + if (Field4 != other.Field4) return false; + if(!field5_.Equals(other.field5_)) return false; + if (Field59 != other.Field59) return false; + if (Field7 != other.Field7) return false; + if (Field16 != other.Field16) return false; + if (Field130 != other.Field130) return false; + if (Field12 != other.Field12) return false; + if (Field17 != other.Field17) return false; + if (Field13 != other.Field13) return false; + if (Field14 != other.Field14) return false; + if (Field104 != other.Field104) return false; + if (Field100 != other.Field100) return false; + if (Field101 != other.Field101) return false; + if (Field102 != other.Field102) return false; + if (Field103 != other.Field103) return false; + if (Field29 != other.Field29) return false; + if (Field30 != other.Field30) return false; + if (Field60 != other.Field60) return false; + if (Field271 != other.Field271) return false; + if (Field272 != other.Field272) return false; + if (Field150 != other.Field150) return false; + if (Field23 != other.Field23) return false; + if (Field24 != other.Field24) return false; + if (Field25 != other.Field25) return false; + if (!object.Equals(Field15, other.Field15)) return false; + if (Field78 != other.Field78) return false; + if (Field67 != other.Field67) return false; + if (Field68 != other.Field68) return false; + if (Field128 != other.Field128) return false; + if (Field129 != other.Field129) return false; + if (Field131 != other.Field131) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Field1.Length != 0) hash ^= Field1.GetHashCode(); + if (Field9.Length != 0) hash ^= Field9.GetHashCode(); + if (Field18.Length != 0) hash ^= Field18.GetHashCode(); + if (Field80 != false) hash ^= Field80.GetHashCode(); + if (Field81 != false) hash ^= Field81.GetHashCode(); + if (Field2 != 0) hash ^= Field2.GetHashCode(); + if (Field3 != 0) hash ^= Field3.GetHashCode(); + if (Field280 != 0) hash ^= Field280.GetHashCode(); + if (Field6 != 0) hash ^= Field6.GetHashCode(); + if (Field22 != 0L) hash ^= Field22.GetHashCode(); + if (Field4.Length != 0) hash ^= Field4.GetHashCode(); + hash ^= field5_.GetHashCode(); + if (Field59 != false) hash ^= Field59.GetHashCode(); + if (Field7.Length != 0) hash ^= Field7.GetHashCode(); + if (Field16 != 0) hash ^= Field16.GetHashCode(); + if (Field130 != 0) hash ^= Field130.GetHashCode(); + if (Field12 != false) hash ^= Field12.GetHashCode(); + if (Field17 != false) hash ^= Field17.GetHashCode(); + if (Field13 != false) hash ^= Field13.GetHashCode(); + if (Field14 != false) hash ^= Field14.GetHashCode(); + if (Field104 != 0) hash ^= Field104.GetHashCode(); + if (Field100 != 0) hash ^= Field100.GetHashCode(); + if (Field101 != 0) hash ^= Field101.GetHashCode(); + if (Field102.Length != 0) hash ^= Field102.GetHashCode(); + if (Field103.Length != 0) hash ^= Field103.GetHashCode(); + if (Field29 != 0) hash ^= Field29.GetHashCode(); + if (Field30 != false) hash ^= Field30.GetHashCode(); + if (Field60 != 0) hash ^= Field60.GetHashCode(); + if (Field271 != 0) hash ^= Field271.GetHashCode(); + if (Field272 != 0) hash ^= Field272.GetHashCode(); + if (Field150 != 0) hash ^= Field150.GetHashCode(); + if (Field23 != 0) hash ^= Field23.GetHashCode(); + if (Field24 != false) hash ^= Field24.GetHashCode(); + if (Field25 != 0) hash ^= Field25.GetHashCode(); + if (field15_ != null) hash ^= Field15.GetHashCode(); + if (Field78 != false) hash ^= Field78.GetHashCode(); + if (Field67 != 0) hash ^= Field67.GetHashCode(); + if (Field68 != 0) hash ^= Field68.GetHashCode(); + if (Field128 != 0) hash ^= Field128.GetHashCode(); + if (Field129.Length != 0) hash ^= Field129.GetHashCode(); + if (Field131 != 0) hash ^= Field131.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Field1.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Field1); + } + if (Field2 != 0) { + output.WriteRawTag(16); + output.WriteInt32(Field2); + } + if (Field3 != 0) { + output.WriteRawTag(24); + output.WriteInt32(Field3); + } + if (Field4.Length != 0) { + output.WriteRawTag(34); + output.WriteString(Field4); + } + field5_.WriteTo(output, _repeated_field5_codec); + if (Field6 != 0) { + output.WriteRawTag(48); + output.WriteInt32(Field6); + } + if (Field7.Length != 0) { + output.WriteRawTag(58); + output.WriteString(Field7); + } + if (Field9.Length != 0) { + output.WriteRawTag(74); + output.WriteString(Field9); + } + if (Field12 != false) { + output.WriteRawTag(96); + output.WriteBool(Field12); + } + if (Field13 != false) { + output.WriteRawTag(104); + output.WriteBool(Field13); + } + if (Field14 != false) { + output.WriteRawTag(112); + output.WriteBool(Field14); + } + if (field15_ != null) { + output.WriteRawTag(122); + output.WriteMessage(Field15); + } + if (Field16 != 0) { + output.WriteRawTag(128, 1); + output.WriteInt32(Field16); + } + if (Field17 != false) { + output.WriteRawTag(136, 1); + output.WriteBool(Field17); + } + if (Field18.Length != 0) { + output.WriteRawTag(146, 1); + output.WriteString(Field18); + } + if (Field22 != 0L) { + output.WriteRawTag(176, 1); + output.WriteInt64(Field22); + } + if (Field23 != 0) { + output.WriteRawTag(184, 1); + output.WriteInt32(Field23); + } + if (Field24 != false) { + output.WriteRawTag(192, 1); + output.WriteBool(Field24); + } + if (Field25 != 0) { + output.WriteRawTag(200, 1); + output.WriteInt32(Field25); + } + if (Field29 != 0) { + output.WriteRawTag(232, 1); + output.WriteInt32(Field29); + } + if (Field30 != false) { + output.WriteRawTag(240, 1); + output.WriteBool(Field30); + } + if (Field59 != false) { + output.WriteRawTag(216, 3); + output.WriteBool(Field59); + } + if (Field60 != 0) { + output.WriteRawTag(224, 3); + output.WriteInt32(Field60); + } + if (Field67 != 0) { + output.WriteRawTag(152, 4); + output.WriteInt32(Field67); + } + if (Field68 != 0) { + output.WriteRawTag(160, 4); + output.WriteInt32(Field68); + } + if (Field78 != false) { + output.WriteRawTag(240, 4); + output.WriteBool(Field78); + } + if (Field80 != false) { + output.WriteRawTag(128, 5); + output.WriteBool(Field80); + } + if (Field81 != false) { + output.WriteRawTag(136, 5); + output.WriteBool(Field81); + } + if (Field100 != 0) { + output.WriteRawTag(160, 6); + output.WriteInt32(Field100); + } + if (Field101 != 0) { + output.WriteRawTag(168, 6); + output.WriteInt32(Field101); + } + if (Field102.Length != 0) { + output.WriteRawTag(178, 6); + output.WriteString(Field102); + } + if (Field103.Length != 0) { + output.WriteRawTag(186, 6); + output.WriteString(Field103); + } + if (Field104 != 0) { + output.WriteRawTag(192, 6); + output.WriteInt32(Field104); + } + if (Field128 != 0) { + output.WriteRawTag(128, 8); + output.WriteInt32(Field128); + } + if (Field129.Length != 0) { + output.WriteRawTag(138, 8); + output.WriteString(Field129); + } + if (Field130 != 0) { + output.WriteRawTag(144, 8); + output.WriteInt32(Field130); + } + if (Field131 != 0) { + output.WriteRawTag(152, 8); + output.WriteInt32(Field131); + } + if (Field150 != 0) { + output.WriteRawTag(176, 9); + output.WriteInt32(Field150); + } + if (Field271 != 0) { + output.WriteRawTag(248, 16); + output.WriteInt32(Field271); + } + if (Field272 != 0) { + output.WriteRawTag(128, 17); + output.WriteInt32(Field272); + } + if (Field280 != 0) { + output.WriteRawTag(192, 17); + output.WriteInt32(Field280); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Field1.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Field1); + } + if (Field9.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Field9); + } + if (Field18.Length != 0) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(Field18); + } + if (Field80 != false) { + size += 2 + 1; + } + if (Field81 != false) { + size += 2 + 1; + } + if (Field2 != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Field2); + } + if (Field3 != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Field3); + } + if (Field280 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field280); + } + if (Field6 != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Field6); + } + if (Field22 != 0L) { + size += 2 + pb::CodedOutputStream.ComputeInt64Size(Field22); + } + if (Field4.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Field4); + } + size += field5_.CalculateSize(_repeated_field5_codec); + if (Field59 != false) { + size += 2 + 1; + } + if (Field7.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Field7); + } + if (Field16 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field16); + } + if (Field130 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field130); + } + if (Field12 != false) { + size += 1 + 1; + } + if (Field17 != false) { + size += 2 + 1; + } + if (Field13 != false) { + size += 1 + 1; + } + if (Field14 != false) { + size += 1 + 1; + } + if (Field104 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field104); + } + if (Field100 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field100); + } + if (Field101 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field101); + } + if (Field102.Length != 0) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(Field102); + } + if (Field103.Length != 0) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(Field103); + } + if (Field29 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field29); + } + if (Field30 != false) { + size += 2 + 1; + } + if (Field60 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field60); + } + if (Field271 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field271); + } + if (Field272 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field272); + } + if (Field150 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field150); + } + if (Field23 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field23); + } + if (Field24 != false) { + size += 2 + 1; + } + if (Field25 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field25); + } + if (field15_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Field15); + } + if (Field78 != false) { + size += 2 + 1; + } + if (Field67 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field67); + } + if (Field68 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field68); + } + if (Field128 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field128); + } + if (Field129.Length != 0) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(Field129); + } + if (Field131 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field131); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(GoogleMessage1 other) { + if (other == null) { + return; + } + if (other.Field1.Length != 0) { + Field1 = other.Field1; + } + if (other.Field9.Length != 0) { + Field9 = other.Field9; + } + if (other.Field18.Length != 0) { + Field18 = other.Field18; + } + if (other.Field80 != false) { + Field80 = other.Field80; + } + if (other.Field81 != false) { + Field81 = other.Field81; + } + if (other.Field2 != 0) { + Field2 = other.Field2; + } + if (other.Field3 != 0) { + Field3 = other.Field3; + } + if (other.Field280 != 0) { + Field280 = other.Field280; + } + if (other.Field6 != 0) { + Field6 = other.Field6; + } + if (other.Field22 != 0L) { + Field22 = other.Field22; + } + if (other.Field4.Length != 0) { + Field4 = other.Field4; + } + field5_.Add(other.field5_); + if (other.Field59 != false) { + Field59 = other.Field59; + } + if (other.Field7.Length != 0) { + Field7 = other.Field7; + } + if (other.Field16 != 0) { + Field16 = other.Field16; + } + if (other.Field130 != 0) { + Field130 = other.Field130; + } + if (other.Field12 != false) { + Field12 = other.Field12; + } + if (other.Field17 != false) { + Field17 = other.Field17; + } + if (other.Field13 != false) { + Field13 = other.Field13; + } + if (other.Field14 != false) { + Field14 = other.Field14; + } + if (other.Field104 != 0) { + Field104 = other.Field104; + } + if (other.Field100 != 0) { + Field100 = other.Field100; + } + if (other.Field101 != 0) { + Field101 = other.Field101; + } + if (other.Field102.Length != 0) { + Field102 = other.Field102; + } + if (other.Field103.Length != 0) { + Field103 = other.Field103; + } + if (other.Field29 != 0) { + Field29 = other.Field29; + } + if (other.Field30 != false) { + Field30 = other.Field30; + } + if (other.Field60 != 0) { + Field60 = other.Field60; + } + if (other.Field271 != 0) { + Field271 = other.Field271; + } + if (other.Field272 != 0) { + Field272 = other.Field272; + } + if (other.Field150 != 0) { + Field150 = other.Field150; + } + if (other.Field23 != 0) { + Field23 = other.Field23; + } + if (other.Field24 != false) { + Field24 = other.Field24; + } + if (other.Field25 != 0) { + Field25 = other.Field25; + } + if (other.field15_ != null) { + if (field15_ == null) { + Field15 = new global::Benchmarks.Proto3.GoogleMessage1SubMessage(); + } + Field15.MergeFrom(other.Field15); + } + if (other.Field78 != false) { + Field78 = other.Field78; + } + if (other.Field67 != 0) { + Field67 = other.Field67; + } + if (other.Field68 != 0) { + Field68 = other.Field68; + } + if (other.Field128 != 0) { + Field128 = other.Field128; + } + if (other.Field129.Length != 0) { + Field129 = other.Field129; + } + if (other.Field131 != 0) { + Field131 = other.Field131; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Field1 = input.ReadString(); + break; + } + case 16: { + Field2 = input.ReadInt32(); + break; + } + case 24: { + Field3 = input.ReadInt32(); + break; + } + case 34: { + Field4 = input.ReadString(); + break; + } + case 42: + case 41: { + field5_.AddEntriesFrom(input, _repeated_field5_codec); + break; + } + case 48: { + Field6 = input.ReadInt32(); + break; + } + case 58: { + Field7 = input.ReadString(); + break; + } + case 74: { + Field9 = input.ReadString(); + break; + } + case 96: { + Field12 = input.ReadBool(); + break; + } + case 104: { + Field13 = input.ReadBool(); + break; + } + case 112: { + Field14 = input.ReadBool(); + break; + } + case 122: { + if (field15_ == null) { + Field15 = new global::Benchmarks.Proto3.GoogleMessage1SubMessage(); + } + input.ReadMessage(Field15); + break; + } + case 128: { + Field16 = input.ReadInt32(); + break; + } + case 136: { + Field17 = input.ReadBool(); + break; + } + case 146: { + Field18 = input.ReadString(); + break; + } + case 176: { + Field22 = input.ReadInt64(); + break; + } + case 184: { + Field23 = input.ReadInt32(); + break; + } + case 192: { + Field24 = input.ReadBool(); + break; + } + case 200: { + Field25 = input.ReadInt32(); + break; + } + case 232: { + Field29 = input.ReadInt32(); + break; + } + case 240: { + Field30 = input.ReadBool(); + break; + } + case 472: { + Field59 = input.ReadBool(); + break; + } + case 480: { + Field60 = input.ReadInt32(); + break; + } + case 536: { + Field67 = input.ReadInt32(); + break; + } + case 544: { + Field68 = input.ReadInt32(); + break; + } + case 624: { + Field78 = input.ReadBool(); + break; + } + case 640: { + Field80 = input.ReadBool(); + break; + } + case 648: { + Field81 = input.ReadBool(); + break; + } + case 800: { + Field100 = input.ReadInt32(); + break; + } + case 808: { + Field101 = input.ReadInt32(); + break; + } + case 818: { + Field102 = input.ReadString(); + break; + } + case 826: { + Field103 = input.ReadString(); + break; + } + case 832: { + Field104 = input.ReadInt32(); + break; + } + case 1024: { + Field128 = input.ReadInt32(); + break; + } + case 1034: { + Field129 = input.ReadString(); + break; + } + case 1040: { + Field130 = input.ReadInt32(); + break; + } + case 1048: { + Field131 = input.ReadInt32(); + break; + } + case 1200: { + Field150 = input.ReadInt32(); + break; + } + case 2168: { + Field271 = input.ReadInt32(); + break; + } + case 2176: { + Field272 = input.ReadInt32(); + break; + } + case 2240: { + Field280 = input.ReadInt32(); + break; + } + } + } + } + + } + + public sealed partial class GoogleMessage1SubMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new GoogleMessage1SubMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Benchmarks.Proto3.BenchmarkMessage1Proto3Reflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public GoogleMessage1SubMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public GoogleMessage1SubMessage(GoogleMessage1SubMessage other) : this() { + field1_ = other.field1_; + field2_ = other.field2_; + field3_ = other.field3_; + field15_ = other.field15_; + field12_ = other.field12_; + field13_ = other.field13_; + field14_ = other.field14_; + field16_ = other.field16_; + field19_ = other.field19_; + field20_ = other.field20_; + field28_ = other.field28_; + field21_ = other.field21_; + field22_ = other.field22_; + field23_ = other.field23_; + field206_ = other.field206_; + field203_ = other.field203_; + field204_ = other.field204_; + field205_ = other.field205_; + field207_ = other.field207_; + field300_ = other.field300_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public GoogleMessage1SubMessage Clone() { + return new GoogleMessage1SubMessage(this); + } + + /// Field number for the "field1" field. + public const int Field1FieldNumber = 1; + private int field1_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field1 { + get { return field1_; } + set { + field1_ = value; + } + } + + /// Field number for the "field2" field. + public const int Field2FieldNumber = 2; + private int field2_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field2 { + get { return field2_; } + set { + field2_ = value; + } + } + + /// Field number for the "field3" field. + public const int Field3FieldNumber = 3; + private int field3_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field3 { + get { return field3_; } + set { + field3_ = value; + } + } + + /// Field number for the "field15" field. + public const int Field15FieldNumber = 15; + private string field15_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Field15 { + get { return field15_; } + set { + field15_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "field12" field. + public const int Field12FieldNumber = 12; + private bool field12_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Field12 { + get { return field12_; } + set { + field12_ = value; + } + } + + /// Field number for the "field13" field. + public const int Field13FieldNumber = 13; + private long field13_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Field13 { + get { return field13_; } + set { + field13_ = value; + } + } + + /// Field number for the "field14" field. + public const int Field14FieldNumber = 14; + private long field14_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Field14 { + get { return field14_; } + set { + field14_ = value; + } + } + + /// Field number for the "field16" field. + public const int Field16FieldNumber = 16; + private int field16_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field16 { + get { return field16_; } + set { + field16_ = value; + } + } + + /// Field number for the "field19" field. + public const int Field19FieldNumber = 19; + private int field19_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field19 { + get { return field19_; } + set { + field19_ = value; + } + } + + /// Field number for the "field20" field. + public const int Field20FieldNumber = 20; + private bool field20_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Field20 { + get { return field20_; } + set { + field20_ = value; + } + } + + /// Field number for the "field28" field. + public const int Field28FieldNumber = 28; + private bool field28_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Field28 { + get { return field28_; } + set { + field28_ = value; + } + } + + /// Field number for the "field21" field. + public const int Field21FieldNumber = 21; + private ulong field21_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ulong Field21 { + get { return field21_; } + set { + field21_ = value; + } + } + + /// Field number for the "field22" field. + public const int Field22FieldNumber = 22; + private int field22_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field22 { + get { return field22_; } + set { + field22_ = value; + } + } + + /// Field number for the "field23" field. + public const int Field23FieldNumber = 23; + private bool field23_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Field23 { + get { return field23_; } + set { + field23_ = value; + } + } + + /// Field number for the "field206" field. + public const int Field206FieldNumber = 206; + private bool field206_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Field206 { + get { return field206_; } + set { + field206_ = value; + } + } + + /// Field number for the "field203" field. + public const int Field203FieldNumber = 203; + private uint field203_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint Field203 { + get { return field203_; } + set { + field203_ = value; + } + } + + /// Field number for the "field204" field. + public const int Field204FieldNumber = 204; + private int field204_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field204 { + get { return field204_; } + set { + field204_ = value; + } + } + + /// Field number for the "field205" field. + public const int Field205FieldNumber = 205; + private string field205_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Field205 { + get { return field205_; } + set { + field205_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "field207" field. + public const int Field207FieldNumber = 207; + private ulong field207_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ulong Field207 { + get { return field207_; } + set { + field207_ = value; + } + } + + /// Field number for the "field300" field. + public const int Field300FieldNumber = 300; + private ulong field300_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ulong Field300 { + get { return field300_; } + set { + field300_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as GoogleMessage1SubMessage); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(GoogleMessage1SubMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Field1 != other.Field1) return false; + if (Field2 != other.Field2) return false; + if (Field3 != other.Field3) return false; + if (Field15 != other.Field15) return false; + if (Field12 != other.Field12) return false; + if (Field13 != other.Field13) return false; + if (Field14 != other.Field14) return false; + if (Field16 != other.Field16) return false; + if (Field19 != other.Field19) return false; + if (Field20 != other.Field20) return false; + if (Field28 != other.Field28) return false; + if (Field21 != other.Field21) return false; + if (Field22 != other.Field22) return false; + if (Field23 != other.Field23) return false; + if (Field206 != other.Field206) return false; + if (Field203 != other.Field203) return false; + if (Field204 != other.Field204) return false; + if (Field205 != other.Field205) return false; + if (Field207 != other.Field207) return false; + if (Field300 != other.Field300) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Field1 != 0) hash ^= Field1.GetHashCode(); + if (Field2 != 0) hash ^= Field2.GetHashCode(); + if (Field3 != 0) hash ^= Field3.GetHashCode(); + if (Field15.Length != 0) hash ^= Field15.GetHashCode(); + if (Field12 != false) hash ^= Field12.GetHashCode(); + if (Field13 != 0L) hash ^= Field13.GetHashCode(); + if (Field14 != 0L) hash ^= Field14.GetHashCode(); + if (Field16 != 0) hash ^= Field16.GetHashCode(); + if (Field19 != 0) hash ^= Field19.GetHashCode(); + if (Field20 != false) hash ^= Field20.GetHashCode(); + if (Field28 != false) hash ^= Field28.GetHashCode(); + if (Field21 != 0UL) hash ^= Field21.GetHashCode(); + if (Field22 != 0) hash ^= Field22.GetHashCode(); + if (Field23 != false) hash ^= Field23.GetHashCode(); + if (Field206 != false) hash ^= Field206.GetHashCode(); + if (Field203 != 0) hash ^= Field203.GetHashCode(); + if (Field204 != 0) hash ^= Field204.GetHashCode(); + if (Field205.Length != 0) hash ^= Field205.GetHashCode(); + if (Field207 != 0UL) hash ^= Field207.GetHashCode(); + if (Field300 != 0UL) hash ^= Field300.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Field1 != 0) { + output.WriteRawTag(8); + output.WriteInt32(Field1); + } + if (Field2 != 0) { + output.WriteRawTag(16); + output.WriteInt32(Field2); + } + if (Field3 != 0) { + output.WriteRawTag(24); + output.WriteInt32(Field3); + } + if (Field12 != false) { + output.WriteRawTag(96); + output.WriteBool(Field12); + } + if (Field13 != 0L) { + output.WriteRawTag(104); + output.WriteInt64(Field13); + } + if (Field14 != 0L) { + output.WriteRawTag(112); + output.WriteInt64(Field14); + } + if (Field15.Length != 0) { + output.WriteRawTag(122); + output.WriteString(Field15); + } + if (Field16 != 0) { + output.WriteRawTag(128, 1); + output.WriteInt32(Field16); + } + if (Field19 != 0) { + output.WriteRawTag(152, 1); + output.WriteInt32(Field19); + } + if (Field20 != false) { + output.WriteRawTag(160, 1); + output.WriteBool(Field20); + } + if (Field21 != 0UL) { + output.WriteRawTag(169, 1); + output.WriteFixed64(Field21); + } + if (Field22 != 0) { + output.WriteRawTag(176, 1); + output.WriteInt32(Field22); + } + if (Field23 != false) { + output.WriteRawTag(184, 1); + output.WriteBool(Field23); + } + if (Field28 != false) { + output.WriteRawTag(224, 1); + output.WriteBool(Field28); + } + if (Field203 != 0) { + output.WriteRawTag(221, 12); + output.WriteFixed32(Field203); + } + if (Field204 != 0) { + output.WriteRawTag(224, 12); + output.WriteInt32(Field204); + } + if (Field205.Length != 0) { + output.WriteRawTag(234, 12); + output.WriteString(Field205); + } + if (Field206 != false) { + output.WriteRawTag(240, 12); + output.WriteBool(Field206); + } + if (Field207 != 0UL) { + output.WriteRawTag(248, 12); + output.WriteUInt64(Field207); + } + if (Field300 != 0UL) { + output.WriteRawTag(224, 18); + output.WriteUInt64(Field300); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Field1 != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Field1); + } + if (Field2 != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Field2); + } + if (Field3 != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Field3); + } + if (Field15.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Field15); + } + if (Field12 != false) { + size += 1 + 1; + } + if (Field13 != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Field13); + } + if (Field14 != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Field14); + } + if (Field16 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field16); + } + if (Field19 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field19); + } + if (Field20 != false) { + size += 2 + 1; + } + if (Field28 != false) { + size += 2 + 1; + } + if (Field21 != 0UL) { + size += 2 + 8; + } + if (Field22 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field22); + } + if (Field23 != false) { + size += 2 + 1; + } + if (Field206 != false) { + size += 2 + 1; + } + if (Field203 != 0) { + size += 2 + 4; + } + if (Field204 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field204); + } + if (Field205.Length != 0) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(Field205); + } + if (Field207 != 0UL) { + size += 2 + pb::CodedOutputStream.ComputeUInt64Size(Field207); + } + if (Field300 != 0UL) { + size += 2 + pb::CodedOutputStream.ComputeUInt64Size(Field300); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(GoogleMessage1SubMessage other) { + if (other == null) { + return; + } + if (other.Field1 != 0) { + Field1 = other.Field1; + } + if (other.Field2 != 0) { + Field2 = other.Field2; + } + if (other.Field3 != 0) { + Field3 = other.Field3; + } + if (other.Field15.Length != 0) { + Field15 = other.Field15; + } + if (other.Field12 != false) { + Field12 = other.Field12; + } + if (other.Field13 != 0L) { + Field13 = other.Field13; + } + if (other.Field14 != 0L) { + Field14 = other.Field14; + } + if (other.Field16 != 0) { + Field16 = other.Field16; + } + if (other.Field19 != 0) { + Field19 = other.Field19; + } + if (other.Field20 != false) { + Field20 = other.Field20; + } + if (other.Field28 != false) { + Field28 = other.Field28; + } + if (other.Field21 != 0UL) { + Field21 = other.Field21; + } + if (other.Field22 != 0) { + Field22 = other.Field22; + } + if (other.Field23 != false) { + Field23 = other.Field23; + } + if (other.Field206 != false) { + Field206 = other.Field206; + } + if (other.Field203 != 0) { + Field203 = other.Field203; + } + if (other.Field204 != 0) { + Field204 = other.Field204; + } + if (other.Field205.Length != 0) { + Field205 = other.Field205; + } + if (other.Field207 != 0UL) { + Field207 = other.Field207; + } + if (other.Field300 != 0UL) { + Field300 = other.Field300; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + Field1 = input.ReadInt32(); + break; + } + case 16: { + Field2 = input.ReadInt32(); + break; + } + case 24: { + Field3 = input.ReadInt32(); + break; + } + case 96: { + Field12 = input.ReadBool(); + break; + } + case 104: { + Field13 = input.ReadInt64(); + break; + } + case 112: { + Field14 = input.ReadInt64(); + break; + } + case 122: { + Field15 = input.ReadString(); + break; + } + case 128: { + Field16 = input.ReadInt32(); + break; + } + case 152: { + Field19 = input.ReadInt32(); + break; + } + case 160: { + Field20 = input.ReadBool(); + break; + } + case 169: { + Field21 = input.ReadFixed64(); + break; + } + case 176: { + Field22 = input.ReadInt32(); + break; + } + case 184: { + Field23 = input.ReadBool(); + break; + } + case 224: { + Field28 = input.ReadBool(); + break; + } + case 1629: { + Field203 = input.ReadFixed32(); + break; + } + case 1632: { + Field204 = input.ReadInt32(); + break; + } + case 1642: { + Field205 = input.ReadString(); + break; + } + case 1648: { + Field206 = input.ReadBool(); + break; + } + case 1656: { + Field207 = input.ReadUInt64(); + break; + } + case 2400: { + Field300 = input.ReadUInt64(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/Benchmarks.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/Benchmarks.cs new file mode 100644 index 000000000000..01dfcd72dc6f --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/Benchmarks.cs @@ -0,0 +1,250 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: benchmarks.proto +// +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Benchmarks { + + /// Holder for reflection information generated from benchmarks.proto + public static partial class BenchmarksReflection { + + #region Descriptor + /// File descriptor for benchmarks.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static BenchmarksReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChBiZW5jaG1hcmtzLnByb3RvEgpiZW5jaG1hcmtzIkcKEEJlbmNobWFya0Rh", + "dGFzZXQSDAoEbmFtZRgBIAEoCRIUCgxtZXNzYWdlX25hbWUYAiABKAkSDwoH", + "cGF5bG9hZBgDIAMoDEIgCh5jb20uZ29vZ2xlLnByb3RvYnVmLmJlbmNobWFy", + "a3NiBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Benchmarks.BenchmarkDataset), global::Benchmarks.BenchmarkDataset.Parser, new[]{ "Name", "MessageName", "Payload" }, null, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class BenchmarkDataset : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BenchmarkDataset()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Benchmarks.BenchmarksReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public BenchmarkDataset() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public BenchmarkDataset(BenchmarkDataset other) : this() { + name_ = other.name_; + messageName_ = other.messageName_; + payload_ = other.payload_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public BenchmarkDataset Clone() { + return new BenchmarkDataset(this); + } + + /// Field number for the "name" field. + public const int NameFieldNumber = 1; + private string name_ = ""; + /// + /// Name of the benchmark dataset. This should be unique across all datasets. + /// Should only contain word characters: [a-zA-Z0-9_] + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Name { + get { return name_; } + set { + name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "message_name" field. + public const int MessageNameFieldNumber = 2; + private string messageName_ = ""; + /// + /// Fully-qualified name of the protobuf message for this dataset. + /// It will be one of the messages defined benchmark_messages_proto2.proto + /// or benchmark_messages_proto3.proto. + /// + /// Implementations that do not support reflection can implement this with + /// an explicit "if/else" chain that lists every known message defined + /// in those files. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string MessageName { + get { return messageName_; } + set { + messageName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "payload" field. + public const int PayloadFieldNumber = 3; + private static readonly pb::FieldCodec _repeated_payload_codec + = pb::FieldCodec.ForBytes(26); + private readonly pbc::RepeatedField payload_ = new pbc::RepeatedField(); + /// + /// The payload(s) for this dataset. They should be parsed or serialized + /// in sequence, in a loop, ie. + /// + /// while (!benchmarkDone) { // Benchmark runner decides when to exit. + /// for (i = 0; i < benchmark.payload.length; i++) { + /// parse(benchmark.payload[i]) + /// } + /// } + /// + /// This is intended to let datasets include a variety of data to provide + /// potentially more realistic results than just parsing the same message + /// over and over. A single message parsed repeatedly could yield unusually + /// good branch prediction performance. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Payload { + get { return payload_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as BenchmarkDataset); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(BenchmarkDataset other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if (MessageName != other.MessageName) return false; + if(!payload_.Equals(other.payload_)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (MessageName.Length != 0) hash ^= MessageName.GetHashCode(); + hash ^= payload_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + if (MessageName.Length != 0) { + output.WriteRawTag(18); + output.WriteString(MessageName); + } + payload_.WriteTo(output, _repeated_payload_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + if (MessageName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(MessageName); + } + size += payload_.CalculateSize(_repeated_payload_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(BenchmarkDataset other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + if (other.MessageName.Length != 0) { + MessageName = other.MessageName; + } + payload_.Add(other.payload_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + MessageName = input.ReadString(); + break; + } + case 26: { + payload_.AddEntriesFrom(input, _repeated_payload_codec); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/Google.Protobuf.Benchmarks.csproj b/third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/Google.Protobuf.Benchmarks.csproj new file mode 100644 index 000000000000..ecc064ea7d09 --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/Google.Protobuf.Benchmarks.csproj @@ -0,0 +1,18 @@ + + + + Exe + netcoreapp2.1 + False + + + + + + + + + + + + diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/Program.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/Program.cs new file mode 100644 index 000000000000..66f71d139154 --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/Program.cs @@ -0,0 +1,46 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2019 Google Inc. All rights reserved. +// https://github.com/protocolbuffers/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using BenchmarkDotNet.Running; + +namespace Google.Protobuf.Benchmarks +{ + /// + /// Entry point, that currently runs the sole benchmark we have. + /// Eventually we might want to be able to specify a particular dataset + /// from the command line. + /// + class Program + { + static void Main() => BenchmarkRunner.Run(); + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/SerializationBenchmark.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/SerializationBenchmark.cs new file mode 100644 index 000000000000..d8c2ec11d73e --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/SerializationBenchmark.cs @@ -0,0 +1,120 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2019 Google Inc. All rights reserved. +// https://github.com/protocolbuffers/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using BenchmarkDotNet.Attributes; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace Google.Protobuf.Benchmarks +{ + /// + /// Benchmark for serializing (to a MemoryStream) and deserializing (from a ByteString). + /// Over time we may wish to test the various different approaches to serialization and deserialization separately. + /// + [MemoryDiagnoser] + public class SerializationBenchmark + { + /// + /// All the configurations to be tested. Add more datasets to the array as they're available. + /// (When C# supports proto2, this will increase significantly.) + /// + public static SerializationConfig[] Configurations => new[] + { + new SerializationConfig("dataset.google_message1_proto3.pb") + }; + + [ParamsSource(nameof(Configurations))] + public SerializationConfig Configuration { get; set; } + + private MessageParser parser; + /// + /// Each data set can contain multiple messages in a single file. + /// Each "write" operation should write each message in turn, and each "parse" + /// operation should parse each message in turn. + /// + private List subTests; + + [GlobalSetup] + public void GlobalSetup() + { + parser = Configuration.Parser; + subTests = Configuration.Payloads.Select(p => new SubTest(p, parser.ParseFrom(p))).ToList(); + } + + [Benchmark] + public void WriteToStream() => subTests.ForEach(item => item.WriteToStream()); + + [Benchmark] + public void ToByteArray() => subTests.ForEach(item => item.ToByteArray()); + + [Benchmark] + public void ParseFromByteString() => subTests.ForEach(item => item.ParseFromByteString(parser)); + + [Benchmark] + public void ParseFromStream() => subTests.ForEach(item => item.ParseFromStream(parser)); + + private class SubTest + { + private readonly Stream destinationStream; + private readonly Stream sourceStream; + private readonly ByteString data; + private readonly IMessage message; + + public SubTest(ByteString data, IMessage message) + { + destinationStream = new MemoryStream(data.Length); + sourceStream = new MemoryStream(data.ToByteArray()); + this.data = data; + this.message = message; + } + + public void Reset() => destinationStream.Position = 0; + + public void WriteToStream() + { + destinationStream.Position = 0; + message.WriteTo(destinationStream); + } + + public void ToByteArray() => message.ToByteArray(); + + public void ParseFromByteString(MessageParser parser) => parser.ParseFrom(data); + + public void ParseFromStream(MessageParser parser) + { + sourceStream.Position = 0; + parser.ParseFrom(sourceStream); + } + } + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/SerializationConfig.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/SerializationConfig.cs new file mode 100644 index 000000000000..679f16cb9a87 --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Benchmarks/SerializationConfig.cs @@ -0,0 +1,89 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2019 Google Inc. All rights reserved. +// https://github.com/protocolbuffers/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using Benchmarks; +using Google.Protobuf.Reflection; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; + +namespace Google.Protobuf.Benchmarks +{ + /// + /// The configuration for a single serialization test, loaded from a dataset. + /// + public class SerializationConfig + { + private static readonly Dictionary parsersByMessageName = + typeof(SerializationBenchmark).Assembly.GetTypes() + .Where(t => typeof(IMessage).IsAssignableFrom(t)) + .ToDictionary( + t => ((MessageDescriptor) t.GetProperty("Descriptor", BindingFlags.Static | BindingFlags.Public).GetValue(null)).FullName, + t => ((MessageParser) t.GetProperty("Parser", BindingFlags.Static | BindingFlags.Public).GetValue(null))); + + public MessageParser Parser { get; } + public IEnumerable Payloads { get; } + public string Name { get; } + + public SerializationConfig(string resource) + { + var data = LoadData(resource); + var dataset = BenchmarkDataset.Parser.ParseFrom(data); + + if (!parsersByMessageName.TryGetValue(dataset.MessageName, out var parser)) + { + throw new ArgumentException($"No parser for message {dataset.MessageName} in this assembly"); + } + Parser = parser; + Payloads = dataset.Payload; + Name = dataset.Name; + } + + private static byte[] LoadData(string resource) + { + using (var stream = typeof(SerializationBenchmark).Assembly.GetManifestResourceStream($"Google.Protobuf.Benchmarks.{resource}")) + { + if (stream == null) + { + throw new ArgumentException($"Unable to load embedded resource {resource}"); + } + var copy = new MemoryStream(); + stream.CopyTo(copy); + return copy.ToArray(); + } + } + + public override string ToString() => Name; + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/App.config b/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/App.config deleted file mode 100644 index 8e15646352ec..000000000000 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Conformance.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Conformance.cs index 1674a6734f72..65ba9b1265ad 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Conformance.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Conformance.cs @@ -1,5 +1,7 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: conformance.proto +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: conformance.proto +// #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -10,7 +12,6 @@ namespace Conformance { /// Holder for reflection information generated from conformance.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class ConformanceReflection { #region Descriptor @@ -23,175 +24,35 @@ public static partial class ConformanceReflection { static ConformanceReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "ChFjb25mb3JtYW5jZS5wcm90bxILY29uZm9ybWFuY2UaGWdvb2dsZS9wcm90", - "b2J1Zi9hbnkucHJvdG8aHmdvb2dsZS9wcm90b2J1Zi9kdXJhdGlvbi5wcm90", - "bxogZ29vZ2xlL3Byb3RvYnVmL2ZpZWxkX21hc2sucHJvdG8aHGdvb2dsZS9w", - "cm90b2J1Zi9zdHJ1Y3QucHJvdG8aH2dvb2dsZS9wcm90b2J1Zi90aW1lc3Rh", - "bXAucHJvdG8aHmdvb2dsZS9wcm90b2J1Zi93cmFwcGVycy5wcm90byKNAQoS", - "Q29uZm9ybWFuY2VSZXF1ZXN0EhoKEHByb3RvYnVmX3BheWxvYWQYASABKAxI", - "ABIWCgxqc29uX3BheWxvYWQYAiABKAlIABI4ChdyZXF1ZXN0ZWRfb3V0cHV0", - "X2Zvcm1hdBgDIAEoDjIXLmNvbmZvcm1hbmNlLldpcmVGb3JtYXRCCQoHcGF5", - "bG9hZCKxAQoTQ29uZm9ybWFuY2VSZXNwb25zZRIVCgtwYXJzZV9lcnJvchgB", - "IAEoCUgAEhkKD3NlcmlhbGl6ZV9lcnJvchgGIAEoCUgAEhcKDXJ1bnRpbWVf", - "ZXJyb3IYAiABKAlIABIaChBwcm90b2J1Zl9wYXlsb2FkGAMgASgMSAASFgoM", - "anNvbl9wYXlsb2FkGAQgASgJSAASEQoHc2tpcHBlZBgFIAEoCUgAQggKBnJl", - "c3VsdCLVMgoMVGVzdEFsbFR5cGVzEhYKDm9wdGlvbmFsX2ludDMyGAEgASgF", - "EhYKDm9wdGlvbmFsX2ludDY0GAIgASgDEhcKD29wdGlvbmFsX3VpbnQzMhgD", - "IAEoDRIXCg9vcHRpb25hbF91aW50NjQYBCABKAQSFwoPb3B0aW9uYWxfc2lu", - "dDMyGAUgASgREhcKD29wdGlvbmFsX3NpbnQ2NBgGIAEoEhIYChBvcHRpb25h", - "bF9maXhlZDMyGAcgASgHEhgKEG9wdGlvbmFsX2ZpeGVkNjQYCCABKAYSGQoR", - "b3B0aW9uYWxfc2ZpeGVkMzIYCSABKA8SGQoRb3B0aW9uYWxfc2ZpeGVkNjQY", - "CiABKBASFgoOb3B0aW9uYWxfZmxvYXQYCyABKAISFwoPb3B0aW9uYWxfZG91", - "YmxlGAwgASgBEhUKDW9wdGlvbmFsX2Jvb2wYDSABKAgSFwoPb3B0aW9uYWxf", - "c3RyaW5nGA4gASgJEhYKDm9wdGlvbmFsX2J5dGVzGA8gASgMEkgKF29wdGlv", - "bmFsX25lc3RlZF9tZXNzYWdlGBIgASgLMicuY29uZm9ybWFuY2UuVGVzdEFs", - "bFR5cGVzLk5lc3RlZE1lc3NhZ2USPQoYb3B0aW9uYWxfZm9yZWlnbl9tZXNz", - "YWdlGBMgASgLMhsuY29uZm9ybWFuY2UuRm9yZWlnbk1lc3NhZ2USQgoUb3B0", - "aW9uYWxfbmVzdGVkX2VudW0YFSABKA4yJC5jb25mb3JtYW5jZS5UZXN0QWxs", - "VHlwZXMuTmVzdGVkRW51bRI3ChVvcHRpb25hbF9mb3JlaWduX2VudW0YFiAB", - "KA4yGC5jb25mb3JtYW5jZS5Gb3JlaWduRW51bRIhChVvcHRpb25hbF9zdHJp", - "bmdfcGllY2UYGCABKAlCAggCEhkKDW9wdGlvbmFsX2NvcmQYGSABKAlCAggB", - "EjQKEXJlY3Vyc2l2ZV9tZXNzYWdlGBsgASgLMhkuY29uZm9ybWFuY2UuVGVz", - "dEFsbFR5cGVzEhYKDnJlcGVhdGVkX2ludDMyGB8gAygFEhYKDnJlcGVhdGVk", - "X2ludDY0GCAgAygDEhcKD3JlcGVhdGVkX3VpbnQzMhghIAMoDRIXCg9yZXBl", - "YXRlZF91aW50NjQYIiADKAQSFwoPcmVwZWF0ZWRfc2ludDMyGCMgAygREhcK", - "D3JlcGVhdGVkX3NpbnQ2NBgkIAMoEhIYChByZXBlYXRlZF9maXhlZDMyGCUg", - "AygHEhgKEHJlcGVhdGVkX2ZpeGVkNjQYJiADKAYSGQoRcmVwZWF0ZWRfc2Zp", - "eGVkMzIYJyADKA8SGQoRcmVwZWF0ZWRfc2ZpeGVkNjQYKCADKBASFgoOcmVw", - "ZWF0ZWRfZmxvYXQYKSADKAISFwoPcmVwZWF0ZWRfZG91YmxlGCogAygBEhUK", - "DXJlcGVhdGVkX2Jvb2wYKyADKAgSFwoPcmVwZWF0ZWRfc3RyaW5nGCwgAygJ", - "EhYKDnJlcGVhdGVkX2J5dGVzGC0gAygMEkgKF3JlcGVhdGVkX25lc3RlZF9t", - "ZXNzYWdlGDAgAygLMicuY29uZm9ybWFuY2UuVGVzdEFsbFR5cGVzLk5lc3Rl", - "ZE1lc3NhZ2USPQoYcmVwZWF0ZWRfZm9yZWlnbl9tZXNzYWdlGDEgAygLMhsu", - "Y29uZm9ybWFuY2UuRm9yZWlnbk1lc3NhZ2USQgoUcmVwZWF0ZWRfbmVzdGVk", - "X2VudW0YMyADKA4yJC5jb25mb3JtYW5jZS5UZXN0QWxsVHlwZXMuTmVzdGVk", - "RW51bRI3ChVyZXBlYXRlZF9mb3JlaWduX2VudW0YNCADKA4yGC5jb25mb3Jt", - "YW5jZS5Gb3JlaWduRW51bRIhChVyZXBlYXRlZF9zdHJpbmdfcGllY2UYNiAD", - "KAlCAggCEhkKDXJlcGVhdGVkX2NvcmQYNyADKAlCAggBEkUKD21hcF9pbnQz", - "Ml9pbnQzMhg4IAMoCzIsLmNvbmZvcm1hbmNlLlRlc3RBbGxUeXBlcy5NYXBJ", - "bnQzMkludDMyRW50cnkSRQoPbWFwX2ludDY0X2ludDY0GDkgAygLMiwuY29u", - "Zm9ybWFuY2UuVGVzdEFsbFR5cGVzLk1hcEludDY0SW50NjRFbnRyeRJJChFt", - "YXBfdWludDMyX3VpbnQzMhg6IAMoCzIuLmNvbmZvcm1hbmNlLlRlc3RBbGxU", - "eXBlcy5NYXBVaW50MzJVaW50MzJFbnRyeRJJChFtYXBfdWludDY0X3VpbnQ2", - "NBg7IAMoCzIuLmNvbmZvcm1hbmNlLlRlc3RBbGxUeXBlcy5NYXBVaW50NjRV", - "aW50NjRFbnRyeRJJChFtYXBfc2ludDMyX3NpbnQzMhg8IAMoCzIuLmNvbmZv", - "cm1hbmNlLlRlc3RBbGxUeXBlcy5NYXBTaW50MzJTaW50MzJFbnRyeRJJChFt", - "YXBfc2ludDY0X3NpbnQ2NBg9IAMoCzIuLmNvbmZvcm1hbmNlLlRlc3RBbGxU", - "eXBlcy5NYXBTaW50NjRTaW50NjRFbnRyeRJNChNtYXBfZml4ZWQzMl9maXhl", - "ZDMyGD4gAygLMjAuY29uZm9ybWFuY2UuVGVzdEFsbFR5cGVzLk1hcEZpeGVk", - "MzJGaXhlZDMyRW50cnkSTQoTbWFwX2ZpeGVkNjRfZml4ZWQ2NBg/IAMoCzIw", - "LmNvbmZvcm1hbmNlLlRlc3RBbGxUeXBlcy5NYXBGaXhlZDY0Rml4ZWQ2NEVu", - "dHJ5ElEKFW1hcF9zZml4ZWQzMl9zZml4ZWQzMhhAIAMoCzIyLmNvbmZvcm1h", - "bmNlLlRlc3RBbGxUeXBlcy5NYXBTZml4ZWQzMlNmaXhlZDMyRW50cnkSUQoV", - "bWFwX3NmaXhlZDY0X3NmaXhlZDY0GEEgAygLMjIuY29uZm9ybWFuY2UuVGVz", - "dEFsbFR5cGVzLk1hcFNmaXhlZDY0U2ZpeGVkNjRFbnRyeRJFCg9tYXBfaW50", - "MzJfZmxvYXQYQiADKAsyLC5jb25mb3JtYW5jZS5UZXN0QWxsVHlwZXMuTWFw", - "SW50MzJGbG9hdEVudHJ5EkcKEG1hcF9pbnQzMl9kb3VibGUYQyADKAsyLS5j", - "b25mb3JtYW5jZS5UZXN0QWxsVHlwZXMuTWFwSW50MzJEb3VibGVFbnRyeRJB", - "Cg1tYXBfYm9vbF9ib29sGEQgAygLMiouY29uZm9ybWFuY2UuVGVzdEFsbFR5", - "cGVzLk1hcEJvb2xCb29sRW50cnkSSQoRbWFwX3N0cmluZ19zdHJpbmcYRSAD", - "KAsyLi5jb25mb3JtYW5jZS5UZXN0QWxsVHlwZXMuTWFwU3RyaW5nU3RyaW5n", - "RW50cnkSRwoQbWFwX3N0cmluZ19ieXRlcxhGIAMoCzItLmNvbmZvcm1hbmNl", - "LlRlc3RBbGxUeXBlcy5NYXBTdHJpbmdCeXRlc0VudHJ5ElgKGW1hcF9zdHJp", - "bmdfbmVzdGVkX21lc3NhZ2UYRyADKAsyNS5jb25mb3JtYW5jZS5UZXN0QWxs", - "VHlwZXMuTWFwU3RyaW5nTmVzdGVkTWVzc2FnZUVudHJ5EloKGm1hcF9zdHJp", - "bmdfZm9yZWlnbl9tZXNzYWdlGEggAygLMjYuY29uZm9ybWFuY2UuVGVzdEFs", - "bFR5cGVzLk1hcFN0cmluZ0ZvcmVpZ25NZXNzYWdlRW50cnkSUgoWbWFwX3N0", - "cmluZ19uZXN0ZWRfZW51bRhJIAMoCzIyLmNvbmZvcm1hbmNlLlRlc3RBbGxU", - "eXBlcy5NYXBTdHJpbmdOZXN0ZWRFbnVtRW50cnkSVAoXbWFwX3N0cmluZ19m", - "b3JlaWduX2VudW0YSiADKAsyMy5jb25mb3JtYW5jZS5UZXN0QWxsVHlwZXMu", - "TWFwU3RyaW5nRm9yZWlnbkVudW1FbnRyeRIWCgxvbmVvZl91aW50MzIYbyAB", - "KA1IABJHChRvbmVvZl9uZXN0ZWRfbWVzc2FnZRhwIAEoCzInLmNvbmZvcm1h", - "bmNlLlRlc3RBbGxUeXBlcy5OZXN0ZWRNZXNzYWdlSAASFgoMb25lb2Zfc3Ry", - "aW5nGHEgASgJSAASFQoLb25lb2ZfYnl0ZXMYciABKAxIABI6ChVvcHRpb25h", - "bF9ib29sX3dyYXBwZXIYyQEgASgLMhouZ29vZ2xlLnByb3RvYnVmLkJvb2xW", - "YWx1ZRI8ChZvcHRpb25hbF9pbnQzMl93cmFwcGVyGMoBIAEoCzIbLmdvb2ds", - "ZS5wcm90b2J1Zi5JbnQzMlZhbHVlEjwKFm9wdGlvbmFsX2ludDY0X3dyYXBw", - "ZXIYywEgASgLMhsuZ29vZ2xlLnByb3RvYnVmLkludDY0VmFsdWUSPgoXb3B0", - "aW9uYWxfdWludDMyX3dyYXBwZXIYzAEgASgLMhwuZ29vZ2xlLnByb3RvYnVm", - "LlVJbnQzMlZhbHVlEj4KF29wdGlvbmFsX3VpbnQ2NF93cmFwcGVyGM0BIAEo", - "CzIcLmdvb2dsZS5wcm90b2J1Zi5VSW50NjRWYWx1ZRI8ChZvcHRpb25hbF9m", - "bG9hdF93cmFwcGVyGM4BIAEoCzIbLmdvb2dsZS5wcm90b2J1Zi5GbG9hdFZh", - "bHVlEj4KF29wdGlvbmFsX2RvdWJsZV93cmFwcGVyGM8BIAEoCzIcLmdvb2ds", - "ZS5wcm90b2J1Zi5Eb3VibGVWYWx1ZRI+ChdvcHRpb25hbF9zdHJpbmdfd3Jh", - "cHBlchjQASABKAsyHC5nb29nbGUucHJvdG9idWYuU3RyaW5nVmFsdWUSPAoW", - "b3B0aW9uYWxfYnl0ZXNfd3JhcHBlchjRASABKAsyGy5nb29nbGUucHJvdG9i", - "dWYuQnl0ZXNWYWx1ZRI6ChVyZXBlYXRlZF9ib29sX3dyYXBwZXIY0wEgAygL", - "MhouZ29vZ2xlLnByb3RvYnVmLkJvb2xWYWx1ZRI8ChZyZXBlYXRlZF9pbnQz", - "Ml93cmFwcGVyGNQBIAMoCzIbLmdvb2dsZS5wcm90b2J1Zi5JbnQzMlZhbHVl", - "EjwKFnJlcGVhdGVkX2ludDY0X3dyYXBwZXIY1QEgAygLMhsuZ29vZ2xlLnBy", - "b3RvYnVmLkludDY0VmFsdWUSPgoXcmVwZWF0ZWRfdWludDMyX3dyYXBwZXIY", - "1gEgAygLMhwuZ29vZ2xlLnByb3RvYnVmLlVJbnQzMlZhbHVlEj4KF3JlcGVh", - "dGVkX3VpbnQ2NF93cmFwcGVyGNcBIAMoCzIcLmdvb2dsZS5wcm90b2J1Zi5V", - "SW50NjRWYWx1ZRI8ChZyZXBlYXRlZF9mbG9hdF93cmFwcGVyGNgBIAMoCzIb", - "Lmdvb2dsZS5wcm90b2J1Zi5GbG9hdFZhbHVlEj4KF3JlcGVhdGVkX2RvdWJs", - "ZV93cmFwcGVyGNkBIAMoCzIcLmdvb2dsZS5wcm90b2J1Zi5Eb3VibGVWYWx1", - "ZRI+ChdyZXBlYXRlZF9zdHJpbmdfd3JhcHBlchjaASADKAsyHC5nb29nbGUu", - "cHJvdG9idWYuU3RyaW5nVmFsdWUSPAoWcmVwZWF0ZWRfYnl0ZXNfd3JhcHBl", - "chjbASADKAsyGy5nb29nbGUucHJvdG9idWYuQnl0ZXNWYWx1ZRI1ChFvcHRp", - "b25hbF9kdXJhdGlvbhitAiABKAsyGS5nb29nbGUucHJvdG9idWYuRHVyYXRp", - "b24SNwoSb3B0aW9uYWxfdGltZXN0YW1wGK4CIAEoCzIaLmdvb2dsZS5wcm90", - "b2J1Zi5UaW1lc3RhbXASOAoTb3B0aW9uYWxfZmllbGRfbWFzaxivAiABKAsy", - "Gi5nb29nbGUucHJvdG9idWYuRmllbGRNYXNrEjEKD29wdGlvbmFsX3N0cnVj", - "dBiwAiABKAsyFy5nb29nbGUucHJvdG9idWYuU3RydWN0EisKDG9wdGlvbmFs", - "X2FueRixAiABKAsyFC5nb29nbGUucHJvdG9idWYuQW55Ei8KDm9wdGlvbmFs", - "X3ZhbHVlGLICIAEoCzIWLmdvb2dsZS5wcm90b2J1Zi5WYWx1ZRI1ChFyZXBl", - "YXRlZF9kdXJhdGlvbhi3AiADKAsyGS5nb29nbGUucHJvdG9idWYuRHVyYXRp", - "b24SNwoScmVwZWF0ZWRfdGltZXN0YW1wGLgCIAMoCzIaLmdvb2dsZS5wcm90", - "b2J1Zi5UaW1lc3RhbXASNwoScmVwZWF0ZWRfZmllbGRtYXNrGLkCIAMoCzIa", - "Lmdvb2dsZS5wcm90b2J1Zi5GaWVsZE1hc2sSMQoPcmVwZWF0ZWRfc3RydWN0", - "GMQCIAMoCzIXLmdvb2dsZS5wcm90b2J1Zi5TdHJ1Y3QSKwoMcmVwZWF0ZWRf", - "YW55GLsCIAMoCzIULmdvb2dsZS5wcm90b2J1Zi5BbnkSLwoOcmVwZWF0ZWRf", - "dmFsdWUYvAIgAygLMhYuZ29vZ2xlLnByb3RvYnVmLlZhbHVlEhMKCmZpZWxk", - "bmFtZTEYkQMgASgFEhQKC2ZpZWxkX25hbWUyGJIDIAEoBRIVCgxfZmllbGRf", - "bmFtZTMYkwMgASgFEhYKDWZpZWxkX19uYW1lNF8YlAMgASgFEhQKC2ZpZWxk", - "MG5hbWU1GJUDIAEoBRIWCg1maWVsZF8wX25hbWU2GJYDIAEoBRITCgpmaWVs", - "ZE5hbWU3GJcDIAEoBRITCgpGaWVsZE5hbWU4GJgDIAEoBRIUCgtmaWVsZF9O", - "YW1lORiZAyABKAUSFQoMRmllbGRfTmFtZTEwGJoDIAEoBRIVCgxGSUVMRF9O", - "QU1FMTEYmwMgASgFEhUKDEZJRUxEX25hbWUxMhicAyABKAUaSgoNTmVzdGVk", - "TWVzc2FnZRIJCgFhGAEgASgFEi4KC2NvcmVjdXJzaXZlGAIgASgLMhkuY29u", - "Zm9ybWFuY2UuVGVzdEFsbFR5cGVzGjQKEk1hcEludDMySW50MzJFbnRyeRIL", - "CgNrZXkYASABKAUSDQoFdmFsdWUYAiABKAU6AjgBGjQKEk1hcEludDY0SW50", - "NjRFbnRyeRILCgNrZXkYASABKAMSDQoFdmFsdWUYAiABKAM6AjgBGjYKFE1h", - "cFVpbnQzMlVpbnQzMkVudHJ5EgsKA2tleRgBIAEoDRINCgV2YWx1ZRgCIAEo", - "DToCOAEaNgoUTWFwVWludDY0VWludDY0RW50cnkSCwoDa2V5GAEgASgEEg0K", - "BXZhbHVlGAIgASgEOgI4ARo2ChRNYXBTaW50MzJTaW50MzJFbnRyeRILCgNr", - "ZXkYASABKBESDQoFdmFsdWUYAiABKBE6AjgBGjYKFE1hcFNpbnQ2NFNpbnQ2", - "NEVudHJ5EgsKA2tleRgBIAEoEhINCgV2YWx1ZRgCIAEoEjoCOAEaOAoWTWFw", - "Rml4ZWQzMkZpeGVkMzJFbnRyeRILCgNrZXkYASABKAcSDQoFdmFsdWUYAiAB", - "KAc6AjgBGjgKFk1hcEZpeGVkNjRGaXhlZDY0RW50cnkSCwoDa2V5GAEgASgG", - "Eg0KBXZhbHVlGAIgASgGOgI4ARo6ChhNYXBTZml4ZWQzMlNmaXhlZDMyRW50", - "cnkSCwoDa2V5GAEgASgPEg0KBXZhbHVlGAIgASgPOgI4ARo6ChhNYXBTZml4", - "ZWQ2NFNmaXhlZDY0RW50cnkSCwoDa2V5GAEgASgQEg0KBXZhbHVlGAIgASgQ", - "OgI4ARo0ChJNYXBJbnQzMkZsb2F0RW50cnkSCwoDa2V5GAEgASgFEg0KBXZh", - "bHVlGAIgASgCOgI4ARo1ChNNYXBJbnQzMkRvdWJsZUVudHJ5EgsKA2tleRgB", - "IAEoBRINCgV2YWx1ZRgCIAEoAToCOAEaMgoQTWFwQm9vbEJvb2xFbnRyeRIL", - "CgNrZXkYASABKAgSDQoFdmFsdWUYAiABKAg6AjgBGjYKFE1hcFN0cmluZ1N0", - "cmluZ0VudHJ5EgsKA2tleRgBIAEoCRINCgV2YWx1ZRgCIAEoCToCOAEaNQoT", - "TWFwU3RyaW5nQnl0ZXNFbnRyeRILCgNrZXkYASABKAkSDQoFdmFsdWUYAiAB", - "KAw6AjgBGmYKG01hcFN0cmluZ05lc3RlZE1lc3NhZ2VFbnRyeRILCgNrZXkY", - "ASABKAkSNgoFdmFsdWUYAiABKAsyJy5jb25mb3JtYW5jZS5UZXN0QWxsVHlw", - "ZXMuTmVzdGVkTWVzc2FnZToCOAEaWwocTWFwU3RyaW5nRm9yZWlnbk1lc3Nh", - "Z2VFbnRyeRILCgNrZXkYASABKAkSKgoFdmFsdWUYAiABKAsyGy5jb25mb3Jt", - "YW5jZS5Gb3JlaWduTWVzc2FnZToCOAEaYAoYTWFwU3RyaW5nTmVzdGVkRW51", - "bUVudHJ5EgsKA2tleRgBIAEoCRIzCgV2YWx1ZRgCIAEoDjIkLmNvbmZvcm1h", - "bmNlLlRlc3RBbGxUeXBlcy5OZXN0ZWRFbnVtOgI4ARpVChlNYXBTdHJpbmdG", - "b3JlaWduRW51bUVudHJ5EgsKA2tleRgBIAEoCRInCgV2YWx1ZRgCIAEoDjIY", - "LmNvbmZvcm1hbmNlLkZvcmVpZ25FbnVtOgI4ASI5CgpOZXN0ZWRFbnVtEgcK", - "A0ZPTxAAEgcKA0JBUhABEgcKA0JBWhACEhAKA05FRxD///////////8BQg0K", - "C29uZW9mX2ZpZWxkIhsKDkZvcmVpZ25NZXNzYWdlEgkKAWMYASABKAUqNQoK", - "V2lyZUZvcm1hdBIPCgtVTlNQRUNJRklFRBAAEgwKCFBST1RPQlVGEAESCAoE", - "SlNPThACKkAKC0ZvcmVpZ25FbnVtEg8KC0ZPUkVJR05fRk9PEAASDwoLRk9S", - "RUlHTl9CQVIQARIPCgtGT1JFSUdOX0JBWhACQiEKH2NvbS5nb29nbGUucHJv", - "dG9idWYuY29uZm9ybWFuY2ViBnByb3RvMw==")); + "ChFjb25mb3JtYW5jZS5wcm90bxILY29uZm9ybWFuY2UiHQoKRmFpbHVyZVNl", + "dBIPCgdmYWlsdXJlGAEgAygJIuMCChJDb25mb3JtYW5jZVJlcXVlc3QSGgoQ", + "cHJvdG9idWZfcGF5bG9hZBgBIAEoDEgAEhYKDGpzb25fcGF5bG9hZBgCIAEo", + "CUgAEhYKDGpzcGJfcGF5bG9hZBgHIAEoCUgAEhYKDHRleHRfcGF5bG9hZBgI", + "IAEoCUgAEjgKF3JlcXVlc3RlZF9vdXRwdXRfZm9ybWF0GAMgASgOMhcuY29u", + "Zm9ybWFuY2UuV2lyZUZvcm1hdBIUCgxtZXNzYWdlX3R5cGUYBCABKAkSMAoN", + "dGVzdF9jYXRlZ29yeRgFIAEoDjIZLmNvbmZvcm1hbmNlLlRlc3RDYXRlZ29y", + "eRI+ChVqc3BiX2VuY29kaW5nX29wdGlvbnMYBiABKAsyHy5jb25mb3JtYW5j", + "ZS5Kc3BiRW5jb2RpbmdDb25maWcSHAoUcHJpbnRfdW5rbm93bl9maWVsZHMY", + "CSABKAhCCQoHcGF5bG9hZCLhAQoTQ29uZm9ybWFuY2VSZXNwb25zZRIVCgtw", + "YXJzZV9lcnJvchgBIAEoCUgAEhkKD3NlcmlhbGl6ZV9lcnJvchgGIAEoCUgA", + "EhcKDXJ1bnRpbWVfZXJyb3IYAiABKAlIABIaChBwcm90b2J1Zl9wYXlsb2Fk", + "GAMgASgMSAASFgoManNvbl9wYXlsb2FkGAQgASgJSAASEQoHc2tpcHBlZBgF", + "IAEoCUgAEhYKDGpzcGJfcGF5bG9hZBgHIAEoCUgAEhYKDHRleHRfcGF5bG9h", + "ZBgIIAEoCUgAQggKBnJlc3VsdCI3ChJKc3BiRW5jb2RpbmdDb25maWcSIQoZ", + "dXNlX2pzcGJfYXJyYXlfYW55X2Zvcm1hdBgBIAEoCCpQCgpXaXJlRm9ybWF0", + "Eg8KC1VOU1BFQ0lGSUVEEAASDAoIUFJPVE9CVUYQARIICgRKU09OEAISCAoE", + "SlNQQhADEg8KC1RFWFRfRk9STUFUEAQqjwEKDFRlc3RDYXRlZ29yeRIUChBV", + "TlNQRUNJRklFRF9URVNUEAASDwoLQklOQVJZX1RFU1QQARINCglKU09OX1RF", + "U1QQAhIkCiBKU09OX0lHTk9SRV9VTktOT1dOX1BBUlNJTkdfVEVTVBADEg0K", + "CUpTUEJfVEVTVBAEEhQKEFRFWFRfRk9STUFUX1RFU1QQBUIhCh9jb20uZ29v", + "Z2xlLnByb3RvYnVmLmNvbmZvcm1hbmNlYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.DurationReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.FieldMaskReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.StructReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.WrappersReflection.Descriptor, }, - new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Conformance.WireFormat), typeof(global::Conformance.ForeignEnum), }, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ConformanceRequest), global::Conformance.ConformanceRequest.Parser, new[]{ "ProtobufPayload", "JsonPayload", "RequestedOutputFormat" }, new[]{ "Payload" }, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ConformanceResponse), global::Conformance.ConformanceResponse.Parser, new[]{ "ParseError", "SerializeError", "RuntimeError", "ProtobufPayload", "JsonPayload", "Skipped" }, new[]{ "Result" }, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.TestAllTypes), global::Conformance.TestAllTypes.Parser, new[]{ "OptionalInt32", "OptionalInt64", "OptionalUint32", "OptionalUint64", "OptionalSint32", "OptionalSint64", "OptionalFixed32", "OptionalFixed64", "OptionalSfixed32", "OptionalSfixed64", "OptionalFloat", "OptionalDouble", "OptionalBool", "OptionalString", "OptionalBytes", "OptionalNestedMessage", "OptionalForeignMessage", "OptionalNestedEnum", "OptionalForeignEnum", "OptionalStringPiece", "OptionalCord", "RecursiveMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedStringPiece", "RepeatedCord", "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapStringString", "MapStringBytes", "MapStringNestedMessage", "MapStringForeignMessage", "MapStringNestedEnum", "MapStringForeignEnum", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", "OptionalBoolWrapper", "OptionalInt32Wrapper", "OptionalInt64Wrapper", "OptionalUint32Wrapper", "OptionalUint64Wrapper", "OptionalFloatWrapper", "OptionalDoubleWrapper", "OptionalStringWrapper", "OptionalBytesWrapper", "RepeatedBoolWrapper", "RepeatedInt32Wrapper", "RepeatedInt64Wrapper", "RepeatedUint32Wrapper", "RepeatedUint64Wrapper", "RepeatedFloatWrapper", "RepeatedDoubleWrapper", "RepeatedStringWrapper", "RepeatedBytesWrapper", "OptionalDuration", "OptionalTimestamp", "OptionalFieldMask", "OptionalStruct", "OptionalAny", "OptionalValue", "RepeatedDuration", "RepeatedTimestamp", "RepeatedFieldmask", "RepeatedStruct", "RepeatedAny", "RepeatedValue", "Fieldname1", "FieldName2", "FieldName3", "FieldName4", "Field0Name5", "Field0Name6", "FieldName7", "FieldName8", "FieldName9", "FieldName10", "FIELDNAME11", "FIELDName12" }, new[]{ "OneofField" }, new[]{ typeof(global::Conformance.TestAllTypes.Types.NestedEnum) }, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.TestAllTypes.Types.NestedMessage), global::Conformance.TestAllTypes.Types.NestedMessage.Parser, new[]{ "A", "Corecursive" }, null, null, null), - null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, }), - new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ForeignMessage), global::Conformance.ForeignMessage.Parser, new[]{ "C" }, null, null, null) + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Conformance.WireFormat), typeof(global::Conformance.TestCategory), }, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.FailureSet), global::Conformance.FailureSet.Parser, new[]{ "Failure" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ConformanceRequest), global::Conformance.ConformanceRequest.Parser, new[]{ "ProtobufPayload", "JsonPayload", "JspbPayload", "TextPayload", "RequestedOutputFormat", "MessageType", "TestCategory", "JspbEncodingOptions", "PrintUnknownFields" }, new[]{ "Payload" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ConformanceResponse), global::Conformance.ConformanceResponse.Parser, new[]{ "ParseError", "SerializeError", "RuntimeError", "ProtobufPayload", "JsonPayload", "Skipped", "JspbPayload", "TextPayload" }, new[]{ "Result" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.JspbEncodingConfig), global::Conformance.JspbEncodingConfig.Parser, new[]{ "UseJspbArrayAnyFormat" }, null, null, null, null) })); } #endregion @@ -202,45 +63,208 @@ public enum WireFormat { [pbr::OriginalName("UNSPECIFIED")] Unspecified = 0, [pbr::OriginalName("PROTOBUF")] Protobuf = 1, [pbr::OriginalName("JSON")] Json = 2, + /// + /// Google internal only. Opensource testees just skip it. + /// + [pbr::OriginalName("JSPB")] Jspb = 3, + [pbr::OriginalName("TEXT_FORMAT")] TextFormat = 4, } - public enum ForeignEnum { - [pbr::OriginalName("FOREIGN_FOO")] ForeignFoo = 0, - [pbr::OriginalName("FOREIGN_BAR")] ForeignBar = 1, - [pbr::OriginalName("FOREIGN_BAZ")] ForeignBaz = 2, + public enum TestCategory { + [pbr::OriginalName("UNSPECIFIED_TEST")] UnspecifiedTest = 0, + /// + /// Test binary wire format. + /// + [pbr::OriginalName("BINARY_TEST")] BinaryTest = 1, + /// + /// Test json wire format. + /// + [pbr::OriginalName("JSON_TEST")] JsonTest = 2, + /// + /// Similar to JSON_TEST. However, during parsing json, testee should ignore + /// unknown fields. This feature is optional. Each implementation can descide + /// whether to support it. See + /// https://developers.google.com/protocol-buffers/docs/proto3#json_options + /// for more detail. + /// + [pbr::OriginalName("JSON_IGNORE_UNKNOWN_PARSING_TEST")] JsonIgnoreUnknownParsingTest = 3, + /// + /// Test jspb wire format. Google internal only. Opensource testees just skip it. + /// + [pbr::OriginalName("JSPB_TEST")] JspbTest = 4, + /// + /// Test text format. For cpp, java and python, testees can already deal with + /// this type. Testees of other languages can simply skip it. + /// + [pbr::OriginalName("TEXT_FORMAT_TEST")] TextFormatTest = 5, } #endregion #region Messages /// - /// Represents a single test case's input. The testee should: + /// The conformance runner will request a list of failures as the first request. + /// This will be known by message_type == "conformance.FailureSet", a conformance + /// test should return a serialized FailureSet in protobuf_payload. + /// + public sealed partial class FailureSet : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FailureSet()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Conformance.ConformanceReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public FailureSet() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public FailureSet(FailureSet other) : this() { + failure_ = other.failure_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public FailureSet Clone() { + return new FailureSet(this); + } + + /// Field number for the "failure" field. + public const int FailureFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_failure_codec + = pb::FieldCodec.ForString(10); + private readonly pbc::RepeatedField failure_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Failure { + get { return failure_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as FailureSet); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(FailureSet other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!failure_.Equals(other.failure_)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + hash ^= failure_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + failure_.WriteTo(output, _repeated_failure_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + size += failure_.CalculateSize(_repeated_failure_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(FailureSet other) { + if (other == null) { + return; + } + failure_.Add(other.failure_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + failure_.AddEntriesFrom(input, _repeated_failure_codec); + break; + } + } + } + } + + } + + /// + /// Represents a single test case's input. The testee should: /// - /// 1. parse this proto (which should always succeed) - /// 2. parse the protobuf or JSON payload in "payload" (which may fail) - /// 3. if the parse succeeded, serialize the message in the requested format. + /// 1. parse this proto (which should always succeed) + /// 2. parse the protobuf or JSON payload in "payload" (which may fail) + /// 3. if the parse succeeded, serialize the message in the requested format. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class ConformanceRequest : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ConformanceRequest()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Conformance.ConformanceReflection.Descriptor.MessageTypes[0]; } + get { return global::Conformance.ConformanceReflection.Descriptor.MessageTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ConformanceRequest() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ConformanceRequest(ConformanceRequest other) : this() { requestedOutputFormat_ = other.requestedOutputFormat_; + messageType_ = other.messageType_; + testCategory_ = other.testCategory_; + jspbEncodingOptions_ = other.jspbEncodingOptions_ != null ? other.jspbEncodingOptions_.Clone() : null; + printUnknownFields_ = other.printUnknownFields_; switch (other.PayloadCase) { case PayloadOneofCase.ProtobufPayload: ProtobufPayload = other.ProtobufPayload; @@ -248,16 +272,25 @@ public ConformanceRequest(ConformanceRequest other) : this() { case PayloadOneofCase.JsonPayload: JsonPayload = other.JsonPayload; break; + case PayloadOneofCase.JspbPayload: + JspbPayload = other.JspbPayload; + break; + case PayloadOneofCase.TextPayload: + TextPayload = other.TextPayload; + break; } + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ConformanceRequest Clone() { return new ConformanceRequest(this); } /// Field number for the "protobuf_payload" field. public const int ProtobufPayloadFieldNumber = 1; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pb::ByteString ProtobufPayload { get { return payloadCase_ == PayloadOneofCase.ProtobufPayload ? (pb::ByteString) payload_ : pb::ByteString.Empty; } set { @@ -268,6 +301,7 @@ public ConformanceRequest Clone() { /// Field number for the "json_payload" field. public const int JsonPayloadFieldNumber = 2; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string JsonPayload { get { return payloadCase_ == PayloadOneofCase.JsonPayload ? (string) payload_ : ""; } set { @@ -276,12 +310,38 @@ public string JsonPayload { } } + /// Field number for the "jspb_payload" field. + public const int JspbPayloadFieldNumber = 7; + /// + /// Google internal only. Opensource testees just skip it. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string JspbPayload { + get { return payloadCase_ == PayloadOneofCase.JspbPayload ? (string) payload_ : ""; } + set { + payload_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + payloadCase_ = PayloadOneofCase.JspbPayload; + } + } + + /// Field number for the "text_payload" field. + public const int TextPayloadFieldNumber = 8; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string TextPayload { + get { return payloadCase_ == PayloadOneofCase.TextPayload ? (string) payload_ : ""; } + set { + payload_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + payloadCase_ = PayloadOneofCase.TextPayload; + } + } + /// Field number for the "requested_output_format" field. public const int RequestedOutputFormatFieldNumber = 3; - private global::Conformance.WireFormat requestedOutputFormat_ = 0; + private global::Conformance.WireFormat requestedOutputFormat_ = global::Conformance.WireFormat.Unspecified; /// - /// Which format should the testee serialize its message to? + /// Which format should the testee serialize its message to? /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Conformance.WireFormat RequestedOutputFormat { get { return requestedOutputFormat_; } set { @@ -289,27 +349,94 @@ public string JsonPayload { } } + /// Field number for the "message_type" field. + public const int MessageTypeFieldNumber = 4; + private string messageType_ = ""; + /// + /// The full name for the test message to use; for the moment, either: + /// protobuf_test_messages.proto3.TestAllTypesProto3 or + /// protobuf_test_messages.proto2.TestAllTypesProto2. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string MessageType { + get { return messageType_; } + set { + messageType_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "test_category" field. + public const int TestCategoryFieldNumber = 5; + private global::Conformance.TestCategory testCategory_ = global::Conformance.TestCategory.UnspecifiedTest; + /// + /// Each test is given a specific test category. Some category may need + /// spedific support in testee programs. Refer to the defintion of TestCategory + /// for more information. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Conformance.TestCategory TestCategory { + get { return testCategory_; } + set { + testCategory_ = value; + } + } + + /// Field number for the "jspb_encoding_options" field. + public const int JspbEncodingOptionsFieldNumber = 6; + private global::Conformance.JspbEncodingConfig jspbEncodingOptions_; + /// + /// Specify details for how to encode jspb. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Conformance.JspbEncodingConfig JspbEncodingOptions { + get { return jspbEncodingOptions_; } + set { + jspbEncodingOptions_ = value; + } + } + + /// Field number for the "print_unknown_fields" field. + public const int PrintUnknownFieldsFieldNumber = 9; + private bool printUnknownFields_; + /// + /// This can be used in json and text format. If true, testee should print + /// unknown fields instead of ignore. This feature is optional. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool PrintUnknownFields { + get { return printUnknownFields_; } + set { + printUnknownFields_ = value; + } + } + private object payload_; /// Enum of possible cases for the "payload" oneof. public enum PayloadOneofCase { None = 0, ProtobufPayload = 1, JsonPayload = 2, + JspbPayload = 7, + TextPayload = 8, } private PayloadOneofCase payloadCase_ = PayloadOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public PayloadOneofCase PayloadCase { get { return payloadCase_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void ClearPayload() { payloadCase_ = PayloadOneofCase.None; payload_ = null; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ConformanceRequest); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(ConformanceRequest other) { if (ReferenceEquals(other, null)) { return false; @@ -319,24 +446,42 @@ public bool Equals(ConformanceRequest other) { } if (ProtobufPayload != other.ProtobufPayload) return false; if (JsonPayload != other.JsonPayload) return false; + if (JspbPayload != other.JspbPayload) return false; + if (TextPayload != other.TextPayload) return false; if (RequestedOutputFormat != other.RequestedOutputFormat) return false; + if (MessageType != other.MessageType) return false; + if (TestCategory != other.TestCategory) return false; + if (!object.Equals(JspbEncodingOptions, other.JspbEncodingOptions)) return false; + if (PrintUnknownFields != other.PrintUnknownFields) return false; if (PayloadCase != other.PayloadCase) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (payloadCase_ == PayloadOneofCase.ProtobufPayload) hash ^= ProtobufPayload.GetHashCode(); if (payloadCase_ == PayloadOneofCase.JsonPayload) hash ^= JsonPayload.GetHashCode(); - if (RequestedOutputFormat != 0) hash ^= RequestedOutputFormat.GetHashCode(); + if (payloadCase_ == PayloadOneofCase.JspbPayload) hash ^= JspbPayload.GetHashCode(); + if (payloadCase_ == PayloadOneofCase.TextPayload) hash ^= TextPayload.GetHashCode(); + if (RequestedOutputFormat != global::Conformance.WireFormat.Unspecified) hash ^= RequestedOutputFormat.GetHashCode(); + if (MessageType.Length != 0) hash ^= MessageType.GetHashCode(); + if (TestCategory != global::Conformance.TestCategory.UnspecifiedTest) hash ^= TestCategory.GetHashCode(); + if (jspbEncodingOptions_ != null) hash ^= JspbEncodingOptions.GetHashCode(); + if (PrintUnknownFields != false) hash ^= PrintUnknownFields.GetHashCode(); hash ^= (int) payloadCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (payloadCase_ == PayloadOneofCase.ProtobufPayload) { output.WriteRawTag(10); @@ -346,12 +491,40 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(18); output.WriteString(JsonPayload); } - if (RequestedOutputFormat != 0) { + if (RequestedOutputFormat != global::Conformance.WireFormat.Unspecified) { output.WriteRawTag(24); output.WriteEnum((int) RequestedOutputFormat); } + if (MessageType.Length != 0) { + output.WriteRawTag(34); + output.WriteString(MessageType); + } + if (TestCategory != global::Conformance.TestCategory.UnspecifiedTest) { + output.WriteRawTag(40); + output.WriteEnum((int) TestCategory); + } + if (jspbEncodingOptions_ != null) { + output.WriteRawTag(50); + output.WriteMessage(JspbEncodingOptions); + } + if (payloadCase_ == PayloadOneofCase.JspbPayload) { + output.WriteRawTag(58); + output.WriteString(JspbPayload); + } + if (payloadCase_ == PayloadOneofCase.TextPayload) { + output.WriteRawTag(66); + output.WriteString(TextPayload); + } + if (PrintUnknownFields != false) { + output.WriteRawTag(72); + output.WriteBool(PrintUnknownFields); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (payloadCase_ == PayloadOneofCase.ProtobufPayload) { @@ -360,19 +533,56 @@ public int CalculateSize() { if (payloadCase_ == PayloadOneofCase.JsonPayload) { size += 1 + pb::CodedOutputStream.ComputeStringSize(JsonPayload); } - if (RequestedOutputFormat != 0) { + if (payloadCase_ == PayloadOneofCase.JspbPayload) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(JspbPayload); + } + if (payloadCase_ == PayloadOneofCase.TextPayload) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TextPayload); + } + if (RequestedOutputFormat != global::Conformance.WireFormat.Unspecified) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) RequestedOutputFormat); } + if (MessageType.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(MessageType); + } + if (TestCategory != global::Conformance.TestCategory.UnspecifiedTest) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) TestCategory); + } + if (jspbEncodingOptions_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(JspbEncodingOptions); + } + if (PrintUnknownFields != false) { + size += 1 + 1; + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(ConformanceRequest other) { if (other == null) { return; } - if (other.RequestedOutputFormat != 0) { + if (other.RequestedOutputFormat != global::Conformance.WireFormat.Unspecified) { RequestedOutputFormat = other.RequestedOutputFormat; } + if (other.MessageType.Length != 0) { + MessageType = other.MessageType; + } + if (other.TestCategory != global::Conformance.TestCategory.UnspecifiedTest) { + TestCategory = other.TestCategory; + } + if (other.jspbEncodingOptions_ != null) { + if (jspbEncodingOptions_ == null) { + JspbEncodingOptions = new global::Conformance.JspbEncodingConfig(); + } + JspbEncodingOptions.MergeFrom(other.JspbEncodingOptions); + } + if (other.PrintUnknownFields != false) { + PrintUnknownFields = other.PrintUnknownFields; + } switch (other.PayloadCase) { case PayloadOneofCase.ProtobufPayload: ProtobufPayload = other.ProtobufPayload; @@ -380,16 +590,24 @@ public void MergeFrom(ConformanceRequest other) { case PayloadOneofCase.JsonPayload: JsonPayload = other.JsonPayload; break; + case PayloadOneofCase.JspbPayload: + JspbPayload = other.JspbPayload; + break; + case PayloadOneofCase.TextPayload: + TextPayload = other.TextPayload; + break; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { ProtobufPayload = input.ReadBytes(); @@ -400,7 +618,34 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 24: { - requestedOutputFormat_ = (global::Conformance.WireFormat) input.ReadEnum(); + RequestedOutputFormat = (global::Conformance.WireFormat) input.ReadEnum(); + break; + } + case 34: { + MessageType = input.ReadString(); + break; + } + case 40: { + TestCategory = (global::Conformance.TestCategory) input.ReadEnum(); + break; + } + case 50: { + if (jspbEncodingOptions_ == null) { + JspbEncodingOptions = new global::Conformance.JspbEncodingConfig(); + } + input.ReadMessage(JspbEncodingOptions); + break; + } + case 58: { + JspbPayload = input.ReadString(); + break; + } + case 66: { + TextPayload = input.ReadString(); + break; + } + case 72: { + PrintUnknownFields = input.ReadBool(); break; } } @@ -410,27 +655,32 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Represents a single test case's output. + /// Represents a single test case's output. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class ConformanceResponse : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ConformanceResponse()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Conformance.ConformanceReflection.Descriptor.MessageTypes[1]; } + get { return global::Conformance.ConformanceReflection.Descriptor.MessageTypes[2]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ConformanceResponse() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ConformanceResponse(ConformanceResponse other) : this() { switch (other.ResultCase) { case ResultOneofCase.ParseError: @@ -451,10 +701,18 @@ public ConformanceResponse(ConformanceResponse other) : this() { case ResultOneofCase.Skipped: Skipped = other.Skipped; break; + case ResultOneofCase.JspbPayload: + JspbPayload = other.JspbPayload; + break; + case ResultOneofCase.TextPayload: + TextPayload = other.TextPayload; + break; } + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ConformanceResponse Clone() { return new ConformanceResponse(this); } @@ -462,12 +720,13 @@ public ConformanceResponse Clone() { /// Field number for the "parse_error" field. public const int ParseErrorFieldNumber = 1; /// - /// This string should be set to indicate parsing failed. The string can - /// provide more information about the parse error if it is available. + /// This string should be set to indicate parsing failed. The string can + /// provide more information about the parse error if it is available. /// - /// Setting this string does not necessarily mean the testee failed the - /// test. Some of the test cases are intentionally invalid input. + /// Setting this string does not necessarily mean the testee failed the + /// test. Some of the test cases are intentionally invalid input. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string ParseError { get { return resultCase_ == ResultOneofCase.ParseError ? (string) result_ : ""; } set { @@ -479,10 +738,11 @@ public string ParseError { /// Field number for the "serialize_error" field. public const int SerializeErrorFieldNumber = 6; /// - /// If the input was successfully parsed but errors occurred when - /// serializing it to the requested output format, set the error message in - /// this field. + /// If the input was successfully parsed but errors occurred when + /// serializing it to the requested output format, set the error message in + /// this field. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string SerializeError { get { return resultCase_ == ResultOneofCase.SerializeError ? (string) result_ : ""; } set { @@ -494,10 +754,11 @@ public string SerializeError { /// Field number for the "runtime_error" field. public const int RuntimeErrorFieldNumber = 2; /// - /// This should be set if some other error occurred. This will always - /// indicate that the test failed. The string can provide more information - /// about the failure. + /// This should be set if some other error occurred. This will always + /// indicate that the test failed. The string can provide more information + /// about the failure. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string RuntimeError { get { return resultCase_ == ResultOneofCase.RuntimeError ? (string) result_ : ""; } set { @@ -509,9 +770,10 @@ public string RuntimeError { /// Field number for the "protobuf_payload" field. public const int ProtobufPayloadFieldNumber = 3; /// - /// If the input was successfully parsed and the requested output was - /// protobuf, serialize it to protobuf and set it in this field. + /// If the input was successfully parsed and the requested output was + /// protobuf, serialize it to protobuf and set it in this field. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pb::ByteString ProtobufPayload { get { return resultCase_ == ResultOneofCase.ProtobufPayload ? (pb::ByteString) result_ : pb::ByteString.Empty; } set { @@ -523,9 +785,10 @@ public string RuntimeError { /// Field number for the "json_payload" field. public const int JsonPayloadFieldNumber = 4; /// - /// If the input was successfully parsed and the requested output was JSON, - /// serialize to JSON and set it in this field. + /// If the input was successfully parsed and the requested output was JSON, + /// serialize to JSON and set it in this field. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string JsonPayload { get { return resultCase_ == ResultOneofCase.JsonPayload ? (string) result_ : ""; } set { @@ -537,9 +800,10 @@ public string JsonPayload { /// Field number for the "skipped" field. public const int SkippedFieldNumber = 5; /// - /// For when the testee skipped the test, likely because a certain feature - /// wasn't supported, like JSON input/output. + /// For when the testee skipped the test, likely because a certain feature + /// wasn't supported, like JSON input/output. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Skipped { get { return resultCase_ == ResultOneofCase.Skipped ? (string) result_ : ""; } set { @@ -548,6 +812,37 @@ public string Skipped { } } + /// Field number for the "jspb_payload" field. + public const int JspbPayloadFieldNumber = 7; + /// + /// If the input was successfully parsed and the requested output was JSPB, + /// serialize to JSPB and set it in this field. JSPB is google internal only + /// format. Opensource testees can just skip it. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string JspbPayload { + get { return resultCase_ == ResultOneofCase.JspbPayload ? (string) result_ : ""; } + set { + result_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + resultCase_ = ResultOneofCase.JspbPayload; + } + } + + /// Field number for the "text_payload" field. + public const int TextPayloadFieldNumber = 8; + /// + /// If the input was successfully parsed and the requested output was + /// TEXT_FORMAT, serialize to TEXT_FORMAT and set it in this field. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string TextPayload { + get { return resultCase_ == ResultOneofCase.TextPayload ? (string) result_ : ""; } + set { + result_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + resultCase_ = ResultOneofCase.TextPayload; + } + } + private object result_; /// Enum of possible cases for the "result" oneof. public enum ResultOneofCase { @@ -558,21 +853,27 @@ public enum ResultOneofCase { ProtobufPayload = 3, JsonPayload = 4, Skipped = 5, + JspbPayload = 7, + TextPayload = 8, } private ResultOneofCase resultCase_ = ResultOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ResultOneofCase ResultCase { get { return resultCase_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void ClearResult() { resultCase_ = ResultOneofCase.None; result_ = null; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ConformanceResponse); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(ConformanceResponse other) { if (ReferenceEquals(other, null)) { return false; @@ -586,10 +887,13 @@ public bool Equals(ConformanceResponse other) { if (ProtobufPayload != other.ProtobufPayload) return false; if (JsonPayload != other.JsonPayload) return false; if (Skipped != other.Skipped) return false; + if (JspbPayload != other.JspbPayload) return false; + if (TextPayload != other.TextPayload) return false; if (ResultCase != other.ResultCase) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (resultCase_ == ResultOneofCase.ParseError) hash ^= ParseError.GetHashCode(); @@ -598,14 +902,21 @@ public override int GetHashCode() { if (resultCase_ == ResultOneofCase.ProtobufPayload) hash ^= ProtobufPayload.GetHashCode(); if (resultCase_ == ResultOneofCase.JsonPayload) hash ^= JsonPayload.GetHashCode(); if (resultCase_ == ResultOneofCase.Skipped) hash ^= Skipped.GetHashCode(); + if (resultCase_ == ResultOneofCase.JspbPayload) hash ^= JspbPayload.GetHashCode(); + if (resultCase_ == ResultOneofCase.TextPayload) hash ^= TextPayload.GetHashCode(); hash ^= (int) resultCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (resultCase_ == ResultOneofCase.ParseError) { output.WriteRawTag(10); @@ -631,8 +942,20 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(50); output.WriteString(SerializeError); } + if (resultCase_ == ResultOneofCase.JspbPayload) { + output.WriteRawTag(58); + output.WriteString(JspbPayload); + } + if (resultCase_ == ResultOneofCase.TextPayload) { + output.WriteRawTag(66); + output.WriteString(TextPayload); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (resultCase_ == ResultOneofCase.ParseError) { @@ -653,9 +976,19 @@ public int CalculateSize() { if (resultCase_ == ResultOneofCase.Skipped) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Skipped); } + if (resultCase_ == ResultOneofCase.JspbPayload) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(JspbPayload); + } + if (resultCase_ == ResultOneofCase.TextPayload) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TextPayload); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(ConformanceResponse other) { if (other == null) { return; @@ -679,16 +1012,24 @@ public void MergeFrom(ConformanceResponse other) { case ResultOneofCase.Skipped: Skipped = other.Skipped; break; + case ResultOneofCase.JspbPayload: + JspbPayload = other.JspbPayload; + break; + case ResultOneofCase.TextPayload: + TextPayload = other.TextPayload; + break; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { ParseError = input.ReadString(); @@ -714,6 +1055,14 @@ public void MergeFrom(pb::CodedInputStream input) { SerializeError = input.ReadString(); break; } + case 58: { + JspbPayload = input.ReadString(); + break; + } + case 66: { + TextPayload = input.ReadString(); + break; + } } } } @@ -721,2978 +1070,132 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// This proto includes every type of field in both singular and repeated - /// forms. + /// Encoding options for jspb format. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestAllTypes : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestAllTypes()); - public static pb::MessageParser Parser { get { return _parser; } } + public sealed partial class JspbEncodingConfig : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new JspbEncodingConfig()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Conformance.ConformanceReflection.Descriptor.MessageTypes[2]; } + get { return global::Conformance.ConformanceReflection.Descriptor.MessageTypes[3]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } - public TestAllTypes() { + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public JspbEncodingConfig() { OnConstruction(); } partial void OnConstruction(); - public TestAllTypes(TestAllTypes other) : this() { - optionalInt32_ = other.optionalInt32_; - optionalInt64_ = other.optionalInt64_; - optionalUint32_ = other.optionalUint32_; - optionalUint64_ = other.optionalUint64_; - optionalSint32_ = other.optionalSint32_; - optionalSint64_ = other.optionalSint64_; - optionalFixed32_ = other.optionalFixed32_; - optionalFixed64_ = other.optionalFixed64_; - optionalSfixed32_ = other.optionalSfixed32_; - optionalSfixed64_ = other.optionalSfixed64_; - optionalFloat_ = other.optionalFloat_; - optionalDouble_ = other.optionalDouble_; - optionalBool_ = other.optionalBool_; - optionalString_ = other.optionalString_; - optionalBytes_ = other.optionalBytes_; - OptionalNestedMessage = other.optionalNestedMessage_ != null ? other.OptionalNestedMessage.Clone() : null; - OptionalForeignMessage = other.optionalForeignMessage_ != null ? other.OptionalForeignMessage.Clone() : null; - optionalNestedEnum_ = other.optionalNestedEnum_; - optionalForeignEnum_ = other.optionalForeignEnum_; - optionalStringPiece_ = other.optionalStringPiece_; - optionalCord_ = other.optionalCord_; - RecursiveMessage = other.recursiveMessage_ != null ? other.RecursiveMessage.Clone() : null; - repeatedInt32_ = other.repeatedInt32_.Clone(); - repeatedInt64_ = other.repeatedInt64_.Clone(); - repeatedUint32_ = other.repeatedUint32_.Clone(); - repeatedUint64_ = other.repeatedUint64_.Clone(); - repeatedSint32_ = other.repeatedSint32_.Clone(); - repeatedSint64_ = other.repeatedSint64_.Clone(); - repeatedFixed32_ = other.repeatedFixed32_.Clone(); - repeatedFixed64_ = other.repeatedFixed64_.Clone(); - repeatedSfixed32_ = other.repeatedSfixed32_.Clone(); - repeatedSfixed64_ = other.repeatedSfixed64_.Clone(); - repeatedFloat_ = other.repeatedFloat_.Clone(); - repeatedDouble_ = other.repeatedDouble_.Clone(); - repeatedBool_ = other.repeatedBool_.Clone(); - repeatedString_ = other.repeatedString_.Clone(); - repeatedBytes_ = other.repeatedBytes_.Clone(); - repeatedNestedMessage_ = other.repeatedNestedMessage_.Clone(); - repeatedForeignMessage_ = other.repeatedForeignMessage_.Clone(); - repeatedNestedEnum_ = other.repeatedNestedEnum_.Clone(); - repeatedForeignEnum_ = other.repeatedForeignEnum_.Clone(); - repeatedStringPiece_ = other.repeatedStringPiece_.Clone(); - repeatedCord_ = other.repeatedCord_.Clone(); - mapInt32Int32_ = other.mapInt32Int32_.Clone(); - mapInt64Int64_ = other.mapInt64Int64_.Clone(); - mapUint32Uint32_ = other.mapUint32Uint32_.Clone(); - mapUint64Uint64_ = other.mapUint64Uint64_.Clone(); - mapSint32Sint32_ = other.mapSint32Sint32_.Clone(); - mapSint64Sint64_ = other.mapSint64Sint64_.Clone(); - mapFixed32Fixed32_ = other.mapFixed32Fixed32_.Clone(); - mapFixed64Fixed64_ = other.mapFixed64Fixed64_.Clone(); - mapSfixed32Sfixed32_ = other.mapSfixed32Sfixed32_.Clone(); - mapSfixed64Sfixed64_ = other.mapSfixed64Sfixed64_.Clone(); - mapInt32Float_ = other.mapInt32Float_.Clone(); - mapInt32Double_ = other.mapInt32Double_.Clone(); - mapBoolBool_ = other.mapBoolBool_.Clone(); - mapStringString_ = other.mapStringString_.Clone(); - mapStringBytes_ = other.mapStringBytes_.Clone(); - mapStringNestedMessage_ = other.mapStringNestedMessage_.Clone(); - mapStringForeignMessage_ = other.mapStringForeignMessage_.Clone(); - mapStringNestedEnum_ = other.mapStringNestedEnum_.Clone(); - mapStringForeignEnum_ = other.mapStringForeignEnum_.Clone(); - OptionalBoolWrapper = other.OptionalBoolWrapper; - OptionalInt32Wrapper = other.OptionalInt32Wrapper; - OptionalInt64Wrapper = other.OptionalInt64Wrapper; - OptionalUint32Wrapper = other.OptionalUint32Wrapper; - OptionalUint64Wrapper = other.OptionalUint64Wrapper; - OptionalFloatWrapper = other.OptionalFloatWrapper; - OptionalDoubleWrapper = other.OptionalDoubleWrapper; - OptionalStringWrapper = other.OptionalStringWrapper; - OptionalBytesWrapper = other.OptionalBytesWrapper; - repeatedBoolWrapper_ = other.repeatedBoolWrapper_.Clone(); - repeatedInt32Wrapper_ = other.repeatedInt32Wrapper_.Clone(); - repeatedInt64Wrapper_ = other.repeatedInt64Wrapper_.Clone(); - repeatedUint32Wrapper_ = other.repeatedUint32Wrapper_.Clone(); - repeatedUint64Wrapper_ = other.repeatedUint64Wrapper_.Clone(); - repeatedFloatWrapper_ = other.repeatedFloatWrapper_.Clone(); - repeatedDoubleWrapper_ = other.repeatedDoubleWrapper_.Clone(); - repeatedStringWrapper_ = other.repeatedStringWrapper_.Clone(); - repeatedBytesWrapper_ = other.repeatedBytesWrapper_.Clone(); - OptionalDuration = other.optionalDuration_ != null ? other.OptionalDuration.Clone() : null; - OptionalTimestamp = other.optionalTimestamp_ != null ? other.OptionalTimestamp.Clone() : null; - OptionalFieldMask = other.optionalFieldMask_ != null ? other.OptionalFieldMask.Clone() : null; - OptionalStruct = other.optionalStruct_ != null ? other.OptionalStruct.Clone() : null; - OptionalAny = other.optionalAny_ != null ? other.OptionalAny.Clone() : null; - OptionalValue = other.optionalValue_ != null ? other.OptionalValue.Clone() : null; - repeatedDuration_ = other.repeatedDuration_.Clone(); - repeatedTimestamp_ = other.repeatedTimestamp_.Clone(); - repeatedFieldmask_ = other.repeatedFieldmask_.Clone(); - repeatedStruct_ = other.repeatedStruct_.Clone(); - repeatedAny_ = other.repeatedAny_.Clone(); - repeatedValue_ = other.repeatedValue_.Clone(); - fieldname1_ = other.fieldname1_; - fieldName2_ = other.fieldName2_; - FieldName3_ = other.FieldName3_; - fieldName4_ = other.fieldName4_; - field0Name5_ = other.field0Name5_; - field0Name6_ = other.field0Name6_; - fieldName7_ = other.fieldName7_; - fieldName8_ = other.fieldName8_; - fieldName9_ = other.fieldName9_; - fieldName10_ = other.fieldName10_; - fIELDNAME11_ = other.fIELDNAME11_; - fIELDName12_ = other.fIELDName12_; - switch (other.OneofFieldCase) { - case OneofFieldOneofCase.OneofUint32: - OneofUint32 = other.OneofUint32; - break; - case OneofFieldOneofCase.OneofNestedMessage: - OneofNestedMessage = other.OneofNestedMessage.Clone(); - break; - case OneofFieldOneofCase.OneofString: - OneofString = other.OneofString; - break; - case OneofFieldOneofCase.OneofBytes: - OneofBytes = other.OneofBytes; - break; - } - + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public JspbEncodingConfig(JspbEncodingConfig other) : this() { + useJspbArrayAnyFormat_ = other.useJspbArrayAnyFormat_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } - public TestAllTypes Clone() { - return new TestAllTypes(this); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public JspbEncodingConfig Clone() { + return new JspbEncodingConfig(this); } - /// Field number for the "optional_int32" field. - public const int OptionalInt32FieldNumber = 1; - private int optionalInt32_; + /// Field number for the "use_jspb_array_any_format" field. + public const int UseJspbArrayAnyFormatFieldNumber = 1; + private bool useJspbArrayAnyFormat_; /// - /// Singular + /// Encode the value field of Any as jspb array if ture, otherwise binary. /// - public int OptionalInt32 { - get { return optionalInt32_; } - set { - optionalInt32_ = value; - } - } - - /// Field number for the "optional_int64" field. - public const int OptionalInt64FieldNumber = 2; - private long optionalInt64_; - public long OptionalInt64 { - get { return optionalInt64_; } - set { - optionalInt64_ = value; - } - } - - /// Field number for the "optional_uint32" field. - public const int OptionalUint32FieldNumber = 3; - private uint optionalUint32_; - public uint OptionalUint32 { - get { return optionalUint32_; } - set { - optionalUint32_ = value; - } - } - - /// Field number for the "optional_uint64" field. - public const int OptionalUint64FieldNumber = 4; - private ulong optionalUint64_; - public ulong OptionalUint64 { - get { return optionalUint64_; } - set { - optionalUint64_ = value; - } - } - - /// Field number for the "optional_sint32" field. - public const int OptionalSint32FieldNumber = 5; - private int optionalSint32_; - public int OptionalSint32 { - get { return optionalSint32_; } - set { - optionalSint32_ = value; - } - } - - /// Field number for the "optional_sint64" field. - public const int OptionalSint64FieldNumber = 6; - private long optionalSint64_; - public long OptionalSint64 { - get { return optionalSint64_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool UseJspbArrayAnyFormat { + get { return useJspbArrayAnyFormat_; } set { - optionalSint64_ = value; + useJspbArrayAnyFormat_ = value; } } - /// Field number for the "optional_fixed32" field. - public const int OptionalFixed32FieldNumber = 7; - private uint optionalFixed32_; - public uint OptionalFixed32 { - get { return optionalFixed32_; } - set { - optionalFixed32_ = value; - } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as JspbEncodingConfig); } - /// Field number for the "optional_fixed64" field. - public const int OptionalFixed64FieldNumber = 8; - private ulong optionalFixed64_; - public ulong OptionalFixed64 { - get { return optionalFixed64_; } - set { - optionalFixed64_ = value; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(JspbEncodingConfig other) { + if (ReferenceEquals(other, null)) { + return false; } - } - - /// Field number for the "optional_sfixed32" field. - public const int OptionalSfixed32FieldNumber = 9; - private int optionalSfixed32_; - public int OptionalSfixed32 { - get { return optionalSfixed32_; } - set { - optionalSfixed32_ = value; + if (ReferenceEquals(other, this)) { + return true; } + if (UseJspbArrayAnyFormat != other.UseJspbArrayAnyFormat) return false; + return Equals(_unknownFields, other._unknownFields); } - /// Field number for the "optional_sfixed64" field. - public const int OptionalSfixed64FieldNumber = 10; - private long optionalSfixed64_; - public long OptionalSfixed64 { - get { return optionalSfixed64_; } - set { - optionalSfixed64_ = value; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (UseJspbArrayAnyFormat != false) hash ^= UseJspbArrayAnyFormat.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); } + return hash; } - /// Field number for the "optional_float" field. - public const int OptionalFloatFieldNumber = 11; - private float optionalFloat_; - public float OptionalFloat { - get { return optionalFloat_; } - set { - optionalFloat_ = value; - } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); } - /// Field number for the "optional_double" field. - public const int OptionalDoubleFieldNumber = 12; - private double optionalDouble_; - public double OptionalDouble { - get { return optionalDouble_; } - set { - optionalDouble_ = value; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (UseJspbArrayAnyFormat != false) { + output.WriteRawTag(8); + output.WriteBool(UseJspbArrayAnyFormat); } - } - - /// Field number for the "optional_bool" field. - public const int OptionalBoolFieldNumber = 13; - private bool optionalBool_; - public bool OptionalBool { - get { return optionalBool_; } - set { - optionalBool_ = value; + if (_unknownFields != null) { + _unknownFields.WriteTo(output); } } - /// Field number for the "optional_string" field. - public const int OptionalStringFieldNumber = 14; - private string optionalString_ = ""; - public string OptionalString { - get { return optionalString_; } - set { - optionalString_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (UseJspbArrayAnyFormat != false) { + size += 1 + 1; } - } - - /// Field number for the "optional_bytes" field. - public const int OptionalBytesFieldNumber = 15; - private pb::ByteString optionalBytes_ = pb::ByteString.Empty; - public pb::ByteString OptionalBytes { - get { return optionalBytes_; } - set { - optionalBytes_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "optional_nested_message" field. - public const int OptionalNestedMessageFieldNumber = 18; - private global::Conformance.TestAllTypes.Types.NestedMessage optionalNestedMessage_; - public global::Conformance.TestAllTypes.Types.NestedMessage OptionalNestedMessage { - get { return optionalNestedMessage_; } - set { - optionalNestedMessage_ = value; - } - } - - /// Field number for the "optional_foreign_message" field. - public const int OptionalForeignMessageFieldNumber = 19; - private global::Conformance.ForeignMessage optionalForeignMessage_; - public global::Conformance.ForeignMessage OptionalForeignMessage { - get { return optionalForeignMessage_; } - set { - optionalForeignMessage_ = value; - } - } - - /// Field number for the "optional_nested_enum" field. - public const int OptionalNestedEnumFieldNumber = 21; - private global::Conformance.TestAllTypes.Types.NestedEnum optionalNestedEnum_ = 0; - public global::Conformance.TestAllTypes.Types.NestedEnum OptionalNestedEnum { - get { return optionalNestedEnum_; } - set { - optionalNestedEnum_ = value; - } - } - - /// Field number for the "optional_foreign_enum" field. - public const int OptionalForeignEnumFieldNumber = 22; - private global::Conformance.ForeignEnum optionalForeignEnum_ = 0; - public global::Conformance.ForeignEnum OptionalForeignEnum { - get { return optionalForeignEnum_; } - set { - optionalForeignEnum_ = value; - } - } - - /// Field number for the "optional_string_piece" field. - public const int OptionalStringPieceFieldNumber = 24; - private string optionalStringPiece_ = ""; - public string OptionalStringPiece { - get { return optionalStringPiece_; } - set { - optionalStringPiece_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "optional_cord" field. - public const int OptionalCordFieldNumber = 25; - private string optionalCord_ = ""; - public string OptionalCord { - get { return optionalCord_; } - set { - optionalCord_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "recursive_message" field. - public const int RecursiveMessageFieldNumber = 27; - private global::Conformance.TestAllTypes recursiveMessage_; - public global::Conformance.TestAllTypes RecursiveMessage { - get { return recursiveMessage_; } - set { - recursiveMessage_ = value; - } - } - - /// Field number for the "repeated_int32" field. - public const int RepeatedInt32FieldNumber = 31; - private static readonly pb::FieldCodec _repeated_repeatedInt32_codec - = pb::FieldCodec.ForInt32(250); - private readonly pbc::RepeatedField repeatedInt32_ = new pbc::RepeatedField(); - /// - /// Repeated - /// - public pbc::RepeatedField RepeatedInt32 { - get { return repeatedInt32_; } - } - - /// Field number for the "repeated_int64" field. - public const int RepeatedInt64FieldNumber = 32; - private static readonly pb::FieldCodec _repeated_repeatedInt64_codec - = pb::FieldCodec.ForInt64(258); - private readonly pbc::RepeatedField repeatedInt64_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedInt64 { - get { return repeatedInt64_; } - } - - /// Field number for the "repeated_uint32" field. - public const int RepeatedUint32FieldNumber = 33; - private static readonly pb::FieldCodec _repeated_repeatedUint32_codec - = pb::FieldCodec.ForUInt32(266); - private readonly pbc::RepeatedField repeatedUint32_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedUint32 { - get { return repeatedUint32_; } - } - - /// Field number for the "repeated_uint64" field. - public const int RepeatedUint64FieldNumber = 34; - private static readonly pb::FieldCodec _repeated_repeatedUint64_codec - = pb::FieldCodec.ForUInt64(274); - private readonly pbc::RepeatedField repeatedUint64_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedUint64 { - get { return repeatedUint64_; } - } - - /// Field number for the "repeated_sint32" field. - public const int RepeatedSint32FieldNumber = 35; - private static readonly pb::FieldCodec _repeated_repeatedSint32_codec - = pb::FieldCodec.ForSInt32(282); - private readonly pbc::RepeatedField repeatedSint32_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedSint32 { - get { return repeatedSint32_; } - } - - /// Field number for the "repeated_sint64" field. - public const int RepeatedSint64FieldNumber = 36; - private static readonly pb::FieldCodec _repeated_repeatedSint64_codec - = pb::FieldCodec.ForSInt64(290); - private readonly pbc::RepeatedField repeatedSint64_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedSint64 { - get { return repeatedSint64_; } - } - - /// Field number for the "repeated_fixed32" field. - public const int RepeatedFixed32FieldNumber = 37; - private static readonly pb::FieldCodec _repeated_repeatedFixed32_codec - = pb::FieldCodec.ForFixed32(298); - private readonly pbc::RepeatedField repeatedFixed32_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedFixed32 { - get { return repeatedFixed32_; } - } - - /// Field number for the "repeated_fixed64" field. - public const int RepeatedFixed64FieldNumber = 38; - private static readonly pb::FieldCodec _repeated_repeatedFixed64_codec - = pb::FieldCodec.ForFixed64(306); - private readonly pbc::RepeatedField repeatedFixed64_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedFixed64 { - get { return repeatedFixed64_; } - } - - /// Field number for the "repeated_sfixed32" field. - public const int RepeatedSfixed32FieldNumber = 39; - private static readonly pb::FieldCodec _repeated_repeatedSfixed32_codec - = pb::FieldCodec.ForSFixed32(314); - private readonly pbc::RepeatedField repeatedSfixed32_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedSfixed32 { - get { return repeatedSfixed32_; } - } - - /// Field number for the "repeated_sfixed64" field. - public const int RepeatedSfixed64FieldNumber = 40; - private static readonly pb::FieldCodec _repeated_repeatedSfixed64_codec - = pb::FieldCodec.ForSFixed64(322); - private readonly pbc::RepeatedField repeatedSfixed64_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedSfixed64 { - get { return repeatedSfixed64_; } - } - - /// Field number for the "repeated_float" field. - public const int RepeatedFloatFieldNumber = 41; - private static readonly pb::FieldCodec _repeated_repeatedFloat_codec - = pb::FieldCodec.ForFloat(330); - private readonly pbc::RepeatedField repeatedFloat_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedFloat { - get { return repeatedFloat_; } - } - - /// Field number for the "repeated_double" field. - public const int RepeatedDoubleFieldNumber = 42; - private static readonly pb::FieldCodec _repeated_repeatedDouble_codec - = pb::FieldCodec.ForDouble(338); - private readonly pbc::RepeatedField repeatedDouble_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedDouble { - get { return repeatedDouble_; } - } - - /// Field number for the "repeated_bool" field. - public const int RepeatedBoolFieldNumber = 43; - private static readonly pb::FieldCodec _repeated_repeatedBool_codec - = pb::FieldCodec.ForBool(346); - private readonly pbc::RepeatedField repeatedBool_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedBool { - get { return repeatedBool_; } - } - - /// Field number for the "repeated_string" field. - public const int RepeatedStringFieldNumber = 44; - private static readonly pb::FieldCodec _repeated_repeatedString_codec - = pb::FieldCodec.ForString(354); - private readonly pbc::RepeatedField repeatedString_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedString { - get { return repeatedString_; } - } - - /// Field number for the "repeated_bytes" field. - public const int RepeatedBytesFieldNumber = 45; - private static readonly pb::FieldCodec _repeated_repeatedBytes_codec - = pb::FieldCodec.ForBytes(362); - private readonly pbc::RepeatedField repeatedBytes_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedBytes { - get { return repeatedBytes_; } - } - - /// Field number for the "repeated_nested_message" field. - public const int RepeatedNestedMessageFieldNumber = 48; - private static readonly pb::FieldCodec _repeated_repeatedNestedMessage_codec - = pb::FieldCodec.ForMessage(386, global::Conformance.TestAllTypes.Types.NestedMessage.Parser); - private readonly pbc::RepeatedField repeatedNestedMessage_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedNestedMessage { - get { return repeatedNestedMessage_; } - } - - /// Field number for the "repeated_foreign_message" field. - public const int RepeatedForeignMessageFieldNumber = 49; - private static readonly pb::FieldCodec _repeated_repeatedForeignMessage_codec - = pb::FieldCodec.ForMessage(394, global::Conformance.ForeignMessage.Parser); - private readonly pbc::RepeatedField repeatedForeignMessage_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedForeignMessage { - get { return repeatedForeignMessage_; } - } - - /// Field number for the "repeated_nested_enum" field. - public const int RepeatedNestedEnumFieldNumber = 51; - private static readonly pb::FieldCodec _repeated_repeatedNestedEnum_codec - = pb::FieldCodec.ForEnum(410, x => (int) x, x => (global::Conformance.TestAllTypes.Types.NestedEnum) x); - private readonly pbc::RepeatedField repeatedNestedEnum_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedNestedEnum { - get { return repeatedNestedEnum_; } - } - - /// Field number for the "repeated_foreign_enum" field. - public const int RepeatedForeignEnumFieldNumber = 52; - private static readonly pb::FieldCodec _repeated_repeatedForeignEnum_codec - = pb::FieldCodec.ForEnum(418, x => (int) x, x => (global::Conformance.ForeignEnum) x); - private readonly pbc::RepeatedField repeatedForeignEnum_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedForeignEnum { - get { return repeatedForeignEnum_; } - } - - /// Field number for the "repeated_string_piece" field. - public const int RepeatedStringPieceFieldNumber = 54; - private static readonly pb::FieldCodec _repeated_repeatedStringPiece_codec - = pb::FieldCodec.ForString(434); - private readonly pbc::RepeatedField repeatedStringPiece_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedStringPiece { - get { return repeatedStringPiece_; } - } - - /// Field number for the "repeated_cord" field. - public const int RepeatedCordFieldNumber = 55; - private static readonly pb::FieldCodec _repeated_repeatedCord_codec - = pb::FieldCodec.ForString(442); - private readonly pbc::RepeatedField repeatedCord_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedCord { - get { return repeatedCord_; } - } - - /// Field number for the "map_int32_int32" field. - public const int MapInt32Int32FieldNumber = 56; - private static readonly pbc::MapField.Codec _map_mapInt32Int32_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForInt32(16), 450); - private readonly pbc::MapField mapInt32Int32_ = new pbc::MapField(); - /// - /// Map - /// - public pbc::MapField MapInt32Int32 { - get { return mapInt32Int32_; } - } - - /// Field number for the "map_int64_int64" field. - public const int MapInt64Int64FieldNumber = 57; - private static readonly pbc::MapField.Codec _map_mapInt64Int64_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt64(8), pb::FieldCodec.ForInt64(16), 458); - private readonly pbc::MapField mapInt64Int64_ = new pbc::MapField(); - public pbc::MapField MapInt64Int64 { - get { return mapInt64Int64_; } - } - - /// Field number for the "map_uint32_uint32" field. - public const int MapUint32Uint32FieldNumber = 58; - private static readonly pbc::MapField.Codec _map_mapUint32Uint32_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForUInt32(8), pb::FieldCodec.ForUInt32(16), 466); - private readonly pbc::MapField mapUint32Uint32_ = new pbc::MapField(); - public pbc::MapField MapUint32Uint32 { - get { return mapUint32Uint32_; } - } - - /// Field number for the "map_uint64_uint64" field. - public const int MapUint64Uint64FieldNumber = 59; - private static readonly pbc::MapField.Codec _map_mapUint64Uint64_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForUInt64(8), pb::FieldCodec.ForUInt64(16), 474); - private readonly pbc::MapField mapUint64Uint64_ = new pbc::MapField(); - public pbc::MapField MapUint64Uint64 { - get { return mapUint64Uint64_; } - } - - /// Field number for the "map_sint32_sint32" field. - public const int MapSint32Sint32FieldNumber = 60; - private static readonly pbc::MapField.Codec _map_mapSint32Sint32_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForSInt32(8), pb::FieldCodec.ForSInt32(16), 482); - private readonly pbc::MapField mapSint32Sint32_ = new pbc::MapField(); - public pbc::MapField MapSint32Sint32 { - get { return mapSint32Sint32_; } - } - - /// Field number for the "map_sint64_sint64" field. - public const int MapSint64Sint64FieldNumber = 61; - private static readonly pbc::MapField.Codec _map_mapSint64Sint64_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForSInt64(8), pb::FieldCodec.ForSInt64(16), 490); - private readonly pbc::MapField mapSint64Sint64_ = new pbc::MapField(); - public pbc::MapField MapSint64Sint64 { - get { return mapSint64Sint64_; } - } - - /// Field number for the "map_fixed32_fixed32" field. - public const int MapFixed32Fixed32FieldNumber = 62; - private static readonly pbc::MapField.Codec _map_mapFixed32Fixed32_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForFixed32(13), pb::FieldCodec.ForFixed32(21), 498); - private readonly pbc::MapField mapFixed32Fixed32_ = new pbc::MapField(); - public pbc::MapField MapFixed32Fixed32 { - get { return mapFixed32Fixed32_; } - } - - /// Field number for the "map_fixed64_fixed64" field. - public const int MapFixed64Fixed64FieldNumber = 63; - private static readonly pbc::MapField.Codec _map_mapFixed64Fixed64_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForFixed64(9), pb::FieldCodec.ForFixed64(17), 506); - private readonly pbc::MapField mapFixed64Fixed64_ = new pbc::MapField(); - public pbc::MapField MapFixed64Fixed64 { - get { return mapFixed64Fixed64_; } - } - - /// Field number for the "map_sfixed32_sfixed32" field. - public const int MapSfixed32Sfixed32FieldNumber = 64; - private static readonly pbc::MapField.Codec _map_mapSfixed32Sfixed32_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForSFixed32(13), pb::FieldCodec.ForSFixed32(21), 514); - private readonly pbc::MapField mapSfixed32Sfixed32_ = new pbc::MapField(); - public pbc::MapField MapSfixed32Sfixed32 { - get { return mapSfixed32Sfixed32_; } - } - - /// Field number for the "map_sfixed64_sfixed64" field. - public const int MapSfixed64Sfixed64FieldNumber = 65; - private static readonly pbc::MapField.Codec _map_mapSfixed64Sfixed64_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForSFixed64(9), pb::FieldCodec.ForSFixed64(17), 522); - private readonly pbc::MapField mapSfixed64Sfixed64_ = new pbc::MapField(); - public pbc::MapField MapSfixed64Sfixed64 { - get { return mapSfixed64Sfixed64_; } - } - - /// Field number for the "map_int32_float" field. - public const int MapInt32FloatFieldNumber = 66; - private static readonly pbc::MapField.Codec _map_mapInt32Float_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForFloat(21), 530); - private readonly pbc::MapField mapInt32Float_ = new pbc::MapField(); - public pbc::MapField MapInt32Float { - get { return mapInt32Float_; } - } - - /// Field number for the "map_int32_double" field. - public const int MapInt32DoubleFieldNumber = 67; - private static readonly pbc::MapField.Codec _map_mapInt32Double_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForDouble(17), 538); - private readonly pbc::MapField mapInt32Double_ = new pbc::MapField(); - public pbc::MapField MapInt32Double { - get { return mapInt32Double_; } - } - - /// Field number for the "map_bool_bool" field. - public const int MapBoolBoolFieldNumber = 68; - private static readonly pbc::MapField.Codec _map_mapBoolBool_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForBool(8), pb::FieldCodec.ForBool(16), 546); - private readonly pbc::MapField mapBoolBool_ = new pbc::MapField(); - public pbc::MapField MapBoolBool { - get { return mapBoolBool_; } - } - - /// Field number for the "map_string_string" field. - public const int MapStringStringFieldNumber = 69; - private static readonly pbc::MapField.Codec _map_mapStringString_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForString(18), 554); - private readonly pbc::MapField mapStringString_ = new pbc::MapField(); - public pbc::MapField MapStringString { - get { return mapStringString_; } - } - - /// Field number for the "map_string_bytes" field. - public const int MapStringBytesFieldNumber = 70; - private static readonly pbc::MapField.Codec _map_mapStringBytes_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForBytes(18), 562); - private readonly pbc::MapField mapStringBytes_ = new pbc::MapField(); - public pbc::MapField MapStringBytes { - get { return mapStringBytes_; } - } - - /// Field number for the "map_string_nested_message" field. - public const int MapStringNestedMessageFieldNumber = 71; - private static readonly pbc::MapField.Codec _map_mapStringNestedMessage_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForMessage(18, global::Conformance.TestAllTypes.Types.NestedMessage.Parser), 570); - private readonly pbc::MapField mapStringNestedMessage_ = new pbc::MapField(); - public pbc::MapField MapStringNestedMessage { - get { return mapStringNestedMessage_; } - } - - /// Field number for the "map_string_foreign_message" field. - public const int MapStringForeignMessageFieldNumber = 72; - private static readonly pbc::MapField.Codec _map_mapStringForeignMessage_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForMessage(18, global::Conformance.ForeignMessage.Parser), 578); - private readonly pbc::MapField mapStringForeignMessage_ = new pbc::MapField(); - public pbc::MapField MapStringForeignMessage { - get { return mapStringForeignMessage_; } - } - - /// Field number for the "map_string_nested_enum" field. - public const int MapStringNestedEnumFieldNumber = 73; - private static readonly pbc::MapField.Codec _map_mapStringNestedEnum_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::Conformance.TestAllTypes.Types.NestedEnum) x), 586); - private readonly pbc::MapField mapStringNestedEnum_ = new pbc::MapField(); - public pbc::MapField MapStringNestedEnum { - get { return mapStringNestedEnum_; } - } - - /// Field number for the "map_string_foreign_enum" field. - public const int MapStringForeignEnumFieldNumber = 74; - private static readonly pbc::MapField.Codec _map_mapStringForeignEnum_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::Conformance.ForeignEnum) x), 594); - private readonly pbc::MapField mapStringForeignEnum_ = new pbc::MapField(); - public pbc::MapField MapStringForeignEnum { - get { return mapStringForeignEnum_; } - } - - /// Field number for the "oneof_uint32" field. - public const int OneofUint32FieldNumber = 111; - public uint OneofUint32 { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint32 ? (uint) oneofField_ : 0; } - set { - oneofField_ = value; - oneofFieldCase_ = OneofFieldOneofCase.OneofUint32; - } - } - - /// Field number for the "oneof_nested_message" field. - public const int OneofNestedMessageFieldNumber = 112; - public global::Conformance.TestAllTypes.Types.NestedMessage OneofNestedMessage { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage ? (global::Conformance.TestAllTypes.Types.NestedMessage) oneofField_ : null; } - set { - oneofField_ = value; - oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.OneofNestedMessage; - } - } - - /// Field number for the "oneof_string" field. - public const int OneofStringFieldNumber = 113; - public string OneofString { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofString ? (string) oneofField_ : ""; } - set { - oneofField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - oneofFieldCase_ = OneofFieldOneofCase.OneofString; - } - } - - /// Field number for the "oneof_bytes" field. - public const int OneofBytesFieldNumber = 114; - public pb::ByteString OneofBytes { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBytes ? (pb::ByteString) oneofField_ : pb::ByteString.Empty; } - set { - oneofField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - oneofFieldCase_ = OneofFieldOneofCase.OneofBytes; - } - } - - /// Field number for the "optional_bool_wrapper" field. - public const int OptionalBoolWrapperFieldNumber = 201; - private static readonly pb::FieldCodec _single_optionalBoolWrapper_codec = pb::FieldCodec.ForStructWrapper(1610); - private bool? optionalBoolWrapper_; - /// - /// Well-known types - /// - public bool? OptionalBoolWrapper { - get { return optionalBoolWrapper_; } - set { - optionalBoolWrapper_ = value; - } - } - - /// Field number for the "optional_int32_wrapper" field. - public const int OptionalInt32WrapperFieldNumber = 202; - private static readonly pb::FieldCodec _single_optionalInt32Wrapper_codec = pb::FieldCodec.ForStructWrapper(1618); - private int? optionalInt32Wrapper_; - public int? OptionalInt32Wrapper { - get { return optionalInt32Wrapper_; } - set { - optionalInt32Wrapper_ = value; - } - } - - /// Field number for the "optional_int64_wrapper" field. - public const int OptionalInt64WrapperFieldNumber = 203; - private static readonly pb::FieldCodec _single_optionalInt64Wrapper_codec = pb::FieldCodec.ForStructWrapper(1626); - private long? optionalInt64Wrapper_; - public long? OptionalInt64Wrapper { - get { return optionalInt64Wrapper_; } - set { - optionalInt64Wrapper_ = value; - } - } - - /// Field number for the "optional_uint32_wrapper" field. - public const int OptionalUint32WrapperFieldNumber = 204; - private static readonly pb::FieldCodec _single_optionalUint32Wrapper_codec = pb::FieldCodec.ForStructWrapper(1634); - private uint? optionalUint32Wrapper_; - public uint? OptionalUint32Wrapper { - get { return optionalUint32Wrapper_; } - set { - optionalUint32Wrapper_ = value; - } - } - - /// Field number for the "optional_uint64_wrapper" field. - public const int OptionalUint64WrapperFieldNumber = 205; - private static readonly pb::FieldCodec _single_optionalUint64Wrapper_codec = pb::FieldCodec.ForStructWrapper(1642); - private ulong? optionalUint64Wrapper_; - public ulong? OptionalUint64Wrapper { - get { return optionalUint64Wrapper_; } - set { - optionalUint64Wrapper_ = value; - } - } - - /// Field number for the "optional_float_wrapper" field. - public const int OptionalFloatWrapperFieldNumber = 206; - private static readonly pb::FieldCodec _single_optionalFloatWrapper_codec = pb::FieldCodec.ForStructWrapper(1650); - private float? optionalFloatWrapper_; - public float? OptionalFloatWrapper { - get { return optionalFloatWrapper_; } - set { - optionalFloatWrapper_ = value; - } - } - - /// Field number for the "optional_double_wrapper" field. - public const int OptionalDoubleWrapperFieldNumber = 207; - private static readonly pb::FieldCodec _single_optionalDoubleWrapper_codec = pb::FieldCodec.ForStructWrapper(1658); - private double? optionalDoubleWrapper_; - public double? OptionalDoubleWrapper { - get { return optionalDoubleWrapper_; } - set { - optionalDoubleWrapper_ = value; - } - } - - /// Field number for the "optional_string_wrapper" field. - public const int OptionalStringWrapperFieldNumber = 208; - private static readonly pb::FieldCodec _single_optionalStringWrapper_codec = pb::FieldCodec.ForClassWrapper(1666); - private string optionalStringWrapper_; - public string OptionalStringWrapper { - get { return optionalStringWrapper_; } - set { - optionalStringWrapper_ = value; - } - } - - /// Field number for the "optional_bytes_wrapper" field. - public const int OptionalBytesWrapperFieldNumber = 209; - private static readonly pb::FieldCodec _single_optionalBytesWrapper_codec = pb::FieldCodec.ForClassWrapper(1674); - private pb::ByteString optionalBytesWrapper_; - public pb::ByteString OptionalBytesWrapper { - get { return optionalBytesWrapper_; } - set { - optionalBytesWrapper_ = value; - } - } - - /// Field number for the "repeated_bool_wrapper" field. - public const int RepeatedBoolWrapperFieldNumber = 211; - private static readonly pb::FieldCodec _repeated_repeatedBoolWrapper_codec - = pb::FieldCodec.ForStructWrapper(1690); - private readonly pbc::RepeatedField repeatedBoolWrapper_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedBoolWrapper { - get { return repeatedBoolWrapper_; } - } - - /// Field number for the "repeated_int32_wrapper" field. - public const int RepeatedInt32WrapperFieldNumber = 212; - private static readonly pb::FieldCodec _repeated_repeatedInt32Wrapper_codec - = pb::FieldCodec.ForStructWrapper(1698); - private readonly pbc::RepeatedField repeatedInt32Wrapper_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedInt32Wrapper { - get { return repeatedInt32Wrapper_; } - } - - /// Field number for the "repeated_int64_wrapper" field. - public const int RepeatedInt64WrapperFieldNumber = 213; - private static readonly pb::FieldCodec _repeated_repeatedInt64Wrapper_codec - = pb::FieldCodec.ForStructWrapper(1706); - private readonly pbc::RepeatedField repeatedInt64Wrapper_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedInt64Wrapper { - get { return repeatedInt64Wrapper_; } - } - - /// Field number for the "repeated_uint32_wrapper" field. - public const int RepeatedUint32WrapperFieldNumber = 214; - private static readonly pb::FieldCodec _repeated_repeatedUint32Wrapper_codec - = pb::FieldCodec.ForStructWrapper(1714); - private readonly pbc::RepeatedField repeatedUint32Wrapper_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedUint32Wrapper { - get { return repeatedUint32Wrapper_; } - } - - /// Field number for the "repeated_uint64_wrapper" field. - public const int RepeatedUint64WrapperFieldNumber = 215; - private static readonly pb::FieldCodec _repeated_repeatedUint64Wrapper_codec - = pb::FieldCodec.ForStructWrapper(1722); - private readonly pbc::RepeatedField repeatedUint64Wrapper_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedUint64Wrapper { - get { return repeatedUint64Wrapper_; } - } - - /// Field number for the "repeated_float_wrapper" field. - public const int RepeatedFloatWrapperFieldNumber = 216; - private static readonly pb::FieldCodec _repeated_repeatedFloatWrapper_codec - = pb::FieldCodec.ForStructWrapper(1730); - private readonly pbc::RepeatedField repeatedFloatWrapper_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedFloatWrapper { - get { return repeatedFloatWrapper_; } - } - - /// Field number for the "repeated_double_wrapper" field. - public const int RepeatedDoubleWrapperFieldNumber = 217; - private static readonly pb::FieldCodec _repeated_repeatedDoubleWrapper_codec - = pb::FieldCodec.ForStructWrapper(1738); - private readonly pbc::RepeatedField repeatedDoubleWrapper_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedDoubleWrapper { - get { return repeatedDoubleWrapper_; } - } - - /// Field number for the "repeated_string_wrapper" field. - public const int RepeatedStringWrapperFieldNumber = 218; - private static readonly pb::FieldCodec _repeated_repeatedStringWrapper_codec - = pb::FieldCodec.ForClassWrapper(1746); - private readonly pbc::RepeatedField repeatedStringWrapper_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedStringWrapper { - get { return repeatedStringWrapper_; } - } - - /// Field number for the "repeated_bytes_wrapper" field. - public const int RepeatedBytesWrapperFieldNumber = 219; - private static readonly pb::FieldCodec _repeated_repeatedBytesWrapper_codec - = pb::FieldCodec.ForClassWrapper(1754); - private readonly pbc::RepeatedField repeatedBytesWrapper_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedBytesWrapper { - get { return repeatedBytesWrapper_; } - } - - /// Field number for the "optional_duration" field. - public const int OptionalDurationFieldNumber = 301; - private global::Google.Protobuf.WellKnownTypes.Duration optionalDuration_; - public global::Google.Protobuf.WellKnownTypes.Duration OptionalDuration { - get { return optionalDuration_; } - set { - optionalDuration_ = value; - } - } - - /// Field number for the "optional_timestamp" field. - public const int OptionalTimestampFieldNumber = 302; - private global::Google.Protobuf.WellKnownTypes.Timestamp optionalTimestamp_; - public global::Google.Protobuf.WellKnownTypes.Timestamp OptionalTimestamp { - get { return optionalTimestamp_; } - set { - optionalTimestamp_ = value; - } - } - - /// Field number for the "optional_field_mask" field. - public const int OptionalFieldMaskFieldNumber = 303; - private global::Google.Protobuf.WellKnownTypes.FieldMask optionalFieldMask_; - public global::Google.Protobuf.WellKnownTypes.FieldMask OptionalFieldMask { - get { return optionalFieldMask_; } - set { - optionalFieldMask_ = value; - } - } - - /// Field number for the "optional_struct" field. - public const int OptionalStructFieldNumber = 304; - private global::Google.Protobuf.WellKnownTypes.Struct optionalStruct_; - public global::Google.Protobuf.WellKnownTypes.Struct OptionalStruct { - get { return optionalStruct_; } - set { - optionalStruct_ = value; - } - } - - /// Field number for the "optional_any" field. - public const int OptionalAnyFieldNumber = 305; - private global::Google.Protobuf.WellKnownTypes.Any optionalAny_; - public global::Google.Protobuf.WellKnownTypes.Any OptionalAny { - get { return optionalAny_; } - set { - optionalAny_ = value; - } - } - - /// Field number for the "optional_value" field. - public const int OptionalValueFieldNumber = 306; - private global::Google.Protobuf.WellKnownTypes.Value optionalValue_; - public global::Google.Protobuf.WellKnownTypes.Value OptionalValue { - get { return optionalValue_; } - set { - optionalValue_ = value; - } - } - - /// Field number for the "repeated_duration" field. - public const int RepeatedDurationFieldNumber = 311; - private static readonly pb::FieldCodec _repeated_repeatedDuration_codec - = pb::FieldCodec.ForMessage(2490, global::Google.Protobuf.WellKnownTypes.Duration.Parser); - private readonly pbc::RepeatedField repeatedDuration_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedDuration { - get { return repeatedDuration_; } - } - - /// Field number for the "repeated_timestamp" field. - public const int RepeatedTimestampFieldNumber = 312; - private static readonly pb::FieldCodec _repeated_repeatedTimestamp_codec - = pb::FieldCodec.ForMessage(2498, global::Google.Protobuf.WellKnownTypes.Timestamp.Parser); - private readonly pbc::RepeatedField repeatedTimestamp_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedTimestamp { - get { return repeatedTimestamp_; } - } - - /// Field number for the "repeated_fieldmask" field. - public const int RepeatedFieldmaskFieldNumber = 313; - private static readonly pb::FieldCodec _repeated_repeatedFieldmask_codec - = pb::FieldCodec.ForMessage(2506, global::Google.Protobuf.WellKnownTypes.FieldMask.Parser); - private readonly pbc::RepeatedField repeatedFieldmask_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedFieldmask { - get { return repeatedFieldmask_; } - } - - /// Field number for the "repeated_struct" field. - public const int RepeatedStructFieldNumber = 324; - private static readonly pb::FieldCodec _repeated_repeatedStruct_codec - = pb::FieldCodec.ForMessage(2594, global::Google.Protobuf.WellKnownTypes.Struct.Parser); - private readonly pbc::RepeatedField repeatedStruct_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedStruct { - get { return repeatedStruct_; } - } - - /// Field number for the "repeated_any" field. - public const int RepeatedAnyFieldNumber = 315; - private static readonly pb::FieldCodec _repeated_repeatedAny_codec - = pb::FieldCodec.ForMessage(2522, global::Google.Protobuf.WellKnownTypes.Any.Parser); - private readonly pbc::RepeatedField repeatedAny_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedAny { - get { return repeatedAny_; } - } - - /// Field number for the "repeated_value" field. - public const int RepeatedValueFieldNumber = 316; - private static readonly pb::FieldCodec _repeated_repeatedValue_codec - = pb::FieldCodec.ForMessage(2530, global::Google.Protobuf.WellKnownTypes.Value.Parser); - private readonly pbc::RepeatedField repeatedValue_ = new pbc::RepeatedField(); - public pbc::RepeatedField RepeatedValue { - get { return repeatedValue_; } - } - - /// Field number for the "fieldname1" field. - public const int Fieldname1FieldNumber = 401; - private int fieldname1_; - /// - /// Test field-name-to-JSON-name convention. - /// - public int Fieldname1 { - get { return fieldname1_; } - set { - fieldname1_ = value; - } - } - - /// Field number for the "field_name2" field. - public const int FieldName2FieldNumber = 402; - private int fieldName2_; - public int FieldName2 { - get { return fieldName2_; } - set { - fieldName2_ = value; - } - } - - /// Field number for the "_field_name3" field. - public const int FieldName3FieldNumber = 403; - private int FieldName3_; - public int FieldName3 { - get { return FieldName3_; } - set { - FieldName3_ = value; - } - } - - /// Field number for the "field__name4_" field. - public const int FieldName4FieldNumber = 404; - private int fieldName4_; - public int FieldName4 { - get { return fieldName4_; } - set { - fieldName4_ = value; - } - } - - /// Field number for the "field0name5" field. - public const int Field0Name5FieldNumber = 405; - private int field0Name5_; - public int Field0Name5 { - get { return field0Name5_; } - set { - field0Name5_ = value; - } - } - - /// Field number for the "field_0_name6" field. - public const int Field0Name6FieldNumber = 406; - private int field0Name6_; - public int Field0Name6 { - get { return field0Name6_; } - set { - field0Name6_ = value; - } - } - - /// Field number for the "fieldName7" field. - public const int FieldName7FieldNumber = 407; - private int fieldName7_; - public int FieldName7 { - get { return fieldName7_; } - set { - fieldName7_ = value; - } - } - - /// Field number for the "FieldName8" field. - public const int FieldName8FieldNumber = 408; - private int fieldName8_; - public int FieldName8 { - get { return fieldName8_; } - set { - fieldName8_ = value; - } - } - - /// Field number for the "field_Name9" field. - public const int FieldName9FieldNumber = 409; - private int fieldName9_; - public int FieldName9 { - get { return fieldName9_; } - set { - fieldName9_ = value; - } - } - - /// Field number for the "Field_Name10" field. - public const int FieldName10FieldNumber = 410; - private int fieldName10_; - public int FieldName10 { - get { return fieldName10_; } - set { - fieldName10_ = value; - } - } - - /// Field number for the "FIELD_NAME11" field. - public const int FIELDNAME11FieldNumber = 411; - private int fIELDNAME11_; - public int FIELDNAME11 { - get { return fIELDNAME11_; } - set { - fIELDNAME11_ = value; - } - } - - /// Field number for the "FIELD_name12" field. - public const int FIELDName12FieldNumber = 412; - private int fIELDName12_; - public int FIELDName12 { - get { return fIELDName12_; } - set { - fIELDName12_ = value; - } - } - - private object oneofField_; - /// Enum of possible cases for the "oneof_field" oneof. - public enum OneofFieldOneofCase { - None = 0, - OneofUint32 = 111, - OneofNestedMessage = 112, - OneofString = 113, - OneofBytes = 114, - } - private OneofFieldOneofCase oneofFieldCase_ = OneofFieldOneofCase.None; - public OneofFieldOneofCase OneofFieldCase { - get { return oneofFieldCase_; } - } - - public void ClearOneofField() { - oneofFieldCase_ = OneofFieldOneofCase.None; - oneofField_ = null; - } - - public override bool Equals(object other) { - return Equals(other as TestAllTypes); - } - - public bool Equals(TestAllTypes other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (OptionalInt32 != other.OptionalInt32) return false; - if (OptionalInt64 != other.OptionalInt64) return false; - if (OptionalUint32 != other.OptionalUint32) return false; - if (OptionalUint64 != other.OptionalUint64) return false; - if (OptionalSint32 != other.OptionalSint32) return false; - if (OptionalSint64 != other.OptionalSint64) return false; - if (OptionalFixed32 != other.OptionalFixed32) return false; - if (OptionalFixed64 != other.OptionalFixed64) return false; - if (OptionalSfixed32 != other.OptionalSfixed32) return false; - if (OptionalSfixed64 != other.OptionalSfixed64) return false; - if (OptionalFloat != other.OptionalFloat) return false; - if (OptionalDouble != other.OptionalDouble) return false; - if (OptionalBool != other.OptionalBool) return false; - if (OptionalString != other.OptionalString) return false; - if (OptionalBytes != other.OptionalBytes) return false; - if (!object.Equals(OptionalNestedMessage, other.OptionalNestedMessage)) return false; - if (!object.Equals(OptionalForeignMessage, other.OptionalForeignMessage)) return false; - if (OptionalNestedEnum != other.OptionalNestedEnum) return false; - if (OptionalForeignEnum != other.OptionalForeignEnum) return false; - if (OptionalStringPiece != other.OptionalStringPiece) return false; - if (OptionalCord != other.OptionalCord) return false; - if (!object.Equals(RecursiveMessage, other.RecursiveMessage)) return false; - if(!repeatedInt32_.Equals(other.repeatedInt32_)) return false; - if(!repeatedInt64_.Equals(other.repeatedInt64_)) return false; - if(!repeatedUint32_.Equals(other.repeatedUint32_)) return false; - if(!repeatedUint64_.Equals(other.repeatedUint64_)) return false; - if(!repeatedSint32_.Equals(other.repeatedSint32_)) return false; - if(!repeatedSint64_.Equals(other.repeatedSint64_)) return false; - if(!repeatedFixed32_.Equals(other.repeatedFixed32_)) return false; - if(!repeatedFixed64_.Equals(other.repeatedFixed64_)) return false; - if(!repeatedSfixed32_.Equals(other.repeatedSfixed32_)) return false; - if(!repeatedSfixed64_.Equals(other.repeatedSfixed64_)) return false; - if(!repeatedFloat_.Equals(other.repeatedFloat_)) return false; - if(!repeatedDouble_.Equals(other.repeatedDouble_)) return false; - if(!repeatedBool_.Equals(other.repeatedBool_)) return false; - if(!repeatedString_.Equals(other.repeatedString_)) return false; - if(!repeatedBytes_.Equals(other.repeatedBytes_)) return false; - if(!repeatedNestedMessage_.Equals(other.repeatedNestedMessage_)) return false; - if(!repeatedForeignMessage_.Equals(other.repeatedForeignMessage_)) return false; - if(!repeatedNestedEnum_.Equals(other.repeatedNestedEnum_)) return false; - if(!repeatedForeignEnum_.Equals(other.repeatedForeignEnum_)) return false; - if(!repeatedStringPiece_.Equals(other.repeatedStringPiece_)) return false; - if(!repeatedCord_.Equals(other.repeatedCord_)) return false; - if (!MapInt32Int32.Equals(other.MapInt32Int32)) return false; - if (!MapInt64Int64.Equals(other.MapInt64Int64)) return false; - if (!MapUint32Uint32.Equals(other.MapUint32Uint32)) return false; - if (!MapUint64Uint64.Equals(other.MapUint64Uint64)) return false; - if (!MapSint32Sint32.Equals(other.MapSint32Sint32)) return false; - if (!MapSint64Sint64.Equals(other.MapSint64Sint64)) return false; - if (!MapFixed32Fixed32.Equals(other.MapFixed32Fixed32)) return false; - if (!MapFixed64Fixed64.Equals(other.MapFixed64Fixed64)) return false; - if (!MapSfixed32Sfixed32.Equals(other.MapSfixed32Sfixed32)) return false; - if (!MapSfixed64Sfixed64.Equals(other.MapSfixed64Sfixed64)) return false; - if (!MapInt32Float.Equals(other.MapInt32Float)) return false; - if (!MapInt32Double.Equals(other.MapInt32Double)) return false; - if (!MapBoolBool.Equals(other.MapBoolBool)) return false; - if (!MapStringString.Equals(other.MapStringString)) return false; - if (!MapStringBytes.Equals(other.MapStringBytes)) return false; - if (!MapStringNestedMessage.Equals(other.MapStringNestedMessage)) return false; - if (!MapStringForeignMessage.Equals(other.MapStringForeignMessage)) return false; - if (!MapStringNestedEnum.Equals(other.MapStringNestedEnum)) return false; - if (!MapStringForeignEnum.Equals(other.MapStringForeignEnum)) return false; - if (OneofUint32 != other.OneofUint32) return false; - if (!object.Equals(OneofNestedMessage, other.OneofNestedMessage)) return false; - if (OneofString != other.OneofString) return false; - if (OneofBytes != other.OneofBytes) return false; - if (OptionalBoolWrapper != other.OptionalBoolWrapper) return false; - if (OptionalInt32Wrapper != other.OptionalInt32Wrapper) return false; - if (OptionalInt64Wrapper != other.OptionalInt64Wrapper) return false; - if (OptionalUint32Wrapper != other.OptionalUint32Wrapper) return false; - if (OptionalUint64Wrapper != other.OptionalUint64Wrapper) return false; - if (OptionalFloatWrapper != other.OptionalFloatWrapper) return false; - if (OptionalDoubleWrapper != other.OptionalDoubleWrapper) return false; - if (OptionalStringWrapper != other.OptionalStringWrapper) return false; - if (OptionalBytesWrapper != other.OptionalBytesWrapper) return false; - if(!repeatedBoolWrapper_.Equals(other.repeatedBoolWrapper_)) return false; - if(!repeatedInt32Wrapper_.Equals(other.repeatedInt32Wrapper_)) return false; - if(!repeatedInt64Wrapper_.Equals(other.repeatedInt64Wrapper_)) return false; - if(!repeatedUint32Wrapper_.Equals(other.repeatedUint32Wrapper_)) return false; - if(!repeatedUint64Wrapper_.Equals(other.repeatedUint64Wrapper_)) return false; - if(!repeatedFloatWrapper_.Equals(other.repeatedFloatWrapper_)) return false; - if(!repeatedDoubleWrapper_.Equals(other.repeatedDoubleWrapper_)) return false; - if(!repeatedStringWrapper_.Equals(other.repeatedStringWrapper_)) return false; - if(!repeatedBytesWrapper_.Equals(other.repeatedBytesWrapper_)) return false; - if (!object.Equals(OptionalDuration, other.OptionalDuration)) return false; - if (!object.Equals(OptionalTimestamp, other.OptionalTimestamp)) return false; - if (!object.Equals(OptionalFieldMask, other.OptionalFieldMask)) return false; - if (!object.Equals(OptionalStruct, other.OptionalStruct)) return false; - if (!object.Equals(OptionalAny, other.OptionalAny)) return false; - if (!object.Equals(OptionalValue, other.OptionalValue)) return false; - if(!repeatedDuration_.Equals(other.repeatedDuration_)) return false; - if(!repeatedTimestamp_.Equals(other.repeatedTimestamp_)) return false; - if(!repeatedFieldmask_.Equals(other.repeatedFieldmask_)) return false; - if(!repeatedStruct_.Equals(other.repeatedStruct_)) return false; - if(!repeatedAny_.Equals(other.repeatedAny_)) return false; - if(!repeatedValue_.Equals(other.repeatedValue_)) return false; - if (Fieldname1 != other.Fieldname1) return false; - if (FieldName2 != other.FieldName2) return false; - if (FieldName3 != other.FieldName3) return false; - if (FieldName4 != other.FieldName4) return false; - if (Field0Name5 != other.Field0Name5) return false; - if (Field0Name6 != other.Field0Name6) return false; - if (FieldName7 != other.FieldName7) return false; - if (FieldName8 != other.FieldName8) return false; - if (FieldName9 != other.FieldName9) return false; - if (FieldName10 != other.FieldName10) return false; - if (FIELDNAME11 != other.FIELDNAME11) return false; - if (FIELDName12 != other.FIELDName12) return false; - if (OneofFieldCase != other.OneofFieldCase) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (OptionalInt32 != 0) hash ^= OptionalInt32.GetHashCode(); - if (OptionalInt64 != 0L) hash ^= OptionalInt64.GetHashCode(); - if (OptionalUint32 != 0) hash ^= OptionalUint32.GetHashCode(); - if (OptionalUint64 != 0UL) hash ^= OptionalUint64.GetHashCode(); - if (OptionalSint32 != 0) hash ^= OptionalSint32.GetHashCode(); - if (OptionalSint64 != 0L) hash ^= OptionalSint64.GetHashCode(); - if (OptionalFixed32 != 0) hash ^= OptionalFixed32.GetHashCode(); - if (OptionalFixed64 != 0UL) hash ^= OptionalFixed64.GetHashCode(); - if (OptionalSfixed32 != 0) hash ^= OptionalSfixed32.GetHashCode(); - if (OptionalSfixed64 != 0L) hash ^= OptionalSfixed64.GetHashCode(); - if (OptionalFloat != 0F) hash ^= OptionalFloat.GetHashCode(); - if (OptionalDouble != 0D) hash ^= OptionalDouble.GetHashCode(); - if (OptionalBool != false) hash ^= OptionalBool.GetHashCode(); - if (OptionalString.Length != 0) hash ^= OptionalString.GetHashCode(); - if (OptionalBytes.Length != 0) hash ^= OptionalBytes.GetHashCode(); - if (optionalNestedMessage_ != null) hash ^= OptionalNestedMessage.GetHashCode(); - if (optionalForeignMessage_ != null) hash ^= OptionalForeignMessage.GetHashCode(); - if (OptionalNestedEnum != 0) hash ^= OptionalNestedEnum.GetHashCode(); - if (OptionalForeignEnum != 0) hash ^= OptionalForeignEnum.GetHashCode(); - if (OptionalStringPiece.Length != 0) hash ^= OptionalStringPiece.GetHashCode(); - if (OptionalCord.Length != 0) hash ^= OptionalCord.GetHashCode(); - if (recursiveMessage_ != null) hash ^= RecursiveMessage.GetHashCode(); - hash ^= repeatedInt32_.GetHashCode(); - hash ^= repeatedInt64_.GetHashCode(); - hash ^= repeatedUint32_.GetHashCode(); - hash ^= repeatedUint64_.GetHashCode(); - hash ^= repeatedSint32_.GetHashCode(); - hash ^= repeatedSint64_.GetHashCode(); - hash ^= repeatedFixed32_.GetHashCode(); - hash ^= repeatedFixed64_.GetHashCode(); - hash ^= repeatedSfixed32_.GetHashCode(); - hash ^= repeatedSfixed64_.GetHashCode(); - hash ^= repeatedFloat_.GetHashCode(); - hash ^= repeatedDouble_.GetHashCode(); - hash ^= repeatedBool_.GetHashCode(); - hash ^= repeatedString_.GetHashCode(); - hash ^= repeatedBytes_.GetHashCode(); - hash ^= repeatedNestedMessage_.GetHashCode(); - hash ^= repeatedForeignMessage_.GetHashCode(); - hash ^= repeatedNestedEnum_.GetHashCode(); - hash ^= repeatedForeignEnum_.GetHashCode(); - hash ^= repeatedStringPiece_.GetHashCode(); - hash ^= repeatedCord_.GetHashCode(); - hash ^= MapInt32Int32.GetHashCode(); - hash ^= MapInt64Int64.GetHashCode(); - hash ^= MapUint32Uint32.GetHashCode(); - hash ^= MapUint64Uint64.GetHashCode(); - hash ^= MapSint32Sint32.GetHashCode(); - hash ^= MapSint64Sint64.GetHashCode(); - hash ^= MapFixed32Fixed32.GetHashCode(); - hash ^= MapFixed64Fixed64.GetHashCode(); - hash ^= MapSfixed32Sfixed32.GetHashCode(); - hash ^= MapSfixed64Sfixed64.GetHashCode(); - hash ^= MapInt32Float.GetHashCode(); - hash ^= MapInt32Double.GetHashCode(); - hash ^= MapBoolBool.GetHashCode(); - hash ^= MapStringString.GetHashCode(); - hash ^= MapStringBytes.GetHashCode(); - hash ^= MapStringNestedMessage.GetHashCode(); - hash ^= MapStringForeignMessage.GetHashCode(); - hash ^= MapStringNestedEnum.GetHashCode(); - hash ^= MapStringForeignEnum.GetHashCode(); - if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) hash ^= OneofUint32.GetHashCode(); - if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) hash ^= OneofNestedMessage.GetHashCode(); - if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) hash ^= OneofString.GetHashCode(); - if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) hash ^= OneofBytes.GetHashCode(); - if (optionalBoolWrapper_ != null) hash ^= OptionalBoolWrapper.GetHashCode(); - if (optionalInt32Wrapper_ != null) hash ^= OptionalInt32Wrapper.GetHashCode(); - if (optionalInt64Wrapper_ != null) hash ^= OptionalInt64Wrapper.GetHashCode(); - if (optionalUint32Wrapper_ != null) hash ^= OptionalUint32Wrapper.GetHashCode(); - if (optionalUint64Wrapper_ != null) hash ^= OptionalUint64Wrapper.GetHashCode(); - if (optionalFloatWrapper_ != null) hash ^= OptionalFloatWrapper.GetHashCode(); - if (optionalDoubleWrapper_ != null) hash ^= OptionalDoubleWrapper.GetHashCode(); - if (optionalStringWrapper_ != null) hash ^= OptionalStringWrapper.GetHashCode(); - if (optionalBytesWrapper_ != null) hash ^= OptionalBytesWrapper.GetHashCode(); - hash ^= repeatedBoolWrapper_.GetHashCode(); - hash ^= repeatedInt32Wrapper_.GetHashCode(); - hash ^= repeatedInt64Wrapper_.GetHashCode(); - hash ^= repeatedUint32Wrapper_.GetHashCode(); - hash ^= repeatedUint64Wrapper_.GetHashCode(); - hash ^= repeatedFloatWrapper_.GetHashCode(); - hash ^= repeatedDoubleWrapper_.GetHashCode(); - hash ^= repeatedStringWrapper_.GetHashCode(); - hash ^= repeatedBytesWrapper_.GetHashCode(); - if (optionalDuration_ != null) hash ^= OptionalDuration.GetHashCode(); - if (optionalTimestamp_ != null) hash ^= OptionalTimestamp.GetHashCode(); - if (optionalFieldMask_ != null) hash ^= OptionalFieldMask.GetHashCode(); - if (optionalStruct_ != null) hash ^= OptionalStruct.GetHashCode(); - if (optionalAny_ != null) hash ^= OptionalAny.GetHashCode(); - if (optionalValue_ != null) hash ^= OptionalValue.GetHashCode(); - hash ^= repeatedDuration_.GetHashCode(); - hash ^= repeatedTimestamp_.GetHashCode(); - hash ^= repeatedFieldmask_.GetHashCode(); - hash ^= repeatedStruct_.GetHashCode(); - hash ^= repeatedAny_.GetHashCode(); - hash ^= repeatedValue_.GetHashCode(); - if (Fieldname1 != 0) hash ^= Fieldname1.GetHashCode(); - if (FieldName2 != 0) hash ^= FieldName2.GetHashCode(); - if (FieldName3 != 0) hash ^= FieldName3.GetHashCode(); - if (FieldName4 != 0) hash ^= FieldName4.GetHashCode(); - if (Field0Name5 != 0) hash ^= Field0Name5.GetHashCode(); - if (Field0Name6 != 0) hash ^= Field0Name6.GetHashCode(); - if (FieldName7 != 0) hash ^= FieldName7.GetHashCode(); - if (FieldName8 != 0) hash ^= FieldName8.GetHashCode(); - if (FieldName9 != 0) hash ^= FieldName9.GetHashCode(); - if (FieldName10 != 0) hash ^= FieldName10.GetHashCode(); - if (FIELDNAME11 != 0) hash ^= FIELDNAME11.GetHashCode(); - if (FIELDName12 != 0) hash ^= FIELDName12.GetHashCode(); - hash ^= (int) oneofFieldCase_; - return hash; - } - - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - public void WriteTo(pb::CodedOutputStream output) { - if (OptionalInt32 != 0) { - output.WriteRawTag(8); - output.WriteInt32(OptionalInt32); - } - if (OptionalInt64 != 0L) { - output.WriteRawTag(16); - output.WriteInt64(OptionalInt64); - } - if (OptionalUint32 != 0) { - output.WriteRawTag(24); - output.WriteUInt32(OptionalUint32); - } - if (OptionalUint64 != 0UL) { - output.WriteRawTag(32); - output.WriteUInt64(OptionalUint64); - } - if (OptionalSint32 != 0) { - output.WriteRawTag(40); - output.WriteSInt32(OptionalSint32); - } - if (OptionalSint64 != 0L) { - output.WriteRawTag(48); - output.WriteSInt64(OptionalSint64); - } - if (OptionalFixed32 != 0) { - output.WriteRawTag(61); - output.WriteFixed32(OptionalFixed32); - } - if (OptionalFixed64 != 0UL) { - output.WriteRawTag(65); - output.WriteFixed64(OptionalFixed64); - } - if (OptionalSfixed32 != 0) { - output.WriteRawTag(77); - output.WriteSFixed32(OptionalSfixed32); - } - if (OptionalSfixed64 != 0L) { - output.WriteRawTag(81); - output.WriteSFixed64(OptionalSfixed64); - } - if (OptionalFloat != 0F) { - output.WriteRawTag(93); - output.WriteFloat(OptionalFloat); - } - if (OptionalDouble != 0D) { - output.WriteRawTag(97); - output.WriteDouble(OptionalDouble); - } - if (OptionalBool != false) { - output.WriteRawTag(104); - output.WriteBool(OptionalBool); - } - if (OptionalString.Length != 0) { - output.WriteRawTag(114); - output.WriteString(OptionalString); - } - if (OptionalBytes.Length != 0) { - output.WriteRawTag(122); - output.WriteBytes(OptionalBytes); - } - if (optionalNestedMessage_ != null) { - output.WriteRawTag(146, 1); - output.WriteMessage(OptionalNestedMessage); - } - if (optionalForeignMessage_ != null) { - output.WriteRawTag(154, 1); - output.WriteMessage(OptionalForeignMessage); - } - if (OptionalNestedEnum != 0) { - output.WriteRawTag(168, 1); - output.WriteEnum((int) OptionalNestedEnum); - } - if (OptionalForeignEnum != 0) { - output.WriteRawTag(176, 1); - output.WriteEnum((int) OptionalForeignEnum); - } - if (OptionalStringPiece.Length != 0) { - output.WriteRawTag(194, 1); - output.WriteString(OptionalStringPiece); - } - if (OptionalCord.Length != 0) { - output.WriteRawTag(202, 1); - output.WriteString(OptionalCord); - } - if (recursiveMessage_ != null) { - output.WriteRawTag(218, 1); - output.WriteMessage(RecursiveMessage); - } - repeatedInt32_.WriteTo(output, _repeated_repeatedInt32_codec); - repeatedInt64_.WriteTo(output, _repeated_repeatedInt64_codec); - repeatedUint32_.WriteTo(output, _repeated_repeatedUint32_codec); - repeatedUint64_.WriteTo(output, _repeated_repeatedUint64_codec); - repeatedSint32_.WriteTo(output, _repeated_repeatedSint32_codec); - repeatedSint64_.WriteTo(output, _repeated_repeatedSint64_codec); - repeatedFixed32_.WriteTo(output, _repeated_repeatedFixed32_codec); - repeatedFixed64_.WriteTo(output, _repeated_repeatedFixed64_codec); - repeatedSfixed32_.WriteTo(output, _repeated_repeatedSfixed32_codec); - repeatedSfixed64_.WriteTo(output, _repeated_repeatedSfixed64_codec); - repeatedFloat_.WriteTo(output, _repeated_repeatedFloat_codec); - repeatedDouble_.WriteTo(output, _repeated_repeatedDouble_codec); - repeatedBool_.WriteTo(output, _repeated_repeatedBool_codec); - repeatedString_.WriteTo(output, _repeated_repeatedString_codec); - repeatedBytes_.WriteTo(output, _repeated_repeatedBytes_codec); - repeatedNestedMessage_.WriteTo(output, _repeated_repeatedNestedMessage_codec); - repeatedForeignMessage_.WriteTo(output, _repeated_repeatedForeignMessage_codec); - repeatedNestedEnum_.WriteTo(output, _repeated_repeatedNestedEnum_codec); - repeatedForeignEnum_.WriteTo(output, _repeated_repeatedForeignEnum_codec); - repeatedStringPiece_.WriteTo(output, _repeated_repeatedStringPiece_codec); - repeatedCord_.WriteTo(output, _repeated_repeatedCord_codec); - mapInt32Int32_.WriteTo(output, _map_mapInt32Int32_codec); - mapInt64Int64_.WriteTo(output, _map_mapInt64Int64_codec); - mapUint32Uint32_.WriteTo(output, _map_mapUint32Uint32_codec); - mapUint64Uint64_.WriteTo(output, _map_mapUint64Uint64_codec); - mapSint32Sint32_.WriteTo(output, _map_mapSint32Sint32_codec); - mapSint64Sint64_.WriteTo(output, _map_mapSint64Sint64_codec); - mapFixed32Fixed32_.WriteTo(output, _map_mapFixed32Fixed32_codec); - mapFixed64Fixed64_.WriteTo(output, _map_mapFixed64Fixed64_codec); - mapSfixed32Sfixed32_.WriteTo(output, _map_mapSfixed32Sfixed32_codec); - mapSfixed64Sfixed64_.WriteTo(output, _map_mapSfixed64Sfixed64_codec); - mapInt32Float_.WriteTo(output, _map_mapInt32Float_codec); - mapInt32Double_.WriteTo(output, _map_mapInt32Double_codec); - mapBoolBool_.WriteTo(output, _map_mapBoolBool_codec); - mapStringString_.WriteTo(output, _map_mapStringString_codec); - mapStringBytes_.WriteTo(output, _map_mapStringBytes_codec); - mapStringNestedMessage_.WriteTo(output, _map_mapStringNestedMessage_codec); - mapStringForeignMessage_.WriteTo(output, _map_mapStringForeignMessage_codec); - mapStringNestedEnum_.WriteTo(output, _map_mapStringNestedEnum_codec); - mapStringForeignEnum_.WriteTo(output, _map_mapStringForeignEnum_codec); - if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { - output.WriteRawTag(248, 6); - output.WriteUInt32(OneofUint32); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { - output.WriteRawTag(130, 7); - output.WriteMessage(OneofNestedMessage); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) { - output.WriteRawTag(138, 7); - output.WriteString(OneofString); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { - output.WriteRawTag(146, 7); - output.WriteBytes(OneofBytes); - } - if (optionalBoolWrapper_ != null) { - _single_optionalBoolWrapper_codec.WriteTagAndValue(output, OptionalBoolWrapper); - } - if (optionalInt32Wrapper_ != null) { - _single_optionalInt32Wrapper_codec.WriteTagAndValue(output, OptionalInt32Wrapper); - } - if (optionalInt64Wrapper_ != null) { - _single_optionalInt64Wrapper_codec.WriteTagAndValue(output, OptionalInt64Wrapper); - } - if (optionalUint32Wrapper_ != null) { - _single_optionalUint32Wrapper_codec.WriteTagAndValue(output, OptionalUint32Wrapper); - } - if (optionalUint64Wrapper_ != null) { - _single_optionalUint64Wrapper_codec.WriteTagAndValue(output, OptionalUint64Wrapper); - } - if (optionalFloatWrapper_ != null) { - _single_optionalFloatWrapper_codec.WriteTagAndValue(output, OptionalFloatWrapper); - } - if (optionalDoubleWrapper_ != null) { - _single_optionalDoubleWrapper_codec.WriteTagAndValue(output, OptionalDoubleWrapper); - } - if (optionalStringWrapper_ != null) { - _single_optionalStringWrapper_codec.WriteTagAndValue(output, OptionalStringWrapper); - } - if (optionalBytesWrapper_ != null) { - _single_optionalBytesWrapper_codec.WriteTagAndValue(output, OptionalBytesWrapper); - } - repeatedBoolWrapper_.WriteTo(output, _repeated_repeatedBoolWrapper_codec); - repeatedInt32Wrapper_.WriteTo(output, _repeated_repeatedInt32Wrapper_codec); - repeatedInt64Wrapper_.WriteTo(output, _repeated_repeatedInt64Wrapper_codec); - repeatedUint32Wrapper_.WriteTo(output, _repeated_repeatedUint32Wrapper_codec); - repeatedUint64Wrapper_.WriteTo(output, _repeated_repeatedUint64Wrapper_codec); - repeatedFloatWrapper_.WriteTo(output, _repeated_repeatedFloatWrapper_codec); - repeatedDoubleWrapper_.WriteTo(output, _repeated_repeatedDoubleWrapper_codec); - repeatedStringWrapper_.WriteTo(output, _repeated_repeatedStringWrapper_codec); - repeatedBytesWrapper_.WriteTo(output, _repeated_repeatedBytesWrapper_codec); - if (optionalDuration_ != null) { - output.WriteRawTag(234, 18); - output.WriteMessage(OptionalDuration); - } - if (optionalTimestamp_ != null) { - output.WriteRawTag(242, 18); - output.WriteMessage(OptionalTimestamp); - } - if (optionalFieldMask_ != null) { - output.WriteRawTag(250, 18); - output.WriteMessage(OptionalFieldMask); - } - if (optionalStruct_ != null) { - output.WriteRawTag(130, 19); - output.WriteMessage(OptionalStruct); - } - if (optionalAny_ != null) { - output.WriteRawTag(138, 19); - output.WriteMessage(OptionalAny); - } - if (optionalValue_ != null) { - output.WriteRawTag(146, 19); - output.WriteMessage(OptionalValue); - } - repeatedDuration_.WriteTo(output, _repeated_repeatedDuration_codec); - repeatedTimestamp_.WriteTo(output, _repeated_repeatedTimestamp_codec); - repeatedFieldmask_.WriteTo(output, _repeated_repeatedFieldmask_codec); - repeatedAny_.WriteTo(output, _repeated_repeatedAny_codec); - repeatedValue_.WriteTo(output, _repeated_repeatedValue_codec); - repeatedStruct_.WriteTo(output, _repeated_repeatedStruct_codec); - if (Fieldname1 != 0) { - output.WriteRawTag(136, 25); - output.WriteInt32(Fieldname1); - } - if (FieldName2 != 0) { - output.WriteRawTag(144, 25); - output.WriteInt32(FieldName2); - } - if (FieldName3 != 0) { - output.WriteRawTag(152, 25); - output.WriteInt32(FieldName3); - } - if (FieldName4 != 0) { - output.WriteRawTag(160, 25); - output.WriteInt32(FieldName4); - } - if (Field0Name5 != 0) { - output.WriteRawTag(168, 25); - output.WriteInt32(Field0Name5); - } - if (Field0Name6 != 0) { - output.WriteRawTag(176, 25); - output.WriteInt32(Field0Name6); - } - if (FieldName7 != 0) { - output.WriteRawTag(184, 25); - output.WriteInt32(FieldName7); - } - if (FieldName8 != 0) { - output.WriteRawTag(192, 25); - output.WriteInt32(FieldName8); - } - if (FieldName9 != 0) { - output.WriteRawTag(200, 25); - output.WriteInt32(FieldName9); - } - if (FieldName10 != 0) { - output.WriteRawTag(208, 25); - output.WriteInt32(FieldName10); - } - if (FIELDNAME11 != 0) { - output.WriteRawTag(216, 25); - output.WriteInt32(FIELDNAME11); - } - if (FIELDName12 != 0) { - output.WriteRawTag(224, 25); - output.WriteInt32(FIELDName12); - } - } - - public int CalculateSize() { - int size = 0; - if (OptionalInt32 != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(OptionalInt32); - } - if (OptionalInt64 != 0L) { - size += 1 + pb::CodedOutputStream.ComputeInt64Size(OptionalInt64); - } - if (OptionalUint32 != 0) { - size += 1 + pb::CodedOutputStream.ComputeUInt32Size(OptionalUint32); - } - if (OptionalUint64 != 0UL) { - size += 1 + pb::CodedOutputStream.ComputeUInt64Size(OptionalUint64); - } - if (OptionalSint32 != 0) { - size += 1 + pb::CodedOutputStream.ComputeSInt32Size(OptionalSint32); - } - if (OptionalSint64 != 0L) { - size += 1 + pb::CodedOutputStream.ComputeSInt64Size(OptionalSint64); - } - if (OptionalFixed32 != 0) { - size += 1 + 4; - } - if (OptionalFixed64 != 0UL) { - size += 1 + 8; - } - if (OptionalSfixed32 != 0) { - size += 1 + 4; - } - if (OptionalSfixed64 != 0L) { - size += 1 + 8; - } - if (OptionalFloat != 0F) { - size += 1 + 4; - } - if (OptionalDouble != 0D) { - size += 1 + 8; - } - if (OptionalBool != false) { - size += 1 + 1; - } - if (OptionalString.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(OptionalString); - } - if (OptionalBytes.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeBytesSize(OptionalBytes); - } - if (optionalNestedMessage_ != null) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalNestedMessage); - } - if (optionalForeignMessage_ != null) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalForeignMessage); - } - if (OptionalNestedEnum != 0) { - size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OptionalNestedEnum); - } - if (OptionalForeignEnum != 0) { - size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OptionalForeignEnum); - } - if (OptionalStringPiece.Length != 0) { - size += 2 + pb::CodedOutputStream.ComputeStringSize(OptionalStringPiece); - } - if (OptionalCord.Length != 0) { - size += 2 + pb::CodedOutputStream.ComputeStringSize(OptionalCord); - } - if (recursiveMessage_ != null) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(RecursiveMessage); - } - size += repeatedInt32_.CalculateSize(_repeated_repeatedInt32_codec); - size += repeatedInt64_.CalculateSize(_repeated_repeatedInt64_codec); - size += repeatedUint32_.CalculateSize(_repeated_repeatedUint32_codec); - size += repeatedUint64_.CalculateSize(_repeated_repeatedUint64_codec); - size += repeatedSint32_.CalculateSize(_repeated_repeatedSint32_codec); - size += repeatedSint64_.CalculateSize(_repeated_repeatedSint64_codec); - size += repeatedFixed32_.CalculateSize(_repeated_repeatedFixed32_codec); - size += repeatedFixed64_.CalculateSize(_repeated_repeatedFixed64_codec); - size += repeatedSfixed32_.CalculateSize(_repeated_repeatedSfixed32_codec); - size += repeatedSfixed64_.CalculateSize(_repeated_repeatedSfixed64_codec); - size += repeatedFloat_.CalculateSize(_repeated_repeatedFloat_codec); - size += repeatedDouble_.CalculateSize(_repeated_repeatedDouble_codec); - size += repeatedBool_.CalculateSize(_repeated_repeatedBool_codec); - size += repeatedString_.CalculateSize(_repeated_repeatedString_codec); - size += repeatedBytes_.CalculateSize(_repeated_repeatedBytes_codec); - size += repeatedNestedMessage_.CalculateSize(_repeated_repeatedNestedMessage_codec); - size += repeatedForeignMessage_.CalculateSize(_repeated_repeatedForeignMessage_codec); - size += repeatedNestedEnum_.CalculateSize(_repeated_repeatedNestedEnum_codec); - size += repeatedForeignEnum_.CalculateSize(_repeated_repeatedForeignEnum_codec); - size += repeatedStringPiece_.CalculateSize(_repeated_repeatedStringPiece_codec); - size += repeatedCord_.CalculateSize(_repeated_repeatedCord_codec); - size += mapInt32Int32_.CalculateSize(_map_mapInt32Int32_codec); - size += mapInt64Int64_.CalculateSize(_map_mapInt64Int64_codec); - size += mapUint32Uint32_.CalculateSize(_map_mapUint32Uint32_codec); - size += mapUint64Uint64_.CalculateSize(_map_mapUint64Uint64_codec); - size += mapSint32Sint32_.CalculateSize(_map_mapSint32Sint32_codec); - size += mapSint64Sint64_.CalculateSize(_map_mapSint64Sint64_codec); - size += mapFixed32Fixed32_.CalculateSize(_map_mapFixed32Fixed32_codec); - size += mapFixed64Fixed64_.CalculateSize(_map_mapFixed64Fixed64_codec); - size += mapSfixed32Sfixed32_.CalculateSize(_map_mapSfixed32Sfixed32_codec); - size += mapSfixed64Sfixed64_.CalculateSize(_map_mapSfixed64Sfixed64_codec); - size += mapInt32Float_.CalculateSize(_map_mapInt32Float_codec); - size += mapInt32Double_.CalculateSize(_map_mapInt32Double_codec); - size += mapBoolBool_.CalculateSize(_map_mapBoolBool_codec); - size += mapStringString_.CalculateSize(_map_mapStringString_codec); - size += mapStringBytes_.CalculateSize(_map_mapStringBytes_codec); - size += mapStringNestedMessage_.CalculateSize(_map_mapStringNestedMessage_codec); - size += mapStringForeignMessage_.CalculateSize(_map_mapStringForeignMessage_codec); - size += mapStringNestedEnum_.CalculateSize(_map_mapStringNestedEnum_codec); - size += mapStringForeignEnum_.CalculateSize(_map_mapStringForeignEnum_codec); - if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { - size += 2 + pb::CodedOutputStream.ComputeUInt32Size(OneofUint32); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(OneofNestedMessage); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) { - size += 2 + pb::CodedOutputStream.ComputeStringSize(OneofString); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { - size += 2 + pb::CodedOutputStream.ComputeBytesSize(OneofBytes); - } - if (optionalBoolWrapper_ != null) { - size += _single_optionalBoolWrapper_codec.CalculateSizeWithTag(OptionalBoolWrapper); - } - if (optionalInt32Wrapper_ != null) { - size += _single_optionalInt32Wrapper_codec.CalculateSizeWithTag(OptionalInt32Wrapper); - } - if (optionalInt64Wrapper_ != null) { - size += _single_optionalInt64Wrapper_codec.CalculateSizeWithTag(OptionalInt64Wrapper); - } - if (optionalUint32Wrapper_ != null) { - size += _single_optionalUint32Wrapper_codec.CalculateSizeWithTag(OptionalUint32Wrapper); - } - if (optionalUint64Wrapper_ != null) { - size += _single_optionalUint64Wrapper_codec.CalculateSizeWithTag(OptionalUint64Wrapper); - } - if (optionalFloatWrapper_ != null) { - size += _single_optionalFloatWrapper_codec.CalculateSizeWithTag(OptionalFloatWrapper); - } - if (optionalDoubleWrapper_ != null) { - size += _single_optionalDoubleWrapper_codec.CalculateSizeWithTag(OptionalDoubleWrapper); - } - if (optionalStringWrapper_ != null) { - size += _single_optionalStringWrapper_codec.CalculateSizeWithTag(OptionalStringWrapper); - } - if (optionalBytesWrapper_ != null) { - size += _single_optionalBytesWrapper_codec.CalculateSizeWithTag(OptionalBytesWrapper); - } - size += repeatedBoolWrapper_.CalculateSize(_repeated_repeatedBoolWrapper_codec); - size += repeatedInt32Wrapper_.CalculateSize(_repeated_repeatedInt32Wrapper_codec); - size += repeatedInt64Wrapper_.CalculateSize(_repeated_repeatedInt64Wrapper_codec); - size += repeatedUint32Wrapper_.CalculateSize(_repeated_repeatedUint32Wrapper_codec); - size += repeatedUint64Wrapper_.CalculateSize(_repeated_repeatedUint64Wrapper_codec); - size += repeatedFloatWrapper_.CalculateSize(_repeated_repeatedFloatWrapper_codec); - size += repeatedDoubleWrapper_.CalculateSize(_repeated_repeatedDoubleWrapper_codec); - size += repeatedStringWrapper_.CalculateSize(_repeated_repeatedStringWrapper_codec); - size += repeatedBytesWrapper_.CalculateSize(_repeated_repeatedBytesWrapper_codec); - if (optionalDuration_ != null) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalDuration); - } - if (optionalTimestamp_ != null) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalTimestamp); - } - if (optionalFieldMask_ != null) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalFieldMask); - } - if (optionalStruct_ != null) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalStruct); - } - if (optionalAny_ != null) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalAny); - } - if (optionalValue_ != null) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalValue); - } - size += repeatedDuration_.CalculateSize(_repeated_repeatedDuration_codec); - size += repeatedTimestamp_.CalculateSize(_repeated_repeatedTimestamp_codec); - size += repeatedFieldmask_.CalculateSize(_repeated_repeatedFieldmask_codec); - size += repeatedStruct_.CalculateSize(_repeated_repeatedStruct_codec); - size += repeatedAny_.CalculateSize(_repeated_repeatedAny_codec); - size += repeatedValue_.CalculateSize(_repeated_repeatedValue_codec); - if (Fieldname1 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(Fieldname1); - } - if (FieldName2 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName2); - } - if (FieldName3 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName3); - } - if (FieldName4 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName4); - } - if (Field0Name5 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field0Name5); - } - if (Field0Name6 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field0Name6); - } - if (FieldName7 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName7); - } - if (FieldName8 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName8); - } - if (FieldName9 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName9); - } - if (FieldName10 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName10); - } - if (FIELDNAME11 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FIELDNAME11); - } - if (FIELDName12 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FIELDName12); - } - return size; - } - - public void MergeFrom(TestAllTypes other) { - if (other == null) { - return; - } - 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.Length != 0) { - OptionalString = other.OptionalString; - } - if (other.OptionalBytes.Length != 0) { - OptionalBytes = other.OptionalBytes; - } - if (other.optionalNestedMessage_ != null) { - if (optionalNestedMessage_ == null) { - optionalNestedMessage_ = new global::Conformance.TestAllTypes.Types.NestedMessage(); - } - OptionalNestedMessage.MergeFrom(other.OptionalNestedMessage); - } - if (other.optionalForeignMessage_ != null) { - if (optionalForeignMessage_ == null) { - optionalForeignMessage_ = new global::Conformance.ForeignMessage(); - } - OptionalForeignMessage.MergeFrom(other.OptionalForeignMessage); - } - if (other.OptionalNestedEnum != 0) { - OptionalNestedEnum = other.OptionalNestedEnum; - } - if (other.OptionalForeignEnum != 0) { - OptionalForeignEnum = other.OptionalForeignEnum; - } - if (other.OptionalStringPiece.Length != 0) { - OptionalStringPiece = other.OptionalStringPiece; - } - if (other.OptionalCord.Length != 0) { - OptionalCord = other.OptionalCord; - } - if (other.recursiveMessage_ != null) { - if (recursiveMessage_ == null) { - recursiveMessage_ = new global::Conformance.TestAllTypes(); - } - RecursiveMessage.MergeFrom(other.RecursiveMessage); - } - repeatedInt32_.Add(other.repeatedInt32_); - repeatedInt64_.Add(other.repeatedInt64_); - repeatedUint32_.Add(other.repeatedUint32_); - repeatedUint64_.Add(other.repeatedUint64_); - repeatedSint32_.Add(other.repeatedSint32_); - repeatedSint64_.Add(other.repeatedSint64_); - repeatedFixed32_.Add(other.repeatedFixed32_); - repeatedFixed64_.Add(other.repeatedFixed64_); - repeatedSfixed32_.Add(other.repeatedSfixed32_); - repeatedSfixed64_.Add(other.repeatedSfixed64_); - repeatedFloat_.Add(other.repeatedFloat_); - repeatedDouble_.Add(other.repeatedDouble_); - repeatedBool_.Add(other.repeatedBool_); - repeatedString_.Add(other.repeatedString_); - repeatedBytes_.Add(other.repeatedBytes_); - repeatedNestedMessage_.Add(other.repeatedNestedMessage_); - repeatedForeignMessage_.Add(other.repeatedForeignMessage_); - repeatedNestedEnum_.Add(other.repeatedNestedEnum_); - repeatedForeignEnum_.Add(other.repeatedForeignEnum_); - repeatedStringPiece_.Add(other.repeatedStringPiece_); - repeatedCord_.Add(other.repeatedCord_); - mapInt32Int32_.Add(other.mapInt32Int32_); - mapInt64Int64_.Add(other.mapInt64Int64_); - mapUint32Uint32_.Add(other.mapUint32Uint32_); - mapUint64Uint64_.Add(other.mapUint64Uint64_); - mapSint32Sint32_.Add(other.mapSint32Sint32_); - mapSint64Sint64_.Add(other.mapSint64Sint64_); - mapFixed32Fixed32_.Add(other.mapFixed32Fixed32_); - mapFixed64Fixed64_.Add(other.mapFixed64Fixed64_); - mapSfixed32Sfixed32_.Add(other.mapSfixed32Sfixed32_); - mapSfixed64Sfixed64_.Add(other.mapSfixed64Sfixed64_); - mapInt32Float_.Add(other.mapInt32Float_); - mapInt32Double_.Add(other.mapInt32Double_); - mapBoolBool_.Add(other.mapBoolBool_); - mapStringString_.Add(other.mapStringString_); - mapStringBytes_.Add(other.mapStringBytes_); - mapStringNestedMessage_.Add(other.mapStringNestedMessage_); - mapStringForeignMessage_.Add(other.mapStringForeignMessage_); - mapStringNestedEnum_.Add(other.mapStringNestedEnum_); - mapStringForeignEnum_.Add(other.mapStringForeignEnum_); - if (other.optionalBoolWrapper_ != null) { - if (optionalBoolWrapper_ == null || other.OptionalBoolWrapper != false) { - OptionalBoolWrapper = other.OptionalBoolWrapper; - } - } - if (other.optionalInt32Wrapper_ != null) { - if (optionalInt32Wrapper_ == null || other.OptionalInt32Wrapper != 0) { - OptionalInt32Wrapper = other.OptionalInt32Wrapper; - } - } - if (other.optionalInt64Wrapper_ != null) { - if (optionalInt64Wrapper_ == null || other.OptionalInt64Wrapper != 0L) { - OptionalInt64Wrapper = other.OptionalInt64Wrapper; - } - } - if (other.optionalUint32Wrapper_ != null) { - if (optionalUint32Wrapper_ == null || other.OptionalUint32Wrapper != 0) { - OptionalUint32Wrapper = other.OptionalUint32Wrapper; - } - } - if (other.optionalUint64Wrapper_ != null) { - if (optionalUint64Wrapper_ == null || other.OptionalUint64Wrapper != 0UL) { - OptionalUint64Wrapper = other.OptionalUint64Wrapper; - } - } - if (other.optionalFloatWrapper_ != null) { - if (optionalFloatWrapper_ == null || other.OptionalFloatWrapper != 0F) { - OptionalFloatWrapper = other.OptionalFloatWrapper; - } - } - if (other.optionalDoubleWrapper_ != null) { - if (optionalDoubleWrapper_ == null || other.OptionalDoubleWrapper != 0D) { - OptionalDoubleWrapper = other.OptionalDoubleWrapper; - } - } - if (other.optionalStringWrapper_ != null) { - if (optionalStringWrapper_ == null || other.OptionalStringWrapper != "") { - OptionalStringWrapper = other.OptionalStringWrapper; - } - } - if (other.optionalBytesWrapper_ != null) { - if (optionalBytesWrapper_ == null || other.OptionalBytesWrapper != pb::ByteString.Empty) { - OptionalBytesWrapper = other.OptionalBytesWrapper; - } - } - repeatedBoolWrapper_.Add(other.repeatedBoolWrapper_); - repeatedInt32Wrapper_.Add(other.repeatedInt32Wrapper_); - repeatedInt64Wrapper_.Add(other.repeatedInt64Wrapper_); - repeatedUint32Wrapper_.Add(other.repeatedUint32Wrapper_); - repeatedUint64Wrapper_.Add(other.repeatedUint64Wrapper_); - repeatedFloatWrapper_.Add(other.repeatedFloatWrapper_); - repeatedDoubleWrapper_.Add(other.repeatedDoubleWrapper_); - repeatedStringWrapper_.Add(other.repeatedStringWrapper_); - repeatedBytesWrapper_.Add(other.repeatedBytesWrapper_); - if (other.optionalDuration_ != null) { - if (optionalDuration_ == null) { - optionalDuration_ = new global::Google.Protobuf.WellKnownTypes.Duration(); - } - OptionalDuration.MergeFrom(other.OptionalDuration); - } - if (other.optionalTimestamp_ != null) { - if (optionalTimestamp_ == null) { - optionalTimestamp_ = new global::Google.Protobuf.WellKnownTypes.Timestamp(); - } - OptionalTimestamp.MergeFrom(other.OptionalTimestamp); - } - if (other.optionalFieldMask_ != null) { - if (optionalFieldMask_ == null) { - optionalFieldMask_ = new global::Google.Protobuf.WellKnownTypes.FieldMask(); - } - OptionalFieldMask.MergeFrom(other.OptionalFieldMask); - } - if (other.optionalStruct_ != null) { - if (optionalStruct_ == null) { - optionalStruct_ = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - OptionalStruct.MergeFrom(other.OptionalStruct); - } - if (other.optionalAny_ != null) { - if (optionalAny_ == null) { - optionalAny_ = new global::Google.Protobuf.WellKnownTypes.Any(); - } - OptionalAny.MergeFrom(other.OptionalAny); - } - if (other.optionalValue_ != null) { - if (optionalValue_ == null) { - optionalValue_ = new global::Google.Protobuf.WellKnownTypes.Value(); - } - OptionalValue.MergeFrom(other.OptionalValue); - } - repeatedDuration_.Add(other.repeatedDuration_); - repeatedTimestamp_.Add(other.repeatedTimestamp_); - repeatedFieldmask_.Add(other.repeatedFieldmask_); - repeatedStruct_.Add(other.repeatedStruct_); - repeatedAny_.Add(other.repeatedAny_); - repeatedValue_.Add(other.repeatedValue_); - if (other.Fieldname1 != 0) { - Fieldname1 = other.Fieldname1; - } - if (other.FieldName2 != 0) { - FieldName2 = other.FieldName2; - } - if (other.FieldName3 != 0) { - FieldName3 = other.FieldName3; - } - if (other.FieldName4 != 0) { - FieldName4 = other.FieldName4; - } - if (other.Field0Name5 != 0) { - Field0Name5 = other.Field0Name5; - } - if (other.Field0Name6 != 0) { - Field0Name6 = other.Field0Name6; - } - if (other.FieldName7 != 0) { - FieldName7 = other.FieldName7; - } - if (other.FieldName8 != 0) { - FieldName8 = other.FieldName8; - } - if (other.FieldName9 != 0) { - FieldName9 = other.FieldName9; - } - if (other.FieldName10 != 0) { - FieldName10 = other.FieldName10; - } - if (other.FIELDNAME11 != 0) { - FIELDNAME11 = other.FIELDNAME11; - } - if (other.FIELDName12 != 0) { - FIELDName12 = other.FIELDName12; - } - switch (other.OneofFieldCase) { - case OneofFieldOneofCase.OneofUint32: - OneofUint32 = other.OneofUint32; - break; - case OneofFieldOneofCase.OneofNestedMessage: - OneofNestedMessage = other.OneofNestedMessage; - break; - case OneofFieldOneofCase.OneofString: - OneofString = other.OneofString; - break; - case OneofFieldOneofCase.OneofBytes: - OneofBytes = other.OneofBytes; - break; - } - - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 8: { - OptionalInt32 = input.ReadInt32(); - break; - } - case 16: { - OptionalInt64 = input.ReadInt64(); - break; - } - case 24: { - OptionalUint32 = input.ReadUInt32(); - break; - } - case 32: { - OptionalUint64 = input.ReadUInt64(); - break; - } - case 40: { - OptionalSint32 = input.ReadSInt32(); - break; - } - case 48: { - OptionalSint64 = input.ReadSInt64(); - break; - } - case 61: { - OptionalFixed32 = input.ReadFixed32(); - break; - } - case 65: { - OptionalFixed64 = input.ReadFixed64(); - break; - } - case 77: { - OptionalSfixed32 = input.ReadSFixed32(); - break; - } - case 81: { - OptionalSfixed64 = input.ReadSFixed64(); - break; - } - case 93: { - OptionalFloat = input.ReadFloat(); - break; - } - case 97: { - OptionalDouble = input.ReadDouble(); - break; - } - case 104: { - OptionalBool = input.ReadBool(); - break; - } - case 114: { - OptionalString = input.ReadString(); - break; - } - case 122: { - OptionalBytes = input.ReadBytes(); - break; - } - case 146: { - if (optionalNestedMessage_ == null) { - optionalNestedMessage_ = new global::Conformance.TestAllTypes.Types.NestedMessage(); - } - input.ReadMessage(optionalNestedMessage_); - break; - } - case 154: { - if (optionalForeignMessage_ == null) { - optionalForeignMessage_ = new global::Conformance.ForeignMessage(); - } - input.ReadMessage(optionalForeignMessage_); - break; - } - case 168: { - optionalNestedEnum_ = (global::Conformance.TestAllTypes.Types.NestedEnum) input.ReadEnum(); - break; - } - case 176: { - optionalForeignEnum_ = (global::Conformance.ForeignEnum) input.ReadEnum(); - break; - } - case 194: { - OptionalStringPiece = input.ReadString(); - break; - } - case 202: { - OptionalCord = input.ReadString(); - break; - } - case 218: { - if (recursiveMessage_ == null) { - recursiveMessage_ = new global::Conformance.TestAllTypes(); - } - input.ReadMessage(recursiveMessage_); - break; - } - case 250: - case 248: { - repeatedInt32_.AddEntriesFrom(input, _repeated_repeatedInt32_codec); - break; - } - case 258: - case 256: { - repeatedInt64_.AddEntriesFrom(input, _repeated_repeatedInt64_codec); - break; - } - case 266: - case 264: { - repeatedUint32_.AddEntriesFrom(input, _repeated_repeatedUint32_codec); - break; - } - case 274: - case 272: { - repeatedUint64_.AddEntriesFrom(input, _repeated_repeatedUint64_codec); - break; - } - case 282: - case 280: { - repeatedSint32_.AddEntriesFrom(input, _repeated_repeatedSint32_codec); - break; - } - case 290: - case 288: { - repeatedSint64_.AddEntriesFrom(input, _repeated_repeatedSint64_codec); - break; - } - case 298: - case 301: { - repeatedFixed32_.AddEntriesFrom(input, _repeated_repeatedFixed32_codec); - break; - } - case 306: - case 305: { - repeatedFixed64_.AddEntriesFrom(input, _repeated_repeatedFixed64_codec); - break; - } - case 314: - case 317: { - repeatedSfixed32_.AddEntriesFrom(input, _repeated_repeatedSfixed32_codec); - break; - } - case 322: - case 321: { - repeatedSfixed64_.AddEntriesFrom(input, _repeated_repeatedSfixed64_codec); - break; - } - case 330: - case 333: { - repeatedFloat_.AddEntriesFrom(input, _repeated_repeatedFloat_codec); - break; - } - case 338: - case 337: { - repeatedDouble_.AddEntriesFrom(input, _repeated_repeatedDouble_codec); - break; - } - case 346: - case 344: { - repeatedBool_.AddEntriesFrom(input, _repeated_repeatedBool_codec); - break; - } - case 354: { - repeatedString_.AddEntriesFrom(input, _repeated_repeatedString_codec); - break; - } - case 362: { - repeatedBytes_.AddEntriesFrom(input, _repeated_repeatedBytes_codec); - break; - } - case 386: { - repeatedNestedMessage_.AddEntriesFrom(input, _repeated_repeatedNestedMessage_codec); - break; - } - case 394: { - repeatedForeignMessage_.AddEntriesFrom(input, _repeated_repeatedForeignMessage_codec); - break; - } - case 410: - case 408: { - repeatedNestedEnum_.AddEntriesFrom(input, _repeated_repeatedNestedEnum_codec); - break; - } - case 418: - case 416: { - repeatedForeignEnum_.AddEntriesFrom(input, _repeated_repeatedForeignEnum_codec); - break; - } - case 434: { - repeatedStringPiece_.AddEntriesFrom(input, _repeated_repeatedStringPiece_codec); - break; - } - case 442: { - repeatedCord_.AddEntriesFrom(input, _repeated_repeatedCord_codec); - break; - } - case 450: { - mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec); - break; - } - case 458: { - mapInt64Int64_.AddEntriesFrom(input, _map_mapInt64Int64_codec); - break; - } - case 466: { - mapUint32Uint32_.AddEntriesFrom(input, _map_mapUint32Uint32_codec); - break; - } - case 474: { - mapUint64Uint64_.AddEntriesFrom(input, _map_mapUint64Uint64_codec); - break; - } - case 482: { - mapSint32Sint32_.AddEntriesFrom(input, _map_mapSint32Sint32_codec); - break; - } - case 490: { - mapSint64Sint64_.AddEntriesFrom(input, _map_mapSint64Sint64_codec); - break; - } - case 498: { - mapFixed32Fixed32_.AddEntriesFrom(input, _map_mapFixed32Fixed32_codec); - break; - } - case 506: { - mapFixed64Fixed64_.AddEntriesFrom(input, _map_mapFixed64Fixed64_codec); - break; - } - case 514: { - mapSfixed32Sfixed32_.AddEntriesFrom(input, _map_mapSfixed32Sfixed32_codec); - break; - } - case 522: { - mapSfixed64Sfixed64_.AddEntriesFrom(input, _map_mapSfixed64Sfixed64_codec); - break; - } - case 530: { - mapInt32Float_.AddEntriesFrom(input, _map_mapInt32Float_codec); - break; - } - case 538: { - mapInt32Double_.AddEntriesFrom(input, _map_mapInt32Double_codec); - break; - } - case 546: { - mapBoolBool_.AddEntriesFrom(input, _map_mapBoolBool_codec); - break; - } - case 554: { - mapStringString_.AddEntriesFrom(input, _map_mapStringString_codec); - break; - } - case 562: { - mapStringBytes_.AddEntriesFrom(input, _map_mapStringBytes_codec); - break; - } - case 570: { - mapStringNestedMessage_.AddEntriesFrom(input, _map_mapStringNestedMessage_codec); - break; - } - case 578: { - mapStringForeignMessage_.AddEntriesFrom(input, _map_mapStringForeignMessage_codec); - break; - } - case 586: { - mapStringNestedEnum_.AddEntriesFrom(input, _map_mapStringNestedEnum_codec); - break; - } - case 594: { - mapStringForeignEnum_.AddEntriesFrom(input, _map_mapStringForeignEnum_codec); - break; - } - case 888: { - OneofUint32 = input.ReadUInt32(); - break; - } - case 898: { - global::Conformance.TestAllTypes.Types.NestedMessage subBuilder = new global::Conformance.TestAllTypes.Types.NestedMessage(); - if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { - subBuilder.MergeFrom(OneofNestedMessage); - } - input.ReadMessage(subBuilder); - OneofNestedMessage = subBuilder; - break; - } - case 906: { - OneofString = input.ReadString(); - break; - } - case 914: { - OneofBytes = input.ReadBytes(); - break; - } - case 1610: { - bool? value = _single_optionalBoolWrapper_codec.Read(input); - if (optionalBoolWrapper_ == null || value != false) { - OptionalBoolWrapper = value; - } - break; - } - case 1618: { - int? value = _single_optionalInt32Wrapper_codec.Read(input); - if (optionalInt32Wrapper_ == null || value != 0) { - OptionalInt32Wrapper = value; - } - break; - } - case 1626: { - long? value = _single_optionalInt64Wrapper_codec.Read(input); - if (optionalInt64Wrapper_ == null || value != 0L) { - OptionalInt64Wrapper = value; - } - break; - } - case 1634: { - uint? value = _single_optionalUint32Wrapper_codec.Read(input); - if (optionalUint32Wrapper_ == null || value != 0) { - OptionalUint32Wrapper = value; - } - break; - } - case 1642: { - ulong? value = _single_optionalUint64Wrapper_codec.Read(input); - if (optionalUint64Wrapper_ == null || value != 0UL) { - OptionalUint64Wrapper = value; - } - break; - } - case 1650: { - float? value = _single_optionalFloatWrapper_codec.Read(input); - if (optionalFloatWrapper_ == null || value != 0F) { - OptionalFloatWrapper = value; - } - break; - } - case 1658: { - double? value = _single_optionalDoubleWrapper_codec.Read(input); - if (optionalDoubleWrapper_ == null || value != 0D) { - OptionalDoubleWrapper = value; - } - break; - } - case 1666: { - string value = _single_optionalStringWrapper_codec.Read(input); - if (optionalStringWrapper_ == null || value != "") { - OptionalStringWrapper = value; - } - break; - } - case 1674: { - pb::ByteString value = _single_optionalBytesWrapper_codec.Read(input); - if (optionalBytesWrapper_ == null || value != pb::ByteString.Empty) { - OptionalBytesWrapper = value; - } - break; - } - case 1690: { - repeatedBoolWrapper_.AddEntriesFrom(input, _repeated_repeatedBoolWrapper_codec); - break; - } - case 1698: { - repeatedInt32Wrapper_.AddEntriesFrom(input, _repeated_repeatedInt32Wrapper_codec); - break; - } - case 1706: { - repeatedInt64Wrapper_.AddEntriesFrom(input, _repeated_repeatedInt64Wrapper_codec); - break; - } - case 1714: { - repeatedUint32Wrapper_.AddEntriesFrom(input, _repeated_repeatedUint32Wrapper_codec); - break; - } - case 1722: { - repeatedUint64Wrapper_.AddEntriesFrom(input, _repeated_repeatedUint64Wrapper_codec); - break; - } - case 1730: { - repeatedFloatWrapper_.AddEntriesFrom(input, _repeated_repeatedFloatWrapper_codec); - break; - } - case 1738: { - repeatedDoubleWrapper_.AddEntriesFrom(input, _repeated_repeatedDoubleWrapper_codec); - break; - } - case 1746: { - repeatedStringWrapper_.AddEntriesFrom(input, _repeated_repeatedStringWrapper_codec); - break; - } - case 1754: { - repeatedBytesWrapper_.AddEntriesFrom(input, _repeated_repeatedBytesWrapper_codec); - break; - } - case 2410: { - if (optionalDuration_ == null) { - optionalDuration_ = new global::Google.Protobuf.WellKnownTypes.Duration(); - } - input.ReadMessage(optionalDuration_); - break; - } - case 2418: { - if (optionalTimestamp_ == null) { - optionalTimestamp_ = new global::Google.Protobuf.WellKnownTypes.Timestamp(); - } - input.ReadMessage(optionalTimestamp_); - break; - } - case 2426: { - if (optionalFieldMask_ == null) { - optionalFieldMask_ = new global::Google.Protobuf.WellKnownTypes.FieldMask(); - } - input.ReadMessage(optionalFieldMask_); - break; - } - case 2434: { - if (optionalStruct_ == null) { - optionalStruct_ = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - input.ReadMessage(optionalStruct_); - break; - } - case 2442: { - if (optionalAny_ == null) { - optionalAny_ = new global::Google.Protobuf.WellKnownTypes.Any(); - } - input.ReadMessage(optionalAny_); - break; - } - case 2450: { - if (optionalValue_ == null) { - optionalValue_ = new global::Google.Protobuf.WellKnownTypes.Value(); - } - input.ReadMessage(optionalValue_); - break; - } - case 2490: { - repeatedDuration_.AddEntriesFrom(input, _repeated_repeatedDuration_codec); - break; - } - case 2498: { - repeatedTimestamp_.AddEntriesFrom(input, _repeated_repeatedTimestamp_codec); - break; - } - case 2506: { - repeatedFieldmask_.AddEntriesFrom(input, _repeated_repeatedFieldmask_codec); - break; - } - case 2522: { - repeatedAny_.AddEntriesFrom(input, _repeated_repeatedAny_codec); - break; - } - case 2530: { - repeatedValue_.AddEntriesFrom(input, _repeated_repeatedValue_codec); - break; - } - case 2594: { - repeatedStruct_.AddEntriesFrom(input, _repeated_repeatedStruct_codec); - break; - } - case 3208: { - Fieldname1 = input.ReadInt32(); - break; - } - case 3216: { - FieldName2 = input.ReadInt32(); - break; - } - case 3224: { - FieldName3 = input.ReadInt32(); - break; - } - case 3232: { - FieldName4 = input.ReadInt32(); - break; - } - case 3240: { - Field0Name5 = input.ReadInt32(); - break; - } - case 3248: { - Field0Name6 = input.ReadInt32(); - break; - } - case 3256: { - FieldName7 = input.ReadInt32(); - break; - } - case 3264: { - FieldName8 = input.ReadInt32(); - break; - } - case 3272: { - FieldName9 = input.ReadInt32(); - break; - } - case 3280: { - FieldName10 = input.ReadInt32(); - break; - } - case 3288: { - FIELDNAME11 = input.ReadInt32(); - break; - } - case 3296: { - FIELDName12 = input.ReadInt32(); - break; - } - } - } - } - - #region Nested types - /// Container for nested types declared in the TestAllTypes message type. - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - public enum NestedEnum { - [pbr::OriginalName("FOO")] Foo = 0, - [pbr::OriginalName("BAR")] Bar = 1, - [pbr::OriginalName("BAZ")] Baz = 2, - /// - /// Intentionally negative. - /// - [pbr::OriginalName("NEG")] Neg = -1, - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedMessage : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); - public static pb::MessageParser Parser { get { return _parser; } } - - public static pbr::MessageDescriptor Descriptor { - get { return global::Conformance.TestAllTypes.Descriptor.NestedTypes[0]; } - } - - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - public NestedMessage() { - OnConstruction(); - } - - partial void OnConstruction(); - - public NestedMessage(NestedMessage other) : this() { - a_ = other.a_; - Corecursive = other.corecursive_ != null ? other.Corecursive.Clone() : null; - } - - public NestedMessage Clone() { - return new NestedMessage(this); - } - - /// Field number for the "a" field. - public const int AFieldNumber = 1; - private int a_; - public int A { - get { return a_; } - set { - a_ = value; - } - } - - /// Field number for the "corecursive" field. - public const int CorecursiveFieldNumber = 2; - private global::Conformance.TestAllTypes corecursive_; - public global::Conformance.TestAllTypes Corecursive { - get { return corecursive_; } - set { - corecursive_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as NestedMessage); - } - - public bool Equals(NestedMessage other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (A != other.A) return false; - if (!object.Equals(Corecursive, other.Corecursive)) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (A != 0) hash ^= A.GetHashCode(); - if (corecursive_ != null) hash ^= Corecursive.GetHashCode(); - return hash; - } - - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - public void WriteTo(pb::CodedOutputStream output) { - if (A != 0) { - output.WriteRawTag(8); - output.WriteInt32(A); - } - if (corecursive_ != null) { - output.WriteRawTag(18); - output.WriteMessage(Corecursive); - } - } - - public int CalculateSize() { - int size = 0; - if (A != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(A); - } - if (corecursive_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Corecursive); - } - return size; - } - - public void MergeFrom(NestedMessage other) { - if (other == null) { - return; - } - if (other.A != 0) { - A = other.A; - } - if (other.corecursive_ != null) { - if (corecursive_ == null) { - corecursive_ = new global::Conformance.TestAllTypes(); - } - Corecursive.MergeFrom(other.Corecursive); - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 8: { - A = input.ReadInt32(); - break; - } - case 18: { - if (corecursive_ == null) { - corecursive_ = new global::Conformance.TestAllTypes(); - } - input.ReadMessage(corecursive_); - break; - } - } - } - } - - } - - } - #endregion - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ForeignMessage : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ForeignMessage()); - public static pb::MessageParser Parser { get { return _parser; } } - - public static pbr::MessageDescriptor Descriptor { - get { return global::Conformance.ConformanceReflection.Descriptor.MessageTypes[3]; } - } - - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - public ForeignMessage() { - OnConstruction(); - } - - partial void OnConstruction(); - - public ForeignMessage(ForeignMessage other) : this() { - c_ = other.c_; - } - - public ForeignMessage Clone() { - return new ForeignMessage(this); - } - - /// Field number for the "c" field. - public const int CFieldNumber = 1; - private int c_; - public int C { - get { return c_; } - set { - c_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as ForeignMessage); - } - - public bool Equals(ForeignMessage other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (C != other.C) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (C != 0) hash ^= C.GetHashCode(); - return hash; - } - - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - public void WriteTo(pb::CodedOutputStream output) { - if (C != 0) { - output.WriteRawTag(8); - output.WriteInt32(C); - } - } - - public int CalculateSize() { - int size = 0; - if (C != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(C); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); } return size; } - public void MergeFrom(ForeignMessage other) { + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(JspbEncodingConfig other) { if (other == null) { return; } - if (other.C != 0) { - C = other.C; + if (other.UseJspbArrayAnyFormat != false) { + UseJspbArrayAnyFormat = other.UseJspbArrayAnyFormat; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { - C = input.ReadInt32(); + UseJspbArrayAnyFormat = input.ReadBool(); break; } } diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj b/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj index 82f728d19294..ec8fb9138947 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj @@ -1,61 +1,14 @@ - - - + + - Debug - AnyCPU - {0607D1B8-80D6-4B35-9857-1263C1B32B94} + netcoreapp2.1 Exe - Properties - Google.Protobuf.Conformance - Google.Protobuf.Conformance - v4.5 - 512 + False - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - + - - {6908bdce-d925-43f3-94ac-a531e6df2591} - Google.Protobuf - + + - - - \ No newline at end of file + + diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Program.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Program.cs index 19827c484458..f5e1dad17e39 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Program.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Program.cs @@ -48,7 +48,7 @@ private static void Main(string[] args) // This way we get the binary streams instead of readers/writers. var input = new BinaryReader(Console.OpenStandardInput()); var output = new BinaryWriter(Console.OpenStandardOutput()); - var typeRegistry = TypeRegistry.FromMessages(TestAllTypes.Descriptor); + var typeRegistry = TypeRegistry.FromMessages(ProtobufTestMessages.Proto3.TestAllTypesProto3.Descriptor); int count = 0; while (RunTest(input, output, typeRegistry)) @@ -81,18 +81,38 @@ private static bool RunTest(BinaryReader input, BinaryWriter output, TypeRegistr private static ConformanceResponse PerformRequest(ConformanceRequest request, TypeRegistry typeRegistry) { - TestAllTypes message; + ProtobufTestMessages.Proto3.TestAllTypesProto3 message; try { switch (request.PayloadCase) { case ConformanceRequest.PayloadOneofCase.JsonPayload: + if (request.TestCategory == global::Conformance.TestCategory.JsonIgnoreUnknownParsingTest) { + return new ConformanceResponse { Skipped = "CSharp doesn't support skipping unknown fields in json parsing." }; + } var parser = new JsonParser(new JsonParser.Settings(20, typeRegistry)); - message = parser.Parse(request.JsonPayload); + message = parser.Parse(request.JsonPayload); break; case ConformanceRequest.PayloadOneofCase.ProtobufPayload: - message = TestAllTypes.Parser.ParseFrom(request.ProtobufPayload); + { + if (request.MessageType.Equals("protobuf_test_messages.proto3.TestAllTypesProto3")) + { + message = ProtobufTestMessages.Proto3.TestAllTypesProto3.Parser.ParseFrom(request.ProtobufPayload); + } + else if (request.MessageType.Equals("protobuf_test_messages.proto2.TestAllTypesProto2")) + { + return new ConformanceResponse { Skipped = "CSharp doesn't support proto2" }; + } + else + { + throw new Exception(" Protobuf request doesn't have specific payload type"); + } break; + } + case ConformanceRequest.PayloadOneofCase.TextPayload: + { + return new ConformanceResponse { Skipped = "CSharp doesn't support text format" }; + } default: throw new Exception("Unsupported request payload: " + request.PayloadCase); } diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj b/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj index 67acf66d4b8b..fee35be9910d 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj +++ b/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj @@ -1,68 +1,13 @@ - - + + - Debug - AnyCPU - 9.0.30729 - 2.0 - {D7282E99-2DC3-405B-946F-177DB2FD2AE2} + netcoreapp2.1 Exe - Properties - Google.Protobuf.JsonDump - Google.Protobuf.JsonDump - v4.5 - 512 - - + False - - true - full - false - bin\Debug - obj\Debug\ - DEBUG;TRACE - prompt - 4 - true - Off - false - - - pdbonly - true - bin\Release - obj\Release\ - TRACE - prompt - 4 - true - Off - false - - - - - - - - - - - - {6908BDCE-D925-43F3-94AC-A531E6DF2591} - Google.Protobuf - - + - + - - - \ No newline at end of file + + diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Program.cs b/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Program.cs index e8a6073e2bcb..296b2f3f1ed5 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Program.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Program.cs @@ -1,72 +1,73 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; -using System.IO; - -namespace Google.Protobuf.ProtoDump -{ - /// - /// Small utility to load a binary message and dump it in JSON format. - /// - internal class Program - { - private static int Main(string[] args) - { - if (args.Length != 2) - { - Console.Error.WriteLine("Usage: Google.Protobuf.JsonDump "); - Console.Error.WriteLine("The descriptor type name is the fully-qualified message name,"); - Console.Error.WriteLine("including assembly e.g. ProjectNamespace.Message,Company.Project"); - return 1; - } - Type type = Type.GetType(args[0]); - if (type == null) - { - Console.Error.WriteLine("Unable to load type {0}.", args[0]); - return 1; - } - if (!typeof(IMessage).IsAssignableFrom(type)) - { - Console.Error.WriteLine("Type {0} doesn't implement IMessage.", args[0]); - return 1; - } - IMessage message = (IMessage) Activator.CreateInstance(type); - using (var input = File.OpenRead(args[1])) - { - message.MergeFrom(input); - } - Console.WriteLine(message); - return 0; - } - } +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.IO; +using System.Reflection; + +namespace Google.Protobuf.ProtoDump +{ + /// + /// Small utility to load a binary message and dump it in JSON format. + /// + internal class Program + { + private static int Main(string[] args) + { + if (args.Length != 2) + { + Console.Error.WriteLine("Usage: Google.Protobuf.JsonDump "); + Console.Error.WriteLine("The descriptor type name is the fully-qualified message name,"); + Console.Error.WriteLine("including assembly e.g. ProjectNamespace.Message,Company.Project"); + return 1; + } + Type type = Type.GetType(args[0]); + if (type == null) + { + Console.Error.WriteLine("Unable to load type {0}.", args[0]); + return 1; + } + if (!typeof(IMessage).GetTypeInfo().IsAssignableFrom(type)) + { + Console.Error.WriteLine("Type {0} doesn't implement IMessage.", args[0]); + return 1; + } + IMessage message = (IMessage) Activator.CreateInstance(type); + using (var input = File.OpenRead(args[1])) + { + message.MergeFrom(input); + } + Console.WriteLine(message); + return 0; + } + } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Properties/AssemblyInfo.cs b/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Properties/AssemblyInfo.cs deleted file mode 100644 index 0a29d2d4722e..000000000000 --- a/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("ProtoDump")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ProtoDump")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -[assembly: AssemblyVersion("3.0.0.0")] -[assembly: AssemblyFileVersion("3.0.0.0")] diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/app.config b/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/app.config deleted file mode 100644 index 51278a456315..000000000000 --- a/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/ByteStringTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/ByteStringTest.cs index 8935b7829d4a..84e6341e9510 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/ByteStringTest.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/ByteStringTest.cs @@ -1,171 +1,237 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; -using System.Text; -using NUnit.Framework; - -namespace Google.Protobuf -{ - public class ByteStringTest - { - [Test] - public void Equality() - { - ByteString b1 = ByteString.CopyFrom(1, 2, 3); - ByteString b2 = ByteString.CopyFrom(1, 2, 3); - ByteString b3 = ByteString.CopyFrom(1, 2, 4); - ByteString b4 = ByteString.CopyFrom(1, 2, 3, 4); - EqualityTester.AssertEquality(b1, b1); - EqualityTester.AssertEquality(b1, b2); - EqualityTester.AssertInequality(b1, b3); - EqualityTester.AssertInequality(b1, b4); - EqualityTester.AssertInequality(b1, null); -#pragma warning disable 1718 // Deliberately calling ==(b1, b1) and !=(b1, b1) - Assert.IsTrue(b1 == b1); - Assert.IsTrue(b1 == b2); - Assert.IsFalse(b1 == b3); - Assert.IsFalse(b1 == b4); - Assert.IsFalse(b1 == null); - Assert.IsTrue((ByteString) null == null); - Assert.IsFalse(b1 != b1); - Assert.IsFalse(b1 != b2); -#pragma warning disable 1718 - Assert.IsTrue(b1 != b3); - Assert.IsTrue(b1 != b4); - Assert.IsTrue(b1 != null); - Assert.IsFalse((ByteString) null != null); - } - - [Test] - public void EmptyByteStringHasZeroSize() - { - Assert.AreEqual(0, ByteString.Empty.Length); - } - - [Test] - public void CopyFromStringWithExplicitEncoding() - { - ByteString bs = ByteString.CopyFrom("AB", Encoding.Unicode); - Assert.AreEqual(4, bs.Length); - Assert.AreEqual(65, bs[0]); - Assert.AreEqual(0, bs[1]); - Assert.AreEqual(66, bs[2]); - Assert.AreEqual(0, bs[3]); - } - - [Test] - public void IsEmptyWhenEmpty() - { - Assert.IsTrue(ByteString.CopyFromUtf8("").IsEmpty); - } - - [Test] - public void IsEmptyWhenNotEmpty() - { - Assert.IsFalse(ByteString.CopyFromUtf8("X").IsEmpty); - } - - [Test] - public void CopyFromByteArrayCopiesContents() - { - byte[] data = new byte[1]; - data[0] = 10; - ByteString bs = ByteString.CopyFrom(data); - Assert.AreEqual(10, bs[0]); - data[0] = 5; - Assert.AreEqual(10, bs[0]); - } - - [Test] - public void ToByteArrayCopiesContents() - { - ByteString bs = ByteString.CopyFromUtf8("Hello"); - byte[] data = bs.ToByteArray(); - Assert.AreEqual((byte)'H', data[0]); - Assert.AreEqual((byte)'H', bs[0]); - data[0] = 0; - Assert.AreEqual(0, data[0]); - Assert.AreEqual((byte)'H', bs[0]); - } - - [Test] - public void CopyFromUtf8UsesUtf8() - { - ByteString bs = ByteString.CopyFromUtf8("\u20ac"); - Assert.AreEqual(3, bs.Length); - Assert.AreEqual(0xe2, bs[0]); - Assert.AreEqual(0x82, bs[1]); - Assert.AreEqual(0xac, bs[2]); - } - - [Test] - public void CopyFromPortion() - { - byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6}; - ByteString bs = ByteString.CopyFrom(data, 2, 3); - Assert.AreEqual(3, bs.Length); - Assert.AreEqual(2, bs[0]); - Assert.AreEqual(3, bs[1]); - } - - [Test] - public void ToStringUtf8() - { - ByteString bs = ByteString.CopyFromUtf8("\u20ac"); - Assert.AreEqual("\u20ac", bs.ToStringUtf8()); - } - - [Test] - public void ToStringWithExplicitEncoding() - { - ByteString bs = ByteString.CopyFrom("\u20ac", Encoding.Unicode); - Assert.AreEqual("\u20ac", bs.ToString(Encoding.Unicode)); - } - - [Test] - public void FromBase64_WithText() - { - byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6}; - string base64 = Convert.ToBase64String(data); - ByteString bs = ByteString.FromBase64(base64); - Assert.AreEqual(data, bs.ToByteArray()); - } - - [Test] - public void FromBase64_Empty() - { - // Optimization which also fixes issue 61. - Assert.AreSame(ByteString.Empty, ByteString.FromBase64("")); - } - } +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Text; +using NUnit.Framework; +using System.IO; +#if !NET35 +using System.Threading.Tasks; +#endif + +namespace Google.Protobuf +{ + public class ByteStringTest + { + [Test] + public void Equality() + { + ByteString b1 = ByteString.CopyFrom(1, 2, 3); + ByteString b2 = ByteString.CopyFrom(1, 2, 3); + ByteString b3 = ByteString.CopyFrom(1, 2, 4); + ByteString b4 = ByteString.CopyFrom(1, 2, 3, 4); + EqualityTester.AssertEquality(b1, b1); + EqualityTester.AssertEquality(b1, b2); + EqualityTester.AssertInequality(b1, b3); + EqualityTester.AssertInequality(b1, b4); + EqualityTester.AssertInequality(b1, null); +#pragma warning disable 1718 // Deliberately calling ==(b1, b1) and !=(b1, b1) + Assert.IsTrue(b1 == b1); + Assert.IsTrue(b1 == b2); + Assert.IsFalse(b1 == b3); + Assert.IsFalse(b1 == b4); + Assert.IsFalse(b1 == null); + Assert.IsTrue((ByteString) null == null); + Assert.IsFalse(b1 != b1); + Assert.IsFalse(b1 != b2); +#pragma warning disable 1718 + Assert.IsTrue(b1 != b3); + Assert.IsTrue(b1 != b4); + Assert.IsTrue(b1 != null); + Assert.IsFalse((ByteString) null != null); + } + + [Test] + public void EmptyByteStringHasZeroSize() + { + Assert.AreEqual(0, ByteString.Empty.Length); + } + + [Test] + public void CopyFromStringWithExplicitEncoding() + { + ByteString bs = ByteString.CopyFrom("AB", Encoding.Unicode); + Assert.AreEqual(4, bs.Length); + Assert.AreEqual(65, bs[0]); + Assert.AreEqual(0, bs[1]); + Assert.AreEqual(66, bs[2]); + Assert.AreEqual(0, bs[3]); + } + + [Test] + public void IsEmptyWhenEmpty() + { + Assert.IsTrue(ByteString.CopyFromUtf8("").IsEmpty); + } + + [Test] + public void IsEmptyWhenNotEmpty() + { + Assert.IsFalse(ByteString.CopyFromUtf8("X").IsEmpty); + } + + [Test] + public void CopyFromByteArrayCopiesContents() + { + byte[] data = new byte[1]; + data[0] = 10; + ByteString bs = ByteString.CopyFrom(data); + Assert.AreEqual(10, bs[0]); + data[0] = 5; + Assert.AreEqual(10, bs[0]); + } + + [Test] + public void ToByteArrayCopiesContents() + { + ByteString bs = ByteString.CopyFromUtf8("Hello"); + byte[] data = bs.ToByteArray(); + Assert.AreEqual((byte)'H', data[0]); + Assert.AreEqual((byte)'H', bs[0]); + data[0] = 0; + Assert.AreEqual(0, data[0]); + Assert.AreEqual((byte)'H', bs[0]); + } + + [Test] + public void CopyFromUtf8UsesUtf8() + { + ByteString bs = ByteString.CopyFromUtf8("\u20ac"); + Assert.AreEqual(3, bs.Length); + Assert.AreEqual(0xe2, bs[0]); + Assert.AreEqual(0x82, bs[1]); + Assert.AreEqual(0xac, bs[2]); + } + + [Test] + public void CopyFromPortion() + { + byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6}; + ByteString bs = ByteString.CopyFrom(data, 2, 3); + Assert.AreEqual(3, bs.Length); + Assert.AreEqual(2, bs[0]); + Assert.AreEqual(3, bs[1]); + } + + [Test] + public void ToStringUtf8() + { + ByteString bs = ByteString.CopyFromUtf8("\u20ac"); + Assert.AreEqual("\u20ac", bs.ToStringUtf8()); + } + + [Test] + public void ToStringWithExplicitEncoding() + { + ByteString bs = ByteString.CopyFrom("\u20ac", Encoding.Unicode); + Assert.AreEqual("\u20ac", bs.ToString(Encoding.Unicode)); + } + + [Test] + public void FromBase64_WithText() + { + byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6}; + string base64 = Convert.ToBase64String(data); + ByteString bs = ByteString.FromBase64(base64); + Assert.AreEqual(data, bs.ToByteArray()); + } + + [Test] + public void FromBase64_Empty() + { + // Optimization which also fixes issue 61. + Assert.AreSame(ByteString.Empty, ByteString.FromBase64("")); + } + + [Test] + public void FromStream_Seekable() + { + var stream = new MemoryStream(new byte[] { 1, 2, 3, 4, 5 }); + // Consume the first byte, just to test that it's "from current position" + stream.ReadByte(); + var actual = ByteString.FromStream(stream); + ByteString expected = ByteString.CopyFrom(2, 3, 4, 5); + Assert.AreEqual(expected, actual, $"{expected.ToBase64()} != {actual.ToBase64()}"); + } + + [Test] + public void FromStream_NotSeekable() + { + var stream = new MemoryStream(new byte[] { 1, 2, 3, 4, 5 }); + // Consume the first byte, just to test that it's "from current position" + stream.ReadByte(); + // Wrap the original stream in LimitedInputStream, which has CanSeek=false + var limitedStream = new LimitedInputStream(stream, 3); + var actual = ByteString.FromStream(limitedStream); + ByteString expected = ByteString.CopyFrom(2, 3, 4); + Assert.AreEqual(expected, actual, $"{expected.ToBase64()} != {actual.ToBase64()}"); + } + +#if !NET35 + [Test] + public async Task FromStreamAsync_Seekable() + { + var stream = new MemoryStream(new byte[] { 1, 2, 3, 4, 5 }); + // Consume the first byte, just to test that it's "from current position" + stream.ReadByte(); + var actual = await ByteString.FromStreamAsync(stream); + ByteString expected = ByteString.CopyFrom(2, 3, 4, 5); + Assert.AreEqual(expected, actual, $"{expected.ToBase64()} != {actual.ToBase64()}"); + } + + [Test] + public async Task FromStreamAsync_NotSeekable() + { + var stream = new MemoryStream(new byte[] { 1, 2, 3, 4, 5 }); + // Consume the first byte, just to test that it's "from current position" + stream.ReadByte(); + // Wrap the original stream in LimitedInputStream, which has CanSeek=false + var limitedStream = new LimitedInputStream(stream, 3); + var actual = await ByteString.FromStreamAsync(limitedStream); + ByteString expected = ByteString.CopyFrom(2, 3, 4); + Assert.AreEqual(expected, actual, $"{expected.ToBase64()} != {actual.ToBase64()}"); + } +#endif + + [Test] + public void GetHashCode_Regression() + { + // We used to have an awful hash algorithm where only the last four + // bytes were relevant. This is a regression test for + // https://github.com/protocolbuffers/protobuf/issues/2511 + + ByteString b1 = ByteString.CopyFrom(100, 1, 2, 3, 4); + ByteString b2 = ByteString.CopyFrom(200, 1, 2, 3, 4); + Assert.AreNotEqual(b1.GetHashCode(), b2.GetHashCode()); + } + } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs index d628ecceb6c8..ba65b328e806 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs @@ -1,598 +1,738 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; -using System.IO; -using Google.Protobuf.TestProtos; -using NUnit.Framework; - -namespace Google.Protobuf -{ - public class CodedInputStreamTest - { - /// - /// Helper to construct a byte array from a bunch of bytes. The inputs are - /// actually ints so that I can use hex notation and not get stupid errors - /// about precision. - /// - private static byte[] Bytes(params int[] bytesAsInts) - { - byte[] bytes = new byte[bytesAsInts.Length]; - for (int i = 0; i < bytesAsInts.Length; i++) - { - bytes[i] = (byte) bytesAsInts[i]; - } - return bytes; - } - - /// - /// Parses the given bytes using ReadRawVarint32() and ReadRawVarint64() - /// - private static void AssertReadVarint(byte[] data, ulong value) - { - CodedInputStream input = new CodedInputStream(data); - Assert.AreEqual((uint) value, input.ReadRawVarint32()); - - input = new CodedInputStream(data); - Assert.AreEqual(value, input.ReadRawVarint64()); - Assert.IsTrue(input.IsAtEnd); - - // Try different block sizes. - for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2) - { - input = new CodedInputStream(new SmallBlockInputStream(data, bufferSize)); - Assert.AreEqual((uint) value, input.ReadRawVarint32()); - - input = new CodedInputStream(new SmallBlockInputStream(data, bufferSize)); - Assert.AreEqual(value, input.ReadRawVarint64()); - Assert.IsTrue(input.IsAtEnd); - } - - // Try reading directly from a MemoryStream. We want to verify that it - // doesn't read past the end of the input, so write an extra byte - this - // lets us test the position at the end. - MemoryStream memoryStream = new MemoryStream(); - memoryStream.Write(data, 0, data.Length); - memoryStream.WriteByte(0); - memoryStream.Position = 0; - Assert.AreEqual((uint) value, CodedInputStream.ReadRawVarint32(memoryStream)); - Assert.AreEqual(data.Length, memoryStream.Position); - } - - /// - /// Parses the given bytes using ReadRawVarint32() and ReadRawVarint64() and - /// expects them to fail with an InvalidProtocolBufferException whose - /// description matches the given one. - /// - private static void AssertReadVarintFailure(InvalidProtocolBufferException expected, byte[] data) - { - CodedInputStream input = new CodedInputStream(data); - var exception = Assert.Throws(() => input.ReadRawVarint32()); - Assert.AreEqual(expected.Message, exception.Message); - - input = new CodedInputStream(data); - exception = Assert.Throws(() => input.ReadRawVarint64()); - Assert.AreEqual(expected.Message, exception.Message); - - // Make sure we get the same error when reading directly from a Stream. - exception = Assert.Throws(() => CodedInputStream.ReadRawVarint32(new MemoryStream(data))); - Assert.AreEqual(expected.Message, exception.Message); - } - - [Test] - public void ReadVarint() - { - AssertReadVarint(Bytes(0x00), 0); - AssertReadVarint(Bytes(0x01), 1); - AssertReadVarint(Bytes(0x7f), 127); - // 14882 - AssertReadVarint(Bytes(0xa2, 0x74), (0x22 << 0) | (0x74 << 7)); - // 2961488830 - AssertReadVarint(Bytes(0xbe, 0xf7, 0x92, 0x84, 0x0b), - (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | - (0x0bL << 28)); - - // 64-bit - // 7256456126 - AssertReadVarint(Bytes(0xbe, 0xf7, 0x92, 0x84, 0x1b), - (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | - (0x1bL << 28)); - // 41256202580718336 - AssertReadVarint(Bytes(0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49), - (0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) | - (0x43L << 28) | (0x49L << 35) | (0x24L << 42) | (0x49L << 49)); - // 11964378330978735131 - AssertReadVarint(Bytes(0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01), - (0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) | - (0x3bUL << 28) | (0x56UL << 35) | (0x00UL << 42) | - (0x05UL << 49) | (0x26UL << 56) | (0x01UL << 63)); - - // Failures - AssertReadVarintFailure( - InvalidProtocolBufferException.MalformedVarint(), - Bytes(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x00)); - AssertReadVarintFailure( - InvalidProtocolBufferException.TruncatedMessage(), - Bytes(0x80)); - } - - /// - /// Parses the given bytes using ReadRawLittleEndian32() and checks - /// that the result matches the given value. - /// - private static void AssertReadLittleEndian32(byte[] data, uint value) - { - CodedInputStream input = new CodedInputStream(data); - Assert.AreEqual(value, input.ReadRawLittleEndian32()); - Assert.IsTrue(input.IsAtEnd); - - // Try different block sizes. - for (int blockSize = 1; blockSize <= 16; blockSize *= 2) - { - input = new CodedInputStream( - new SmallBlockInputStream(data, blockSize)); - Assert.AreEqual(value, input.ReadRawLittleEndian32()); - Assert.IsTrue(input.IsAtEnd); - } - } - - /// - /// Parses the given bytes using ReadRawLittleEndian64() and checks - /// that the result matches the given value. - /// - private static void AssertReadLittleEndian64(byte[] data, ulong value) - { - CodedInputStream input = new CodedInputStream(data); - Assert.AreEqual(value, input.ReadRawLittleEndian64()); - Assert.IsTrue(input.IsAtEnd); - - // Try different block sizes. - for (int blockSize = 1; blockSize <= 16; blockSize *= 2) - { - input = new CodedInputStream( - new SmallBlockInputStream(data, blockSize)); - Assert.AreEqual(value, input.ReadRawLittleEndian64()); - Assert.IsTrue(input.IsAtEnd); - } - } - - [Test] - public void ReadLittleEndian() - { - AssertReadLittleEndian32(Bytes(0x78, 0x56, 0x34, 0x12), 0x12345678); - AssertReadLittleEndian32(Bytes(0xf0, 0xde, 0xbc, 0x9a), 0x9abcdef0); - - AssertReadLittleEndian64(Bytes(0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12), - 0x123456789abcdef0L); - AssertReadLittleEndian64( - Bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a), 0x9abcdef012345678UL); - } - - [Test] - public void DecodeZigZag32() - { - Assert.AreEqual(0, CodedInputStream.DecodeZigZag32(0)); - Assert.AreEqual(-1, CodedInputStream.DecodeZigZag32(1)); - Assert.AreEqual(1, CodedInputStream.DecodeZigZag32(2)); - Assert.AreEqual(-2, CodedInputStream.DecodeZigZag32(3)); - Assert.AreEqual(0x3FFFFFFF, CodedInputStream.DecodeZigZag32(0x7FFFFFFE)); - Assert.AreEqual(unchecked((int) 0xC0000000), CodedInputStream.DecodeZigZag32(0x7FFFFFFF)); - Assert.AreEqual(0x7FFFFFFF, CodedInputStream.DecodeZigZag32(0xFFFFFFFE)); - Assert.AreEqual(unchecked((int) 0x80000000), CodedInputStream.DecodeZigZag32(0xFFFFFFFF)); - } - - [Test] - public void DecodeZigZag64() - { - Assert.AreEqual(0, CodedInputStream.DecodeZigZag64(0)); - Assert.AreEqual(-1, CodedInputStream.DecodeZigZag64(1)); - Assert.AreEqual(1, CodedInputStream.DecodeZigZag64(2)); - Assert.AreEqual(-2, CodedInputStream.DecodeZigZag64(3)); - Assert.AreEqual(0x000000003FFFFFFFL, CodedInputStream.DecodeZigZag64(0x000000007FFFFFFEL)); - Assert.AreEqual(unchecked((long) 0xFFFFFFFFC0000000L), CodedInputStream.DecodeZigZag64(0x000000007FFFFFFFL)); - Assert.AreEqual(0x000000007FFFFFFFL, CodedInputStream.DecodeZigZag64(0x00000000FFFFFFFEL)); - Assert.AreEqual(unchecked((long) 0xFFFFFFFF80000000L), CodedInputStream.DecodeZigZag64(0x00000000FFFFFFFFL)); - Assert.AreEqual(0x7FFFFFFFFFFFFFFFL, CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFEL)); - Assert.AreEqual(unchecked((long) 0x8000000000000000L), CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFFL)); - } - - [Test] - public void ReadWholeMessage_VaryingBlockSizes() - { - TestAllTypes message = SampleMessages.CreateFullTestAllTypes(); - - byte[] rawBytes = message.ToByteArray(); - Assert.AreEqual(rawBytes.Length, message.CalculateSize()); - TestAllTypes message2 = TestAllTypes.Parser.ParseFrom(rawBytes); - Assert.AreEqual(message, message2); - - // Try different block sizes. - for (int blockSize = 1; blockSize < 256; blockSize *= 2) - { - message2 = TestAllTypes.Parser.ParseFrom(new SmallBlockInputStream(rawBytes, blockSize)); - Assert.AreEqual(message, message2); - } - } - - [Test] - public void ReadHugeBlob() - { - // Allocate and initialize a 1MB blob. - byte[] blob = new byte[1 << 20]; - for (int i = 0; i < blob.Length; i++) - { - blob[i] = (byte) i; - } - - // Make a message containing it. - var message = new TestAllTypes { SingleBytes = ByteString.CopyFrom(blob) }; - - // Serialize and parse it. Make sure to parse from an InputStream, not - // directly from a ByteString, so that CodedInputStream uses buffered - // reading. - TestAllTypes message2 = TestAllTypes.Parser.ParseFrom(message.ToByteString()); - - Assert.AreEqual(message, message2); - } - - [Test] - public void ReadMaliciouslyLargeBlob() - { - MemoryStream ms = new MemoryStream(); - CodedOutputStream output = new CodedOutputStream(ms); - - uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); - output.WriteRawVarint32(tag); - output.WriteRawVarint32(0x7FFFFFFF); - output.WriteRawBytes(new byte[32]); // Pad with a few random bytes. - output.Flush(); - ms.Position = 0; - - CodedInputStream input = new CodedInputStream(ms); - Assert.AreEqual(tag, input.ReadTag()); - - Assert.Throws(() => input.ReadBytes()); - } - - internal static TestRecursiveMessage MakeRecursiveMessage(int depth) - { - if (depth == 0) - { - return new TestRecursiveMessage { I = 5 }; - } - else - { - return new TestRecursiveMessage { A = MakeRecursiveMessage(depth - 1) }; - } - } - - internal static void AssertMessageDepth(TestRecursiveMessage message, int depth) - { - if (depth == 0) - { - Assert.IsNull(message.A); - Assert.AreEqual(5, message.I); - } - else - { - Assert.IsNotNull(message.A); - AssertMessageDepth(message.A, depth - 1); - } - } - - [Test] - public void MaliciousRecursion() - { - ByteString data64 = MakeRecursiveMessage(64).ToByteString(); - ByteString data65 = MakeRecursiveMessage(65).ToByteString(); - - AssertMessageDepth(TestRecursiveMessage.Parser.ParseFrom(data64), 64); - - Assert.Throws(() => TestRecursiveMessage.Parser.ParseFrom(data65)); - - CodedInputStream input = CodedInputStream.CreateWithLimits(new MemoryStream(data64.ToByteArray()), 1000000, 63); - Assert.Throws(() => TestRecursiveMessage.Parser.ParseFrom(input)); - } - - [Test] - public void SizeLimit() - { - // Have to use a Stream rather than ByteString.CreateCodedInput as SizeLimit doesn't - // apply to the latter case. - MemoryStream ms = new MemoryStream(SampleMessages.CreateFullTestAllTypes().ToByteArray()); - CodedInputStream input = CodedInputStream.CreateWithLimits(ms, 16, 100); - Assert.Throws(() => TestAllTypes.Parser.ParseFrom(input)); - } - - /// - /// Tests that if we read an string that contains invalid UTF-8, no exception - /// is thrown. Instead, the invalid bytes are replaced with the Unicode - /// "replacement character" U+FFFD. - /// - [Test] - public void ReadInvalidUtf8() - { - MemoryStream ms = new MemoryStream(); - CodedOutputStream output = new CodedOutputStream(ms); - - uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); - output.WriteRawVarint32(tag); - output.WriteRawVarint32(1); - output.WriteRawBytes(new byte[] {0x80}); - output.Flush(); - ms.Position = 0; - - CodedInputStream input = new CodedInputStream(ms); - - Assert.AreEqual(tag, input.ReadTag()); - string text = input.ReadString(); - Assert.AreEqual('\ufffd', text[0]); - } - - /// - /// A stream which limits the number of bytes it reads at a time. - /// We use this to make sure that CodedInputStream doesn't screw up when - /// reading in small blocks. - /// - private sealed class SmallBlockInputStream : MemoryStream - { - private readonly int blockSize; - - public SmallBlockInputStream(byte[] data, int blockSize) - : base(data) - { - this.blockSize = blockSize; - } - - public override int Read(byte[] buffer, int offset, int count) - { - return base.Read(buffer, offset, Math.Min(count, blockSize)); - } - } - - [Test] - public void TestNegativeEnum() - { - byte[] bytes = { 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01 }; - CodedInputStream input = new CodedInputStream(bytes); - Assert.AreEqual((int)SampleEnum.NegativeValue, input.ReadEnum()); - Assert.IsTrue(input.IsAtEnd); - } - - //Issue 71: CodedInputStream.ReadBytes go to slow path unnecessarily - [Test] - public void TestSlowPathAvoidance() - { - using (var ms = new MemoryStream()) - { - CodedOutputStream output = new CodedOutputStream(ms); - output.WriteTag(1, WireFormat.WireType.LengthDelimited); - output.WriteBytes(ByteString.CopyFrom(new byte[100])); - output.WriteTag(2, WireFormat.WireType.LengthDelimited); - output.WriteBytes(ByteString.CopyFrom(new byte[100])); - output.Flush(); - - ms.Position = 0; - CodedInputStream input = new CodedInputStream(ms, new byte[ms.Length / 2], 0, 0); - - uint tag = input.ReadTag(); - Assert.AreEqual(1, WireFormat.GetTagFieldNumber(tag)); - Assert.AreEqual(100, input.ReadBytes().Length); - - tag = input.ReadTag(); - Assert.AreEqual(2, WireFormat.GetTagFieldNumber(tag)); - Assert.AreEqual(100, input.ReadBytes().Length); - } - } - - [Test] - public void Tag0Throws() - { - var input = new CodedInputStream(new byte[] { 0 }); - Assert.Throws(() => input.ReadTag()); - } - - [Test] - public void SkipGroup() - { - // Create an output stream with a group in: - // Field 1: string "field 1" - // Field 2: group containing: - // Field 1: fixed int32 value 100 - // Field 2: string "ignore me" - // Field 3: nested group containing - // Field 1: fixed int64 value 1000 - // Field 3: string "field 3" - var stream = new MemoryStream(); - var output = new CodedOutputStream(stream); - output.WriteTag(1, WireFormat.WireType.LengthDelimited); - output.WriteString("field 1"); - - // The outer group... - output.WriteTag(2, WireFormat.WireType.StartGroup); - output.WriteTag(1, WireFormat.WireType.Fixed32); - output.WriteFixed32(100); - output.WriteTag(2, WireFormat.WireType.LengthDelimited); - output.WriteString("ignore me"); - // The nested group... - output.WriteTag(3, WireFormat.WireType.StartGroup); - output.WriteTag(1, WireFormat.WireType.Fixed64); - output.WriteFixed64(1000); - // Note: Not sure the field number is relevant for end group... - output.WriteTag(3, WireFormat.WireType.EndGroup); - - // End the outer group - output.WriteTag(2, WireFormat.WireType.EndGroup); - - output.WriteTag(3, WireFormat.WireType.LengthDelimited); - output.WriteString("field 3"); - output.Flush(); - stream.Position = 0; - - // Now act like a generated client - var input = new CodedInputStream(stream); - Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited), input.ReadTag()); - Assert.AreEqual("field 1", input.ReadString()); - Assert.AreEqual(WireFormat.MakeTag(2, WireFormat.WireType.StartGroup), input.ReadTag()); - input.SkipLastField(); // Should consume the whole group, including the nested one. - Assert.AreEqual(WireFormat.MakeTag(3, WireFormat.WireType.LengthDelimited), input.ReadTag()); - Assert.AreEqual("field 3", input.ReadString()); - } - - [Test] - public void SkipGroup_WrongEndGroupTag() - { - // Create an output stream with: - // Field 1: string "field 1" - // Start group 2 - // Field 3: fixed int32 - // End group 4 (should give an error) - var stream = new MemoryStream(); - var output = new CodedOutputStream(stream); - output.WriteTag(1, WireFormat.WireType.LengthDelimited); - output.WriteString("field 1"); - - // The outer group... - output.WriteTag(2, WireFormat.WireType.StartGroup); - output.WriteTag(3, WireFormat.WireType.Fixed32); - output.WriteFixed32(100); - output.WriteTag(4, WireFormat.WireType.EndGroup); - output.Flush(); - stream.Position = 0; - - // Now act like a generated client - var input = new CodedInputStream(stream); - Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited), input.ReadTag()); - Assert.AreEqual("field 1", input.ReadString()); - Assert.AreEqual(WireFormat.MakeTag(2, WireFormat.WireType.StartGroup), input.ReadTag()); - Assert.Throws(input.SkipLastField); - } - - [Test] - public void RogueEndGroupTag() - { - // If we have an end-group tag without a leading start-group tag, generated - // code will just call SkipLastField... so that should fail. - - var stream = new MemoryStream(); - var output = new CodedOutputStream(stream); - output.WriteTag(1, WireFormat.WireType.EndGroup); - output.Flush(); - stream.Position = 0; - - var input = new CodedInputStream(stream); - Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.EndGroup), input.ReadTag()); - Assert.Throws(input.SkipLastField); - } - - [Test] - public void EndOfStreamReachedWhileSkippingGroup() - { - var stream = new MemoryStream(); - var output = new CodedOutputStream(stream); - output.WriteTag(1, WireFormat.WireType.StartGroup); - output.WriteTag(2, WireFormat.WireType.StartGroup); - output.WriteTag(2, WireFormat.WireType.EndGroup); - - output.Flush(); - stream.Position = 0; - - // Now act like a generated client - var input = new CodedInputStream(stream); - input.ReadTag(); - Assert.Throws(input.SkipLastField); - } - - [Test] - public void RecursionLimitAppliedWhileSkippingGroup() - { - var stream = new MemoryStream(); - var output = new CodedOutputStream(stream); - for (int i = 0; i < CodedInputStream.DefaultRecursionLimit + 1; i++) - { - output.WriteTag(1, WireFormat.WireType.StartGroup); - } - for (int i = 0; i < CodedInputStream.DefaultRecursionLimit + 1; i++) - { - output.WriteTag(1, WireFormat.WireType.EndGroup); - } - output.Flush(); - stream.Position = 0; - - // Now act like a generated client - var input = new CodedInputStream(stream); - Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.StartGroup), input.ReadTag()); - Assert.Throws(input.SkipLastField); - } - - [Test] - public void Construction_Invalid() - { - Assert.Throws(() => new CodedInputStream((byte[]) null)); - Assert.Throws(() => new CodedInputStream(null, 0, 0)); - Assert.Throws(() => new CodedInputStream((Stream) null)); - Assert.Throws(() => new CodedInputStream(new byte[10], 100, 0)); - Assert.Throws(() => new CodedInputStream(new byte[10], 5, 10)); - } - - [Test] - public void CreateWithLimits_InvalidLimits() - { - var stream = new MemoryStream(); - Assert.Throws(() => CodedInputStream.CreateWithLimits(stream, 0, 1)); - Assert.Throws(() => CodedInputStream.CreateWithLimits(stream, 1, 0)); - } - - [Test] - public void Dispose_DisposesUnderlyingStream() - { - var memoryStream = new MemoryStream(); - Assert.IsTrue(memoryStream.CanRead); - using (var cis = new CodedInputStream(memoryStream)) - { - } - Assert.IsFalse(memoryStream.CanRead); // Disposed - } - - [Test] - public void Dispose_WithLeaveOpen() - { - var memoryStream = new MemoryStream(); - Assert.IsTrue(memoryStream.CanRead); - using (var cis = new CodedInputStream(memoryStream, true)) - { - } - Assert.IsTrue(memoryStream.CanRead); // We left the stream open - } - } +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.IO; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class CodedInputStreamTest + { + /// + /// Helper to construct a byte array from a bunch of bytes. The inputs are + /// actually ints so that I can use hex notation and not get stupid errors + /// about precision. + /// + private static byte[] Bytes(params int[] bytesAsInts) + { + byte[] bytes = new byte[bytesAsInts.Length]; + for (int i = 0; i < bytesAsInts.Length; i++) + { + bytes[i] = (byte) bytesAsInts[i]; + } + return bytes; + } + + /// + /// Parses the given bytes using ReadRawVarint32() and ReadRawVarint64() + /// + private static void AssertReadVarint(byte[] data, ulong value) + { + CodedInputStream input = new CodedInputStream(data); + Assert.AreEqual((uint) value, input.ReadRawVarint32()); + + input = new CodedInputStream(data); + Assert.AreEqual(value, input.ReadRawVarint64()); + Assert.IsTrue(input.IsAtEnd); + + // Try different block sizes. + for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2) + { + input = new CodedInputStream(new SmallBlockInputStream(data, bufferSize)); + Assert.AreEqual((uint) value, input.ReadRawVarint32()); + + input = new CodedInputStream(new SmallBlockInputStream(data, bufferSize)); + Assert.AreEqual(value, input.ReadRawVarint64()); + Assert.IsTrue(input.IsAtEnd); + } + + // Try reading directly from a MemoryStream. We want to verify that it + // doesn't read past the end of the input, so write an extra byte - this + // lets us test the position at the end. + MemoryStream memoryStream = new MemoryStream(); + memoryStream.Write(data, 0, data.Length); + memoryStream.WriteByte(0); + memoryStream.Position = 0; + Assert.AreEqual((uint) value, CodedInputStream.ReadRawVarint32(memoryStream)); + Assert.AreEqual(data.Length, memoryStream.Position); + } + + /// + /// Parses the given bytes using ReadRawVarint32() and ReadRawVarint64() and + /// expects them to fail with an InvalidProtocolBufferException whose + /// description matches the given one. + /// + private static void AssertReadVarintFailure(InvalidProtocolBufferException expected, byte[] data) + { + CodedInputStream input = new CodedInputStream(data); + var exception = Assert.Throws(() => input.ReadRawVarint32()); + Assert.AreEqual(expected.Message, exception.Message); + + input = new CodedInputStream(data); + exception = Assert.Throws(() => input.ReadRawVarint64()); + Assert.AreEqual(expected.Message, exception.Message); + + // Make sure we get the same error when reading directly from a Stream. + exception = Assert.Throws(() => CodedInputStream.ReadRawVarint32(new MemoryStream(data))); + Assert.AreEqual(expected.Message, exception.Message); + } + + [Test] + public void ReadVarint() + { + AssertReadVarint(Bytes(0x00), 0); + AssertReadVarint(Bytes(0x01), 1); + AssertReadVarint(Bytes(0x7f), 127); + // 14882 + AssertReadVarint(Bytes(0xa2, 0x74), (0x22 << 0) | (0x74 << 7)); + // 2961488830 + AssertReadVarint(Bytes(0xbe, 0xf7, 0x92, 0x84, 0x0b), + (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | + (0x0bL << 28)); + + // 64-bit + // 7256456126 + AssertReadVarint(Bytes(0xbe, 0xf7, 0x92, 0x84, 0x1b), + (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | + (0x1bL << 28)); + // 41256202580718336 + AssertReadVarint(Bytes(0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49), + (0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) | + (0x43L << 28) | (0x49L << 35) | (0x24L << 42) | (0x49L << 49)); + // 11964378330978735131 + AssertReadVarint(Bytes(0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01), + (0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) | + (0x3bUL << 28) | (0x56UL << 35) | (0x00UL << 42) | + (0x05UL << 49) | (0x26UL << 56) | (0x01UL << 63)); + + // Failures + AssertReadVarintFailure( + InvalidProtocolBufferException.MalformedVarint(), + Bytes(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x00)); + AssertReadVarintFailure( + InvalidProtocolBufferException.TruncatedMessage(), + Bytes(0x80)); + } + + /// + /// Parses the given bytes using ReadRawLittleEndian32() and checks + /// that the result matches the given value. + /// + private static void AssertReadLittleEndian32(byte[] data, uint value) + { + CodedInputStream input = new CodedInputStream(data); + Assert.AreEqual(value, input.ReadRawLittleEndian32()); + Assert.IsTrue(input.IsAtEnd); + + // Try different block sizes. + for (int blockSize = 1; blockSize <= 16; blockSize *= 2) + { + input = new CodedInputStream( + new SmallBlockInputStream(data, blockSize)); + Assert.AreEqual(value, input.ReadRawLittleEndian32()); + Assert.IsTrue(input.IsAtEnd); + } + } + + /// + /// Parses the given bytes using ReadRawLittleEndian64() and checks + /// that the result matches the given value. + /// + private static void AssertReadLittleEndian64(byte[] data, ulong value) + { + CodedInputStream input = new CodedInputStream(data); + Assert.AreEqual(value, input.ReadRawLittleEndian64()); + Assert.IsTrue(input.IsAtEnd); + + // Try different block sizes. + for (int blockSize = 1; blockSize <= 16; blockSize *= 2) + { + input = new CodedInputStream( + new SmallBlockInputStream(data, blockSize)); + Assert.AreEqual(value, input.ReadRawLittleEndian64()); + Assert.IsTrue(input.IsAtEnd); + } + } + + [Test] + public void ReadLittleEndian() + { + AssertReadLittleEndian32(Bytes(0x78, 0x56, 0x34, 0x12), 0x12345678); + AssertReadLittleEndian32(Bytes(0xf0, 0xde, 0xbc, 0x9a), 0x9abcdef0); + + AssertReadLittleEndian64(Bytes(0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12), + 0x123456789abcdef0L); + AssertReadLittleEndian64( + Bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a), 0x9abcdef012345678UL); + } + + [Test] + public void DecodeZigZag32() + { + Assert.AreEqual(0, CodedInputStream.DecodeZigZag32(0)); + Assert.AreEqual(-1, CodedInputStream.DecodeZigZag32(1)); + Assert.AreEqual(1, CodedInputStream.DecodeZigZag32(2)); + Assert.AreEqual(-2, CodedInputStream.DecodeZigZag32(3)); + Assert.AreEqual(0x3FFFFFFF, CodedInputStream.DecodeZigZag32(0x7FFFFFFE)); + Assert.AreEqual(unchecked((int) 0xC0000000), CodedInputStream.DecodeZigZag32(0x7FFFFFFF)); + Assert.AreEqual(0x7FFFFFFF, CodedInputStream.DecodeZigZag32(0xFFFFFFFE)); + Assert.AreEqual(unchecked((int) 0x80000000), CodedInputStream.DecodeZigZag32(0xFFFFFFFF)); + } + + [Test] + public void DecodeZigZag64() + { + Assert.AreEqual(0, CodedInputStream.DecodeZigZag64(0)); + Assert.AreEqual(-1, CodedInputStream.DecodeZigZag64(1)); + Assert.AreEqual(1, CodedInputStream.DecodeZigZag64(2)); + Assert.AreEqual(-2, CodedInputStream.DecodeZigZag64(3)); + Assert.AreEqual(0x000000003FFFFFFFL, CodedInputStream.DecodeZigZag64(0x000000007FFFFFFEL)); + Assert.AreEqual(unchecked((long) 0xFFFFFFFFC0000000L), CodedInputStream.DecodeZigZag64(0x000000007FFFFFFFL)); + Assert.AreEqual(0x000000007FFFFFFFL, CodedInputStream.DecodeZigZag64(0x00000000FFFFFFFEL)); + Assert.AreEqual(unchecked((long) 0xFFFFFFFF80000000L), CodedInputStream.DecodeZigZag64(0x00000000FFFFFFFFL)); + Assert.AreEqual(0x7FFFFFFFFFFFFFFFL, CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFEL)); + Assert.AreEqual(unchecked((long) 0x8000000000000000L), CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFFL)); + } + + [Test] + public void ReadWholeMessage_VaryingBlockSizes() + { + TestAllTypes message = SampleMessages.CreateFullTestAllTypes(); + + byte[] rawBytes = message.ToByteArray(); + Assert.AreEqual(rawBytes.Length, message.CalculateSize()); + TestAllTypes message2 = TestAllTypes.Parser.ParseFrom(rawBytes); + Assert.AreEqual(message, message2); + + // Try different block sizes. + for (int blockSize = 1; blockSize < 256; blockSize *= 2) + { + message2 = TestAllTypes.Parser.ParseFrom(new SmallBlockInputStream(rawBytes, blockSize)); + Assert.AreEqual(message, message2); + } + } + + [Test] + public void ReadHugeBlob() + { + // Allocate and initialize a 1MB blob. + byte[] blob = new byte[1 << 20]; + for (int i = 0; i < blob.Length; i++) + { + blob[i] = (byte) i; + } + + // Make a message containing it. + var message = new TestAllTypes { SingleBytes = ByteString.CopyFrom(blob) }; + + // Serialize and parse it. Make sure to parse from an InputStream, not + // directly from a ByteString, so that CodedInputStream uses buffered + // reading. + TestAllTypes message2 = TestAllTypes.Parser.ParseFrom(message.ToByteString()); + + Assert.AreEqual(message, message2); + } + + [Test] + public void ReadMaliciouslyLargeBlob() + { + MemoryStream ms = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(ms); + + uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); + output.WriteRawVarint32(tag); + output.WriteRawVarint32(0x7FFFFFFF); + output.WriteRawBytes(new byte[32]); // Pad with a few random bytes. + output.Flush(); + ms.Position = 0; + + CodedInputStream input = new CodedInputStream(ms); + Assert.AreEqual(tag, input.ReadTag()); + + Assert.Throws(() => input.ReadBytes()); + } + + // Representations of a tag for field 0 with various wire types + [Test] + [TestCase(0)] + [TestCase(1)] + [TestCase(2)] + [TestCase(3)] + [TestCase(4)] + [TestCase(5)] + public void ReadTag_ZeroFieldRejected(byte tag) + { + CodedInputStream cis = new CodedInputStream(new byte[] { tag }); + Assert.Throws(() => cis.ReadTag()); + } + + internal static TestRecursiveMessage MakeRecursiveMessage(int depth) + { + if (depth == 0) + { + return new TestRecursiveMessage { I = 5 }; + } + else + { + return new TestRecursiveMessage { A = MakeRecursiveMessage(depth - 1) }; + } + } + + internal static void AssertMessageDepth(TestRecursiveMessage message, int depth) + { + if (depth == 0) + { + Assert.IsNull(message.A); + Assert.AreEqual(5, message.I); + } + else + { + Assert.IsNotNull(message.A); + AssertMessageDepth(message.A, depth - 1); + } + } + + [Test] + public void MaliciousRecursion() + { + ByteString atRecursiveLimit = MakeRecursiveMessage(CodedInputStream.DefaultRecursionLimit).ToByteString(); + ByteString beyondRecursiveLimit = MakeRecursiveMessage(CodedInputStream.DefaultRecursionLimit + 1).ToByteString(); + + AssertMessageDepth(TestRecursiveMessage.Parser.ParseFrom(atRecursiveLimit), CodedInputStream.DefaultRecursionLimit); + + Assert.Throws(() => TestRecursiveMessage.Parser.ParseFrom(beyondRecursiveLimit)); + + CodedInputStream input = CodedInputStream.CreateWithLimits(new MemoryStream(atRecursiveLimit.ToByteArray()), 1000000, CodedInputStream.DefaultRecursionLimit - 1); + Assert.Throws(() => TestRecursiveMessage.Parser.ParseFrom(input)); + } + + [Test] + public void SizeLimit() + { + // Have to use a Stream rather than ByteString.CreateCodedInput as SizeLimit doesn't + // apply to the latter case. + MemoryStream ms = new MemoryStream(SampleMessages.CreateFullTestAllTypes().ToByteArray()); + CodedInputStream input = CodedInputStream.CreateWithLimits(ms, 16, 100); + Assert.Throws(() => TestAllTypes.Parser.ParseFrom(input)); + } + + /// + /// Tests that if we read an string that contains invalid UTF-8, no exception + /// is thrown. Instead, the invalid bytes are replaced with the Unicode + /// "replacement character" U+FFFD. + /// + [Test] + public void ReadInvalidUtf8() + { + MemoryStream ms = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(ms); + + uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); + output.WriteRawVarint32(tag); + output.WriteRawVarint32(1); + output.WriteRawBytes(new byte[] {0x80}); + output.Flush(); + ms.Position = 0; + + CodedInputStream input = new CodedInputStream(ms); + + Assert.AreEqual(tag, input.ReadTag()); + string text = input.ReadString(); + Assert.AreEqual('\ufffd', text[0]); + } + + [Test] + public void ReadNegativeSizedStringThrowsInvalidProtocolBufferException() + { + MemoryStream ms = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(ms); + + uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); + output.WriteRawVarint32(tag); + output.WriteLength(-1); + output.Flush(); + ms.Position = 0; + + CodedInputStream input = new CodedInputStream(ms); + + Assert.AreEqual(tag, input.ReadTag()); + Assert.Throws(() => input.ReadString()); + } + + [Test] + public void ReadNegativeSizedBytesThrowsInvalidProtocolBufferException() + { + MemoryStream ms = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(ms); + + uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); + output.WriteRawVarint32(tag); + output.WriteLength(-1); + output.Flush(); + ms.Position = 0; + + CodedInputStream input = new CodedInputStream(ms); + + Assert.AreEqual(tag, input.ReadTag()); + Assert.Throws(() => input.ReadBytes()); + } + + /// + /// A stream which limits the number of bytes it reads at a time. + /// We use this to make sure that CodedInputStream doesn't screw up when + /// reading in small blocks. + /// + private sealed class SmallBlockInputStream : MemoryStream + { + private readonly int blockSize; + + public SmallBlockInputStream(byte[] data, int blockSize) + : base(data) + { + this.blockSize = blockSize; + } + + public override int Read(byte[] buffer, int offset, int count) + { + return base.Read(buffer, offset, Math.Min(count, blockSize)); + } + } + + [Test] + public void TestNegativeEnum() + { + byte[] bytes = { 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01 }; + CodedInputStream input = new CodedInputStream(bytes); + Assert.AreEqual((int)SampleEnum.NegativeValue, input.ReadEnum()); + Assert.IsTrue(input.IsAtEnd); + } + + //Issue 71: CodedInputStream.ReadBytes go to slow path unnecessarily + [Test] + public void TestSlowPathAvoidance() + { + using (var ms = new MemoryStream()) + { + CodedOutputStream output = new CodedOutputStream(ms); + output.WriteTag(1, WireFormat.WireType.LengthDelimited); + output.WriteBytes(ByteString.CopyFrom(new byte[100])); + output.WriteTag(2, WireFormat.WireType.LengthDelimited); + output.WriteBytes(ByteString.CopyFrom(new byte[100])); + output.Flush(); + + ms.Position = 0; + CodedInputStream input = new CodedInputStream(ms, new byte[ms.Length / 2], 0, 0, false); + + uint tag = input.ReadTag(); + Assert.AreEqual(1, WireFormat.GetTagFieldNumber(tag)); + Assert.AreEqual(100, input.ReadBytes().Length); + + tag = input.ReadTag(); + Assert.AreEqual(2, WireFormat.GetTagFieldNumber(tag)); + Assert.AreEqual(100, input.ReadBytes().Length); + } + } + + [Test] + public void Tag0Throws() + { + var input = new CodedInputStream(new byte[] { 0 }); + Assert.Throws(() => input.ReadTag()); + } + + [Test] + public void SkipGroup() + { + // Create an output stream with a group in: + // Field 1: string "field 1" + // Field 2: group containing: + // Field 1: fixed int32 value 100 + // Field 2: string "ignore me" + // Field 3: nested group containing + // Field 1: fixed int64 value 1000 + // Field 3: string "field 3" + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + output.WriteTag(1, WireFormat.WireType.LengthDelimited); + output.WriteString("field 1"); + + // The outer group... + output.WriteTag(2, WireFormat.WireType.StartGroup); + output.WriteTag(1, WireFormat.WireType.Fixed32); + output.WriteFixed32(100); + output.WriteTag(2, WireFormat.WireType.LengthDelimited); + output.WriteString("ignore me"); + // The nested group... + output.WriteTag(3, WireFormat.WireType.StartGroup); + output.WriteTag(1, WireFormat.WireType.Fixed64); + output.WriteFixed64(1000); + // Note: Not sure the field number is relevant for end group... + output.WriteTag(3, WireFormat.WireType.EndGroup); + + // End the outer group + output.WriteTag(2, WireFormat.WireType.EndGroup); + + output.WriteTag(3, WireFormat.WireType.LengthDelimited); + output.WriteString("field 3"); + output.Flush(); + stream.Position = 0; + + // Now act like a generated client + var input = new CodedInputStream(stream); + Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited), input.ReadTag()); + Assert.AreEqual("field 1", input.ReadString()); + Assert.AreEqual(WireFormat.MakeTag(2, WireFormat.WireType.StartGroup), input.ReadTag()); + input.SkipLastField(); // Should consume the whole group, including the nested one. + Assert.AreEqual(WireFormat.MakeTag(3, WireFormat.WireType.LengthDelimited), input.ReadTag()); + Assert.AreEqual("field 3", input.ReadString()); + } + + [Test] + public void SkipGroup_WrongEndGroupTag() + { + // Create an output stream with: + // Field 1: string "field 1" + // Start group 2 + // Field 3: fixed int32 + // End group 4 (should give an error) + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + output.WriteTag(1, WireFormat.WireType.LengthDelimited); + output.WriteString("field 1"); + + // The outer group... + output.WriteTag(2, WireFormat.WireType.StartGroup); + output.WriteTag(3, WireFormat.WireType.Fixed32); + output.WriteFixed32(100); + output.WriteTag(4, WireFormat.WireType.EndGroup); + output.Flush(); + stream.Position = 0; + + // Now act like a generated client + var input = new CodedInputStream(stream); + Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited), input.ReadTag()); + Assert.AreEqual("field 1", input.ReadString()); + Assert.AreEqual(WireFormat.MakeTag(2, WireFormat.WireType.StartGroup), input.ReadTag()); + Assert.Throws(input.SkipLastField); + } + + [Test] + public void RogueEndGroupTag() + { + // If we have an end-group tag without a leading start-group tag, generated + // code will just call SkipLastField... so that should fail. + + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + output.WriteTag(1, WireFormat.WireType.EndGroup); + output.Flush(); + stream.Position = 0; + + var input = new CodedInputStream(stream); + Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.EndGroup), input.ReadTag()); + Assert.Throws(input.SkipLastField); + } + + [Test] + public void EndOfStreamReachedWhileSkippingGroup() + { + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + output.WriteTag(1, WireFormat.WireType.StartGroup); + output.WriteTag(2, WireFormat.WireType.StartGroup); + output.WriteTag(2, WireFormat.WireType.EndGroup); + + output.Flush(); + stream.Position = 0; + + // Now act like a generated client + var input = new CodedInputStream(stream); + input.ReadTag(); + Assert.Throws(input.SkipLastField); + } + + [Test] + public void RecursionLimitAppliedWhileSkippingGroup() + { + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + for (int i = 0; i < CodedInputStream.DefaultRecursionLimit + 1; i++) + { + output.WriteTag(1, WireFormat.WireType.StartGroup); + } + for (int i = 0; i < CodedInputStream.DefaultRecursionLimit + 1; i++) + { + output.WriteTag(1, WireFormat.WireType.EndGroup); + } + output.Flush(); + stream.Position = 0; + + // Now act like a generated client + var input = new CodedInputStream(stream); + Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.StartGroup), input.ReadTag()); + Assert.Throws(input.SkipLastField); + } + + [Test] + public void Construction_Invalid() + { + Assert.Throws(() => new CodedInputStream((byte[]) null)); + Assert.Throws(() => new CodedInputStream(null, 0, 0)); + Assert.Throws(() => new CodedInputStream((Stream) null)); + Assert.Throws(() => new CodedInputStream(new byte[10], 100, 0)); + Assert.Throws(() => new CodedInputStream(new byte[10], 5, 10)); + } + + [Test] + public void CreateWithLimits_InvalidLimits() + { + var stream = new MemoryStream(); + Assert.Throws(() => CodedInputStream.CreateWithLimits(stream, 0, 1)); + Assert.Throws(() => CodedInputStream.CreateWithLimits(stream, 1, 0)); + } + + [Test] + public void Dispose_DisposesUnderlyingStream() + { + var memoryStream = new MemoryStream(); + Assert.IsTrue(memoryStream.CanRead); + using (var cis = new CodedInputStream(memoryStream)) + { + } + Assert.IsFalse(memoryStream.CanRead); // Disposed + } + + [Test] + public void Dispose_WithLeaveOpen() + { + var memoryStream = new MemoryStream(); + Assert.IsTrue(memoryStream.CanRead); + using (var cis = new CodedInputStream(memoryStream, true)) + { + } + Assert.IsTrue(memoryStream.CanRead); // We left the stream open + } + + [Test] + public void Dispose_FromByteArray() + { + var stream = new CodedInputStream(new byte[10]); + stream.Dispose(); + } + + [Test] + public void TestParseMessagesCloseTo2G() + { + byte[] serializedMessage = GenerateBigSerializedMessage(); + // How many of these big messages do we need to take us near our 2GB limit? + int count = Int32.MaxValue / serializedMessage.Length; + // Now make a MemoryStream that will fake a near-2GB stream of messages by returning + // our big serialized message 'count' times. + using (RepeatingMemoryStream stream = new RepeatingMemoryStream(serializedMessage, count)) + { + Assert.DoesNotThrow(()=>TestAllTypes.Parser.ParseFrom(stream)); + } + } + + [Test] + public void TestParseMessagesOver2G() + { + byte[] serializedMessage = GenerateBigSerializedMessage(); + // How many of these big messages do we need to take us near our 2GB limit? + int count = Int32.MaxValue / serializedMessage.Length; + // Now add one to take us over the 2GB limit + count++; + // Now make a MemoryStream that will fake a near-2GB stream of messages by returning + // our big serialized message 'count' times. + using (RepeatingMemoryStream stream = new RepeatingMemoryStream(serializedMessage, count)) + { + Assert.Throws(() => TestAllTypes.Parser.ParseFrom(stream), + "Protocol message was too large. May be malicious. " + + "Use CodedInputStream.SetSizeLimit() to increase the size limit."); + } + } + + /// A serialized big message + private static byte[] GenerateBigSerializedMessage() + { + byte[] value = new byte[16 * 1024 * 1024]; + TestAllTypes message = SampleMessages.CreateFullTestAllTypes(); + message.SingleBytes = ByteString.CopyFrom(value); + return message.ToByteArray(); + } + + /// + /// A MemoryStream that repeats a byte arrays' content a number of times. + /// Simulates really large input without consuming loads of memory. Used above + /// to test the parsing behavior when the input size exceeds 2GB or close to it. + /// + private class RepeatingMemoryStream: MemoryStream + { + private readonly byte[] bytes; + private readonly int maxIterations; + private int index = 0; + + public RepeatingMemoryStream(byte[] bytes, int maxIterations) + { + this.bytes = bytes; + this.maxIterations = maxIterations; + } + + public override int Read(byte[] buffer, int offset, int count) + { + if (bytes.Length == 0) + { + return 0; + } + int numBytesCopiedTotal = 0; + while (numBytesCopiedTotal < count && index < maxIterations) + { + int numBytesToCopy = Math.Min(bytes.Length - (int)Position, count); + Array.Copy(bytes, (int)Position, buffer, offset, numBytesToCopy); + numBytesCopiedTotal += numBytesToCopy; + offset += numBytesToCopy; + count -= numBytesCopiedTotal; + Position += numBytesToCopy; + if (Position >= bytes.Length) + { + Position = 0; + index++; + } + } + return numBytesCopiedTotal; + } + } + } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs index 83bcb1760658..98cabd55adc4 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs @@ -1,419 +1,426 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; -using System.IO; -using Google.Protobuf.TestProtos; -using NUnit.Framework; - -namespace Google.Protobuf -{ - public class CodedOutputStreamTest - { - /// - /// Writes the given value using WriteRawVarint32() and WriteRawVarint64() and - /// checks that the result matches the given bytes - /// - private static void AssertWriteVarint(byte[] data, ulong value) - { - // Only do 32-bit write if the value fits in 32 bits. - if ((value >> 32) == 0) - { - MemoryStream rawOutput = new MemoryStream(); - CodedOutputStream output = new CodedOutputStream(rawOutput); - output.WriteRawVarint32((uint) value); - output.Flush(); - Assert.AreEqual(data, rawOutput.ToArray()); - // Also try computing size. - Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint32Size((uint) value)); - } - - { - MemoryStream rawOutput = new MemoryStream(); - CodedOutputStream output = new CodedOutputStream(rawOutput); - output.WriteRawVarint64(value); - output.Flush(); - Assert.AreEqual(data, rawOutput.ToArray()); - - // Also try computing size. - Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint64Size(value)); - } - - // Try different buffer sizes. - for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2) - { - // Only do 32-bit write if the value fits in 32 bits. - if ((value >> 32) == 0) - { - MemoryStream rawOutput = new MemoryStream(); - CodedOutputStream output = - new CodedOutputStream(rawOutput, bufferSize); - output.WriteRawVarint32((uint) value); - output.Flush(); - Assert.AreEqual(data, rawOutput.ToArray()); - } - - { - MemoryStream rawOutput = new MemoryStream(); - CodedOutputStream output = new CodedOutputStream(rawOutput, bufferSize); - output.WriteRawVarint64(value); - output.Flush(); - Assert.AreEqual(data, rawOutput.ToArray()); - } - } - } - - /// - /// Tests WriteRawVarint32() and WriteRawVarint64() - /// - [Test] - public void WriteVarint() - { - AssertWriteVarint(new byte[] {0x00}, 0); - AssertWriteVarint(new byte[] {0x01}, 1); - AssertWriteVarint(new byte[] {0x7f}, 127); - // 14882 - AssertWriteVarint(new byte[] {0xa2, 0x74}, (0x22 << 0) | (0x74 << 7)); - // 2961488830 - AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x0b}, - (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | - (0x0bL << 28)); - - // 64-bit - // 7256456126 - AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x1b}, - (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | - (0x1bL << 28)); - // 41256202580718336 - AssertWriteVarint( - new byte[] {0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49}, - (0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) | - (0x43UL << 28) | (0x49L << 35) | (0x24UL << 42) | (0x49UL << 49)); - // 11964378330978735131 - AssertWriteVarint( - new byte[] {0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01}, - unchecked((ulong) - ((0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) | - (0x3bL << 28) | (0x56L << 35) | (0x00L << 42) | - (0x05L << 49) | (0x26L << 56) | (0x01L << 63)))); - } - - /// - /// Parses the given bytes using WriteRawLittleEndian32() and checks - /// that the result matches the given value. - /// - private static void AssertWriteLittleEndian32(byte[] data, uint value) - { - MemoryStream rawOutput = new MemoryStream(); - CodedOutputStream output = new CodedOutputStream(rawOutput); - output.WriteRawLittleEndian32(value); - output.Flush(); - Assert.AreEqual(data, rawOutput.ToArray()); - - // Try different buffer sizes. - for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2) - { - rawOutput = new MemoryStream(); - output = new CodedOutputStream(rawOutput, bufferSize); - output.WriteRawLittleEndian32(value); - output.Flush(); - Assert.AreEqual(data, rawOutput.ToArray()); - } - } - - /// - /// Parses the given bytes using WriteRawLittleEndian64() and checks - /// that the result matches the given value. - /// - private static void AssertWriteLittleEndian64(byte[] data, ulong value) - { - MemoryStream rawOutput = new MemoryStream(); - CodedOutputStream output = new CodedOutputStream(rawOutput); - output.WriteRawLittleEndian64(value); - output.Flush(); - Assert.AreEqual(data, rawOutput.ToArray()); - - // Try different block sizes. - for (int blockSize = 1; blockSize <= 16; blockSize *= 2) - { - rawOutput = new MemoryStream(); - output = new CodedOutputStream(rawOutput, blockSize); - output.WriteRawLittleEndian64(value); - output.Flush(); - Assert.AreEqual(data, rawOutput.ToArray()); - } - } - - /// - /// Tests writeRawLittleEndian32() and writeRawLittleEndian64(). - /// - [Test] - public void WriteLittleEndian() - { - AssertWriteLittleEndian32(new byte[] {0x78, 0x56, 0x34, 0x12}, 0x12345678); - AssertWriteLittleEndian32(new byte[] {0xf0, 0xde, 0xbc, 0x9a}, 0x9abcdef0); - - AssertWriteLittleEndian64( - new byte[] {0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12}, - 0x123456789abcdef0L); - AssertWriteLittleEndian64( - new byte[] {0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a}, - 0x9abcdef012345678UL); - } - - [Test] - public void WriteWholeMessage_VaryingBlockSizes() - { - TestAllTypes message = SampleMessages.CreateFullTestAllTypes(); - - byte[] rawBytes = message.ToByteArray(); - - // Try different block sizes. - for (int blockSize = 1; blockSize < 256; blockSize *= 2) - { - MemoryStream rawOutput = new MemoryStream(); - CodedOutputStream output = new CodedOutputStream(rawOutput, blockSize); - message.WriteTo(output); - output.Flush(); - Assert.AreEqual(rawBytes, rawOutput.ToArray()); - } - } - - [Test] - public void EncodeZigZag32() - { - Assert.AreEqual(0u, CodedOutputStream.EncodeZigZag32(0)); - Assert.AreEqual(1u, CodedOutputStream.EncodeZigZag32(-1)); - Assert.AreEqual(2u, CodedOutputStream.EncodeZigZag32(1)); - Assert.AreEqual(3u, CodedOutputStream.EncodeZigZag32(-2)); - Assert.AreEqual(0x7FFFFFFEu, CodedOutputStream.EncodeZigZag32(0x3FFFFFFF)); - Assert.AreEqual(0x7FFFFFFFu, CodedOutputStream.EncodeZigZag32(unchecked((int) 0xC0000000))); - Assert.AreEqual(0xFFFFFFFEu, CodedOutputStream.EncodeZigZag32(0x7FFFFFFF)); - Assert.AreEqual(0xFFFFFFFFu, CodedOutputStream.EncodeZigZag32(unchecked((int) 0x80000000))); - } - - [Test] - public void EncodeZigZag64() - { - Assert.AreEqual(0u, CodedOutputStream.EncodeZigZag64(0)); - Assert.AreEqual(1u, CodedOutputStream.EncodeZigZag64(-1)); - Assert.AreEqual(2u, CodedOutputStream.EncodeZigZag64(1)); - Assert.AreEqual(3u, CodedOutputStream.EncodeZigZag64(-2)); - Assert.AreEqual(0x000000007FFFFFFEuL, - CodedOutputStream.EncodeZigZag64(unchecked((long) 0x000000003FFFFFFFUL))); - Assert.AreEqual(0x000000007FFFFFFFuL, - CodedOutputStream.EncodeZigZag64(unchecked((long) 0xFFFFFFFFC0000000UL))); - Assert.AreEqual(0x00000000FFFFFFFEuL, - CodedOutputStream.EncodeZigZag64(unchecked((long) 0x000000007FFFFFFFUL))); - Assert.AreEqual(0x00000000FFFFFFFFuL, - CodedOutputStream.EncodeZigZag64(unchecked((long) 0xFFFFFFFF80000000UL))); - Assert.AreEqual(0xFFFFFFFFFFFFFFFEL, - CodedOutputStream.EncodeZigZag64(unchecked((long) 0x7FFFFFFFFFFFFFFFUL))); - Assert.AreEqual(0xFFFFFFFFFFFFFFFFL, - CodedOutputStream.EncodeZigZag64(unchecked((long) 0x8000000000000000UL))); - } - - [Test] - public void RoundTripZigZag32() - { - // Some easier-to-verify round-trip tests. The inputs (other than 0, 1, -1) - // were chosen semi-randomly via keyboard bashing. - Assert.AreEqual(0, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(0))); - Assert.AreEqual(1, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(1))); - Assert.AreEqual(-1, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-1))); - Assert.AreEqual(14927, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(14927))); - Assert.AreEqual(-3612, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-3612))); - } - - [Test] - public void RoundTripZigZag64() - { - Assert.AreEqual(0, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(0))); - Assert.AreEqual(1, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(1))); - Assert.AreEqual(-1, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-1))); - Assert.AreEqual(14927, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(14927))); - Assert.AreEqual(-3612, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-3612))); - - Assert.AreEqual(856912304801416L, - CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(856912304801416L))); - Assert.AreEqual(-75123905439571256L, - CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-75123905439571256L))); - } - - [Test] - public void TestNegativeEnumNoTag() - { - Assert.AreEqual(10, CodedOutputStream.ComputeInt32Size(-2)); - Assert.AreEqual(10, CodedOutputStream.ComputeEnumSize((int) SampleEnum.NegativeValue)); - - byte[] bytes = new byte[10]; - CodedOutputStream output = new CodedOutputStream(bytes); - output.WriteEnum((int) SampleEnum.NegativeValue); - - Assert.AreEqual(0, output.SpaceLeft); - Assert.AreEqual("FE-FF-FF-FF-FF-FF-FF-FF-FF-01", BitConverter.ToString(bytes)); - } - - [Test] - public void TestCodedInputOutputPosition() - { - byte[] content = new byte[110]; - for (int i = 0; i < content.Length; i++) - content[i] = (byte)i; - - byte[] child = new byte[120]; - { - MemoryStream ms = new MemoryStream(child); - CodedOutputStream cout = new CodedOutputStream(ms, 20); - // Field 11: numeric value: 500 - cout.WriteTag(11, WireFormat.WireType.Varint); - Assert.AreEqual(1, cout.Position); - cout.WriteInt32(500); - Assert.AreEqual(3, cout.Position); - //Field 12: length delimited 120 bytes - cout.WriteTag(12, WireFormat.WireType.LengthDelimited); - Assert.AreEqual(4, cout.Position); - cout.WriteBytes(ByteString.CopyFrom(content)); - Assert.AreEqual(115, cout.Position); - // Field 13: fixed numeric value: 501 - cout.WriteTag(13, WireFormat.WireType.Fixed32); - Assert.AreEqual(116, cout.Position); - cout.WriteSFixed32(501); - Assert.AreEqual(120, cout.Position); - cout.Flush(); - } - - byte[] bytes = new byte[130]; - { - CodedOutputStream cout = new CodedOutputStream(bytes); - // Field 1: numeric value: 500 - cout.WriteTag(1, WireFormat.WireType.Varint); - Assert.AreEqual(1, cout.Position); - cout.WriteInt32(500); - Assert.AreEqual(3, cout.Position); - //Field 2: length delimited 120 bytes - cout.WriteTag(2, WireFormat.WireType.LengthDelimited); - Assert.AreEqual(4, cout.Position); - cout.WriteBytes(ByteString.CopyFrom(child)); - Assert.AreEqual(125, cout.Position); - // Field 3: fixed numeric value: 500 - cout.WriteTag(3, WireFormat.WireType.Fixed32); - Assert.AreEqual(126, cout.Position); - cout.WriteSFixed32(501); - Assert.AreEqual(130, cout.Position); - cout.Flush(); - } - // Now test Input stream: - { - CodedInputStream cin = new CodedInputStream(new MemoryStream(bytes), new byte[50], 0, 0); - Assert.AreEqual(0, cin.Position); - // Field 1: - uint tag = cin.ReadTag(); - Assert.AreEqual(1, tag >> 3); - Assert.AreEqual(1, cin.Position); - Assert.AreEqual(500, cin.ReadInt32()); - Assert.AreEqual(3, cin.Position); - //Field 2: - tag = cin.ReadTag(); - Assert.AreEqual(2, tag >> 3); - Assert.AreEqual(4, cin.Position); - int childlen = cin.ReadLength(); - Assert.AreEqual(120, childlen); - Assert.AreEqual(5, cin.Position); - int oldlimit = cin.PushLimit((int)childlen); - Assert.AreEqual(5, cin.Position); - // Now we are reading child message - { - // Field 11: numeric value: 500 - tag = cin.ReadTag(); - Assert.AreEqual(11, tag >> 3); - Assert.AreEqual(6, cin.Position); - Assert.AreEqual(500, cin.ReadInt32()); - Assert.AreEqual(8, cin.Position); - //Field 12: length delimited 120 bytes - tag = cin.ReadTag(); - Assert.AreEqual(12, tag >> 3); - Assert.AreEqual(9, cin.Position); - ByteString bstr = cin.ReadBytes(); - Assert.AreEqual(110, bstr.Length); - Assert.AreEqual((byte) 109, bstr[109]); - Assert.AreEqual(120, cin.Position); - // Field 13: fixed numeric value: 501 - tag = cin.ReadTag(); - Assert.AreEqual(13, tag >> 3); - // ROK - Previously broken here, this returned 126 failing to account for bufferSizeAfterLimit - Assert.AreEqual(121, cin.Position); - Assert.AreEqual(501, cin.ReadSFixed32()); - Assert.AreEqual(125, cin.Position); - Assert.IsTrue(cin.IsAtEnd); - } - cin.PopLimit(oldlimit); - Assert.AreEqual(125, cin.Position); - // Field 3: fixed numeric value: 501 - tag = cin.ReadTag(); - Assert.AreEqual(3, tag >> 3); - Assert.AreEqual(126, cin.Position); - Assert.AreEqual(501, cin.ReadSFixed32()); - Assert.AreEqual(130, cin.Position); - Assert.IsTrue(cin.IsAtEnd); - } - } - - [Test] - public void Dispose_DisposesUnderlyingStream() - { - var memoryStream = new MemoryStream(); - Assert.IsTrue(memoryStream.CanWrite); - using (var cos = new CodedOutputStream(memoryStream)) - { - cos.WriteRawByte(0); - Assert.AreEqual(0, memoryStream.Position); // Not flushed yet - } - Assert.AreEqual(1, memoryStream.ToArray().Length); // Flushed data from CodedOutputStream to MemoryStream - Assert.IsFalse(memoryStream.CanWrite); // Disposed - } - - [Test] - public void Dispose_WithLeaveOpen() - { - var memoryStream = new MemoryStream(); - Assert.IsTrue(memoryStream.CanWrite); - using (var cos = new CodedOutputStream(memoryStream, true)) - { - cos.WriteRawByte(0); - Assert.AreEqual(0, memoryStream.Position); // Not flushed yet - } - Assert.AreEqual(1, memoryStream.Position); // Flushed data from CodedOutputStream to MemoryStream - Assert.IsTrue(memoryStream.CanWrite); // We left the stream open - } - } +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.IO; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class CodedOutputStreamTest + { + /// + /// Writes the given value using WriteRawVarint32() and WriteRawVarint64() and + /// checks that the result matches the given bytes + /// + private static void AssertWriteVarint(byte[] data, ulong value) + { + // Only do 32-bit write if the value fits in 32 bits. + if ((value >> 32) == 0) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput); + output.WriteRawVarint32((uint) value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + // Also try computing size. + Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint32Size((uint) value)); + } + + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput); + output.WriteRawVarint64(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + + // Also try computing size. + Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint64Size(value)); + } + + // Try different buffer sizes. + for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2) + { + // Only do 32-bit write if the value fits in 32 bits. + if ((value >> 32) == 0) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = + new CodedOutputStream(rawOutput, bufferSize); + output.WriteRawVarint32((uint) value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + } + + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput, bufferSize); + output.WriteRawVarint64(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + } + } + } + + /// + /// Tests WriteRawVarint32() and WriteRawVarint64() + /// + [Test] + public void WriteVarint() + { + AssertWriteVarint(new byte[] {0x00}, 0); + AssertWriteVarint(new byte[] {0x01}, 1); + AssertWriteVarint(new byte[] {0x7f}, 127); + // 14882 + AssertWriteVarint(new byte[] {0xa2, 0x74}, (0x22 << 0) | (0x74 << 7)); + // 2961488830 + AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x0b}, + (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | + (0x0bL << 28)); + + // 64-bit + // 7256456126 + AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x1b}, + (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | + (0x1bL << 28)); + // 41256202580718336 + AssertWriteVarint( + new byte[] {0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49}, + (0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) | + (0x43UL << 28) | (0x49L << 35) | (0x24UL << 42) | (0x49UL << 49)); + // 11964378330978735131 + AssertWriteVarint( + new byte[] {0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01}, + unchecked((ulong) + ((0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) | + (0x3bL << 28) | (0x56L << 35) | (0x00L << 42) | + (0x05L << 49) | (0x26L << 56) | (0x01L << 63)))); + } + + /// + /// Parses the given bytes using WriteRawLittleEndian32() and checks + /// that the result matches the given value. + /// + private static void AssertWriteLittleEndian32(byte[] data, uint value) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput); + output.WriteRawLittleEndian32(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + + // Try different buffer sizes. + for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2) + { + rawOutput = new MemoryStream(); + output = new CodedOutputStream(rawOutput, bufferSize); + output.WriteRawLittleEndian32(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + } + } + + /// + /// Parses the given bytes using WriteRawLittleEndian64() and checks + /// that the result matches the given value. + /// + private static void AssertWriteLittleEndian64(byte[] data, ulong value) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput); + output.WriteRawLittleEndian64(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + + // Try different block sizes. + for (int blockSize = 1; blockSize <= 16; blockSize *= 2) + { + rawOutput = new MemoryStream(); + output = new CodedOutputStream(rawOutput, blockSize); + output.WriteRawLittleEndian64(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + } + } + + /// + /// Tests writeRawLittleEndian32() and writeRawLittleEndian64(). + /// + [Test] + public void WriteLittleEndian() + { + AssertWriteLittleEndian32(new byte[] {0x78, 0x56, 0x34, 0x12}, 0x12345678); + AssertWriteLittleEndian32(new byte[] {0xf0, 0xde, 0xbc, 0x9a}, 0x9abcdef0); + + AssertWriteLittleEndian64( + new byte[] {0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12}, + 0x123456789abcdef0L); + AssertWriteLittleEndian64( + new byte[] {0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a}, + 0x9abcdef012345678UL); + } + + [Test] + public void WriteWholeMessage_VaryingBlockSizes() + { + TestAllTypes message = SampleMessages.CreateFullTestAllTypes(); + + byte[] rawBytes = message.ToByteArray(); + + // Try different block sizes. + for (int blockSize = 1; blockSize < 256; blockSize *= 2) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput, blockSize); + message.WriteTo(output); + output.Flush(); + Assert.AreEqual(rawBytes, rawOutput.ToArray()); + } + } + + [Test] + public void EncodeZigZag32() + { + Assert.AreEqual(0u, CodedOutputStream.EncodeZigZag32(0)); + Assert.AreEqual(1u, CodedOutputStream.EncodeZigZag32(-1)); + Assert.AreEqual(2u, CodedOutputStream.EncodeZigZag32(1)); + Assert.AreEqual(3u, CodedOutputStream.EncodeZigZag32(-2)); + Assert.AreEqual(0x7FFFFFFEu, CodedOutputStream.EncodeZigZag32(0x3FFFFFFF)); + Assert.AreEqual(0x7FFFFFFFu, CodedOutputStream.EncodeZigZag32(unchecked((int) 0xC0000000))); + Assert.AreEqual(0xFFFFFFFEu, CodedOutputStream.EncodeZigZag32(0x7FFFFFFF)); + Assert.AreEqual(0xFFFFFFFFu, CodedOutputStream.EncodeZigZag32(unchecked((int) 0x80000000))); + } + + [Test] + public void EncodeZigZag64() + { + Assert.AreEqual(0u, CodedOutputStream.EncodeZigZag64(0)); + Assert.AreEqual(1u, CodedOutputStream.EncodeZigZag64(-1)); + Assert.AreEqual(2u, CodedOutputStream.EncodeZigZag64(1)); + Assert.AreEqual(3u, CodedOutputStream.EncodeZigZag64(-2)); + Assert.AreEqual(0x000000007FFFFFFEuL, + CodedOutputStream.EncodeZigZag64(unchecked((long) 0x000000003FFFFFFFUL))); + Assert.AreEqual(0x000000007FFFFFFFuL, + CodedOutputStream.EncodeZigZag64(unchecked((long) 0xFFFFFFFFC0000000UL))); + Assert.AreEqual(0x00000000FFFFFFFEuL, + CodedOutputStream.EncodeZigZag64(unchecked((long) 0x000000007FFFFFFFUL))); + Assert.AreEqual(0x00000000FFFFFFFFuL, + CodedOutputStream.EncodeZigZag64(unchecked((long) 0xFFFFFFFF80000000UL))); + Assert.AreEqual(0xFFFFFFFFFFFFFFFEL, + CodedOutputStream.EncodeZigZag64(unchecked((long) 0x7FFFFFFFFFFFFFFFUL))); + Assert.AreEqual(0xFFFFFFFFFFFFFFFFL, + CodedOutputStream.EncodeZigZag64(unchecked((long) 0x8000000000000000UL))); + } + + [Test] + public void RoundTripZigZag32() + { + // Some easier-to-verify round-trip tests. The inputs (other than 0, 1, -1) + // were chosen semi-randomly via keyboard bashing. + Assert.AreEqual(0, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(0))); + Assert.AreEqual(1, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(1))); + Assert.AreEqual(-1, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-1))); + Assert.AreEqual(14927, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(14927))); + Assert.AreEqual(-3612, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-3612))); + } + + [Test] + public void RoundTripZigZag64() + { + Assert.AreEqual(0, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(0))); + Assert.AreEqual(1, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(1))); + Assert.AreEqual(-1, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-1))); + Assert.AreEqual(14927, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(14927))); + Assert.AreEqual(-3612, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-3612))); + + Assert.AreEqual(856912304801416L, + CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(856912304801416L))); + Assert.AreEqual(-75123905439571256L, + CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-75123905439571256L))); + } + + [Test] + public void TestNegativeEnumNoTag() + { + Assert.AreEqual(10, CodedOutputStream.ComputeInt32Size(-2)); + Assert.AreEqual(10, CodedOutputStream.ComputeEnumSize((int) SampleEnum.NegativeValue)); + + byte[] bytes = new byte[10]; + CodedOutputStream output = new CodedOutputStream(bytes); + output.WriteEnum((int) SampleEnum.NegativeValue); + + Assert.AreEqual(0, output.SpaceLeft); + Assert.AreEqual("FE-FF-FF-FF-FF-FF-FF-FF-FF-01", BitConverter.ToString(bytes)); + } + + [Test] + public void TestCodedInputOutputPosition() + { + byte[] content = new byte[110]; + for (int i = 0; i < content.Length; i++) + content[i] = (byte)i; + + byte[] child = new byte[120]; + { + MemoryStream ms = new MemoryStream(child); + CodedOutputStream cout = new CodedOutputStream(ms, 20); + // Field 11: numeric value: 500 + cout.WriteTag(11, WireFormat.WireType.Varint); + Assert.AreEqual(1, cout.Position); + cout.WriteInt32(500); + Assert.AreEqual(3, cout.Position); + //Field 12: length delimited 120 bytes + cout.WriteTag(12, WireFormat.WireType.LengthDelimited); + Assert.AreEqual(4, cout.Position); + cout.WriteBytes(ByteString.CopyFrom(content)); + Assert.AreEqual(115, cout.Position); + // Field 13: fixed numeric value: 501 + cout.WriteTag(13, WireFormat.WireType.Fixed32); + Assert.AreEqual(116, cout.Position); + cout.WriteSFixed32(501); + Assert.AreEqual(120, cout.Position); + cout.Flush(); + } + + byte[] bytes = new byte[130]; + { + CodedOutputStream cout = new CodedOutputStream(bytes); + // Field 1: numeric value: 500 + cout.WriteTag(1, WireFormat.WireType.Varint); + Assert.AreEqual(1, cout.Position); + cout.WriteInt32(500); + Assert.AreEqual(3, cout.Position); + //Field 2: length delimited 120 bytes + cout.WriteTag(2, WireFormat.WireType.LengthDelimited); + Assert.AreEqual(4, cout.Position); + cout.WriteBytes(ByteString.CopyFrom(child)); + Assert.AreEqual(125, cout.Position); + // Field 3: fixed numeric value: 500 + cout.WriteTag(3, WireFormat.WireType.Fixed32); + Assert.AreEqual(126, cout.Position); + cout.WriteSFixed32(501); + Assert.AreEqual(130, cout.Position); + cout.Flush(); + } + // Now test Input stream: + { + CodedInputStream cin = new CodedInputStream(new MemoryStream(bytes), new byte[50], 0, 0, false); + Assert.AreEqual(0, cin.Position); + // Field 1: + uint tag = cin.ReadTag(); + Assert.AreEqual(1, tag >> 3); + Assert.AreEqual(1, cin.Position); + Assert.AreEqual(500, cin.ReadInt32()); + Assert.AreEqual(3, cin.Position); + //Field 2: + tag = cin.ReadTag(); + Assert.AreEqual(2, tag >> 3); + Assert.AreEqual(4, cin.Position); + int childlen = cin.ReadLength(); + Assert.AreEqual(120, childlen); + Assert.AreEqual(5, cin.Position); + int oldlimit = cin.PushLimit((int)childlen); + Assert.AreEqual(5, cin.Position); + // Now we are reading child message + { + // Field 11: numeric value: 500 + tag = cin.ReadTag(); + Assert.AreEqual(11, tag >> 3); + Assert.AreEqual(6, cin.Position); + Assert.AreEqual(500, cin.ReadInt32()); + Assert.AreEqual(8, cin.Position); + //Field 12: length delimited 120 bytes + tag = cin.ReadTag(); + Assert.AreEqual(12, tag >> 3); + Assert.AreEqual(9, cin.Position); + ByteString bstr = cin.ReadBytes(); + Assert.AreEqual(110, bstr.Length); + Assert.AreEqual((byte) 109, bstr[109]); + Assert.AreEqual(120, cin.Position); + // Field 13: fixed numeric value: 501 + tag = cin.ReadTag(); + Assert.AreEqual(13, tag >> 3); + // ROK - Previously broken here, this returned 126 failing to account for bufferSizeAfterLimit + Assert.AreEqual(121, cin.Position); + Assert.AreEqual(501, cin.ReadSFixed32()); + Assert.AreEqual(125, cin.Position); + Assert.IsTrue(cin.IsAtEnd); + } + cin.PopLimit(oldlimit); + Assert.AreEqual(125, cin.Position); + // Field 3: fixed numeric value: 501 + tag = cin.ReadTag(); + Assert.AreEqual(3, tag >> 3); + Assert.AreEqual(126, cin.Position); + Assert.AreEqual(501, cin.ReadSFixed32()); + Assert.AreEqual(130, cin.Position); + Assert.IsTrue(cin.IsAtEnd); + } + } + + [Test] + public void Dispose_DisposesUnderlyingStream() + { + var memoryStream = new MemoryStream(); + Assert.IsTrue(memoryStream.CanWrite); + using (var cos = new CodedOutputStream(memoryStream)) + { + cos.WriteRawByte(0); + Assert.AreEqual(0, memoryStream.Position); // Not flushed yet + } + Assert.AreEqual(1, memoryStream.ToArray().Length); // Flushed data from CodedOutputStream to MemoryStream + Assert.IsFalse(memoryStream.CanWrite); // Disposed + } + + [Test] + public void Dispose_WithLeaveOpen() + { + var memoryStream = new MemoryStream(); + Assert.IsTrue(memoryStream.CanWrite); + using (var cos = new CodedOutputStream(memoryStream, true)) + { + cos.WriteRawByte(0); + Assert.AreEqual(0, memoryStream.Position); // Not flushed yet + } + Assert.AreEqual(1, memoryStream.Position); // Flushed data from CodedOutputStream to MemoryStream + Assert.IsTrue(memoryStream.CanWrite); // We left the stream open + } + + [Test] + public void Dispose_FromByteArray() + { + var stream = new CodedOutputStream(new byte[10]); + stream.Dispose(); + } + } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs index 9c8459073c64..f64ebac4ef9f 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs @@ -86,7 +86,7 @@ public void Indexer_ForbidsNullKeys() var map = new MapField(); Assert.Throws(() => map[null] = new ForeignMessage()); } - + [Test] public void AddPreservesInsertionOrder() { @@ -471,7 +471,7 @@ public void ViewCopyTo() keys.CopyTo(array, 1); CollectionAssert.AreEqual(new[] { null, "foo", "x", null }, array); } - + // Just test keys - we know the implementation is the same for values [Test] public void NonGenericViewCopyTo() @@ -498,6 +498,14 @@ public void KeysContains() Assert.Throws(() => keys.Contains(null)); } + [Test] + public void KeysCopyTo() + { + var map = new MapField { { "foo", "bar" }, { "x", "y" } }; + var keys = map.Keys.ToArray(); // Uses CopyTo internally + CollectionAssert.AreEquivalent(new[] { "foo", "x" }, keys); + } + [Test] public void ValuesContains() { @@ -510,6 +518,14 @@ public void ValuesContains() Assert.IsFalse(values.Contains(null)); } + [Test] + public void ValuesCopyTo() + { + var map = new MapField { { "foo", "bar" }, { "x", "y" } }; + var values = map.Values.ToArray(); // Uses CopyTo internally + CollectionAssert.AreEquivalent(new[] { "bar", "y" }, values); + } + [Test] public void ToString_StringToString() { @@ -524,6 +540,65 @@ public void ToString_UnsupportedKeyType() Assert.Throws(() => map.ToString()); } + [Test] + public void NaNValuesComparedBitwise() + { + var map1 = new MapField + { + { "x", SampleNaNs.Regular }, + { "y", SampleNaNs.SignallingFlipped } + }; + + var map2 = new MapField + { + { "x", SampleNaNs.Regular }, + { "y", SampleNaNs.PayloadFlipped } + }; + + var map3 = new MapField + { + { "x", SampleNaNs.Regular }, + { "y", SampleNaNs.SignallingFlipped } + }; + + EqualityTester.AssertInequality(map1, map2); + EqualityTester.AssertEquality(map1, map3); + Assert.True(map1.Values.Contains(SampleNaNs.SignallingFlipped)); + Assert.False(map2.Values.Contains(SampleNaNs.SignallingFlipped)); + } + + // This wouldn't usually happen, as protos can't use doubles as map keys, + // but let's be consistent. + [Test] + public void NaNKeysComparedBitwise() + { + var map = new MapField + { + { SampleNaNs.Regular, "x" }, + { SampleNaNs.SignallingFlipped, "y" } + }; + Assert.AreEqual("x", map[SampleNaNs.Regular]); + Assert.AreEqual("y", map[SampleNaNs.SignallingFlipped]); + string ignored; + Assert.False(map.TryGetValue(SampleNaNs.PayloadFlipped, out ignored)); + } + +#if !NET35 + [Test] + public void IDictionaryKeys_Equals_IReadOnlyDictionaryKeys() + { + var map = new MapField { { "foo", "bar" }, { "x", "y" } }; + CollectionAssert.AreEquivalent(((IDictionary)map).Keys, ((IReadOnlyDictionary)map).Keys); + } + + [Test] + public void IDictionaryValues_Equals_IReadOnlyDictionaryValues() + { + var map = new MapField { { "foo", "bar" }, { "x", "y" } }; + CollectionAssert.AreEquivalent(((IDictionary)map).Values, ((IReadOnlyDictionary)map).Values); + } +#endif + private static KeyValuePair NewKeyValuePair(TKey key, TValue value) { return new KeyValuePair(key, value); diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Collections/ProtobufEqualityComparersTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Collections/ProtobufEqualityComparersTest.cs new file mode 100644 index 000000000000..594a879865ac --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Collections/ProtobufEqualityComparersTest.cs @@ -0,0 +1,124 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2017 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using NUnit.Framework; +using System.Collections.Generic; +using System.Linq; +using static Google.Protobuf.Collections.ProtobufEqualityComparers; + +namespace Google.Protobuf.Collections +{ + public class ProtobufEqualityComparersTest + { + private static readonly double[] doubles = + { + 0, + 1, + 1.5, + -1.5, + double.PositiveInfinity, + double.NegativeInfinity, + // Three different types of NaN... + SampleNaNs.Regular, + SampleNaNs.SignallingFlipped, + SampleNaNs.PayloadFlipped + }; + + [Test] + public void GetEqualityComparer_Default() + { + // It's more pain than it's worth to try to parameterize these tests. + Assert.AreSame(EqualityComparer.Default, GetEqualityComparer()); + Assert.AreSame(EqualityComparer.Default, GetEqualityComparer()); + Assert.AreSame(EqualityComparer.Default, GetEqualityComparer()); + Assert.AreSame(EqualityComparer.Default, GetEqualityComparer()); + } + + [Test] + public void GetEqualityComparer_NotDefault() + { + // It's more pain than it's worth to try to parameterize these tests. + Assert.AreSame(BitwiseDoubleEqualityComparer, GetEqualityComparer()); + Assert.AreSame(BitwiseSingleEqualityComparer, GetEqualityComparer()); + Assert.AreSame(BitwiseNullableDoubleEqualityComparer, GetEqualityComparer()); + Assert.AreSame(BitwiseNullableSingleEqualityComparer, GetEqualityComparer()); + } + + [Test] + public void DoubleComparisons() + { + ValidateEqualityComparer(BitwiseDoubleEqualityComparer, doubles); + } + + [Test] + public void NullableDoubleComparisons() + { + ValidateEqualityComparer(BitwiseNullableDoubleEqualityComparer, doubles.Select(d => (double?) d).Concat(new double?[] { null })); + } + + [Test] + public void SingleComparisons() + { + ValidateEqualityComparer(BitwiseSingleEqualityComparer, doubles.Select(d => (float) d)); + } + + [Test] + public void NullableSingleComparisons() + { + ValidateEqualityComparer(BitwiseNullableSingleEqualityComparer, doubles.Select(d => (float?) d).Concat(new float?[] { null })); + } + + private static void ValidateEqualityComparer(EqualityComparer comparer, IEnumerable values) + { + var array = values.ToArray(); + // Each value should be equal to itself, but not to any other value. + for (int i = 0; i < array.Length; i++) + { + for (int j = 0; j < array.Length; j++) + { + if (i == j) + { + Assert.IsTrue(comparer.Equals(array[i], array[j]), + "{0} should be equal to itself", array[i], array[j]); + } + else + { + Assert.IsFalse(comparer.Equals(array[i], array[j]), + "{0} and {1} should not be equal", array[i], array[j]); + Assert.AreNotEqual(comparer.GetHashCode(array[i]), comparer.GetHashCode(array[j]), + "Hash codes for {0} and {1} should not be equal", array[i], array[j]); + } + } + } + } + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs index 8ed54cfb4845..b3863a4965a1 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs @@ -75,10 +75,96 @@ public void Add_Sequence() } [Test] - public void Add_RepeatedField() + public void AddRange_SlowPath() + { + var list = new RepeatedField(); + list.AddRange(new[] { "foo", "bar" }.Select(x => x)); + Assert.AreEqual(2, list.Count); + Assert.AreEqual("foo", list[0]); + Assert.AreEqual("bar", list[1]); + } + + [Test] + public void AddRange_SlowPath_NullsProhibited_ReferenceType() + { + var list = new RepeatedField(); + // It's okay for this to throw ArgumentNullException if necessary. + // It's not ideal, but not awful. + Assert.Catch(() => list.AddRange(new[] { "foo", null }.Select(x => x))); + } + + [Test] + public void AddRange_SlowPath_NullsProhibited_NullableValueType() + { + var list = new RepeatedField(); + // It's okay for this to throw ArgumentNullException if necessary. + // It's not ideal, but not awful. + Assert.Catch(() => list.AddRange(new[] { 20, (int?)null }.Select(x => x))); + } + + [Test] + public void AddRange_Optimized_NonNullableValueType() + { + var list = new RepeatedField(); + list.AddRange(new List { 20, 30 }); + Assert.AreEqual(2, list.Count); + Assert.AreEqual(20, list[0]); + Assert.AreEqual(30, list[1]); + } + + [Test] + public void AddRange_Optimized_ReferenceType() + { + var list = new RepeatedField(); + list.AddRange(new List { "foo", "bar" }); + Assert.AreEqual(2, list.Count); + Assert.AreEqual("foo", list[0]); + Assert.AreEqual("bar", list[1]); + } + + [Test] + public void AddRange_Optimized_NullableValueType() + { + var list = new RepeatedField(); + list.AddRange(new List { 20, 30 }); + Assert.AreEqual(2, list.Count); + Assert.AreEqual((int?) 20, list[0]); + Assert.AreEqual((int?) 30, list[1]); + } + + [Test] + public void AddRange_Optimized_NullsProhibited_ReferenceType() + { + // We don't just trust that a collection with a nullable element type doesn't contain nulls + var list = new RepeatedField(); + // It's okay for this to throw ArgumentNullException if necessary. + // It's not ideal, but not awful. + Assert.Catch(() => list.AddRange(new List { "foo", null })); + } + + [Test] + public void AddRange_Optimized_NullsProhibited_NullableValueType() + { + // We don't just trust that a collection with a nullable element type doesn't contain nulls + var list = new RepeatedField(); + // It's okay for this to throw ArgumentNullException if necessary. + // It's not ideal, but not awful. + Assert.Catch(() => list.AddRange(new List { 20, null })); + } + + [Test] + public void AddRange_AlreadyNotEmpty() + { + var list = new RepeatedField { 1, 2, 3 }; + list.AddRange(new List { 4, 5, 6 }); + CollectionAssert.AreEqual(new[] { 1, 2, 3, 4, 5, 6 }, list); + } + + [Test] + public void AddRange_RepeatedField() { var list = new RepeatedField { "original" }; - list.Add(new RepeatedField { "foo", "bar" }); + list.AddRange(new RepeatedField { "foo", "bar" }); Assert.AreEqual(3, list.Count); Assert.AreEqual("original", list[0]); Assert.AreEqual("foo", list[1]); @@ -656,5 +742,19 @@ public void ToString_Struct() var text = list.ToString(); Assert.AreEqual(text, "[ { \"foo\": 20 } ]", message.ToString()); } + + [Test] + public void NaNValuesComparedBitwise() + { + var list1 = new RepeatedField { SampleNaNs.Regular, SampleNaNs.SignallingFlipped }; + var list2 = new RepeatedField { SampleNaNs.Regular, SampleNaNs.PayloadFlipped }; + var list3 = new RepeatedField { SampleNaNs.Regular, SampleNaNs.SignallingFlipped }; + + // All SampleNaNs have the same hashcode under certain targets (e.g. netcoreapp2.1) + EqualityTester.AssertInequality(list1, list2, checkHashcode: false); + EqualityTester.AssertEquality(list1, list3); + Assert.True(list1.Contains(SampleNaNs.SignallingFlipped)); + Assert.False(list2.Contains(SampleNaNs.SignallingFlipped)); + } } } diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Compatibility/StreamExtensionsTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Compatibility/StreamExtensionsTest.cs new file mode 100644 index 000000000000..48c0725fa665 --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Compatibility/StreamExtensionsTest.cs @@ -0,0 +1,67 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +#if NET35 +using System; +using System.IO; +using NUnit.Framework; +using Google.Protobuf.Compatibility; + +namespace Google.Protobuf.Test.Compatibility +{ + public class StreamExtensionsTest + { + [Test] + public void CopyToNullArgument() + { + var memoryStream = new MemoryStream(); + Assert.Throws(() => memoryStream.CopyTo(null)); + } + + [Test] + public void CopyToTest() + { + byte[] bytesToStream = new byte[] { 0x31, 0x08, 0xFF, 0x00 }; + Stream source = new MemoryStream(bytesToStream); + Stream destination = new MemoryStream((int)source.Length); + source.CopyTo(destination); + destination.Seek(0, SeekOrigin.Begin); + + Assert.AreEqual(0x31, destination.ReadByte()); + Assert.AreEqual(0x08, destination.ReadByte()); + Assert.AreEqual(0xFF, destination.ReadByte()); + Assert.AreEqual(0x00, destination.ReadByte()); + Assert.AreEqual(-1, destination.ReadByte()); + } + } +} +#endif diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs index f0c8d3bcc6e3..5d86c20896e1 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs @@ -34,6 +34,7 @@ using System.Collections.Generic; using System.Reflection; +#if !NET35 namespace Google.Protobuf.Compatibility { public class TypeExtensionsTest @@ -50,24 +51,6 @@ private void PrivateMethod() { } - [Test] - [TestCase(typeof(int), true)] - [TestCase(typeof(int?), true)] - [TestCase(typeof(Nullable<>), true)] - [TestCase(typeof(WireFormat.WireType), true)] - [TestCase(typeof(string), false)] - [TestCase(typeof(object), false)] - [TestCase(typeof(Enum), false)] - [TestCase(typeof(ValueType), false)] - [TestCase(typeof(TypeExtensionsTest), false)] - [TestCase(typeof(Action), false)] - [TestCase(typeof(Action<>), false)] - [TestCase(typeof(IDisposable), false)] - public void IsValueType(Type type, bool expected) - { - Assert.AreEqual(expected, TypeExtensions.IsValueType(type)); - } - [Test] [TestCase(typeof(object), typeof(string), true)] [TestCase(typeof(object), typeof(int), true)] @@ -76,7 +59,7 @@ public void IsValueType(Type type, bool expected) [TestCase(typeof(string), typeof(int), false)] [TestCase(typeof(int), typeof(int), true)] [TestCase(typeof(ValueType), typeof(int), true)] - [TestCase(typeof(long), typeof(int), false)] // + [TestCase(typeof(long), typeof(int), false)] // public void IsAssignableFrom(Type target, Type argument, bool expected) { Assert.AreEqual(expected, TypeExtensions.IsAssignableFrom(target, argument)); @@ -131,3 +114,4 @@ public void GetMethod_Ambiguous(Type type, string name) } } } +#endif diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs index 8dfad8b331c1..34d5b9f98cbb 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs @@ -1,55 +1,55 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2015 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; -using System.Reflection; -using Google.Protobuf.TestProtos; -using NUnit.Framework; - -namespace Google.Protobuf -{ - public class DeprecatedMemberTest - { - private static void AssertIsDeprecated(MemberInfo member) - { - Assert.NotNull(member); - Assert.IsTrue(member.IsDefined(typeof(ObsoleteAttribute), false), "Member not obsolete: " + member); - } - - [Test] - public void TestDepreatedPrimitiveValue() - { - AssertIsDeprecated(typeof(TestDeprecatedFields).GetProperty("DeprecatedInt32")); - } - - } -} +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Reflection; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class DeprecatedMemberTest + { + private static void AssertIsDeprecated(MemberInfo member) + { + Assert.NotNull(member); + Assert.IsTrue(member.IsDefined(typeof(ObsoleteAttribute), false), "Member not obsolete: " + member); + } + + [Test] + public void TestDepreatedPrimitiveValue() + { + AssertIsDeprecated(typeof(TestDeprecatedFields).GetProperty("DeprecatedInt32")); + } + + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/EqualityTester.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/EqualityTester.cs index a669baba17bf..d4b3c1341ac6 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/EqualityTester.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/EqualityTester.cs @@ -49,13 +49,14 @@ public static void AssertEquality(T first, T second) where T : IEquatable Assert.AreEqual(first.GetHashCode(), second.GetHashCode()); } - public static void AssertInequality(T first, T second) where T : IEquatable + public static void AssertInequality(T first, T second, bool checkHashcode = true) where T : IEquatable { Assert.IsFalse(first.Equals(second)); Assert.IsFalse(first.Equals((object) second)); // While this isn't a requirement, the chances of this test failing due to // coincidence rather than a bug are very small. - if (first != null && second != null) + // For such rare cases, an argument can be used to disable the check. + if (checkHashcode && first != null && second != null) { Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode()); } diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs index c616470e81fc..b20ecccde2d0 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs @@ -32,6 +32,7 @@ using System.Collections.Generic; using System.IO; +using System.Reflection; using Google.Protobuf.TestProtos; using NUnit.Framework; @@ -42,7 +43,7 @@ public class FieldCodecTest #pragma warning disable 0414 // Used by tests via reflection - do not remove! private static readonly List Codecs = new List { - new FieldCodecTestData(FieldCodec.ForBool(100), true, "Bool"), + new FieldCodecTestData(FieldCodec.ForBool(100), true, "FixedBool"), new FieldCodecTestData(FieldCodec.ForString(100), "sample", "String"), new FieldCodecTestData(FieldCodec.ForBytes(100), ByteString.CopyFrom(1, 2, 3), "Bytes"), new FieldCodecTestData(FieldCodec.ForInt32(100), -1000, "Int32"), @@ -55,8 +56,8 @@ public class FieldCodecTest new FieldCodecTestData(FieldCodec.ForSFixed64(100), -1000, "SFixed64"), new FieldCodecTestData(FieldCodec.ForUInt64(100), 1234, "UInt64"), new FieldCodecTestData(FieldCodec.ForFixed64(100), 1234, "Fixed64"), - new FieldCodecTestData(FieldCodec.ForFloat(100), 1234.5f, "Float"), - new FieldCodecTestData(FieldCodec.ForDouble(100), 1234567890.5d, "Double"), + new FieldCodecTestData(FieldCodec.ForFloat(100), 1234.5f, "FixedFloat"), + new FieldCodecTestData(FieldCodec.ForDouble(100), 1234567890.5d, "FixedDouble"), new FieldCodecTestData( FieldCodec.ForEnum(100, t => (int) t, t => (ForeignEnum) t), ForeignEnum.ForeignBaz, "Enum"), new FieldCodecTestData( @@ -157,15 +158,18 @@ public void TestDefaultValue() { // WriteTagAndValue ignores default values var stream = new MemoryStream(); - var codedOutput = new CodedOutputStream(stream); + CodedOutputStream codedOutput; +#if !NET35 + codedOutput = new CodedOutputStream(stream); codec.WriteTagAndValue(codedOutput, codec.DefaultValue); codedOutput.Flush(); Assert.AreEqual(0, stream.Position); Assert.AreEqual(0, codec.CalculateSizeWithTag(codec.DefaultValue)); - if (typeof(T).IsValueType) + if (typeof(T).GetTypeInfo().IsValueType) { Assert.AreEqual(default(T), codec.DefaultValue); } +#endif // The plain ValueWriter/ValueReader delegates don't. if (codec.DefaultValue != null) // This part isn't appropriate for message types. diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/FieldMaskTreeTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/FieldMaskTreeTest.cs new file mode 100644 index 000000000000..f71744a8745a --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/FieldMaskTreeTest.cs @@ -0,0 +1,436 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System.Collections.Generic; +using Google.Protobuf.Collections; +using Google.Protobuf.TestProtos; +using NUnit.Framework; +using Google.Protobuf.WellKnownTypes; + +namespace Google.Protobuf +{ + public class FieldMaskTreeTest + { + [Test] + public void AddFieldPath() + { + FieldMaskTree tree = new FieldMaskTree(); + RepeatedField paths = tree.ToFieldMask().Paths; + Assert.AreEqual(0, paths.Count); + + tree.AddFieldPath(""); + paths = tree.ToFieldMask().Paths; + Assert.AreEqual(1, paths.Count); + Assert.Contains("", paths); + + // New branch. + tree.AddFieldPath("foo"); + paths = tree.ToFieldMask().Paths; + Assert.AreEqual(2, paths.Count); + Assert.Contains("foo", paths); + + // Redundant path. + tree.AddFieldPath("foo"); + paths = tree.ToFieldMask().Paths; + Assert.AreEqual(2, paths.Count); + + // New branch. + tree.AddFieldPath("bar.baz"); + paths = tree.ToFieldMask().Paths; + Assert.AreEqual(3, paths.Count); + Assert.Contains("bar.baz", paths); + + // Redundant sub-path. + tree.AddFieldPath("foo.bar"); + paths = tree.ToFieldMask().Paths; + Assert.AreEqual(3, paths.Count); + + // New branch from a non-root node. + tree.AddFieldPath("bar.quz"); + paths = tree.ToFieldMask().Paths; + Assert.AreEqual(4, paths.Count); + Assert.Contains("bar.quz", paths); + + // A path that matches several existing sub-paths. + tree.AddFieldPath("bar"); + paths = tree.ToFieldMask().Paths; + Assert.AreEqual(3, paths.Count); + Assert.Contains("foo", paths); + Assert.Contains("bar", paths); + } + + [Test] + public void MergeFromFieldMask() + { + FieldMaskTree tree = new FieldMaskTree(); + tree.MergeFromFieldMask(new FieldMask + { + Paths = {"foo", "bar.baz", "bar.quz"} + }); + RepeatedField paths = tree.ToFieldMask().Paths; + Assert.AreEqual(3, paths.Count); + Assert.Contains("foo", paths); + Assert.Contains("bar.baz", paths); + Assert.Contains("bar.quz", paths); + + tree.MergeFromFieldMask(new FieldMask + { + Paths = {"foo.bar", "bar"} + }); + paths = tree.ToFieldMask().Paths; + Assert.AreEqual(2, paths.Count); + Assert.Contains("foo", paths); + Assert.Contains("bar", paths); + } + + [Test] + public void IntersectFieldPath() + { + FieldMaskTree tree = new FieldMaskTree(); + FieldMaskTree result = new FieldMaskTree(); + tree.MergeFromFieldMask(new FieldMask + { + Paths = {"foo", "bar.baz", "bar.quz"} + }); + + // Empty path. + tree.IntersectFieldPath("", result); + RepeatedField paths = result.ToFieldMask().Paths; + Assert.AreEqual(0, paths.Count); + + // Non-exist path. + tree.IntersectFieldPath("quz", result); + paths = result.ToFieldMask().Paths; + Assert.AreEqual(0, paths.Count); + + // Sub-path of an existing leaf. + tree.IntersectFieldPath("foo.bar", result); + paths = result.ToFieldMask().Paths; + Assert.AreEqual(1, paths.Count); + Assert.Contains("foo.bar", paths); + + // Match an existing leaf node. + tree.IntersectFieldPath("foo", result); + paths = result.ToFieldMask().Paths; + Assert.AreEqual(1, paths.Count); + Assert.Contains("foo", paths); + + // Non-exist path. + tree.IntersectFieldPath("bar.foo", result); + paths = result.ToFieldMask().Paths; + Assert.AreEqual(1, paths.Count); + Assert.Contains("foo", paths); + + // Match a non-leaf node. + tree.IntersectFieldPath("bar", result); + paths = result.ToFieldMask().Paths; + Assert.AreEqual(3, paths.Count); + Assert.Contains("foo", paths); + Assert.Contains("bar.baz", paths); + Assert.Contains("bar.quz", paths); + } + + private void Merge(FieldMaskTree tree, IMessage source, IMessage destination, FieldMask.MergeOptions options, bool useDynamicMessage) + { + if (useDynamicMessage) + { + var newSource = source.Descriptor.Parser.CreateTemplate(); + newSource.MergeFrom(source.ToByteString()); + + var newDestination = source.Descriptor.Parser.CreateTemplate(); + newDestination.MergeFrom(destination.ToByteString()); + + tree.Merge(newSource, newDestination, options); + + // Clear before merging: + foreach (var fieldDescriptor in destination.Descriptor.Fields.InFieldNumberOrder()) + { + fieldDescriptor.Accessor.Clear(destination); + } + destination.MergeFrom(newDestination.ToByteString()); + } + else + { + tree.Merge(source, destination, options); + } + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Merge(bool useDynamicMessage) + { + TestAllTypes value = new TestAllTypes + { + SingleInt32 = 1234, + SingleNestedMessage = new TestAllTypes.Types.NestedMessage {Bb = 5678}, + RepeatedInt32 = {4321}, + RepeatedNestedMessage = {new TestAllTypes.Types.NestedMessage {Bb = 8765}} + }; + + NestedTestAllTypes source = new NestedTestAllTypes + { + Payload = value, + Child = new NestedTestAllTypes {Payload = value} + }; + // Now we have a message source with the following structure: + // [root] -+- payload -+- single_int32 + // | +- single_nested_message + // | +- repeated_int32 + // | +- repeated_nested_message + // | + // +- child --- payload -+- single_int32 + // +- single_nested_message + // +- repeated_int32 + // +- repeated_nested_message + + FieldMask.MergeOptions options = new FieldMask.MergeOptions(); + + // Test merging each individual field. + NestedTestAllTypes destination = new NestedTestAllTypes(); + Merge(new FieldMaskTree().AddFieldPath("payload.single_int32"), + source, destination, options, useDynamicMessage); + NestedTestAllTypes expected = new NestedTestAllTypes + { + Payload = new TestAllTypes + { + SingleInt32 = 1234 + } + }; + Assert.AreEqual(expected, destination); + + destination = new NestedTestAllTypes(); + Merge(new FieldMaskTree().AddFieldPath("payload.single_nested_message"), + source, destination, options, useDynamicMessage); + expected = new NestedTestAllTypes + { + Payload = new TestAllTypes + { + SingleNestedMessage = new TestAllTypes.Types.NestedMessage {Bb = 5678} + } + }; + Assert.AreEqual(expected, destination); + + destination = new NestedTestAllTypes(); + Merge(new FieldMaskTree().AddFieldPath("payload.repeated_int32"), + source, destination, options, useDynamicMessage); + expected = new NestedTestAllTypes + { + Payload = new TestAllTypes + { + RepeatedInt32 = {4321} + } + }; + Assert.AreEqual(expected, destination); + + destination = new NestedTestAllTypes(); + Merge(new FieldMaskTree().AddFieldPath("payload.repeated_nested_message"), + source, destination, options, useDynamicMessage); + expected = new NestedTestAllTypes + { + Payload = new TestAllTypes + { + RepeatedNestedMessage = {new TestAllTypes.Types.NestedMessage {Bb = 8765}} + } + }; + Assert.AreEqual(expected, destination); + + destination = new NestedTestAllTypes(); + Merge( + new FieldMaskTree().AddFieldPath("child.payload.single_int32"), + source, + destination, + options, + useDynamicMessage); + expected = new NestedTestAllTypes + { + Child = new NestedTestAllTypes + { + Payload = new TestAllTypes + { + SingleInt32 = 1234 + } + } + }; + Assert.AreEqual(expected, destination); + + destination = new NestedTestAllTypes(); + Merge( + new FieldMaskTree().AddFieldPath("child.payload.single_nested_message"), + source, + destination, + options, + useDynamicMessage); + expected = new NestedTestAllTypes + { + Child = new NestedTestAllTypes + { + Payload = new TestAllTypes + { + SingleNestedMessage = new TestAllTypes.Types.NestedMessage {Bb = 5678} + } + } + }; + Assert.AreEqual(expected, destination); + + destination = new NestedTestAllTypes(); + Merge(new FieldMaskTree().AddFieldPath("child.payload.repeated_int32"), + source, destination, options, useDynamicMessage); + expected = new NestedTestAllTypes + { + Child = new NestedTestAllTypes + { + Payload = new TestAllTypes + { + RepeatedInt32 = {4321} + } + } + }; + Assert.AreEqual(expected, destination); + + destination = new NestedTestAllTypes(); + Merge(new FieldMaskTree().AddFieldPath("child.payload.repeated_nested_message"), + source, destination, options, useDynamicMessage); + expected = new NestedTestAllTypes + { + Child = new NestedTestAllTypes + { + Payload = new TestAllTypes + { + RepeatedNestedMessage = {new TestAllTypes.Types.NestedMessage {Bb = 8765}} + } + } + }; + Assert.AreEqual(expected, destination); + + destination = new NestedTestAllTypes(); + Merge(new FieldMaskTree().AddFieldPath("child").AddFieldPath("payload"), + source, destination, options, useDynamicMessage); + Assert.AreEqual(source, destination); + + // Test repeated options. + destination = new NestedTestAllTypes + { + Payload = new TestAllTypes + { + RepeatedInt32 = { 1000 } + } + }; + Merge(new FieldMaskTree().AddFieldPath("payload.repeated_int32"), + source, destination, options, useDynamicMessage); + // Default behavior is to append repeated fields. + Assert.AreEqual(2, destination.Payload.RepeatedInt32.Count); + Assert.AreEqual(1000, destination.Payload.RepeatedInt32[0]); + Assert.AreEqual(4321, destination.Payload.RepeatedInt32[1]); + // Change to replace repeated fields. + options.ReplaceRepeatedFields = true; + Merge(new FieldMaskTree().AddFieldPath("payload.repeated_int32"), + source, destination, options, useDynamicMessage); + Assert.AreEqual(1, destination.Payload.RepeatedInt32.Count); + Assert.AreEqual(4321, destination.Payload.RepeatedInt32[0]); + + // Test message options. + destination = new NestedTestAllTypes + { + Payload = new TestAllTypes + { + SingleInt32 = 1000, + SingleUint32 = 2000 + } + }; + Merge(new FieldMaskTree().AddFieldPath("payload"), + source, destination, options, useDynamicMessage); + // Default behavior is to merge message fields. + Assert.AreEqual(1234, destination.Payload.SingleInt32); + Assert.AreEqual(2000, destination.Payload.SingleUint32); + + // Test merging unset message fields. + NestedTestAllTypes clearedSource = source.Clone(); + clearedSource.Payload = null; + destination = new NestedTestAllTypes(); + Merge(new FieldMaskTree().AddFieldPath("payload"), + clearedSource, destination, options, useDynamicMessage); + Assert.IsNull(destination.Payload); + + // Skip a message field if they are unset in both source and target. + destination = new NestedTestAllTypes(); + Merge(new FieldMaskTree().AddFieldPath("payload.single_int32"), + clearedSource, destination, options, useDynamicMessage); + Assert.IsNull(destination.Payload); + + // Change to replace message fields. + options.ReplaceMessageFields = true; + destination = new NestedTestAllTypes + { + Payload = new TestAllTypes + { + SingleInt32 = 1000, + SingleUint32 = 2000 + } + }; + Merge(new FieldMaskTree().AddFieldPath("payload"), + source, destination, options, useDynamicMessage); + Assert.AreEqual(1234, destination.Payload.SingleInt32); + Assert.AreEqual(0, destination.Payload.SingleUint32); + + // Test merging unset message fields. + destination = new NestedTestAllTypes + { + Payload = new TestAllTypes + { + SingleInt32 = 1000, + SingleUint32 = 2000 + } + }; + Merge(new FieldMaskTree().AddFieldPath("payload"), + clearedSource, destination, options, useDynamicMessage); + Assert.IsNull(destination.Payload); + + // Test merging unset primitive fields. + destination = source.Clone(); + destination.Payload.SingleInt32 = 0; + NestedTestAllTypes sourceWithPayloadInt32Unset = destination; + destination = source.Clone(); + Merge(new FieldMaskTree().AddFieldPath("payload.single_int32"), + sourceWithPayloadInt32Unset, destination, options, useDynamicMessage); + Assert.AreEqual(0, destination.Payload.SingleInt32); + + // Change to clear unset primitive fields. + options.ReplacePrimitiveFields = true; + destination = source.Clone(); + Merge(new FieldMaskTree().AddFieldPath("payload.single_int32"), + sourceWithPayloadInt32Unset, destination, options, useDynamicMessage); + Assert.IsNotNull(destination.Payload); + } + + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs index b029551c0b48..5694754e38b0 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs @@ -1,723 +1,736 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2015 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; -using System.IO; -using Google.Protobuf.TestProtos; -using NUnit.Framework; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using Google.Protobuf.WellKnownTypes; - -namespace Google.Protobuf -{ - /// - /// Tests around the generated TestAllTypes message. - /// - public class GeneratedMessageTest - { - [Test] - public void EmptyMessageFieldDistinctFromMissingMessageField() - { - // This demonstrates what we're really interested in... - var message1 = new TestAllTypes { SingleForeignMessage = new ForeignMessage() }; - var message2 = new TestAllTypes(); // SingleForeignMessage is null - EqualityTester.AssertInequality(message1, message2); - } - - [Test] - public void DefaultValues() - { - // Single fields - var message = new TestAllTypes(); - Assert.AreEqual(false, message.SingleBool); - Assert.AreEqual(ByteString.Empty, message.SingleBytes); - Assert.AreEqual(0.0, message.SingleDouble); - Assert.AreEqual(0, message.SingleFixed32); - Assert.AreEqual(0L, message.SingleFixed64); - Assert.AreEqual(0.0f, message.SingleFloat); - Assert.AreEqual(ForeignEnum.ForeignUnspecified, message.SingleForeignEnum); - Assert.IsNull(message.SingleForeignMessage); - Assert.AreEqual(ImportEnum.Unspecified, message.SingleImportEnum); - Assert.IsNull(message.SingleImportMessage); - Assert.AreEqual(0, message.SingleInt32); - Assert.AreEqual(0L, message.SingleInt64); - Assert.AreEqual(TestAllTypes.Types.NestedEnum.Unspecified, message.SingleNestedEnum); - Assert.IsNull(message.SingleNestedMessage); - Assert.IsNull(message.SinglePublicImportMessage); - Assert.AreEqual(0, message.SingleSfixed32); - Assert.AreEqual(0L, message.SingleSfixed64); - Assert.AreEqual(0, message.SingleSint32); - Assert.AreEqual(0L, message.SingleSint64); - Assert.AreEqual("", message.SingleString); - Assert.AreEqual(0U, message.SingleUint32); - Assert.AreEqual(0UL, message.SingleUint64); - - // Repeated fields - Assert.AreEqual(0, message.RepeatedBool.Count); - Assert.AreEqual(0, message.RepeatedBytes.Count); - Assert.AreEqual(0, message.RepeatedDouble.Count); - Assert.AreEqual(0, message.RepeatedFixed32.Count); - Assert.AreEqual(0, message.RepeatedFixed64.Count); - Assert.AreEqual(0, message.RepeatedFloat.Count); - Assert.AreEqual(0, message.RepeatedForeignEnum.Count); - Assert.AreEqual(0, message.RepeatedForeignMessage.Count); - Assert.AreEqual(0, message.RepeatedImportEnum.Count); - Assert.AreEqual(0, message.RepeatedImportMessage.Count); - Assert.AreEqual(0, message.RepeatedNestedEnum.Count); - Assert.AreEqual(0, message.RepeatedNestedMessage.Count); - Assert.AreEqual(0, message.RepeatedPublicImportMessage.Count); - Assert.AreEqual(0, message.RepeatedSfixed32.Count); - Assert.AreEqual(0, message.RepeatedSfixed64.Count); - Assert.AreEqual(0, message.RepeatedSint32.Count); - Assert.AreEqual(0, message.RepeatedSint64.Count); - Assert.AreEqual(0, message.RepeatedString.Count); - Assert.AreEqual(0, message.RepeatedUint32.Count); - Assert.AreEqual(0, message.RepeatedUint64.Count); - - // Oneof fields - Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); - Assert.AreEqual(0, message.OneofUint32); - Assert.AreEqual("", message.OneofString); - Assert.AreEqual(ByteString.Empty, message.OneofBytes); - Assert.IsNull(message.OneofNestedMessage); - } - - [Test] - public void NullStringAndBytesRejected() - { - var message = new TestAllTypes(); - Assert.Throws(() => message.SingleString = null); - Assert.Throws(() => message.OneofString = null); - Assert.Throws(() => message.SingleBytes = null); - Assert.Throws(() => message.OneofBytes = null); - } - - [Test] - public void RoundTrip_Empty() - { - var message = new TestAllTypes(); - // Without setting any values, there's nothing to write. - byte[] bytes = message.ToByteArray(); - Assert.AreEqual(0, bytes.Length); - TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes); - Assert.AreEqual(message, parsed); - } - - [Test] - public void RoundTrip_SingleValues() - { - var message = new TestAllTypes - { - SingleBool = true, - SingleBytes = ByteString.CopyFrom(1, 2, 3, 4), - SingleDouble = 23.5, - SingleFixed32 = 23, - SingleFixed64 = 1234567890123, - SingleFloat = 12.25f, - SingleForeignEnum = ForeignEnum.ForeignBar, - SingleForeignMessage = new ForeignMessage { C = 10 }, - SingleImportEnum = ImportEnum.ImportBaz, - SingleImportMessage = new ImportMessage { D = 20 }, - SingleInt32 = 100, - SingleInt64 = 3210987654321, - SingleNestedEnum = TestAllTypes.Types.NestedEnum.Foo, - SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 }, - SinglePublicImportMessage = new PublicImportMessage { E = 54 }, - SingleSfixed32 = -123, - SingleSfixed64 = -12345678901234, - SingleSint32 = -456, - SingleSint64 = -12345678901235, - SingleString = "test", - SingleUint32 = uint.MaxValue, - SingleUint64 = ulong.MaxValue - }; - - byte[] bytes = message.ToByteArray(); - TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes); - Assert.AreEqual(message, parsed); - } - - [Test] - public void RoundTrip_RepeatedValues() - { - var message = new TestAllTypes - { - RepeatedBool = { true, false }, - RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6) }, - RepeatedDouble = { -12.25, 23.5 }, - RepeatedFixed32 = { uint.MaxValue, 23 }, - RepeatedFixed64 = { ulong.MaxValue, 1234567890123 }, - RepeatedFloat = { 100f, 12.25f }, - RepeatedForeignEnum = { ForeignEnum.ForeignFoo, ForeignEnum.ForeignBar }, - RepeatedForeignMessage = { new ForeignMessage(), new ForeignMessage { C = 10 } }, - RepeatedImportEnum = { ImportEnum.ImportBaz, ImportEnum.Unspecified }, - RepeatedImportMessage = { new ImportMessage { D = 20 }, new ImportMessage { D = 25 } }, - RepeatedInt32 = { 100, 200 }, - RepeatedInt64 = { 3210987654321, long.MaxValue }, - RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.Foo, TestAllTypes.Types.NestedEnum.Neg }, - RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 35 }, new TestAllTypes.Types.NestedMessage { Bb = 10 } }, - RepeatedPublicImportMessage = { new PublicImportMessage { E = 54 }, new PublicImportMessage { E = -1 } }, - RepeatedSfixed32 = { -123, 123 }, - RepeatedSfixed64 = { -12345678901234, 12345678901234 }, - RepeatedSint32 = { -456, 100 }, - RepeatedSint64 = { -12345678901235, 123 }, - RepeatedString = { "foo", "bar" }, - RepeatedUint32 = { uint.MaxValue, uint.MinValue }, - RepeatedUint64 = { ulong.MaxValue, uint.MinValue } - }; - - byte[] bytes = message.ToByteArray(); - TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes); - Assert.AreEqual(message, parsed); - } - - // Note that not every map within map_unittest_proto3 is used. They all go through very - // similar code paths. The fact that all maps are present is validation that we have codecs - // for every type. - [Test] - public void RoundTrip_Maps() - { - var message = new TestMap - { - MapBoolBool = { - { false, true }, - { true, false } - }, - MapInt32Bytes = { - { 5, ByteString.CopyFrom(6, 7, 8) }, - { 25, ByteString.CopyFrom(1, 2, 3, 4, 5) }, - { 10, ByteString.Empty } - }, - MapInt32ForeignMessage = { - { 0, new ForeignMessage { C = 10 } }, - { 5, new ForeignMessage() }, - }, - MapInt32Enum = { - { 1, MapEnum.Bar }, - { 2000, MapEnum.Foo } - } - }; - - byte[] bytes = message.ToByteArray(); - TestMap parsed = TestMap.Parser.ParseFrom(bytes); - Assert.AreEqual(message, parsed); - } - - [Test] - public void MapWithEmptyEntry() - { - var message = new TestMap - { - MapInt32Bytes = { { 0, ByteString.Empty } } - }; - - byte[] bytes = message.ToByteArray(); - Assert.AreEqual(2, bytes.Length); // Tag for field entry (1 byte), length of entry (0; 1 byte) - - var parsed = TestMap.Parser.ParseFrom(bytes); - Assert.AreEqual(1, parsed.MapInt32Bytes.Count); - Assert.AreEqual(ByteString.Empty, parsed.MapInt32Bytes[0]); - } - - [Test] - public void MapWithOnlyValue() - { - // Hand-craft the stream to contain a single entry with just a value. - var memoryStream = new MemoryStream(); - var output = new CodedOutputStream(memoryStream); - output.WriteTag(TestMap.MapInt32ForeignMessageFieldNumber, WireFormat.WireType.LengthDelimited); - var nestedMessage = new ForeignMessage { C = 20 }; - // Size of the entry (tag, size written by WriteMessage, data written by WriteMessage) - output.WriteLength(2 + nestedMessage.CalculateSize()); - output.WriteTag(2, WireFormat.WireType.LengthDelimited); - output.WriteMessage(nestedMessage); - output.Flush(); - - var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); - Assert.AreEqual(nestedMessage, parsed.MapInt32ForeignMessage[0]); - } - - [Test] - public void MapWithOnlyKey_PrimitiveValue() - { - // Hand-craft the stream to contain a single entry with just a key. - var memoryStream = new MemoryStream(); - var output = new CodedOutputStream(memoryStream); - output.WriteTag(TestMap.MapInt32DoubleFieldNumber, WireFormat.WireType.LengthDelimited); - int key = 10; - output.WriteLength(1 + CodedOutputStream.ComputeInt32Size(key)); - output.WriteTag(1, WireFormat.WireType.Varint); - output.WriteInt32(key); - output.Flush(); - - var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); - Assert.AreEqual(0.0, parsed.MapInt32Double[key]); - } - - [Test] - public void MapWithOnlyKey_MessageValue() - { - // Hand-craft the stream to contain a single entry with just a key. - var memoryStream = new MemoryStream(); - var output = new CodedOutputStream(memoryStream); - output.WriteTag(TestMap.MapInt32ForeignMessageFieldNumber, WireFormat.WireType.LengthDelimited); - int key = 10; - output.WriteLength(1 + CodedOutputStream.ComputeInt32Size(key)); - output.WriteTag(1, WireFormat.WireType.Varint); - output.WriteInt32(key); - output.Flush(); - - var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); - Assert.AreEqual(new ForeignMessage(), parsed.MapInt32ForeignMessage[key]); - } - - [Test] - public void MapIgnoresExtraFieldsWithinEntryMessages() - { - // Hand-craft the stream to contain a single entry with three fields - var memoryStream = new MemoryStream(); - var output = new CodedOutputStream(memoryStream); - - output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); - - var key = 10; // Field 1 - var value = 20; // Field 2 - var extra = 30; // Field 3 - - // Each field can be represented in a single byte, with a single byte tag. - // Total message size: 6 bytes. - output.WriteLength(6); - output.WriteTag(1, WireFormat.WireType.Varint); - output.WriteInt32(key); - output.WriteTag(2, WireFormat.WireType.Varint); - output.WriteInt32(value); - output.WriteTag(3, WireFormat.WireType.Varint); - output.WriteInt32(extra); - output.Flush(); - - var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); - Assert.AreEqual(value, parsed.MapInt32Int32[key]); - } - - [Test] - public void MapFieldOrderIsIrrelevant() - { - var memoryStream = new MemoryStream(); - var output = new CodedOutputStream(memoryStream); - - output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); - - var key = 10; - var value = 20; - - // Each field can be represented in a single byte, with a single byte tag. - // Total message size: 4 bytes. - output.WriteLength(4); - output.WriteTag(2, WireFormat.WireType.Varint); - output.WriteInt32(value); - output.WriteTag(1, WireFormat.WireType.Varint); - output.WriteInt32(key); - output.Flush(); - - var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); - Assert.AreEqual(value, parsed.MapInt32Int32[key]); - } - - [Test] - public void MapNonContiguousEntries() - { - var memoryStream = new MemoryStream(); - var output = new CodedOutputStream(memoryStream); - - // Message structure: - // Entry for MapInt32Int32 - // Entry for MapStringString - // Entry for MapInt32Int32 - - // First entry - var key1 = 10; - var value1 = 20; - output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); - output.WriteLength(4); - output.WriteTag(1, WireFormat.WireType.Varint); - output.WriteInt32(key1); - output.WriteTag(2, WireFormat.WireType.Varint); - output.WriteInt32(value1); - - // Second entry - var key2 = "a"; - var value2 = "b"; - output.WriteTag(TestMap.MapStringStringFieldNumber, WireFormat.WireType.LengthDelimited); - output.WriteLength(6); // 3 bytes per entry: tag, size, character - output.WriteTag(1, WireFormat.WireType.LengthDelimited); - output.WriteString(key2); - output.WriteTag(2, WireFormat.WireType.LengthDelimited); - output.WriteString(value2); - - // Third entry - var key3 = 15; - var value3 = 25; - output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); - output.WriteLength(4); - output.WriteTag(1, WireFormat.WireType.Varint); - output.WriteInt32(key3); - output.WriteTag(2, WireFormat.WireType.Varint); - output.WriteInt32(value3); - - output.Flush(); - var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); - var expected = new TestMap - { - MapInt32Int32 = { { key1, value1 }, { key3, value3 } }, - MapStringString = { { key2, value2 } } - }; - Assert.AreEqual(expected, parsed); - } - - [Test] - public void DuplicateKeys_LastEntryWins() - { - var memoryStream = new MemoryStream(); - var output = new CodedOutputStream(memoryStream); - - var key = 10; - var value1 = 20; - var value2 = 30; - - // First entry - output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); - output.WriteLength(4); - output.WriteTag(1, WireFormat.WireType.Varint); - output.WriteInt32(key); - output.WriteTag(2, WireFormat.WireType.Varint); - output.WriteInt32(value1); - - // Second entry - same key, different value - output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); - output.WriteLength(4); - output.WriteTag(1, WireFormat.WireType.Varint); - output.WriteInt32(key); - output.WriteTag(2, WireFormat.WireType.Varint); - output.WriteInt32(value2); - output.Flush(); - - var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); - Assert.AreEqual(value2, parsed.MapInt32Int32[key]); - } - - [Test] - public void CloneSingleNonMessageValues() - { - var original = new TestAllTypes - { - SingleBool = true, - SingleBytes = ByteString.CopyFrom(1, 2, 3, 4), - SingleDouble = 23.5, - SingleFixed32 = 23, - SingleFixed64 = 1234567890123, - SingleFloat = 12.25f, - SingleInt32 = 100, - SingleInt64 = 3210987654321, - SingleNestedEnum = TestAllTypes.Types.NestedEnum.Foo, - SingleSfixed32 = -123, - SingleSfixed64 = -12345678901234, - SingleSint32 = -456, - SingleSint64 = -12345678901235, - SingleString = "test", - SingleUint32 = uint.MaxValue, - SingleUint64 = ulong.MaxValue - }; - var clone = original.Clone(); - Assert.AreNotSame(original, clone); - Assert.AreEqual(original, clone); - // Just as a single example - clone.SingleInt32 = 150; - Assert.AreNotEqual(original, clone); - } - - [Test] - public void CloneRepeatedNonMessageValues() - { - var original = new TestAllTypes - { - RepeatedBool = { true, false }, - RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6) }, - RepeatedDouble = { -12.25, 23.5 }, - RepeatedFixed32 = { uint.MaxValue, 23 }, - RepeatedFixed64 = { ulong.MaxValue, 1234567890123 }, - RepeatedFloat = { 100f, 12.25f }, - RepeatedInt32 = { 100, 200 }, - RepeatedInt64 = { 3210987654321, long.MaxValue }, - RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.Foo, TestAllTypes.Types.NestedEnum.Neg }, - RepeatedSfixed32 = { -123, 123 }, - RepeatedSfixed64 = { -12345678901234, 12345678901234 }, - RepeatedSint32 = { -456, 100 }, - RepeatedSint64 = { -12345678901235, 123 }, - RepeatedString = { "foo", "bar" }, - RepeatedUint32 = { uint.MaxValue, uint.MinValue }, - RepeatedUint64 = { ulong.MaxValue, uint.MinValue } - }; - - var clone = original.Clone(); - Assert.AreNotSame(original, clone); - Assert.AreEqual(original, clone); - // Just as a single example - clone.RepeatedDouble.Add(25.5); - Assert.AreNotEqual(original, clone); - } - - [Test] - public void CloneSingleMessageField() - { - var original = new TestAllTypes - { - SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 } - }; - - var clone = original.Clone(); - Assert.AreNotSame(original, clone); - Assert.AreNotSame(original.SingleNestedMessage, clone.SingleNestedMessage); - Assert.AreEqual(original, clone); - - clone.SingleNestedMessage.Bb = 30; - Assert.AreNotEqual(original, clone); - } - - [Test] - public void CloneRepeatedMessageField() - { - var original = new TestAllTypes - { - RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 20 } } - }; - - var clone = original.Clone(); - Assert.AreNotSame(original, clone); - Assert.AreNotSame(original.RepeatedNestedMessage, clone.RepeatedNestedMessage); - Assert.AreNotSame(original.RepeatedNestedMessage[0], clone.RepeatedNestedMessage[0]); - Assert.AreEqual(original, clone); - - clone.RepeatedNestedMessage[0].Bb = 30; - Assert.AreNotEqual(original, clone); - } - - [Test] - public void CloneOneofField() - { - var original = new TestAllTypes - { - OneofNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 } - }; - - var clone = original.Clone(); - Assert.AreNotSame(original, clone); - Assert.AreEqual(original, clone); - - // We should have cloned the message - original.OneofNestedMessage.Bb = 30; - Assert.AreNotEqual(original, clone); - } - - [Test] - public void OneofProperties() - { - // Switch the oneof case between each of the different options, and check everything behaves - // as expected in each case. - var message = new TestAllTypes(); - Assert.AreEqual("", message.OneofString); - Assert.AreEqual(0, message.OneofUint32); - Assert.AreEqual(ByteString.Empty, message.OneofBytes); - Assert.IsNull(message.OneofNestedMessage); - Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); - - message.OneofString = "sample"; - Assert.AreEqual("sample", message.OneofString); - Assert.AreEqual(0, message.OneofUint32); - Assert.AreEqual(ByteString.Empty, message.OneofBytes); - Assert.IsNull(message.OneofNestedMessage); - Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofString, message.OneofFieldCase); - - var bytes = ByteString.CopyFrom(1, 2, 3); - message.OneofBytes = bytes; - Assert.AreEqual("", message.OneofString); - Assert.AreEqual(0, message.OneofUint32); - Assert.AreEqual(bytes, message.OneofBytes); - Assert.IsNull(message.OneofNestedMessage); - Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofBytes, message.OneofFieldCase); - - message.OneofUint32 = 20; - Assert.AreEqual("", message.OneofString); - Assert.AreEqual(20, message.OneofUint32); - Assert.AreEqual(ByteString.Empty, message.OneofBytes); - Assert.IsNull(message.OneofNestedMessage); - Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message.OneofFieldCase); - - var nestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 25 }; - message.OneofNestedMessage = nestedMessage; - Assert.AreEqual("", message.OneofString); - Assert.AreEqual(0, message.OneofUint32); - Assert.AreEqual(ByteString.Empty, message.OneofBytes); - Assert.AreEqual(nestedMessage, message.OneofNestedMessage); - Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofNestedMessage, message.OneofFieldCase); - - message.ClearOneofField(); - Assert.AreEqual("", message.OneofString); - Assert.AreEqual(0, message.OneofUint32); - Assert.AreEqual(ByteString.Empty, message.OneofBytes); - Assert.IsNull(message.OneofNestedMessage); - Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); - } - - [Test] - public void Oneof_DefaultValuesNotEqual() - { - var message1 = new TestAllTypes { OneofString = "" }; - var message2 = new TestAllTypes { OneofUint32 = 0 }; - Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofString, message1.OneofFieldCase); - Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase); - Assert.AreNotEqual(message1, message2); - } - - [Test] - public void OneofSerialization_NonDefaultValue() - { - var message = new TestAllTypes(); - message.OneofString = "this would take a bit of space"; - message.OneofUint32 = 10; - var bytes = message.ToByteArray(); - Assert.AreEqual(3, bytes.Length); // 2 bytes for the tag + 1 for the value - no string! - - var message2 = TestAllTypes.Parser.ParseFrom(bytes); - Assert.AreEqual(message, message2); - Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase); - } - - [Test] - public void OneofSerialization_DefaultValue() - { - var message = new TestAllTypes(); - message.OneofString = "this would take a bit of space"; - message.OneofUint32 = 0; // This is the default value for UInt32; normally wouldn't be serialized - var bytes = message.ToByteArray(); - Assert.AreEqual(3, bytes.Length); // 2 bytes for the tag + 1 for the value - it's still serialized - - var message2 = TestAllTypes.Parser.ParseFrom(bytes); - Assert.AreEqual(message, message2); - Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase); - } - - [Test] - public void IgnoreUnknownFields_RealDataStillRead() - { - var message = SampleMessages.CreateFullTestAllTypes(); - var stream = new MemoryStream(); - var output = new CodedOutputStream(stream); - var unusedFieldNumber = 23456; - Assert.IsFalse(TestAllTypes.Descriptor.Fields.InDeclarationOrder().Select(x => x.FieldNumber).Contains(unusedFieldNumber)); - output.WriteTag(unusedFieldNumber, WireFormat.WireType.LengthDelimited); - output.WriteString("ignore me"); - message.WriteTo(output); - output.Flush(); - - stream.Position = 0; - var parsed = TestAllTypes.Parser.ParseFrom(stream); - Assert.AreEqual(message, parsed); - } - - [Test] - public void IgnoreUnknownFields_AllTypes() - { - // Simple way of ensuring we can skip all kinds of fields. - var data = SampleMessages.CreateFullTestAllTypes().ToByteArray(); - var empty = Empty.Parser.ParseFrom(data); - Assert.AreEqual(new Empty(), empty); - } - - // This was originally seen as a conformance test failure. - [Test] - public void TruncatedMessageFieldThrows() - { - // 130, 3 is the message tag - // 1 is the data length - but there's no data. - var data = new byte[] { 130, 3, 1 }; - Assert.Throws(() => TestAllTypes.Parser.ParseFrom(data)); - } - - /// - /// Demonstrates current behaviour with an extraneous end group tag - see issue 688 - /// for details; we may want to change this. - /// - [Test] - public void ExtraEndGroupThrows() - { - var message = SampleMessages.CreateFullTestAllTypes(); - var stream = new MemoryStream(); - var output = new CodedOutputStream(stream); - - output.WriteTag(TestAllTypes.SingleFixed32FieldNumber, WireFormat.WireType.Fixed32); - output.WriteFixed32(123); - output.WriteTag(100, WireFormat.WireType.EndGroup); - - output.Flush(); - - stream.Position = 0; - Assert.Throws(() => TestAllTypes.Parser.ParseFrom(stream)); - } - - [Test] - public void CustomDiagnosticMessage_DirectToStringCall() - { - var message = new ForeignMessage { C = 31 }; - Assert.AreEqual("{ \"c\": 31, \"@cInHex\": \"1f\" }", message.ToString()); - Assert.AreEqual("{ \"c\": 31 }", JsonFormatter.Default.Format(message)); - } - - [Test] - public void CustomDiagnosticMessage_Nested() - { - var message = new TestAllTypes { SingleForeignMessage = new ForeignMessage { C = 16 } }; - Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16, \"@cInHex\": \"10\" } }", message.ToString()); - Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16 } }", JsonFormatter.Default.Format(message)); - } - - [Test] - public void CustomDiagnosticMessage_DirectToTextWriterCall() - { - var message = new ForeignMessage { C = 31 }; - var writer = new StringWriter(); - JsonFormatter.Default.Format(message, writer); - Assert.AreEqual("{ \"c\": 31 }", writer.ToString()); - } - } +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.IO; +using Google.Protobuf.TestProtos; +using NUnit.Framework; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using Google.Protobuf.WellKnownTypes; + +namespace Google.Protobuf +{ + /// + /// Tests around the generated TestAllTypes message. + /// + public class GeneratedMessageTest + { + [Test] + public void EmptyMessageFieldDistinctFromMissingMessageField() + { + // This demonstrates what we're really interested in... + var message1 = new TestAllTypes { SingleForeignMessage = new ForeignMessage() }; + var message2 = new TestAllTypes(); // SingleForeignMessage is null + EqualityTester.AssertInequality(message1, message2); + } + + [Test] + public void DefaultValues() + { + // Single fields + var message = new TestAllTypes(); + Assert.AreEqual(false, message.SingleBool); + Assert.AreEqual(ByteString.Empty, message.SingleBytes); + Assert.AreEqual(0.0, message.SingleDouble); + Assert.AreEqual(0, message.SingleFixed32); + Assert.AreEqual(0L, message.SingleFixed64); + Assert.AreEqual(0.0f, message.SingleFloat); + Assert.AreEqual(ForeignEnum.ForeignUnspecified, message.SingleForeignEnum); + Assert.IsNull(message.SingleForeignMessage); + Assert.AreEqual(ImportEnum.Unspecified, message.SingleImportEnum); + Assert.IsNull(message.SingleImportMessage); + Assert.AreEqual(0, message.SingleInt32); + Assert.AreEqual(0L, message.SingleInt64); + Assert.AreEqual(TestAllTypes.Types.NestedEnum.Unspecified, message.SingleNestedEnum); + Assert.IsNull(message.SingleNestedMessage); + Assert.IsNull(message.SinglePublicImportMessage); + Assert.AreEqual(0, message.SingleSfixed32); + Assert.AreEqual(0L, message.SingleSfixed64); + Assert.AreEqual(0, message.SingleSint32); + Assert.AreEqual(0L, message.SingleSint64); + Assert.AreEqual("", message.SingleString); + Assert.AreEqual(0U, message.SingleUint32); + Assert.AreEqual(0UL, message.SingleUint64); + + // Repeated fields + Assert.AreEqual(0, message.RepeatedBool.Count); + Assert.AreEqual(0, message.RepeatedBytes.Count); + Assert.AreEqual(0, message.RepeatedDouble.Count); + Assert.AreEqual(0, message.RepeatedFixed32.Count); + Assert.AreEqual(0, message.RepeatedFixed64.Count); + Assert.AreEqual(0, message.RepeatedFloat.Count); + Assert.AreEqual(0, message.RepeatedForeignEnum.Count); + Assert.AreEqual(0, message.RepeatedForeignMessage.Count); + Assert.AreEqual(0, message.RepeatedImportEnum.Count); + Assert.AreEqual(0, message.RepeatedImportMessage.Count); + Assert.AreEqual(0, message.RepeatedNestedEnum.Count); + Assert.AreEqual(0, message.RepeatedNestedMessage.Count); + Assert.AreEqual(0, message.RepeatedPublicImportMessage.Count); + Assert.AreEqual(0, message.RepeatedSfixed32.Count); + Assert.AreEqual(0, message.RepeatedSfixed64.Count); + Assert.AreEqual(0, message.RepeatedSint32.Count); + Assert.AreEqual(0, message.RepeatedSint64.Count); + Assert.AreEqual(0, message.RepeatedString.Count); + Assert.AreEqual(0, message.RepeatedUint32.Count); + Assert.AreEqual(0, message.RepeatedUint64.Count); + + // Oneof fields + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + } + + [Test] + public void NullStringAndBytesRejected() + { + var message = new TestAllTypes(); + Assert.Throws(() => message.SingleString = null); + Assert.Throws(() => message.OneofString = null); + Assert.Throws(() => message.SingleBytes = null); + Assert.Throws(() => message.OneofBytes = null); + } + + [Test] + public void RoundTrip_Empty() + { + var message = new TestAllTypes(); + // Without setting any values, there's nothing to write. + byte[] bytes = message.ToByteArray(); + Assert.AreEqual(0, bytes.Length); + TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes); + Assert.AreEqual(message, parsed); + } + + [Test] + public void RoundTrip_SingleValues() + { + var message = new TestAllTypes + { + SingleBool = true, + SingleBytes = ByteString.CopyFrom(1, 2, 3, 4), + SingleDouble = 23.5, + SingleFixed32 = 23, + SingleFixed64 = 1234567890123, + SingleFloat = 12.25f, + SingleForeignEnum = ForeignEnum.ForeignBar, + SingleForeignMessage = new ForeignMessage { C = 10 }, + SingleImportEnum = ImportEnum.ImportBaz, + SingleImportMessage = new ImportMessage { D = 20 }, + SingleInt32 = 100, + SingleInt64 = 3210987654321, + SingleNestedEnum = TestAllTypes.Types.NestedEnum.Foo, + SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 }, + SinglePublicImportMessage = new PublicImportMessage { E = 54 }, + SingleSfixed32 = -123, + SingleSfixed64 = -12345678901234, + SingleSint32 = -456, + SingleSint64 = -12345678901235, + SingleString = "test", + SingleUint32 = uint.MaxValue, + SingleUint64 = ulong.MaxValue + }; + + byte[] bytes = message.ToByteArray(); + TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes); + Assert.AreEqual(message, parsed); + } + + [Test] + public void RoundTrip_RepeatedValues() + { + var message = new TestAllTypes + { + RepeatedBool = { true, false }, + RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6) }, + RepeatedDouble = { -12.25, 23.5 }, + RepeatedFixed32 = { uint.MaxValue, 23 }, + RepeatedFixed64 = { ulong.MaxValue, 1234567890123 }, + RepeatedFloat = { 100f, 12.25f }, + RepeatedForeignEnum = { ForeignEnum.ForeignFoo, ForeignEnum.ForeignBar }, + RepeatedForeignMessage = { new ForeignMessage(), new ForeignMessage { C = 10 } }, + RepeatedImportEnum = { ImportEnum.ImportBaz, ImportEnum.Unspecified }, + RepeatedImportMessage = { new ImportMessage { D = 20 }, new ImportMessage { D = 25 } }, + RepeatedInt32 = { 100, 200 }, + RepeatedInt64 = { 3210987654321, long.MaxValue }, + RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.Foo, TestAllTypes.Types.NestedEnum.Neg }, + RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 35 }, new TestAllTypes.Types.NestedMessage { Bb = 10 } }, + RepeatedPublicImportMessage = { new PublicImportMessage { E = 54 }, new PublicImportMessage { E = -1 } }, + RepeatedSfixed32 = { -123, 123 }, + RepeatedSfixed64 = { -12345678901234, 12345678901234 }, + RepeatedSint32 = { -456, 100 }, + RepeatedSint64 = { -12345678901235, 123 }, + RepeatedString = { "foo", "bar" }, + RepeatedUint32 = { uint.MaxValue, uint.MinValue }, + RepeatedUint64 = { ulong.MaxValue, uint.MinValue } + }; + + byte[] bytes = message.ToByteArray(); + TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes); + Assert.AreEqual(message, parsed); + } + + // Note that not every map within map_unittest_proto3 is used. They all go through very + // similar code paths. The fact that all maps are present is validation that we have codecs + // for every type. + [Test] + public void RoundTrip_Maps() + { + var message = new TestMap + { + MapBoolBool = { + { false, true }, + { true, false } + }, + MapInt32Bytes = { + { 5, ByteString.CopyFrom(6, 7, 8) }, + { 25, ByteString.CopyFrom(1, 2, 3, 4, 5) }, + { 10, ByteString.Empty } + }, + MapInt32ForeignMessage = { + { 0, new ForeignMessage { C = 10 } }, + { 5, new ForeignMessage() }, + }, + MapInt32Enum = { + { 1, MapEnum.Bar }, + { 2000, MapEnum.Foo } + } + }; + + byte[] bytes = message.ToByteArray(); + TestMap parsed = TestMap.Parser.ParseFrom(bytes); + Assert.AreEqual(message, parsed); + } + + [Test] + public void MapWithEmptyEntry() + { + var message = new TestMap + { + MapInt32Bytes = { { 0, ByteString.Empty } } + }; + + byte[] bytes = message.ToByteArray(); + Assert.AreEqual(2, bytes.Length); // Tag for field entry (1 byte), length of entry (0; 1 byte) + + var parsed = TestMap.Parser.ParseFrom(bytes); + Assert.AreEqual(1, parsed.MapInt32Bytes.Count); + Assert.AreEqual(ByteString.Empty, parsed.MapInt32Bytes[0]); + } + + [Test] + public void MapWithOnlyValue() + { + // Hand-craft the stream to contain a single entry with just a value. + var memoryStream = new MemoryStream(); + var output = new CodedOutputStream(memoryStream); + output.WriteTag(TestMap.MapInt32ForeignMessageFieldNumber, WireFormat.WireType.LengthDelimited); + var nestedMessage = new ForeignMessage { C = 20 }; + // Size of the entry (tag, size written by WriteMessage, data written by WriteMessage) + output.WriteLength(2 + nestedMessage.CalculateSize()); + output.WriteTag(2, WireFormat.WireType.LengthDelimited); + output.WriteMessage(nestedMessage); + output.Flush(); + + var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); + Assert.AreEqual(nestedMessage, parsed.MapInt32ForeignMessage[0]); + } + + [Test] + public void MapWithOnlyKey_PrimitiveValue() + { + // Hand-craft the stream to contain a single entry with just a key. + var memoryStream = new MemoryStream(); + var output = new CodedOutputStream(memoryStream); + output.WriteTag(TestMap.MapInt32DoubleFieldNumber, WireFormat.WireType.LengthDelimited); + int key = 10; + output.WriteLength(1 + CodedOutputStream.ComputeInt32Size(key)); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key); + output.Flush(); + + var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); + Assert.AreEqual(0.0, parsed.MapInt32Double[key]); + } + + [Test] + public void MapWithOnlyKey_MessageValue() + { + // Hand-craft the stream to contain a single entry with just a key. + var memoryStream = new MemoryStream(); + var output = new CodedOutputStream(memoryStream); + output.WriteTag(TestMap.MapInt32ForeignMessageFieldNumber, WireFormat.WireType.LengthDelimited); + int key = 10; + output.WriteLength(1 + CodedOutputStream.ComputeInt32Size(key)); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key); + output.Flush(); + + var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); + Assert.AreEqual(new ForeignMessage(), parsed.MapInt32ForeignMessage[key]); + } + + [Test] + public void MapIgnoresExtraFieldsWithinEntryMessages() + { + // Hand-craft the stream to contain a single entry with three fields + var memoryStream = new MemoryStream(); + var output = new CodedOutputStream(memoryStream); + + output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); + + var key = 10; // Field 1 + var value = 20; // Field 2 + var extra = 30; // Field 3 + + // Each field can be represented in a single byte, with a single byte tag. + // Total message size: 6 bytes. + output.WriteLength(6); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key); + output.WriteTag(2, WireFormat.WireType.Varint); + output.WriteInt32(value); + output.WriteTag(3, WireFormat.WireType.Varint); + output.WriteInt32(extra); + output.Flush(); + + var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); + Assert.AreEqual(value, parsed.MapInt32Int32[key]); + } + + [Test] + public void MapFieldOrderIsIrrelevant() + { + var memoryStream = new MemoryStream(); + var output = new CodedOutputStream(memoryStream); + + output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); + + var key = 10; + var value = 20; + + // Each field can be represented in a single byte, with a single byte tag. + // Total message size: 4 bytes. + output.WriteLength(4); + output.WriteTag(2, WireFormat.WireType.Varint); + output.WriteInt32(value); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key); + output.Flush(); + + var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); + Assert.AreEqual(value, parsed.MapInt32Int32[key]); + } + + [Test] + public void MapNonContiguousEntries() + { + var memoryStream = new MemoryStream(); + var output = new CodedOutputStream(memoryStream); + + // Message structure: + // Entry for MapInt32Int32 + // Entry for MapStringString + // Entry for MapInt32Int32 + + // First entry + var key1 = 10; + var value1 = 20; + output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteLength(4); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key1); + output.WriteTag(2, WireFormat.WireType.Varint); + output.WriteInt32(value1); + + // Second entry + var key2 = "a"; + var value2 = "b"; + output.WriteTag(TestMap.MapStringStringFieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteLength(6); // 3 bytes per entry: tag, size, character + output.WriteTag(1, WireFormat.WireType.LengthDelimited); + output.WriteString(key2); + output.WriteTag(2, WireFormat.WireType.LengthDelimited); + output.WriteString(value2); + + // Third entry + var key3 = 15; + var value3 = 25; + output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteLength(4); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key3); + output.WriteTag(2, WireFormat.WireType.Varint); + output.WriteInt32(value3); + + output.Flush(); + var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); + var expected = new TestMap + { + MapInt32Int32 = { { key1, value1 }, { key3, value3 } }, + MapStringString = { { key2, value2 } } + }; + Assert.AreEqual(expected, parsed); + } + + [Test] + public void DuplicateKeys_LastEntryWins() + { + var memoryStream = new MemoryStream(); + var output = new CodedOutputStream(memoryStream); + + var key = 10; + var value1 = 20; + var value2 = 30; + + // First entry + output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteLength(4); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key); + output.WriteTag(2, WireFormat.WireType.Varint); + output.WriteInt32(value1); + + // Second entry - same key, different value + output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteLength(4); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key); + output.WriteTag(2, WireFormat.WireType.Varint); + output.WriteInt32(value2); + output.Flush(); + + var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); + Assert.AreEqual(value2, parsed.MapInt32Int32[key]); + } + + [Test] + public void CloneSingleNonMessageValues() + { + var original = new TestAllTypes + { + SingleBool = true, + SingleBytes = ByteString.CopyFrom(1, 2, 3, 4), + SingleDouble = 23.5, + SingleFixed32 = 23, + SingleFixed64 = 1234567890123, + SingleFloat = 12.25f, + SingleInt32 = 100, + SingleInt64 = 3210987654321, + SingleNestedEnum = TestAllTypes.Types.NestedEnum.Foo, + SingleSfixed32 = -123, + SingleSfixed64 = -12345678901234, + SingleSint32 = -456, + SingleSint64 = -12345678901235, + SingleString = "test", + SingleUint32 = uint.MaxValue, + SingleUint64 = ulong.MaxValue + }; + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreEqual(original, clone); + // Just as a single example + clone.SingleInt32 = 150; + Assert.AreNotEqual(original, clone); + } + + [Test] + public void CloneRepeatedNonMessageValues() + { + var original = new TestAllTypes + { + RepeatedBool = { true, false }, + RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6) }, + RepeatedDouble = { -12.25, 23.5 }, + RepeatedFixed32 = { uint.MaxValue, 23 }, + RepeatedFixed64 = { ulong.MaxValue, 1234567890123 }, + RepeatedFloat = { 100f, 12.25f }, + RepeatedInt32 = { 100, 200 }, + RepeatedInt64 = { 3210987654321, long.MaxValue }, + RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.Foo, TestAllTypes.Types.NestedEnum.Neg }, + RepeatedSfixed32 = { -123, 123 }, + RepeatedSfixed64 = { -12345678901234, 12345678901234 }, + RepeatedSint32 = { -456, 100 }, + RepeatedSint64 = { -12345678901235, 123 }, + RepeatedString = { "foo", "bar" }, + RepeatedUint32 = { uint.MaxValue, uint.MinValue }, + RepeatedUint64 = { ulong.MaxValue, uint.MinValue } + }; + + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreEqual(original, clone); + // Just as a single example + clone.RepeatedDouble.Add(25.5); + Assert.AreNotEqual(original, clone); + } + + [Test] + public void CloneSingleMessageField() + { + var original = new TestAllTypes + { + SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 } + }; + + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreNotSame(original.SingleNestedMessage, clone.SingleNestedMessage); + Assert.AreEqual(original, clone); + + clone.SingleNestedMessage.Bb = 30; + Assert.AreNotEqual(original, clone); + } + + [Test] + public void CloneRepeatedMessageField() + { + var original = new TestAllTypes + { + RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 20 } } + }; + + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreNotSame(original.RepeatedNestedMessage, clone.RepeatedNestedMessage); + Assert.AreNotSame(original.RepeatedNestedMessage[0], clone.RepeatedNestedMessage[0]); + Assert.AreEqual(original, clone); + + clone.RepeatedNestedMessage[0].Bb = 30; + Assert.AreNotEqual(original, clone); + } + + [Test] + public void CloneOneofField() + { + var original = new TestAllTypes + { + OneofNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 } + }; + + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreEqual(original, clone); + + // We should have cloned the message + original.OneofNestedMessage.Bb = 30; + Assert.AreNotEqual(original, clone); + } + + [Test] + public void OneofProperties() + { + // Switch the oneof case between each of the different options, and check everything behaves + // as expected in each case. + var message = new TestAllTypes(); + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); + + message.OneofString = "sample"; + Assert.AreEqual("sample", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofString, message.OneofFieldCase); + + var bytes = ByteString.CopyFrom(1, 2, 3); + message.OneofBytes = bytes; + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(bytes, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofBytes, message.OneofFieldCase); + + message.OneofUint32 = 20; + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(20, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message.OneofFieldCase); + + var nestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 25 }; + message.OneofNestedMessage = nestedMessage; + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.AreEqual(nestedMessage, message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofNestedMessage, message.OneofFieldCase); + + message.ClearOneofField(); + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); + } + + [Test] + public void Oneof_DefaultValuesNotEqual() + { + var message1 = new TestAllTypes { OneofString = "" }; + var message2 = new TestAllTypes { OneofUint32 = 0 }; + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofString, message1.OneofFieldCase); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase); + Assert.AreNotEqual(message1, message2); + } + + [Test] + public void OneofSerialization_NonDefaultValue() + { + var message = new TestAllTypes(); + message.OneofString = "this would take a bit of space"; + message.OneofUint32 = 10; + var bytes = message.ToByteArray(); + Assert.AreEqual(3, bytes.Length); // 2 bytes for the tag + 1 for the value - no string! + + var message2 = TestAllTypes.Parser.ParseFrom(bytes); + Assert.AreEqual(message, message2); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase); + } + + [Test] + public void OneofSerialization_DefaultValue() + { + var message = new TestAllTypes(); + message.OneofString = "this would take a bit of space"; + message.OneofUint32 = 0; // This is the default value for UInt32; normally wouldn't be serialized + var bytes = message.ToByteArray(); + Assert.AreEqual(3, bytes.Length); // 2 bytes for the tag + 1 for the value - it's still serialized + + var message2 = TestAllTypes.Parser.ParseFrom(bytes); + Assert.AreEqual(message, message2); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase); + } + + [Test] + public void DiscardUnknownFields_RealDataStillRead() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + var unusedFieldNumber = 23456; + Assert.IsFalse(TestAllTypes.Descriptor.Fields.InDeclarationOrder().Select(x => x.FieldNumber).Contains(unusedFieldNumber)); + output.WriteTag(unusedFieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteString("ignore me"); + message.WriteTo(output); + output.Flush(); + + stream.Position = 0; + var parsed = TestAllTypes.Parser.ParseFrom(stream); + // TODO(jieluo): Add test back when DiscardUnknownFields API is supported. + // Assert.AreEqual(message, parsed); + } + + [Test] + public void DiscardUnknownFields_AllTypes() + { + // Simple way of ensuring we can skip all kinds of fields. + var data = SampleMessages.CreateFullTestAllTypes().ToByteArray(); + var empty = Empty.Parser.ParseFrom(data); + // TODO(jieluo): Add test back when DiscardUnknownFields API is supported. + // Assert.AreNotEqual(new Empty(), empty); + } + + // This was originally seen as a conformance test failure. + [Test] + public void TruncatedMessageFieldThrows() + { + // 130, 3 is the message tag + // 1 is the data length - but there's no data. + var data = new byte[] { 130, 3, 1 }; + Assert.Throws(() => TestAllTypes.Parser.ParseFrom(data)); + } + + /// + /// Demonstrates current behaviour with an extraneous end group tag - see issue 688 + /// for details; we may want to change this. + /// + [Test] + public void ExtraEndGroupThrows() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + + output.WriteTag(TestAllTypes.SingleFixed32FieldNumber, WireFormat.WireType.Fixed32); + output.WriteFixed32(123); + output.WriteTag(100, WireFormat.WireType.EndGroup); + + output.Flush(); + + stream.Position = 0; + Assert.Throws(() => TestAllTypes.Parser.ParseFrom(stream)); + } + + [Test] + public void CustomDiagnosticMessage_DirectToStringCall() + { + var message = new ForeignMessage { C = 31 }; + Assert.AreEqual("{ \"c\": 31, \"@cInHex\": \"1f\" }", message.ToString()); + Assert.AreEqual("{ \"c\": 31 }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void CustomDiagnosticMessage_Nested() + { + var message = new TestAllTypes { SingleForeignMessage = new ForeignMessage { C = 16 } }; + Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16, \"@cInHex\": \"10\" } }", message.ToString()); + Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16 } }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void CustomDiagnosticMessage_DirectToTextWriterCall() + { + var message = new ForeignMessage { C = 31 }; + var writer = new StringWriter(); + JsonFormatter.Default.Format(message, writer); + Assert.AreEqual("{ \"c\": 31 }", writer.ToString()); + } + + [Test] + public void NaNComparisons() + { + var message1 = new TestAllTypes { SingleDouble = SampleNaNs.Regular }; + var message2 = new TestAllTypes { SingleDouble = SampleNaNs.PayloadFlipped }; + var message3 = new TestAllTypes { SingleDouble = SampleNaNs.Regular }; + + EqualityTester.AssertInequality(message1, message2); + EqualityTester.AssertEquality(message1, message3); + } + } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj index 5d3de4a436b6..32bb26c99050 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj @@ -1,143 +1,34 @@ - - + + - Debug - AnyCPU - 9.0.30729 - 2.0 - {DD01ED24-3750-4567-9A23-1DB676A15610} - Library - Properties - Google.Protobuf - Google.Protobuf.Test - v4.5 - 512 - 3.5 - - - - + net451;netcoreapp2.1 + ../../keys/Google.Protobuf.snk + true + true + False - - true - full - false - bin\Debug - obj\Debug\ - DEBUG;TRACE;$(EnvironmentFlavor);$(EnvironmentTemplate) - prompt - 4 - true - Off - false - - - pdbonly - true - bin\Release - obj\Release\ - TRACE;$(EnvironmentFlavor);$(EnvironmentTemplate) - prompt - 4 - true - Off - false - - - pdbonly - true - bin\ReleaseSigned - obj\ReleaseSigned\ - TRACE;$(EnvironmentFlavor);$(EnvironmentTemplate) - prompt - 4 - true - Off - false - True - ..\..\keys\Google.Protobuf.snk - - - - - ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.dll - True - - - ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.interfaces.dll - True - - - ..\packages\NUnit.2.6.4\lib\nunit.framework.dll - True - - - ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.util.dll - True - - - ..\packages\NUnitTestAdapter.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - {6908BDCE-D925-43F3-94AC-A531E6DF2591} - Google.Protobuf - + + - + + + + + + + netcoreapp2.1 + + - + - - - - \ No newline at end of file + + diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/IssuesTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/IssuesTest.cs index ddb23aa6855d..2caf80a93fa4 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/IssuesTest.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/IssuesTest.cs @@ -1,82 +1,94 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using Google.Protobuf.Reflection; -using UnitTest.Issues.TestProtos; -using NUnit.Framework; - - -namespace Google.Protobuf -{ - /// - /// Tests for issues which aren't easily compartmentalized into other unit tests. - /// - public class IssuesTest - { - // Issue 45 - [Test] - public void FieldCalledItem() - { - ItemField message = new ItemField { Item = 3 }; - FieldDescriptor field = ItemField.Descriptor.FindFieldByName("item"); - Assert.NotNull(field); - Assert.AreEqual(3, (int)field.Accessor.GetValue(message)); - } - - [Test] - public void ReservedNames() - { - var message = new ReservedNames { Types_ = 10, Descriptor_ = 20 }; - // Underscores aren't reflected in the JSON. - Assert.AreEqual("{ \"types\": 10, \"descriptor\": 20 }", message.ToString()); - } - - [Test] - public void JsonNameParseTest() - { - var settings = new JsonParser.Settings(10, TypeRegistry.FromFiles(UnittestIssuesReflection.Descriptor)); - var parser = new JsonParser(settings); - - // It is safe to use either original field name or explicitly specified json_name - Assert.AreEqual(new TestJsonName { Name = "test", Description = "test2", Guid = "test3" }, - parser.Parse("{ \"name\": \"test\", \"desc\": \"test2\", \"guid\": \"test3\" }")); - } - - [Test] - public void JsonNameFormatTest() - { - var message = new TestJsonName { Name = "test", Description = "test2", Guid = "test3" }; - Assert.AreEqual("{ \"name\": \"test\", \"desc\": \"test2\", \"exid\": \"test3\" }", - JsonFormatter.Default.Format(message)); - } - } -} +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using Google.Protobuf.Reflection; +using UnitTest.Issues.TestProtos; +using NUnit.Framework; +using static UnitTest.Issues.TestProtos.OneofMerging.Types; + +namespace Google.Protobuf +{ + /// + /// Tests for issues which aren't easily compartmentalized into other unit tests. + /// + public class IssuesTest + { + // Issue 45 + [Test] + public void FieldCalledItem() + { + ItemField message = new ItemField { Item = 3 }; + FieldDescriptor field = ItemField.Descriptor.FindFieldByName("item"); + Assert.NotNull(field); + Assert.AreEqual(3, (int)field.Accessor.GetValue(message)); + } + + [Test] + public void ReservedNames() + { + var message = new ReservedNames { Types_ = 10, Descriptor_ = 20 }; + // Underscores aren't reflected in the JSON. + Assert.AreEqual("{ \"types\": 10, \"descriptor\": 20 }", message.ToString()); + } + + [Test] + public void JsonNameParseTest() + { + var settings = new JsonParser.Settings(10, TypeRegistry.FromFiles(UnittestIssuesReflection.Descriptor)); + var parser = new JsonParser(settings); + + // It is safe to use either original field name or explicitly specified json_name + Assert.AreEqual(new TestJsonName { Name = "test", Description = "test2", Guid = "test3" }, + parser.Parse("{ \"name\": \"test\", \"desc\": \"test2\", \"guid\": \"test3\" }")); + } + + [Test] + public void JsonNameFormatTest() + { + var message = new TestJsonName { Name = "test", Description = "test2", Guid = "test3" }; + Assert.AreEqual("{ \"name\": \"test\", \"desc\": \"test2\", \"exid\": \"test3\" }", + JsonFormatter.Default.Format(message)); + } + + [Test] + public void OneofMerging() + { + var message1 = new OneofMerging { Nested = new Nested { X = 10 } }; + var message2 = new OneofMerging { Nested = new Nested { Y = 20 } }; + var expected = new OneofMerging { Nested = new Nested { X = 10, Y = 20 } }; + + var merged = message1.Clone(); + merged.MergeFrom(message2); + Assert.AreEqual(expected, merged); + } + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs index 827a75956fc0..b07a84161ae8 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs @@ -38,6 +38,8 @@ using Google.Protobuf.Reflection; using static Google.Protobuf.JsonParserTest; // For WrapInQuotes +using System.IO; +using Google.Protobuf.Collections; namespace Google.Protobuf { @@ -50,7 +52,7 @@ public class JsonFormatterTest [Test] public void DefaultValues_WhenOmitted() { - var formatter = new JsonFormatter(new JsonFormatter.Settings(formatDefaultValues: false)); + var formatter = JsonFormatter.Default; AssertJson("{ }", formatter.Format(new ForeignMessage())); AssertJson("{ }", formatter.Format(new TestAllTypes())); @@ -60,10 +62,39 @@ public void DefaultValues_WhenOmitted() [Test] public void DefaultValues_WhenIncluded() { - var formatter = new JsonFormatter(new JsonFormatter.Settings(formatDefaultValues: true)); + var formatter = new JsonFormatter(JsonFormatter.Settings.Default.WithFormatDefaultValues(true)); AssertJson("{ 'c': 0 }", formatter.Format(new ForeignMessage())); } + [Test] + public void EnumAllowAlias() + { + var message = new TestEnumAllowAlias + { + Value = TestEnumWithDupValue.Foo2, + }; + var actualText = JsonFormatter.Default.Format(message); + var expectedText = "{ 'value': 'FOO1' }"; + AssertJson(expectedText, actualText); + } + + [Test] + public void EnumAsInt() + { + var message = new TestAllTypes + { + SingleForeignEnum = ForeignEnum.ForeignBar, + RepeatedForeignEnum = { ForeignEnum.ForeignBaz, (ForeignEnum) 100, ForeignEnum.ForeignFoo } + }; + var formatter = new JsonFormatter(JsonFormatter.Settings.Default.WithFormatEnumsAsIntegers(true)); + var actualText = formatter.Format(message); + var expectedText = "{ " + + "'singleForeignEnum': 5, " + + "'repeatedForeignEnum': [ 6, 100, 4 ]" + + " }"; + AssertJson(expectedText, actualText); + } + [Test] public void AllSingleFields() { @@ -212,7 +243,7 @@ public void SurrogatePairEscaping() [Test] public void InvalidSurrogatePairsFail() { - // Note: don't use TestCase for these, as the strings can't be reliably represented + // Note: don't use TestCase for these, as the strings can't be reliably represented // See http://codeblog.jonskeet.uk/2014/11/07/when-is-a-string-not-a-string/ // Lone low surrogate @@ -227,10 +258,16 @@ public void InvalidSurrogatePairsFail() [Test] [TestCase("foo_bar", "fooBar")] [TestCase("bananaBanana", "bananaBanana")] - [TestCase("BANANABanana", "bananaBanana")] - public void ToCamelCase(string original, string expected) + [TestCase("BANANABanana", "BANANABanana")] + [TestCase("simple", "simple")] + [TestCase("ACTION_AND_ADVENTURE", "ACTIONANDADVENTURE")] + [TestCase("action_and_adventure", "actionAndAdventure")] + [TestCase("kFoo", "kFoo")] + [TestCase("HTTPServer", "HTTPServer")] + [TestCase("CLIENT", "CLIENT")] + public void ToJsonName(string original, string expected) { - Assert.AreEqual(expected, JsonFormatter.ToCamelCase(original)); + Assert.AreEqual(expected, JsonFormatter.ToJsonName(original)); } [Test] @@ -246,9 +283,9 @@ public void Oneof(string fooStringValue, string expectedJson) } // We should get the same result both with and without "format default values". - var formatter = new JsonFormatter(new JsonFormatter.Settings(false)); + var formatter = JsonFormatter.Default; AssertJson(expectedJson, formatter.Format(message)); - formatter = new JsonFormatter(new JsonFormatter.Settings(true)); + formatter = new JsonFormatter(JsonFormatter.Settings.Default.WithFormatDefaultValues(true)); AssertJson(expectedJson, formatter.Format(message)); } @@ -280,7 +317,7 @@ public void WrapperFormatting_IncludeNull() { // The actual JSON here is very large because there are lots of fields. Just test a couple of them. var message = new TestWellKnownTypes { Int32Field = 10 }; - var formatter = new JsonFormatter(new JsonFormatter.Settings(true)); + var formatter = new JsonFormatter(JsonFormatter.Settings.Default.WithFormatDefaultValues(true)); var actualJson = formatter.Format(message); Assert.IsTrue(actualJson.Contains("\"int64Field\": null")); Assert.IsFalse(actualJson.Contains("\"int32Field\": null")); @@ -289,7 +326,7 @@ public void WrapperFormatting_IncludeNull() [Test] public void OutputIsInNumericFieldOrder_NoDefaults() { - var formatter = new JsonFormatter(new JsonFormatter.Settings(false)); + var formatter = JsonFormatter.Default; var message = new TestJsonFieldOrdering { PlainString = "p1", PlainInt32 = 2 }; AssertJson("{ 'plainString': 'p1', 'plainInt32': 2 }", formatter.Format(message)); message = new TestJsonFieldOrdering { O1Int32 = 5, O2String = "o2", PlainInt32 = 10, PlainString = "plain" }; @@ -301,7 +338,7 @@ public void OutputIsInNumericFieldOrder_NoDefaults() [Test] public void OutputIsInNumericFieldOrder_WithDefaults() { - var formatter = new JsonFormatter(new JsonFormatter.Settings(true)); + var formatter = new JsonFormatter(JsonFormatter.Settings.Default.WithFormatDefaultValues(true)); var message = new TestJsonFieldOrdering(); AssertJson("{ 'plainString': '', 'plainInt32': 0 }", formatter.Format(message)); message = new TestJsonFieldOrdering { O1Int32 = 5, O2String = "o2", PlainInt32 = 10, PlainString = "plain" }; @@ -465,7 +502,7 @@ public void SourceContextStandalone() [Test] public void AnyWellKnownType() { - var formatter = new JsonFormatter(new JsonFormatter.Settings(false, TypeRegistry.FromMessages(Timestamp.Descriptor))); + var formatter = new JsonFormatter(JsonFormatter.Settings.Default.WithTypeRegistry(TypeRegistry.FromMessages(Timestamp.Descriptor))); var timestamp = new DateTime(1673, 6, 19, 12, 34, 56, DateTimeKind.Utc).ToTimestamp(); var any = Any.Pack(timestamp); AssertJson("{ '@type': 'type.googleapis.com/google.protobuf.Timestamp', 'value': '1673-06-19T12:34:56Z' }", formatter.Format(any)); @@ -474,32 +511,32 @@ public void AnyWellKnownType() [Test] public void AnyMessageType() { - var formatter = new JsonFormatter(new JsonFormatter.Settings(false, TypeRegistry.FromMessages(TestAllTypes.Descriptor))); + var formatter = new JsonFormatter(JsonFormatter.Settings.Default.WithTypeRegistry(TypeRegistry.FromMessages(TestAllTypes.Descriptor))); var message = new TestAllTypes { SingleInt32 = 10, SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 } }; var any = Any.Pack(message); - AssertJson("{ '@type': 'type.googleapis.com/protobuf_unittest.TestAllTypes', 'singleInt32': 10, 'singleNestedMessage': { 'bb': 20 } }", formatter.Format(any)); + AssertJson("{ '@type': 'type.googleapis.com/protobuf_unittest3.TestAllTypes', 'singleInt32': 10, 'singleNestedMessage': { 'bb': 20 } }", formatter.Format(any)); } [Test] public void AnyMessageType_CustomPrefix() { - var formatter = new JsonFormatter(new JsonFormatter.Settings(false, TypeRegistry.FromMessages(TestAllTypes.Descriptor))); + var formatter = new JsonFormatter(JsonFormatter.Settings.Default.WithTypeRegistry(TypeRegistry.FromMessages(TestAllTypes.Descriptor))); var message = new TestAllTypes { SingleInt32 = 10 }; var any = Any.Pack(message, "foo.bar/baz"); - AssertJson("{ '@type': 'foo.bar/baz/protobuf_unittest.TestAllTypes', 'singleInt32': 10 }", formatter.Format(any)); + AssertJson("{ '@type': 'foo.bar/baz/protobuf_unittest3.TestAllTypes', 'singleInt32': 10 }", formatter.Format(any)); } [Test] public void AnyNested() { var registry = TypeRegistry.FromMessages(TestWellKnownTypes.Descriptor, TestAllTypes.Descriptor); - var formatter = new JsonFormatter(new JsonFormatter.Settings(false, registry)); + var formatter = new JsonFormatter(JsonFormatter.Settings.Default.WithTypeRegistry(registry)); // Nest an Any as the value of an Any. var doubleNestedMessage = new TestAllTypes { SingleInt32 = 20 }; var nestedMessage = Any.Pack(doubleNestedMessage); var message = new TestWellKnownTypes { AnyField = Any.Pack(nestedMessage) }; - AssertJson("{ 'anyField': { '@type': 'type.googleapis.com/google.protobuf.Any', 'value': { '@type': 'type.googleapis.com/protobuf_unittest.TestAllTypes', 'singleInt32': 20 } } }", + AssertJson("{ 'anyField': { '@type': 'type.googleapis.com/google.protobuf.Any', 'value': { '@type': 'type.googleapis.com/protobuf_unittest3.TestAllTypes', 'singleInt32': 20 } } }", formatter.Format(message)); } @@ -512,6 +549,67 @@ public void AnyUnknownType() Assert.Throws(() => JsonFormatter.Default.Format(any)); } + [Test] + [TestCase(typeof(BoolValue), true, "true")] + [TestCase(typeof(Int32Value), 32, "32")] + [TestCase(typeof(Int64Value), 32L, "\"32\"")] + [TestCase(typeof(UInt32Value), 32U, "32")] + [TestCase(typeof(UInt64Value), 32UL, "\"32\"")] + [TestCase(typeof(StringValue), "foo", "\"foo\"")] + [TestCase(typeof(FloatValue), 1.5f, "1.5")] + [TestCase(typeof(DoubleValue), 1.5d, "1.5")] + public void Wrappers_Standalone(System.Type wrapperType, object value, string expectedJson) + { + IMessage populated = (IMessage)Activator.CreateInstance(wrapperType); + populated.Descriptor.Fields[WrappersReflection.WrapperValueFieldNumber].Accessor.SetValue(populated, value); + Assert.AreEqual(expectedJson, JsonFormatter.Default.Format(populated)); + } + + // Sanity tests for WriteValue. Not particularly comprehensive, as it's all covered above already, + // as FormatMessage uses WriteValue. + + [TestCase(null, "null")] + [TestCase(1, "1")] + [TestCase(1L, "'1'")] + [TestCase(0.5f, "0.5")] + [TestCase(0.5d, "0.5")] + [TestCase("text", "'text'")] + [TestCase("x\ny", @"'x\ny'")] + [TestCase(ForeignEnum.ForeignBar, "'FOREIGN_BAR'")] + public void WriteValue_Constant(object value, string expectedJson) + { + AssertWriteValue(value, expectedJson); + } + + [Test] + public void WriteValue_Timestamp() + { + var value = new DateTime(1673, 6, 19, 12, 34, 56, DateTimeKind.Utc).ToTimestamp(); + AssertWriteValue(value, "'1673-06-19T12:34:56Z'"); + } + + [Test] + public void WriteValue_Message() + { + var value = new TestAllTypes { SingleInt32 = 100, SingleInt64 = 3210987654321L }; + AssertWriteValue(value, "{ 'singleInt32': 100, 'singleInt64': '3210987654321' }"); + } + + [Test] + public void WriteValue_List() + { + var value = new RepeatedField { 1, 2, 3 }; + AssertWriteValue(value, "[ 1, 2, 3 ]"); + } + + private static void AssertWriteValue(object value, string expectedJson) + { + var writer = new StringWriter(); + JsonFormatter.Default.WriteValue(writer, value); + string actual = writer.ToString(); + AssertJson(expectedJson, actual); + } + /// /// Checks that the actual JSON is the same as the expected JSON - but after replacing /// all apostrophes in the expected JSON with double quotes. This basically makes the tests easier diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/JsonParserTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/JsonParserTest.cs index c3ad851b8aac..a6cf04ab7af2 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/JsonParserTest.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/JsonParserTest.cs @@ -133,9 +133,12 @@ public void SingularWrappers_ExplicitNulls() } [Test] + [TestCase(typeof(BoolValue), "true", true)] [TestCase(typeof(Int32Value), "32", 32)] [TestCase(typeof(Int64Value), "32", 32L)] + [TestCase(typeof(Int64Value), "\"32\"", 32L)] [TestCase(typeof(UInt32Value), "32", 32U)] + [TestCase(typeof(UInt64Value), "\"32\"", 32UL)] [TestCase(typeof(UInt64Value), "32", 32UL)] [TestCase(typeof(StringValue), "\"foo\"", "foo")] [TestCase(typeof(FloatValue), "1.5", 1.5f)] @@ -692,6 +695,22 @@ public void StructValue_List() Assert.AreEqual(Value.ForList(Value.ForNumber(1), Value.ForString("x")), Value.Parser.ParseJson("[1, \"x\"]")); } + [Test] + public void Value_List_WithNullElement() + { + var expected = Value.ForList(Value.ForString("x"), Value.ForNull(), Value.ForString("y")); + var actual = Value.Parser.ParseJson("[\"x\", null, \"y\"]"); + Assert.AreEqual(expected, actual); + } + + [Test] + public void StructValue_NullElement() + { + var expected = Value.ForStruct(new Struct { Fields = { { "x", Value.ForNull() } } }); + var actual = Value.Parser.ParseJson("{ \"x\": null }"); + Assert.AreEqual(expected, actual); + } + [Test] public void ParseListValue() { @@ -806,7 +825,7 @@ public void Any_RegularMessage() var json = formatter.Format(original); // This is tested in JsonFormatterTest var parser = new JsonParser(new JsonParser.Settings(10, registry)); Assert.AreEqual(original, parser.Parse(json)); - string valueFirstJson = "{ \"singleInt32\": 10, \"singleNestedMessage\": { \"bb\": 20 }, \"@type\": \"type.googleapis.com/protobuf_unittest.TestAllTypes\" }"; + string valueFirstJson = "{ \"singleInt32\": 10, \"singleNestedMessage\": { \"bb\": 20 }, \"@type\": \"type.googleapis.com/protobuf_unittest3.TestAllTypes\" }"; Assert.AreEqual(original, parser.Parse(valueFirstJson)); } @@ -817,7 +836,7 @@ public void Any_CustomPrefix() var message = new TestAllTypes { SingleInt32 = 10 }; var original = Any.Pack(message, "custom.prefix/middle-part"); var parser = new JsonParser(new JsonParser.Settings(10, registry)); - string json = "{ \"@type\": \"custom.prefix/middle-part/protobuf_unittest.TestAllTypes\", \"singleInt32\": 10 }"; + string json = "{ \"@type\": \"custom.prefix/middle-part/protobuf_unittest3.TestAllTypes\", \"singleInt32\": 10 }"; Assert.AreEqual(original, parser.Parse(json)); } @@ -923,6 +942,27 @@ public void OneofDuplicate_Invalid() Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); } + [Test] + public void UnknownField_NotIgnored() + { + string json = "{ \"unknownField\": 10, \"singleString\": \"x\" }"; + Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); + } + + [Test] + [TestCase("5")] + [TestCase("\"text\"")] + [TestCase("[0, 1, 2]")] + [TestCase("{ \"a\": { \"b\": 10 } }")] + public void UnknownField_Ignored(string value) + { + var parser = new JsonParser(JsonParser.Settings.Default.WithIgnoreUnknownFields(true)); + string json = "{ \"unknownField\": " + value + ", \"singleString\": \"x\" }"; + var actual = parser.Parse(json); + var expected = new TestAllTypes { SingleString = "x" }; + Assert.AreEqual(expected, actual); + } + /// /// Various tests use strings which have quotes round them for parsing or as the result /// of formatting, but without those quotes being specified in the tests (for the sake of readability). diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs index 527ab3361e9f..df43effd4ff0 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs @@ -240,7 +240,7 @@ public void SimpleObject() AssertTokens("{'x': 'y'}", JsonToken.StartObject, JsonToken.Name("x"), JsonToken.Value("y"), JsonToken.EndObject); } - + [Test] [TestCase("[10, 20", 3)] [TestCase("[10,", 2)] @@ -305,7 +305,7 @@ public void ArrayMixedType() [Test] public void ObjectMixedType() { - AssertTokens(@"{'a': 1, 'b': 'bar', 'c': null, 'd': false, 'e': true, + AssertTokens(@"{'a': 1, 'b': 'bar', 'c': null, 'd': false, 'e': true, 'f': [2], 'g': {'x':'y' }}", JsonToken.StartObject, JsonToken.Name("a"), @@ -349,12 +349,28 @@ public void CanPushBackEndDocument() Assert.AreEqual(JsonToken.EndDocument, tokenizer.Next()); Assert.Throws(() => tokenizer.Next()); } - + + [Test] + [TestCase("{ 'skip': 0, 'next': 1")] + [TestCase("{ 'skip': [0, 1, 2], 'next': 1")] + [TestCase("{ 'skip': 'x', 'next': 1")] + [TestCase("{ 'skip': ['x', 'y'], 'next': 1")] + [TestCase("{ 'skip': {'a': 0}, 'next': 1")] + [TestCase("{ 'skip': {'a': [0, {'b':[]}]}, 'next': 1")] + public void SkipValue(string json) + { + var tokenizer = JsonTokenizer.FromTextReader(new StringReader(json.Replace('\'', '"'))); + Assert.AreEqual(JsonToken.StartObject, tokenizer.Next()); + Assert.AreEqual("skip", tokenizer.Next().StringValue); + tokenizer.SkipValue(); + Assert.AreEqual("next", tokenizer.Next().StringValue); + } + /// /// Asserts that the specified JSON is tokenized into the given sequence of tokens. /// All apostrophes are first converted to double quotes, allowing any tests /// that don't need to check actual apostrophe handling to use apostrophes in the JSON, avoiding - /// messy string literal escaping. The "end document" token is not specified in the list of + /// messy string literal escaping. The "end document" token is not specified in the list of /// expected tokens, but is implicit. /// private static void AssertTokens(string json, params JsonToken[] expectedTokens) @@ -366,7 +382,7 @@ private static void AssertTokens(string json, params JsonToken[] expectedTokens) /// Asserts that the specified JSON is tokenized into the given sequence of tokens. /// Unlike , this does not perform any character /// replacement on the specified JSON, and should be used when the text contains apostrophes which - /// are expected to be used *as* apostrophes. The "end document" token is not specified in the list of + /// are expected to be used *as* apostrophes. The "end document" token is not specified in the list of /// expected tokens, but is implicit. /// private static void AssertTokensNoReplacement(string json, params JsonToken[] expectedTokens) diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Properties/AppManifest.xml b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Properties/AppManifest.xml deleted file mode 100644 index 6712a1178393..000000000000 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Properties/AppManifest.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Properties/AssemblyInfo.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Properties/AssemblyInfo.cs deleted file mode 100644 index f50940e3a6c8..000000000000 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("Google.Protobuf.Test")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Google.Protobuf.Test")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -[assembly: AssemblyVersion("3.0.0.0")] -[assembly: AssemblyFileVersion("3.0.0.0")] diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Reflection/CustomOptionsTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Reflection/CustomOptionsTest.cs new file mode 100644 index 000000000000..ff4e9a7ffd05 --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Reflection/CustomOptionsTest.cs @@ -0,0 +1,212 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2017 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using Google.Protobuf.Reflection; +using Google.Protobuf.WellKnownTypes; +using NUnit.Framework; +using System.IO; +using System.Linq; +using UnitTest.Issues.TestProtos; +using static Google.Protobuf.WireFormat; +using static UnitTest.Issues.TestProtos.ComplexOptionType2.Types; +using static UnitTest.Issues.TestProtos.DummyMessageContainingEnum.Types; +using static Google.Protobuf.Test.Reflection.CustomOptionNumber; + +namespace Google.Protobuf.Test.Reflection +{ + // Internal enum to allow us to use "using static" for convenience. + // These are the options defined in unittest_custom_options_proto3.proto + internal enum CustomOptionNumber + { + FileOpt1 = 7736974, + MessageOpt1 = 7739036, + FieldOpt1 = 7740936, + OneofOpt1 = 7740111, + EnumOpt1 = 7753576, + EnumValueOpt1 = 1560678, + ServiceOpt1 = 7887650, + MethodOpt1 = 7890860, + + // All message options... + BoolOpt = 7706090, + Int32Opt = 7705709, + Int64Opt = 7705542, + UInt32Opt = 7704880, + UInt64Opt = 7702367, + SInt32Opt = 7701568, + SInt64Opt = 7700863, + Fixed32Opt = 7700307, + Fixed64Opt = 7700194, + SFixed32Opt = 7698645, + SFixed64Opt = 7685475, + FloatOpt = 7675390, + DoubleOpt = 7673293, + StringOpt = 7673285, + BytesOpt = 7673238, + EnumOpt = 7673233, + MessageTypeOpt = 7665967, + + // Miscellaneous + ComplexOpt4 = 7633546, + ComplexOpt1 = 7646756, + ComplexOpt2 = 7636949, + ComplexOpt3 = 7636463, + + // Aggregates + AggregateFileOpt = 15478479, + AggregateMsgOpt = 15480088, + AggregateFieldOpt = 15481374, + AggregateEnumOpt = 15483218, + AggregateEnumValueOpt = 15486921, + AggregateServiceOpt = 15497145, + AggregateMethodOpt = 15512713, + } + + /// + /// The majority of the testing here is done via parsed descriptors. That's simpler to + /// achieve (and more important) than constructing a CodedInputStream manually. + /// + public class CustomOptionsTest + { + delegate bool OptionFetcher(int field, out T value); + + [Test] + public void ScalarOptions() + { + var options = CustomOptionOtherValues.Descriptor.CustomOptions; + AssertOption(-100, options.TryGetInt32, Int32Opt); + AssertOption(12.3456789f, options.TryGetFloat, FloatOpt); + AssertOption(1.234567890123456789d, options.TryGetDouble, DoubleOpt); + AssertOption("Hello, \"World\"", options.TryGetString, StringOpt); + AssertOption(ByteString.CopyFromUtf8("Hello\0World"), options.TryGetBytes, BytesOpt); + AssertOption((int)TestEnumType.TestOptionEnumType2, options.TryGetInt32, EnumOpt); + } + + [Test] + public void MessageOptions() + { + var options = VariousComplexOptions.Descriptor.CustomOptions; + AssertOption(new ComplexOptionType1 { Foo = 42, Foo4 = { 99, 88 } }, options.TryGetMessage, ComplexOpt1); + AssertOption(new ComplexOptionType2 + { + Baz = 987, + Bar = new ComplexOptionType1 { Foo = 743 }, + Fred = new ComplexOptionType4 { Waldo = 321 }, + Barney = { new ComplexOptionType4 { Waldo = 101 }, new ComplexOptionType4 { Waldo = 212 } } + }, + options.TryGetMessage, ComplexOpt2); + AssertOption(new ComplexOptionType3 { Qux = 9 }, options.TryGetMessage, ComplexOpt3); + } + + [Test] + public void OptionLocations() + { + var fileOptions = UnittestCustomOptionsProto3Reflection.Descriptor.CustomOptions; + AssertOption(9876543210UL, fileOptions.TryGetUInt64, FileOpt1); + + var messageOptions = TestMessageWithCustomOptions.Descriptor.CustomOptions; + AssertOption(-56, messageOptions.TryGetInt32, MessageOpt1); + + var fieldOptions = TestMessageWithCustomOptions.Descriptor.Fields["field1"].CustomOptions; + AssertOption(8765432109UL, fieldOptions.TryGetFixed64, FieldOpt1); + + var oneofOptions = TestMessageWithCustomOptions.Descriptor.Oneofs[0].CustomOptions; + AssertOption(-99, oneofOptions.TryGetInt32, OneofOpt1); + + var enumOptions = TestMessageWithCustomOptions.Descriptor.EnumTypes[0].CustomOptions; + AssertOption(-789, enumOptions.TryGetSFixed32, EnumOpt1); + + var enumValueOptions = TestMessageWithCustomOptions.Descriptor.EnumTypes[0].FindValueByNumber(2).CustomOptions; + AssertOption(123, enumValueOptions.TryGetInt32, EnumValueOpt1); + + var service = UnittestCustomOptionsProto3Reflection.Descriptor.Services + .Single(s => s.Name == "TestServiceWithCustomOptions"); + var serviceOptions = service.CustomOptions; + AssertOption(-9876543210, serviceOptions.TryGetSInt64, ServiceOpt1); + + var methodOptions = service.Methods[0].CustomOptions; + AssertOption((int)UnitTest.Issues.TestProtos.MethodOpt1.Val2, methodOptions.TryGetInt32, CustomOptionNumber.MethodOpt1); + } + + [Test] + public void MinValues() + { + var options = CustomOptionMinIntegerValues.Descriptor.CustomOptions; + AssertOption(false, options.TryGetBool, BoolOpt); + AssertOption(int.MinValue, options.TryGetInt32, Int32Opt); + AssertOption(long.MinValue, options.TryGetInt64, Int64Opt); + AssertOption(uint.MinValue, options.TryGetUInt32, UInt32Opt); + AssertOption(ulong.MinValue, options.TryGetUInt64, UInt64Opt); + AssertOption(int.MinValue, options.TryGetSInt32, SInt32Opt); + AssertOption(long.MinValue, options.TryGetSInt64, SInt64Opt); + AssertOption(uint.MinValue, options.TryGetUInt32, Fixed32Opt); + AssertOption(ulong.MinValue, options.TryGetUInt64, Fixed64Opt); + AssertOption(int.MinValue, options.TryGetInt32, SFixed32Opt); + AssertOption(long.MinValue, options.TryGetInt64, SFixed64Opt); + } + + [Test] + public void MaxValues() + { + var options = CustomOptionMaxIntegerValues.Descriptor.CustomOptions; + AssertOption(true, options.TryGetBool, BoolOpt); + AssertOption(int.MaxValue, options.TryGetInt32, Int32Opt); + AssertOption(long.MaxValue, options.TryGetInt64, Int64Opt); + AssertOption(uint.MaxValue, options.TryGetUInt32, UInt32Opt); + AssertOption(ulong.MaxValue, options.TryGetUInt64, UInt64Opt); + AssertOption(int.MaxValue, options.TryGetSInt32, SInt32Opt); + AssertOption(long.MaxValue, options.TryGetSInt64, SInt64Opt); + AssertOption(uint.MaxValue, options.TryGetFixed32, Fixed32Opt); + AssertOption(ulong.MaxValue, options.TryGetFixed64, Fixed64Opt); + AssertOption(int.MaxValue, options.TryGetSFixed32, SFixed32Opt); + AssertOption(long.MaxValue, options.TryGetSFixed64, SFixed64Opt); + } + + [Test] + public void AggregateOptions() + { + // Just two examples + var messageOptions = AggregateMessage.Descriptor.CustomOptions; + AssertOption(new Aggregate { I = 101, S = "MessageAnnotation" }, messageOptions.TryGetMessage, AggregateMsgOpt); + + var fieldOptions = AggregateMessage.Descriptor.Fields["fieldname"].CustomOptions; + AssertOption(new Aggregate { S = "FieldAnnotation" }, fieldOptions.TryGetMessage, AggregateFieldOpt); + } + + private void AssertOption(T expected, OptionFetcher fetcher, CustomOptionNumber field) + { + T actual; + Assert.IsTrue(fetcher((int)field, out actual)); + Assert.AreEqual(expected, actual); + } + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Reflection/DescriptorDeclarationTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Reflection/DescriptorDeclarationTest.cs new file mode 100644 index 000000000000..d9d56672458c --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Reflection/DescriptorDeclarationTest.cs @@ -0,0 +1,175 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2018 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using Google.Protobuf.Reflection; +using NUnit.Framework; +using System.Linq; +using System.Reflection; + +namespace Google.Protobuf.Test.Reflection +{ + // In reality this isn't a test for DescriptorDeclaration so much as the way they're loaded. + public class DescriptorDeclarationTest + { + static readonly FileDescriptor unitTestProto3Descriptor = LoadProtos(); + + // Note: we don't expose a declaration for FileDescriptor as it doesn't have comments + // at the moment and the locations aren't terribly useful. + + // The tests for most elements are quite basic: we don't test every aspect of every element. + // The code within the library falls into two categories: + // - Exposing the properties for *any* declaration + // - Finding the right declaration for an element from the descriptor data + // We have a per-element check to make sure we *are* finding the right declaration, and we + // check every property of declarations in at least one test, but we don't have a cross-product. + // That would effectively be testing protoc, which seems redundant here. + + [Test] + public void ServiceComments() + { + var service = unitTestProto3Descriptor.FindTypeByName("TestService"); + Assert.NotNull(service.Declaration); + Assert.AreEqual(" This is a test service\n", service.Declaration.LeadingComments); + } + + [Test] + public void MethodComments() + { + var service = unitTestProto3Descriptor.FindTypeByName("TestService"); + var method = service.FindMethodByName("Foo"); + Assert.NotNull(method.Declaration); + Assert.AreEqual(" This is a test method\n", method.Declaration.LeadingComments); + } + + [Test] + public void MessageComments() + { + var message = unitTestProto3Descriptor.FindTypeByName("CommentMessage"); + Assert.NotNull(message.Declaration); + Assert.AreEqual(" This is a leading comment\n", message.Declaration.LeadingComments); + Assert.AreEqual(new[] { " This is leading detached comment 1\n", " This is leading detached comment 2\n" }, + message.Declaration.LeadingDetachedComments); + } + + // Note: this test is somewhat brittle; a change earlier in the proto will break it. + [Test] + public void MessageLocations() + { + var message = unitTestProto3Descriptor.FindTypeByName("CommentMessage"); + Assert.NotNull(message.Declaration); + Assert.AreEqual(389, message.Declaration.StartLine); + Assert.AreEqual(1, message.Declaration.StartColumn); + + Assert.AreEqual(404, message.Declaration.EndLine); + Assert.AreEqual(2, message.Declaration.EndColumn); + } + + [Test] + public void EnumComments() + { + var descriptor = unitTestProto3Descriptor.FindTypeByName("CommentEnum"); + Assert.NotNull(descriptor.Declaration); + Assert.AreEqual(" Leading enum comment\n", descriptor.Declaration.LeadingComments); + } + + [Test] + public void NestedMessageComments() + { + var outer = unitTestProto3Descriptor.FindTypeByName("CommentMessage"); + var nested = outer.FindDescriptor("NestedCommentMessage"); + Assert.NotNull(nested.Declaration); + Assert.AreEqual(" Leading nested message comment\n", nested.Declaration.LeadingComments); + } + + [Test] + public void NestedEnumComments() + { + var outer = unitTestProto3Descriptor.FindTypeByName("CommentMessage"); + var nested = outer.FindDescriptor("NestedCommentEnum"); + Assert.NotNull(nested.Declaration); + Assert.AreEqual(" Leading nested enum comment\n", nested.Declaration.LeadingComments); + } + + [Test] + public void FieldComments() + { + var message = unitTestProto3Descriptor.FindTypeByName("CommentMessage"); + var field = message.FindFieldByName("text"); + Assert.NotNull(field.Declaration); + Assert.AreEqual(" Leading field comment\n", field.Declaration.LeadingComments); + Assert.AreEqual(" Trailing field comment\n", field.Declaration.TrailingComments); + } + + [Test] + public void NestedMessageFieldComments() + { + var outer = unitTestProto3Descriptor.FindTypeByName("CommentMessage"); + var nested = outer.FindDescriptor("NestedCommentMessage"); + var field = nested.FindFieldByName("nested_text"); + Assert.NotNull(field.Declaration); + Assert.AreEqual(" Leading nested message field comment\n", field.Declaration.LeadingComments); + } + + [Test] + public void EnumValueComments() + { + var enumDescriptor = unitTestProto3Descriptor.FindTypeByName("CommentEnum"); + var value = enumDescriptor.FindValueByName("ZERO_VALUE"); + Assert.NotNull(value.Declaration); + Assert.AreEqual(" Zero value comment\n", value.Declaration.LeadingComments); + } + + [Test] + public void NestedEnumValueComments() + { + var outer = unitTestProto3Descriptor.FindTypeByName("CommentMessage"); + var nested = outer.FindDescriptor("NestedCommentEnum"); + var value = nested.FindValueByName("ZERO_VALUE"); + Assert.NotNull(value.Declaration); + Assert.AreEqual(" Zero value comment\n", value.Declaration.LeadingComments); + } + + private static FileDescriptor LoadProtos() + { + var type = typeof(DescriptorDeclarationTest); + // TODO: Make this simpler :) + FileDescriptorSet descriptorSet; + using (var stream = type.GetTypeInfo().Assembly.GetManifestResourceStream($"Google.Protobuf.Test.testprotos.pb")) + { + descriptorSet = FileDescriptorSet.Parser.ParseFrom(stream); + } + var byteStrings = descriptorSet.File.Select(f => f.ToByteString()).ToList(); + var descriptors = FileDescriptor.BuildFromByteStrings(byteStrings); + return descriptors.Single(d => d.Name == "unittest_proto3.proto"); + } + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs index 52d5a6769729..264cbbe03720 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs @@ -30,10 +30,11 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion -using System.Linq; using Google.Protobuf.TestProtos; using NUnit.Framework; -using UnitTest.Issues.TestProtos; +using System; +using System.Collections.Generic; +using System.Linq; namespace Google.Protobuf.Reflection { @@ -44,31 +45,48 @@ namespace Google.Protobuf.Reflection public class DescriptorsTest { [Test] - public void FileDescriptor() + public void FileDescriptor_GeneratedCode() { - FileDescriptor file = UnittestProto3Reflection.Descriptor; + TestFileDescriptor( + UnittestProto3Reflection.Descriptor, + UnittestImportProto3Reflection.Descriptor, + UnittestImportPublicProto3Reflection.Descriptor); + } - Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Name); - Assert.AreEqual("protobuf_unittest", file.Package); + [Test] + public void FileDescriptor_BuildFromByteStrings() + { + // The descriptors have to be supplied in an order such that all the + // dependencies come before the descriptors depending on them. + var descriptorData = new List + { + UnittestImportPublicProto3Reflection.Descriptor.SerializedData, + UnittestImportProto3Reflection.Descriptor.SerializedData, + UnittestProto3Reflection.Descriptor.SerializedData + }; + var converted = FileDescriptor.BuildFromByteStrings(descriptorData); + Assert.AreEqual(3, converted.Count); + TestFileDescriptor(converted[2], converted[1], converted[0]); + } + + private void TestFileDescriptor(FileDescriptor file, FileDescriptor importedFile, FileDescriptor importedPublicFile) + { + Assert.AreEqual("unittest_proto3.proto", file.Name); + Assert.AreEqual("protobuf_unittest3", file.Package); Assert.AreEqual("UnittestProto", file.Proto.Options.JavaOuterClassname); - Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Proto.Name); + Assert.AreEqual("unittest_proto3.proto", file.Proto.Name); - // unittest.proto doesn't have any public imports, but unittest_import.proto does. + // unittest_proto3.proto doesn't have any public imports, but unittest_import_proto3.proto does. Assert.AreEqual(0, file.PublicDependencies.Count); - Assert.AreEqual(1, UnittestImportProto3Reflection.Descriptor.PublicDependencies.Count); - Assert.AreEqual(UnittestImportPublicProto3Reflection.Descriptor, UnittestImportProto3Reflection.Descriptor.PublicDependencies[0]); + Assert.AreEqual(1, importedFile.PublicDependencies.Count); + Assert.AreEqual(importedPublicFile, importedFile.PublicDependencies[0]); Assert.AreEqual(1, file.Dependencies.Count); - Assert.AreEqual(UnittestImportProto3Reflection.Descriptor, file.Dependencies[0]); + Assert.AreEqual(importedFile, file.Dependencies[0]); - MessageDescriptor messageType = TestAllTypes.Descriptor; - Assert.AreSame(typeof(TestAllTypes), messageType.ClrType); - Assert.AreSame(TestAllTypes.Parser, messageType.Parser); - Assert.AreEqual(messageType, file.MessageTypes[0]); - Assert.AreEqual(messageType, file.FindTypeByName("TestAllTypes")); Assert.Null(file.FindTypeByName("NoSuchType")); - Assert.Null(file.FindTypeByName("protobuf_unittest.TestAllTypes")); + Assert.Null(file.FindTypeByName("protobuf_unittest3.TestAllTypes")); for (int i = 0; i < file.MessageTypes.Count; i++) { Assert.AreEqual(i, file.MessageTypes[i].Index); @@ -76,9 +94,9 @@ public void FileDescriptor() Assert.AreEqual(file.EnumTypes[0], file.FindTypeByName("ForeignEnum")); Assert.Null(file.FindTypeByName("NoSuchType")); - Assert.Null(file.FindTypeByName("protobuf_unittest.ForeignEnum")); - Assert.AreEqual(1, UnittestImportProto3Reflection.Descriptor.EnumTypes.Count); - Assert.AreEqual("ImportEnum", UnittestImportProto3Reflection.Descriptor.EnumTypes[0].Name); + Assert.Null(file.FindTypeByName("protobuf_unittest3.ForeignEnum")); + Assert.AreEqual(1, importedFile.EnumTypes.Count); + Assert.AreEqual("ImportEnum", importedFile.EnumTypes[0].Name); for (int i = 0; i < file.EnumTypes.Count; i++) { Assert.AreEqual(i, file.EnumTypes[i].Index); @@ -87,6 +105,66 @@ public void FileDescriptor() Assert.AreEqual(10, file.SerializedData[0]); } + [Test] + public void FileDescriptor_NonRootPath() + { + // unittest_proto3.proto used to be in google/protobuf. Now it's in the C#-specific location, + // let's test something that's still in a directory. + FileDescriptor file = UnittestWellKnownTypesReflection.Descriptor; + Assert.AreEqual("google/protobuf/unittest_well_known_types.proto", file.Name); + Assert.AreEqual("protobuf_unittest", file.Package); + } + + [Test] + public void FileDescriptor_BuildFromByteStrings_MissingDependency() + { + var descriptorData = new List + { + UnittestImportProto3Reflection.Descriptor.SerializedData, + UnittestProto3Reflection.Descriptor.SerializedData, + }; + // This will fail, because we're missing UnittestImportPublicProto3Reflection + Assert.Throws(() => FileDescriptor.BuildFromByteStrings(descriptorData)); + } + + [Test] + public void FileDescriptor_BuildFromByteStrings_DuplicateNames() + { + var descriptorData = new List + { + UnittestImportPublicProto3Reflection.Descriptor.SerializedData, + UnittestImportPublicProto3Reflection.Descriptor.SerializedData, + }; + // This will fail due to the same name being used twice + Assert.Throws(() => FileDescriptor.BuildFromByteStrings(descriptorData)); + } + + [Test] + public void FileDescriptor_BuildFromByteStrings_IncorrectOrder() + { + var descriptorData = new List + { + UnittestProto3Reflection.Descriptor.SerializedData, + UnittestImportPublicProto3Reflection.Descriptor.SerializedData, + UnittestImportProto3Reflection.Descriptor.SerializedData + }; + // This will fail, because the dependencies should come first + Assert.Throws(() => FileDescriptor.BuildFromByteStrings(descriptorData)); + + } + + [Test] + public void MessageDescriptorFromGeneratedCodeFileDescriptor() + { + var file = UnittestProto3Reflection.Descriptor; + + MessageDescriptor messageType = TestAllTypes.Descriptor; + Assert.AreSame(typeof(TestAllTypes), messageType.ClrType); + Assert.AreSame(TestAllTypes.Parser, messageType.Parser); + Assert.AreEqual(messageType, file.MessageTypes[0]); + Assert.AreEqual(messageType, file.FindTypeByName("TestAllTypes")); + } + [Test] public void MessageDescriptor() { @@ -94,7 +172,7 @@ public void MessageDescriptor() MessageDescriptor nestedType = TestAllTypes.Types.NestedMessage.Descriptor; Assert.AreEqual("TestAllTypes", messageType.Name); - Assert.AreEqual("protobuf_unittest.TestAllTypes", messageType.FullName); + Assert.AreEqual("protobuf_unittest3.TestAllTypes", messageType.FullName); Assert.AreEqual(UnittestProto3Reflection.Descriptor, messageType.File); Assert.IsNull(messageType.ContainingType); Assert.IsNull(messageType.Proto.Options); @@ -102,7 +180,7 @@ public void MessageDescriptor() Assert.AreEqual("TestAllTypes", messageType.Name); Assert.AreEqual("NestedMessage", nestedType.Name); - Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedMessage", nestedType.FullName); + Assert.AreEqual("protobuf_unittest3.TestAllTypes.NestedMessage", nestedType.FullName); Assert.AreEqual(UnittestProto3Reflection.Descriptor, nestedType.File); Assert.AreEqual(messageType, nestedType.ContainingType); @@ -135,29 +213,61 @@ public void MessageDescriptor() } [Test] - public void FieldDescriptor() + public void FieldDescriptor_GeneratedCode() { - MessageDescriptor messageType = TestAllTypes.Descriptor; - FieldDescriptor primitiveField = messageType.FindDescriptor("single_int32"); - FieldDescriptor enumField = messageType.FindDescriptor("single_nested_enum"); - FieldDescriptor messageField = messageType.FindDescriptor("single_foreign_message"); + TestFieldDescriptor(UnittestProto3Reflection.Descriptor, TestAllTypes.Descriptor, ForeignMessage.Descriptor, ImportMessage.Descriptor); + } + + [Test] + public void FieldDescriptor_BuildFromByteStrings() + { + // The descriptors have to be supplied in an order such that all the + // dependencies come before the descriptors depending on them. + var descriptorData = new List + { + UnittestImportPublicProto3Reflection.Descriptor.SerializedData, + UnittestImportProto3Reflection.Descriptor.SerializedData, + UnittestProto3Reflection.Descriptor.SerializedData + }; + var converted = FileDescriptor.BuildFromByteStrings(descriptorData); + TestFieldDescriptor( + converted[2], + converted[2].FindTypeByName("TestAllTypes"), + converted[2].FindTypeByName("ForeignMessage"), + converted[1].FindTypeByName("ImportMessage")); + } + + public void TestFieldDescriptor( + FileDescriptor unitTestProto3Descriptor, + MessageDescriptor testAllTypesDescriptor, + MessageDescriptor foreignMessageDescriptor, + MessageDescriptor importMessageDescriptor) + { + FieldDescriptor primitiveField = testAllTypesDescriptor.FindDescriptor("single_int32"); + FieldDescriptor enumField = testAllTypesDescriptor.FindDescriptor("single_nested_enum"); + FieldDescriptor foreignMessageField = testAllTypesDescriptor.FindDescriptor("single_foreign_message"); + FieldDescriptor importMessageField = testAllTypesDescriptor.FindDescriptor("single_import_message"); Assert.AreEqual("single_int32", primitiveField.Name); - Assert.AreEqual("protobuf_unittest.TestAllTypes.single_int32", + Assert.AreEqual("protobuf_unittest3.TestAllTypes.single_int32", primitiveField.FullName); Assert.AreEqual(1, primitiveField.FieldNumber); - Assert.AreEqual(messageType, primitiveField.ContainingType); - Assert.AreEqual(UnittestProto3Reflection.Descriptor, primitiveField.File); + Assert.AreEqual(testAllTypesDescriptor, primitiveField.ContainingType); + Assert.AreEqual(unitTestProto3Descriptor, primitiveField.File); Assert.AreEqual(FieldType.Int32, primitiveField.FieldType); Assert.IsNull(primitiveField.Proto.Options); - + Assert.AreEqual("single_nested_enum", enumField.Name); Assert.AreEqual(FieldType.Enum, enumField.FieldType); - // Assert.AreEqual(TestAllTypes.Types.NestedEnum.DescriptorProtoFile, enumField.EnumType); + Assert.AreEqual(testAllTypesDescriptor.EnumTypes[0], enumField.EnumType); + + Assert.AreEqual("single_foreign_message", foreignMessageField.Name); + Assert.AreEqual(FieldType.Message, foreignMessageField.FieldType); + Assert.AreEqual(foreignMessageDescriptor, foreignMessageField.MessageType); - Assert.AreEqual("single_foreign_message", messageField.Name); - Assert.AreEqual(FieldType.Message, messageField.FieldType); - Assert.AreEqual(ForeignMessage.Descriptor, messageField.MessageType); + Assert.AreEqual("single_import_message", importMessageField.Name); + Assert.AreEqual(FieldType.Message, importMessageField.FieldType); + Assert.AreEqual(importMessageDescriptor, importMessageField.MessageType); } [Test] @@ -180,13 +290,13 @@ public void EnumDescriptor() EnumDescriptor nestedType = TestAllTypes.Descriptor.FindDescriptor("NestedEnum"); Assert.AreEqual("ForeignEnum", enumType.Name); - Assert.AreEqual("protobuf_unittest.ForeignEnum", enumType.FullName); + Assert.AreEqual("protobuf_unittest3.ForeignEnum", enumType.FullName); Assert.AreEqual(UnittestProto3Reflection.Descriptor, enumType.File); Assert.Null(enumType.ContainingType); Assert.Null(enumType.Proto.Options); Assert.AreEqual("NestedEnum", nestedType.Name); - Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedEnum", + Assert.AreEqual("protobuf_unittest3.TestAllTypes.NestedEnum", nestedType.FullName); Assert.AreEqual(UnittestProto3Reflection.Descriptor, nestedType.File); Assert.AreEqual(TestAllTypes.Descriptor, nestedType.ContainingType); @@ -209,7 +319,7 @@ public void OneofDescriptor() { OneofDescriptor descriptor = TestAllTypes.Descriptor.FindDescriptor("oneof_field"); Assert.AreEqual("oneof_field", descriptor.Name); - Assert.AreEqual("protobuf_unittest.TestAllTypes.oneof_field", descriptor.FullName); + Assert.AreEqual("protobuf_unittest3.TestAllTypes.oneof_field", descriptor.FullName); var expectedFields = new[] { TestAllTypes.OneofBytesFieldNumber, @@ -242,7 +352,7 @@ public void MapEntryMessageDescriptor() // NestedMessage single_nested_message = 200; [Test] public void FieldListOrderings() - { + { var fields = TestFieldOrderings.Descriptor.Fields; Assert.AreEqual(new[] { 11, 1, 101, 200 }, fields.InDeclarationOrder().Select(x => x.FieldNumber)); Assert.AreEqual(new[] { 1, 11, 101, 200 }, fields.InFieldNumberOrder().Select(x => x.FieldNumber)); diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs index a488af30d44d..46cb1afcd5fd 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs @@ -213,6 +213,6 @@ public void FieldDescriptor_NotFound() var descriptor = TestAllTypes.Descriptor; Assert.Throws(() => descriptor.Fields[999999].ToString()); Assert.Throws(() => descriptor.Fields["not found"].ToString()); - } + } } } diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/SampleEnum.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/SampleEnum.cs index 77447afa1273..44f232a53ef6 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/SampleEnum.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/SampleEnum.cs @@ -29,7 +29,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion - + namespace Google.Protobuf { // Just a sample enum with positive and negative values to be used in tests. diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/SampleNaNs.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/SampleNaNs.cs new file mode 100644 index 000000000000..34019ac1d2a2 --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/SampleNaNs.cs @@ -0,0 +1,53 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2017 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; + +namespace Google.Protobuf +{ + /// + /// Samples of different not-a-number values, for testing equality comparisons. + /// + public static class SampleNaNs + { + public static double Regular { get; } = double.NaN; + + // Signalling bit is inverted compared with double.NaN. Doesn't really matter + // whether that makes it quiet or signalling - it's different. + public static double SignallingFlipped { get; } = + BitConverter.Int64BitsToDouble(BitConverter.DoubleToInt64Bits(double.NaN) ^ -0x8000_0000_0000_0000L); + + // A bit in the middle of the mantissa is flipped; this difference is preserved when casting to float. + public static double PayloadFlipped { get; } = + BitConverter.Int64BitsToDouble(BitConverter.DoubleToInt64Bits(double.NaN) ^ 0x1_0000_0000L); + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestCornerCases.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestCornerCases.cs index fd75b19f42ed..248f5fa913f2 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestCornerCases.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestCornerCases.cs @@ -1,62 +1,62 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using UnitTest.Issues.TestProtos; -using NUnit.Framework; - -namespace Google.Protobuf -{ - public class TestCornerCases - { - [Test] - public void TestRoundTripNegativeEnums() - { - NegativeEnumMessage msg = new NegativeEnumMessage - { - Value = NegativeEnum.MinusOne, - Values = { NegativeEnum.Zero, NegativeEnum.MinusOne, NegativeEnum.FiveBelow }, - PackedValues = { NegativeEnum.Zero, NegativeEnum.MinusOne, NegativeEnum.FiveBelow } - }; - - Assert.AreEqual(58, msg.CalculateSize()); - - byte[] bytes = new byte[58]; - CodedOutputStream output = new CodedOutputStream(bytes); - - msg.WriteTo(output); - Assert.AreEqual(0, output.SpaceLeft); - - NegativeEnumMessage copy = NegativeEnumMessage.Parser.ParseFrom(bytes); - Assert.AreEqual(msg, copy); - } - } -} +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using UnitTest.Issues.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class TestCornerCases + { + [Test] + public void TestRoundTripNegativeEnums() + { + NegativeEnumMessage msg = new NegativeEnumMessage + { + Value = NegativeEnum.MinusOne, + Values = { NegativeEnum.Zero, NegativeEnum.MinusOne, NegativeEnum.FiveBelow }, + PackedValues = { NegativeEnum.Zero, NegativeEnum.MinusOne, NegativeEnum.FiveBelow } + }; + + Assert.AreEqual(58, msg.CalculateSize()); + + byte[] bytes = new byte[58]; + CodedOutputStream output = new CodedOutputStream(bytes); + + msg.WriteTo(output); + Assert.AreEqual(0, output.SpaceLeft); + + NegativeEnumMessage copy = NegativeEnumMessage.Parser.ParseFrom(bytes); + Assert.AreEqual(msg, copy); + } + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs index 3ba4a2b663c4..197b197d0ea4 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs @@ -1,5 +1,7 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/map_unittest_proto3.proto +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: map_unittest_proto3.proto +// #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -9,12 +11,11 @@ using scg = global::System.Collections.Generic; namespace Google.Protobuf.TestProtos { - /// Holder for reflection information generated from google/protobuf/map_unittest_proto3.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + /// Holder for reflection information generated from map_unittest_proto3.proto public static partial class MapUnittestProto3Reflection { #region Descriptor - /// File descriptor for google/protobuf/map_unittest_proto3.proto + /// File descriptor for map_unittest_proto3.proto public static pbr::FileDescriptor Descriptor { get { return descriptor; } } @@ -23,140 +24,140 @@ public static partial class MapUnittestProto3Reflection { static MapUnittestProto3Reflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "Cilnb29nbGUvcHJvdG9idWYvbWFwX3VuaXR0ZXN0X3Byb3RvMy5wcm90bxIR", - "cHJvdG9idWZfdW5pdHRlc3QaJWdvb2dsZS9wcm90b2J1Zi91bml0dGVzdF9w", - "cm90bzMucHJvdG8ilhIKB1Rlc3RNYXASRgoPbWFwX2ludDMyX2ludDMyGAEg", - "AygLMi0ucHJvdG9idWZfdW5pdHRlc3QuVGVzdE1hcC5NYXBJbnQzMkludDMy", - "RW50cnkSRgoPbWFwX2ludDY0X2ludDY0GAIgAygLMi0ucHJvdG9idWZfdW5p", - "dHRlc3QuVGVzdE1hcC5NYXBJbnQ2NEludDY0RW50cnkSSgoRbWFwX3VpbnQz", - "Ml91aW50MzIYAyADKAsyLy5wcm90b2J1Zl91bml0dGVzdC5UZXN0TWFwLk1h", - "cFVpbnQzMlVpbnQzMkVudHJ5EkoKEW1hcF91aW50NjRfdWludDY0GAQgAygL", - "Mi8ucHJvdG9idWZfdW5pdHRlc3QuVGVzdE1hcC5NYXBVaW50NjRVaW50NjRF", - "bnRyeRJKChFtYXBfc2ludDMyX3NpbnQzMhgFIAMoCzIvLnByb3RvYnVmX3Vu", - "aXR0ZXN0LlRlc3RNYXAuTWFwU2ludDMyU2ludDMyRW50cnkSSgoRbWFwX3Np", - "bnQ2NF9zaW50NjQYBiADKAsyLy5wcm90b2J1Zl91bml0dGVzdC5UZXN0TWFw", - "Lk1hcFNpbnQ2NFNpbnQ2NEVudHJ5Ek4KE21hcF9maXhlZDMyX2ZpeGVkMzIY", - "ByADKAsyMS5wcm90b2J1Zl91bml0dGVzdC5UZXN0TWFwLk1hcEZpeGVkMzJG", - "aXhlZDMyRW50cnkSTgoTbWFwX2ZpeGVkNjRfZml4ZWQ2NBgIIAMoCzIxLnBy", - "b3RvYnVmX3VuaXR0ZXN0LlRlc3RNYXAuTWFwRml4ZWQ2NEZpeGVkNjRFbnRy", - "eRJSChVtYXBfc2ZpeGVkMzJfc2ZpeGVkMzIYCSADKAsyMy5wcm90b2J1Zl91", - "bml0dGVzdC5UZXN0TWFwLk1hcFNmaXhlZDMyU2ZpeGVkMzJFbnRyeRJSChVt", - "YXBfc2ZpeGVkNjRfc2ZpeGVkNjQYCiADKAsyMy5wcm90b2J1Zl91bml0dGVz", - "dC5UZXN0TWFwLk1hcFNmaXhlZDY0U2ZpeGVkNjRFbnRyeRJGCg9tYXBfaW50", - "MzJfZmxvYXQYCyADKAsyLS5wcm90b2J1Zl91bml0dGVzdC5UZXN0TWFwLk1h", - "cEludDMyRmxvYXRFbnRyeRJIChBtYXBfaW50MzJfZG91YmxlGAwgAygLMi4u", - "cHJvdG9idWZfdW5pdHRlc3QuVGVzdE1hcC5NYXBJbnQzMkRvdWJsZUVudHJ5", - "EkIKDW1hcF9ib29sX2Jvb2wYDSADKAsyKy5wcm90b2J1Zl91bml0dGVzdC5U", - "ZXN0TWFwLk1hcEJvb2xCb29sRW50cnkSSgoRbWFwX3N0cmluZ19zdHJpbmcY", - "DiADKAsyLy5wcm90b2J1Zl91bml0dGVzdC5UZXN0TWFwLk1hcFN0cmluZ1N0", - "cmluZ0VudHJ5EkYKD21hcF9pbnQzMl9ieXRlcxgPIAMoCzItLnByb3RvYnVm", - "X3VuaXR0ZXN0LlRlc3RNYXAuTWFwSW50MzJCeXRlc0VudHJ5EkQKDm1hcF9p", - "bnQzMl9lbnVtGBAgAygLMiwucHJvdG9idWZfdW5pdHRlc3QuVGVzdE1hcC5N", - "YXBJbnQzMkVudW1FbnRyeRJZChltYXBfaW50MzJfZm9yZWlnbl9tZXNzYWdl", - "GBEgAygLMjYucHJvdG9idWZfdW5pdHRlc3QuVGVzdE1hcC5NYXBJbnQzMkZv", - "cmVpZ25NZXNzYWdlRW50cnkaNAoSTWFwSW50MzJJbnQzMkVudHJ5EgsKA2tl", - "eRgBIAEoBRINCgV2YWx1ZRgCIAEoBToCOAEaNAoSTWFwSW50NjRJbnQ2NEVu", - "dHJ5EgsKA2tleRgBIAEoAxINCgV2YWx1ZRgCIAEoAzoCOAEaNgoUTWFwVWlu", - "dDMyVWludDMyRW50cnkSCwoDa2V5GAEgASgNEg0KBXZhbHVlGAIgASgNOgI4", - "ARo2ChRNYXBVaW50NjRVaW50NjRFbnRyeRILCgNrZXkYASABKAQSDQoFdmFs", - "dWUYAiABKAQ6AjgBGjYKFE1hcFNpbnQzMlNpbnQzMkVudHJ5EgsKA2tleRgB", - "IAEoERINCgV2YWx1ZRgCIAEoEToCOAEaNgoUTWFwU2ludDY0U2ludDY0RW50", - "cnkSCwoDa2V5GAEgASgSEg0KBXZhbHVlGAIgASgSOgI4ARo4ChZNYXBGaXhl", - "ZDMyRml4ZWQzMkVudHJ5EgsKA2tleRgBIAEoBxINCgV2YWx1ZRgCIAEoBzoC", - "OAEaOAoWTWFwRml4ZWQ2NEZpeGVkNjRFbnRyeRILCgNrZXkYASABKAYSDQoF", - "dmFsdWUYAiABKAY6AjgBGjoKGE1hcFNmaXhlZDMyU2ZpeGVkMzJFbnRyeRIL", - "CgNrZXkYASABKA8SDQoFdmFsdWUYAiABKA86AjgBGjoKGE1hcFNmaXhlZDY0", - "U2ZpeGVkNjRFbnRyeRILCgNrZXkYASABKBASDQoFdmFsdWUYAiABKBA6AjgB", - "GjQKEk1hcEludDMyRmxvYXRFbnRyeRILCgNrZXkYASABKAUSDQoFdmFsdWUY", - "AiABKAI6AjgBGjUKE01hcEludDMyRG91YmxlRW50cnkSCwoDa2V5GAEgASgF", - "Eg0KBXZhbHVlGAIgASgBOgI4ARoyChBNYXBCb29sQm9vbEVudHJ5EgsKA2tl", - "eRgBIAEoCBINCgV2YWx1ZRgCIAEoCDoCOAEaNgoUTWFwU3RyaW5nU3RyaW5n", - "RW50cnkSCwoDa2V5GAEgASgJEg0KBXZhbHVlGAIgASgJOgI4ARo0ChJNYXBJ", - "bnQzMkJ5dGVzRW50cnkSCwoDa2V5GAEgASgFEg0KBXZhbHVlGAIgASgMOgI4", - "ARpPChFNYXBJbnQzMkVudW1FbnRyeRILCgNrZXkYASABKAUSKQoFdmFsdWUY", - "AiABKA4yGi5wcm90b2J1Zl91bml0dGVzdC5NYXBFbnVtOgI4ARpgChtNYXBJ", - "bnQzMkZvcmVpZ25NZXNzYWdlRW50cnkSCwoDa2V5GAEgASgFEjAKBXZhbHVl", - "GAIgASgLMiEucHJvdG9idWZfdW5pdHRlc3QuRm9yZWlnbk1lc3NhZ2U6AjgB", - "IkEKEVRlc3RNYXBTdWJtZXNzYWdlEiwKCHRlc3RfbWFwGAEgASgLMhoucHJv", - "dG9idWZfdW5pdHRlc3QuVGVzdE1hcCK8AQoOVGVzdE1lc3NhZ2VNYXASUQoR", - "bWFwX2ludDMyX21lc3NhZ2UYASADKAsyNi5wcm90b2J1Zl91bml0dGVzdC5U", - "ZXN0TWVzc2FnZU1hcC5NYXBJbnQzMk1lc3NhZ2VFbnRyeRpXChRNYXBJbnQz", - "Mk1lc3NhZ2VFbnRyeRILCgNrZXkYASABKAUSLgoFdmFsdWUYAiABKAsyHy5w", - "cm90b2J1Zl91bml0dGVzdC5UZXN0QWxsVHlwZXM6AjgBIuMBCg9UZXN0U2Ft", - "ZVR5cGVNYXASOgoEbWFwMRgBIAMoCzIsLnByb3RvYnVmX3VuaXR0ZXN0LlRl", - "c3RTYW1lVHlwZU1hcC5NYXAxRW50cnkSOgoEbWFwMhgCIAMoCzIsLnByb3Rv", - "YnVmX3VuaXR0ZXN0LlRlc3RTYW1lVHlwZU1hcC5NYXAyRW50cnkaKwoJTWFw", - "MUVudHJ5EgsKA2tleRgBIAEoBRINCgV2YWx1ZRgCIAEoBToCOAEaKwoJTWFw", - "MkVudHJ5EgsKA2tleRgBIAEoBRINCgV2YWx1ZRgCIAEoBToCOAEi5BAKDFRl", - "c3RBcmVuYU1hcBJLCg9tYXBfaW50MzJfaW50MzIYASADKAsyMi5wcm90b2J1", - "Zl91bml0dGVzdC5UZXN0QXJlbmFNYXAuTWFwSW50MzJJbnQzMkVudHJ5EksK", - "D21hcF9pbnQ2NF9pbnQ2NBgCIAMoCzIyLnByb3RvYnVmX3VuaXR0ZXN0LlRl", - "c3RBcmVuYU1hcC5NYXBJbnQ2NEludDY0RW50cnkSTwoRbWFwX3VpbnQzMl91", - "aW50MzIYAyADKAsyNC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QXJlbmFNYXAu", - "TWFwVWludDMyVWludDMyRW50cnkSTwoRbWFwX3VpbnQ2NF91aW50NjQYBCAD", - "KAsyNC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QXJlbmFNYXAuTWFwVWludDY0", - "VWludDY0RW50cnkSTwoRbWFwX3NpbnQzMl9zaW50MzIYBSADKAsyNC5wcm90", - "b2J1Zl91bml0dGVzdC5UZXN0QXJlbmFNYXAuTWFwU2ludDMyU2ludDMyRW50", - "cnkSTwoRbWFwX3NpbnQ2NF9zaW50NjQYBiADKAsyNC5wcm90b2J1Zl91bml0", - "dGVzdC5UZXN0QXJlbmFNYXAuTWFwU2ludDY0U2ludDY0RW50cnkSUwoTbWFw", - "X2ZpeGVkMzJfZml4ZWQzMhgHIAMoCzI2LnByb3RvYnVmX3VuaXR0ZXN0LlRl", - "c3RBcmVuYU1hcC5NYXBGaXhlZDMyRml4ZWQzMkVudHJ5ElMKE21hcF9maXhl", - "ZDY0X2ZpeGVkNjQYCCADKAsyNi5wcm90b2J1Zl91bml0dGVzdC5UZXN0QXJl", - "bmFNYXAuTWFwRml4ZWQ2NEZpeGVkNjRFbnRyeRJXChVtYXBfc2ZpeGVkMzJf", - "c2ZpeGVkMzIYCSADKAsyOC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QXJlbmFN", - "YXAuTWFwU2ZpeGVkMzJTZml4ZWQzMkVudHJ5ElcKFW1hcF9zZml4ZWQ2NF9z", - "Zml4ZWQ2NBgKIAMoCzI4LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBcmVuYU1h", - "cC5NYXBTZml4ZWQ2NFNmaXhlZDY0RW50cnkSSwoPbWFwX2ludDMyX2Zsb2F0", - "GAsgAygLMjIucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFyZW5hTWFwLk1hcElu", - "dDMyRmxvYXRFbnRyeRJNChBtYXBfaW50MzJfZG91YmxlGAwgAygLMjMucHJv", - "dG9idWZfdW5pdHRlc3QuVGVzdEFyZW5hTWFwLk1hcEludDMyRG91YmxlRW50", - "cnkSRwoNbWFwX2Jvb2xfYm9vbBgNIAMoCzIwLnByb3RvYnVmX3VuaXR0ZXN0", - "LlRlc3RBcmVuYU1hcC5NYXBCb29sQm9vbEVudHJ5EkkKDm1hcF9pbnQzMl9l", - "bnVtGA4gAygLMjEucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFyZW5hTWFwLk1h", - "cEludDMyRW51bUVudHJ5El4KGW1hcF9pbnQzMl9mb3JlaWduX21lc3NhZ2UY", - "DyADKAsyOy5wcm90b2J1Zl91bml0dGVzdC5UZXN0QXJlbmFNYXAuTWFwSW50", - "MzJGb3JlaWduTWVzc2FnZUVudHJ5GjQKEk1hcEludDMySW50MzJFbnRyeRIL", - "CgNrZXkYASABKAUSDQoFdmFsdWUYAiABKAU6AjgBGjQKEk1hcEludDY0SW50", - "NjRFbnRyeRILCgNrZXkYASABKAMSDQoFdmFsdWUYAiABKAM6AjgBGjYKFE1h", - "cFVpbnQzMlVpbnQzMkVudHJ5EgsKA2tleRgBIAEoDRINCgV2YWx1ZRgCIAEo", - "DToCOAEaNgoUTWFwVWludDY0VWludDY0RW50cnkSCwoDa2V5GAEgASgEEg0K", - "BXZhbHVlGAIgASgEOgI4ARo2ChRNYXBTaW50MzJTaW50MzJFbnRyeRILCgNr", - "ZXkYASABKBESDQoFdmFsdWUYAiABKBE6AjgBGjYKFE1hcFNpbnQ2NFNpbnQ2", - "NEVudHJ5EgsKA2tleRgBIAEoEhINCgV2YWx1ZRgCIAEoEjoCOAEaOAoWTWFw", - "Rml4ZWQzMkZpeGVkMzJFbnRyeRILCgNrZXkYASABKAcSDQoFdmFsdWUYAiAB", - "KAc6AjgBGjgKFk1hcEZpeGVkNjRGaXhlZDY0RW50cnkSCwoDa2V5GAEgASgG", - "Eg0KBXZhbHVlGAIgASgGOgI4ARo6ChhNYXBTZml4ZWQzMlNmaXhlZDMyRW50", - "cnkSCwoDa2V5GAEgASgPEg0KBXZhbHVlGAIgASgPOgI4ARo6ChhNYXBTZml4", - "ZWQ2NFNmaXhlZDY0RW50cnkSCwoDa2V5GAEgASgQEg0KBXZhbHVlGAIgASgQ", - "OgI4ARo0ChJNYXBJbnQzMkZsb2F0RW50cnkSCwoDa2V5GAEgASgFEg0KBXZh", - "bHVlGAIgASgCOgI4ARo1ChNNYXBJbnQzMkRvdWJsZUVudHJ5EgsKA2tleRgB", - "IAEoBRINCgV2YWx1ZRgCIAEoAToCOAEaMgoQTWFwQm9vbEJvb2xFbnRyeRIL", - "CgNrZXkYASABKAgSDQoFdmFsdWUYAiABKAg6AjgBGk8KEU1hcEludDMyRW51", - "bUVudHJ5EgsKA2tleRgBIAEoBRIpCgV2YWx1ZRgCIAEoDjIaLnByb3RvYnVm", - "X3VuaXR0ZXN0Lk1hcEVudW06AjgBGmAKG01hcEludDMyRm9yZWlnbk1lc3Nh", - "Z2VFbnRyeRILCgNrZXkYASABKAUSMAoFdmFsdWUYAiABKAsyIS5wcm90b2J1", - "Zl91bml0dGVzdC5Gb3JlaWduTWVzc2FnZToCOAEi5AEKH01lc3NhZ2VDb250", - "YWluaW5nRW51bUNhbGxlZFR5cGUSSgoEdHlwZRgBIAMoCzI8LnByb3RvYnVm", - "X3VuaXR0ZXN0Lk1lc3NhZ2VDb250YWluaW5nRW51bUNhbGxlZFR5cGUuVHlw", - "ZUVudHJ5Gl8KCVR5cGVFbnRyeRILCgNrZXkYASABKAUSQQoFdmFsdWUYAiAB", - "KAsyMi5wcm90b2J1Zl91bml0dGVzdC5NZXNzYWdlQ29udGFpbmluZ0VudW1D", - "YWxsZWRUeXBlOgI4ASIUCgRUeXBlEgwKCFRZUEVfRk9PEAAinQEKH01lc3Nh", - "Z2VDb250YWluaW5nTWFwQ2FsbGVkRW50cnkSTAoFZW50cnkYASADKAsyPS5w", - "cm90b2J1Zl91bml0dGVzdC5NZXNzYWdlQ29udGFpbmluZ01hcENhbGxlZEVu", - "dHJ5LkVudHJ5RW50cnkaLAoKRW50cnlFbnRyeRILCgNrZXkYASABKAUSDQoF", - "dmFsdWUYAiABKAU6AjgBKj8KB01hcEVudW0SEAoMTUFQX0VOVU1fRk9PEAAS", - "EAoMTUFQX0VOVU1fQkFSEAESEAoMTUFQX0VOVU1fQkFaEAJCIPgBAaoCGkdv", - "b2dsZS5Qcm90b2J1Zi5UZXN0UHJvdG9zYgZwcm90bzM=")); + "ChltYXBfdW5pdHRlc3RfcHJvdG8zLnByb3RvEhJwcm90b2J1Zl91bml0dGVz", + "dDMaFXVuaXR0ZXN0X3Byb3RvMy5wcm90byKpEgoHVGVzdE1hcBJHCg9tYXBf", + "aW50MzJfaW50MzIYASADKAsyLi5wcm90b2J1Zl91bml0dGVzdDMuVGVzdE1h", + "cC5NYXBJbnQzMkludDMyRW50cnkSRwoPbWFwX2ludDY0X2ludDY0GAIgAygL", + "Mi4ucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RNYXAuTWFwSW50NjRJbnQ2NEVu", + "dHJ5EksKEW1hcF91aW50MzJfdWludDMyGAMgAygLMjAucHJvdG9idWZfdW5p", + "dHRlc3QzLlRlc3RNYXAuTWFwVWludDMyVWludDMyRW50cnkSSwoRbWFwX3Vp", + "bnQ2NF91aW50NjQYBCADKAsyMC5wcm90b2J1Zl91bml0dGVzdDMuVGVzdE1h", + "cC5NYXBVaW50NjRVaW50NjRFbnRyeRJLChFtYXBfc2ludDMyX3NpbnQzMhgF", + "IAMoCzIwLnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0TWFwLk1hcFNpbnQzMlNp", + "bnQzMkVudHJ5EksKEW1hcF9zaW50NjRfc2ludDY0GAYgAygLMjAucHJvdG9i", + "dWZfdW5pdHRlc3QzLlRlc3RNYXAuTWFwU2ludDY0U2ludDY0RW50cnkSTwoT", + "bWFwX2ZpeGVkMzJfZml4ZWQzMhgHIAMoCzIyLnByb3RvYnVmX3VuaXR0ZXN0", + "My5UZXN0TWFwLk1hcEZpeGVkMzJGaXhlZDMyRW50cnkSTwoTbWFwX2ZpeGVk", + "NjRfZml4ZWQ2NBgIIAMoCzIyLnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0TWFw", + "Lk1hcEZpeGVkNjRGaXhlZDY0RW50cnkSUwoVbWFwX3NmaXhlZDMyX3NmaXhl", + "ZDMyGAkgAygLMjQucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RNYXAuTWFwU2Zp", + "eGVkMzJTZml4ZWQzMkVudHJ5ElMKFW1hcF9zZml4ZWQ2NF9zZml4ZWQ2NBgK", + "IAMoCzI0LnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0TWFwLk1hcFNmaXhlZDY0", + "U2ZpeGVkNjRFbnRyeRJHCg9tYXBfaW50MzJfZmxvYXQYCyADKAsyLi5wcm90", + "b2J1Zl91bml0dGVzdDMuVGVzdE1hcC5NYXBJbnQzMkZsb2F0RW50cnkSSQoQ", + "bWFwX2ludDMyX2RvdWJsZRgMIAMoCzIvLnByb3RvYnVmX3VuaXR0ZXN0My5U", + "ZXN0TWFwLk1hcEludDMyRG91YmxlRW50cnkSQwoNbWFwX2Jvb2xfYm9vbBgN", + "IAMoCzIsLnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0TWFwLk1hcEJvb2xCb29s", + "RW50cnkSSwoRbWFwX3N0cmluZ19zdHJpbmcYDiADKAsyMC5wcm90b2J1Zl91", + "bml0dGVzdDMuVGVzdE1hcC5NYXBTdHJpbmdTdHJpbmdFbnRyeRJHCg9tYXBf", + "aW50MzJfYnl0ZXMYDyADKAsyLi5wcm90b2J1Zl91bml0dGVzdDMuVGVzdE1h", + "cC5NYXBJbnQzMkJ5dGVzRW50cnkSRQoObWFwX2ludDMyX2VudW0YECADKAsy", + "LS5wcm90b2J1Zl91bml0dGVzdDMuVGVzdE1hcC5NYXBJbnQzMkVudW1FbnRy", + "eRJaChltYXBfaW50MzJfZm9yZWlnbl9tZXNzYWdlGBEgAygLMjcucHJvdG9i", + "dWZfdW5pdHRlc3QzLlRlc3RNYXAuTWFwSW50MzJGb3JlaWduTWVzc2FnZUVu", + "dHJ5GjQKEk1hcEludDMySW50MzJFbnRyeRILCgNrZXkYASABKAUSDQoFdmFs", + "dWUYAiABKAU6AjgBGjQKEk1hcEludDY0SW50NjRFbnRyeRILCgNrZXkYASAB", + "KAMSDQoFdmFsdWUYAiABKAM6AjgBGjYKFE1hcFVpbnQzMlVpbnQzMkVudHJ5", + "EgsKA2tleRgBIAEoDRINCgV2YWx1ZRgCIAEoDToCOAEaNgoUTWFwVWludDY0", + "VWludDY0RW50cnkSCwoDa2V5GAEgASgEEg0KBXZhbHVlGAIgASgEOgI4ARo2", + "ChRNYXBTaW50MzJTaW50MzJFbnRyeRILCgNrZXkYASABKBESDQoFdmFsdWUY", + "AiABKBE6AjgBGjYKFE1hcFNpbnQ2NFNpbnQ2NEVudHJ5EgsKA2tleRgBIAEo", + "EhINCgV2YWx1ZRgCIAEoEjoCOAEaOAoWTWFwRml4ZWQzMkZpeGVkMzJFbnRy", + "eRILCgNrZXkYASABKAcSDQoFdmFsdWUYAiABKAc6AjgBGjgKFk1hcEZpeGVk", + "NjRGaXhlZDY0RW50cnkSCwoDa2V5GAEgASgGEg0KBXZhbHVlGAIgASgGOgI4", + "ARo6ChhNYXBTZml4ZWQzMlNmaXhlZDMyRW50cnkSCwoDa2V5GAEgASgPEg0K", + "BXZhbHVlGAIgASgPOgI4ARo6ChhNYXBTZml4ZWQ2NFNmaXhlZDY0RW50cnkS", + "CwoDa2V5GAEgASgQEg0KBXZhbHVlGAIgASgQOgI4ARo0ChJNYXBJbnQzMkZs", + "b2F0RW50cnkSCwoDa2V5GAEgASgFEg0KBXZhbHVlGAIgASgCOgI4ARo1ChNN", + "YXBJbnQzMkRvdWJsZUVudHJ5EgsKA2tleRgBIAEoBRINCgV2YWx1ZRgCIAEo", + "AToCOAEaMgoQTWFwQm9vbEJvb2xFbnRyeRILCgNrZXkYASABKAgSDQoFdmFs", + "dWUYAiABKAg6AjgBGjYKFE1hcFN0cmluZ1N0cmluZ0VudHJ5EgsKA2tleRgB", + "IAEoCRINCgV2YWx1ZRgCIAEoCToCOAEaNAoSTWFwSW50MzJCeXRlc0VudHJ5", + "EgsKA2tleRgBIAEoBRINCgV2YWx1ZRgCIAEoDDoCOAEaUAoRTWFwSW50MzJF", + "bnVtRW50cnkSCwoDa2V5GAEgASgFEioKBXZhbHVlGAIgASgOMhsucHJvdG9i", + "dWZfdW5pdHRlc3QzLk1hcEVudW06AjgBGmEKG01hcEludDMyRm9yZWlnbk1l", + "c3NhZ2VFbnRyeRILCgNrZXkYASABKAUSMQoFdmFsdWUYAiABKAsyIi5wcm90", + "b2J1Zl91bml0dGVzdDMuRm9yZWlnbk1lc3NhZ2U6AjgBIkIKEVRlc3RNYXBT", + "dWJtZXNzYWdlEi0KCHRlc3RfbWFwGAEgASgLMhsucHJvdG9idWZfdW5pdHRl", + "c3QzLlRlc3RNYXAivgEKDlRlc3RNZXNzYWdlTWFwElIKEW1hcF9pbnQzMl9t", + "ZXNzYWdlGAEgAygLMjcucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RNZXNzYWdl", + "TWFwLk1hcEludDMyTWVzc2FnZUVudHJ5GlgKFE1hcEludDMyTWVzc2FnZUVu", + "dHJ5EgsKA2tleRgBIAEoBRIvCgV2YWx1ZRgCIAEoCzIgLnByb3RvYnVmX3Vu", + "aXR0ZXN0My5UZXN0QWxsVHlwZXM6AjgBIuUBCg9UZXN0U2FtZVR5cGVNYXAS", + "OwoEbWFwMRgBIAMoCzItLnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0U2FtZVR5", + "cGVNYXAuTWFwMUVudHJ5EjsKBG1hcDIYAiADKAsyLS5wcm90b2J1Zl91bml0", + "dGVzdDMuVGVzdFNhbWVUeXBlTWFwLk1hcDJFbnRyeRorCglNYXAxRW50cnkS", + "CwoDa2V5GAEgASgFEg0KBXZhbHVlGAIgASgFOgI4ARorCglNYXAyRW50cnkS", + "CwoDa2V5GAEgASgFEg0KBXZhbHVlGAIgASgFOgI4ASL1EAoMVGVzdEFyZW5h", + "TWFwEkwKD21hcF9pbnQzMl9pbnQzMhgBIAMoCzIzLnByb3RvYnVmX3VuaXR0", + "ZXN0My5UZXN0QXJlbmFNYXAuTWFwSW50MzJJbnQzMkVudHJ5EkwKD21hcF9p", + "bnQ2NF9pbnQ2NBgCIAMoCzIzLnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0QXJl", + "bmFNYXAuTWFwSW50NjRJbnQ2NEVudHJ5ElAKEW1hcF91aW50MzJfdWludDMy", + "GAMgAygLMjUucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RBcmVuYU1hcC5NYXBV", + "aW50MzJVaW50MzJFbnRyeRJQChFtYXBfdWludDY0X3VpbnQ2NBgEIAMoCzI1", + "LnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0QXJlbmFNYXAuTWFwVWludDY0VWlu", + "dDY0RW50cnkSUAoRbWFwX3NpbnQzMl9zaW50MzIYBSADKAsyNS5wcm90b2J1", + "Zl91bml0dGVzdDMuVGVzdEFyZW5hTWFwLk1hcFNpbnQzMlNpbnQzMkVudHJ5", + "ElAKEW1hcF9zaW50NjRfc2ludDY0GAYgAygLMjUucHJvdG9idWZfdW5pdHRl", + "c3QzLlRlc3RBcmVuYU1hcC5NYXBTaW50NjRTaW50NjRFbnRyeRJUChNtYXBf", + "Zml4ZWQzMl9maXhlZDMyGAcgAygLMjcucHJvdG9idWZfdW5pdHRlc3QzLlRl", + "c3RBcmVuYU1hcC5NYXBGaXhlZDMyRml4ZWQzMkVudHJ5ElQKE21hcF9maXhl", + "ZDY0X2ZpeGVkNjQYCCADKAsyNy5wcm90b2J1Zl91bml0dGVzdDMuVGVzdEFy", + "ZW5hTWFwLk1hcEZpeGVkNjRGaXhlZDY0RW50cnkSWAoVbWFwX3NmaXhlZDMy", + "X3NmaXhlZDMyGAkgAygLMjkucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RBcmVu", + "YU1hcC5NYXBTZml4ZWQzMlNmaXhlZDMyRW50cnkSWAoVbWFwX3NmaXhlZDY0", + "X3NmaXhlZDY0GAogAygLMjkucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RBcmVu", + "YU1hcC5NYXBTZml4ZWQ2NFNmaXhlZDY0RW50cnkSTAoPbWFwX2ludDMyX2Zs", + "b2F0GAsgAygLMjMucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RBcmVuYU1hcC5N", + "YXBJbnQzMkZsb2F0RW50cnkSTgoQbWFwX2ludDMyX2RvdWJsZRgMIAMoCzI0", + "LnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0QXJlbmFNYXAuTWFwSW50MzJEb3Vi", + "bGVFbnRyeRJICg1tYXBfYm9vbF9ib29sGA0gAygLMjEucHJvdG9idWZfdW5p", + "dHRlc3QzLlRlc3RBcmVuYU1hcC5NYXBCb29sQm9vbEVudHJ5EkoKDm1hcF9p", + "bnQzMl9lbnVtGA4gAygLMjIucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RBcmVu", + "YU1hcC5NYXBJbnQzMkVudW1FbnRyeRJfChltYXBfaW50MzJfZm9yZWlnbl9t", + "ZXNzYWdlGA8gAygLMjwucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RBcmVuYU1h", + "cC5NYXBJbnQzMkZvcmVpZ25NZXNzYWdlRW50cnkaNAoSTWFwSW50MzJJbnQz", + "MkVudHJ5EgsKA2tleRgBIAEoBRINCgV2YWx1ZRgCIAEoBToCOAEaNAoSTWFw", + "SW50NjRJbnQ2NEVudHJ5EgsKA2tleRgBIAEoAxINCgV2YWx1ZRgCIAEoAzoC", + "OAEaNgoUTWFwVWludDMyVWludDMyRW50cnkSCwoDa2V5GAEgASgNEg0KBXZh", + "bHVlGAIgASgNOgI4ARo2ChRNYXBVaW50NjRVaW50NjRFbnRyeRILCgNrZXkY", + "ASABKAQSDQoFdmFsdWUYAiABKAQ6AjgBGjYKFE1hcFNpbnQzMlNpbnQzMkVu", + "dHJ5EgsKA2tleRgBIAEoERINCgV2YWx1ZRgCIAEoEToCOAEaNgoUTWFwU2lu", + "dDY0U2ludDY0RW50cnkSCwoDa2V5GAEgASgSEg0KBXZhbHVlGAIgASgSOgI4", + "ARo4ChZNYXBGaXhlZDMyRml4ZWQzMkVudHJ5EgsKA2tleRgBIAEoBxINCgV2", + "YWx1ZRgCIAEoBzoCOAEaOAoWTWFwRml4ZWQ2NEZpeGVkNjRFbnRyeRILCgNr", + "ZXkYASABKAYSDQoFdmFsdWUYAiABKAY6AjgBGjoKGE1hcFNmaXhlZDMyU2Zp", + "eGVkMzJFbnRyeRILCgNrZXkYASABKA8SDQoFdmFsdWUYAiABKA86AjgBGjoK", + "GE1hcFNmaXhlZDY0U2ZpeGVkNjRFbnRyeRILCgNrZXkYASABKBASDQoFdmFs", + "dWUYAiABKBA6AjgBGjQKEk1hcEludDMyRmxvYXRFbnRyeRILCgNrZXkYASAB", + "KAUSDQoFdmFsdWUYAiABKAI6AjgBGjUKE01hcEludDMyRG91YmxlRW50cnkS", + "CwoDa2V5GAEgASgFEg0KBXZhbHVlGAIgASgBOgI4ARoyChBNYXBCb29sQm9v", + "bEVudHJ5EgsKA2tleRgBIAEoCBINCgV2YWx1ZRgCIAEoCDoCOAEaUAoRTWFw", + "SW50MzJFbnVtRW50cnkSCwoDa2V5GAEgASgFEioKBXZhbHVlGAIgASgOMhsu", + "cHJvdG9idWZfdW5pdHRlc3QzLk1hcEVudW06AjgBGmEKG01hcEludDMyRm9y", + "ZWlnbk1lc3NhZ2VFbnRyeRILCgNrZXkYASABKAUSMQoFdmFsdWUYAiABKAsy", + "Ii5wcm90b2J1Zl91bml0dGVzdDMuRm9yZWlnbk1lc3NhZ2U6AjgBIuYBCh9N", + "ZXNzYWdlQ29udGFpbmluZ0VudW1DYWxsZWRUeXBlEksKBHR5cGUYASADKAsy", + "PS5wcm90b2J1Zl91bml0dGVzdDMuTWVzc2FnZUNvbnRhaW5pbmdFbnVtQ2Fs", + "bGVkVHlwZS5UeXBlRW50cnkaYAoJVHlwZUVudHJ5EgsKA2tleRgBIAEoBRJC", + "CgV2YWx1ZRgCIAEoCzIzLnByb3RvYnVmX3VuaXR0ZXN0My5NZXNzYWdlQ29u", + "dGFpbmluZ0VudW1DYWxsZWRUeXBlOgI4ASIUCgRUeXBlEgwKCFRZUEVfRk9P", + "EAAingEKH01lc3NhZ2VDb250YWluaW5nTWFwQ2FsbGVkRW50cnkSTQoFZW50", + "cnkYASADKAsyPi5wcm90b2J1Zl91bml0dGVzdDMuTWVzc2FnZUNvbnRhaW5p", + "bmdNYXBDYWxsZWRFbnRyeS5FbnRyeUVudHJ5GiwKCkVudHJ5RW50cnkSCwoD", + "a2V5GAEgASgFEg0KBXZhbHVlGAIgASgFOgI4ASo/CgdNYXBFbnVtEhAKDE1B", + "UF9FTlVNX0ZPTxAAEhAKDE1BUF9FTlVNX0JBUhABEhAKDE1BUF9FTlVNX0JB", + "WhACQh2qAhpHb29nbGUuUHJvdG9idWYuVGVzdFByb3Rvc2IGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor, }, - new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.TestProtos.MapEnum), }, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestMap), global::Google.Protobuf.TestProtos.TestMap.Parser, new[]{ "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapStringString", "MapInt32Bytes", "MapInt32Enum", "MapInt32ForeignMessage" }, null, null, new pbr::GeneratedClrTypeInfo[] { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, }), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestMapSubmessage), global::Google.Protobuf.TestProtos.TestMapSubmessage.Parser, new[]{ "TestMap" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestMessageMap), global::Google.Protobuf.TestProtos.TestMessageMap.Parser, new[]{ "MapInt32Message" }, null, null, new pbr::GeneratedClrTypeInfo[] { null, }), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestSameTypeMap), global::Google.Protobuf.TestProtos.TestSameTypeMap.Parser, new[]{ "Map1", "Map2" }, null, null, new pbr::GeneratedClrTypeInfo[] { null, null, }), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestArenaMap), global::Google.Protobuf.TestProtos.TestArenaMap.Parser, new[]{ "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapInt32Enum", "MapInt32ForeignMessage" }, null, null, new pbr::GeneratedClrTypeInfo[] { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, }), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType), global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType.Parser, new[]{ "Type" }, null, new[]{ typeof(global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType.Types.Type) }, new pbr::GeneratedClrTypeInfo[] { null, }), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.MessageContainingMapCalledEntry), global::Google.Protobuf.TestProtos.MessageContainingMapCalledEntry.Parser, new[]{ "Entry" }, null, null, new pbr::GeneratedClrTypeInfo[] { null, }) + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.TestProtos.MapEnum), }, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestMap), global::Google.Protobuf.TestProtos.TestMap.Parser, new[]{ "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapStringString", "MapInt32Bytes", "MapInt32Enum", "MapInt32ForeignMessage" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, }), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestMapSubmessage), global::Google.Protobuf.TestProtos.TestMapSubmessage.Parser, new[]{ "TestMap" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestMessageMap), global::Google.Protobuf.TestProtos.TestMessageMap.Parser, new[]{ "MapInt32Message" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { null, }), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestSameTypeMap), global::Google.Protobuf.TestProtos.TestSameTypeMap.Parser, new[]{ "Map1", "Map2" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { null, null, }), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestArenaMap), global::Google.Protobuf.TestProtos.TestArenaMap.Parser, new[]{ "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapInt32Enum", "MapInt32ForeignMessage" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, }), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType), global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType.Parser, new[]{ "Type" }, null, new[]{ typeof(global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType.Types.Type) }, null, new pbr::GeneratedClrTypeInfo[] { null, }), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.MessageContainingMapCalledEntry), global::Google.Protobuf.TestProtos.MessageContainingMapCalledEntry.Parser, new[]{ "Entry" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { null, }) })); } #endregion @@ -173,27 +174,32 @@ public enum MapEnum { #region Messages /// - /// Tests maps. + /// Tests maps. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestMap : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMap()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3Reflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMap() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMap(TestMap other) : this() { mapInt32Int32_ = other.mapInt32Int32_.Clone(); mapInt64Int64_ = other.mapInt64Int64_.Clone(); @@ -212,8 +218,10 @@ public TestMap(TestMap other) : this() { mapInt32Bytes_ = other.mapInt32Bytes_.Clone(); mapInt32Enum_ = other.mapInt32Enum_.Clone(); mapInt32ForeignMessage_ = other.mapInt32ForeignMessage_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMap Clone() { return new TestMap(this); } @@ -221,8 +229,9 @@ public TestMap Clone() { /// Field number for the "map_int32_int32" field. public const int MapInt32Int32FieldNumber = 1; private static readonly pbc::MapField.Codec _map_mapInt32Int32_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForInt32(16), 10); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForInt32(16, 0), 10); private readonly pbc::MapField mapInt32Int32_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapInt32Int32 { get { return mapInt32Int32_; } } @@ -230,8 +239,9 @@ public TestMap Clone() { /// Field number for the "map_int64_int64" field. public const int MapInt64Int64FieldNumber = 2; private static readonly pbc::MapField.Codec _map_mapInt64Int64_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt64(8), pb::FieldCodec.ForInt64(16), 18); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt64(8, 0L), pb::FieldCodec.ForInt64(16, 0L), 18); private readonly pbc::MapField mapInt64Int64_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapInt64Int64 { get { return mapInt64Int64_; } } @@ -239,8 +249,9 @@ public TestMap Clone() { /// Field number for the "map_uint32_uint32" field. public const int MapUint32Uint32FieldNumber = 3; private static readonly pbc::MapField.Codec _map_mapUint32Uint32_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForUInt32(8), pb::FieldCodec.ForUInt32(16), 26); + = new pbc::MapField.Codec(pb::FieldCodec.ForUInt32(8, 0), pb::FieldCodec.ForUInt32(16, 0), 26); private readonly pbc::MapField mapUint32Uint32_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapUint32Uint32 { get { return mapUint32Uint32_; } } @@ -248,8 +259,9 @@ public TestMap Clone() { /// Field number for the "map_uint64_uint64" field. public const int MapUint64Uint64FieldNumber = 4; private static readonly pbc::MapField.Codec _map_mapUint64Uint64_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForUInt64(8), pb::FieldCodec.ForUInt64(16), 34); + = new pbc::MapField.Codec(pb::FieldCodec.ForUInt64(8, 0UL), pb::FieldCodec.ForUInt64(16, 0UL), 34); private readonly pbc::MapField mapUint64Uint64_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapUint64Uint64 { get { return mapUint64Uint64_; } } @@ -257,8 +269,9 @@ public TestMap Clone() { /// Field number for the "map_sint32_sint32" field. public const int MapSint32Sint32FieldNumber = 5; private static readonly pbc::MapField.Codec _map_mapSint32Sint32_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForSInt32(8), pb::FieldCodec.ForSInt32(16), 42); + = new pbc::MapField.Codec(pb::FieldCodec.ForSInt32(8, 0), pb::FieldCodec.ForSInt32(16, 0), 42); private readonly pbc::MapField mapSint32Sint32_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapSint32Sint32 { get { return mapSint32Sint32_; } } @@ -266,8 +279,9 @@ public TestMap Clone() { /// Field number for the "map_sint64_sint64" field. public const int MapSint64Sint64FieldNumber = 6; private static readonly pbc::MapField.Codec _map_mapSint64Sint64_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForSInt64(8), pb::FieldCodec.ForSInt64(16), 50); + = new pbc::MapField.Codec(pb::FieldCodec.ForSInt64(8, 0L), pb::FieldCodec.ForSInt64(16, 0L), 50); private readonly pbc::MapField mapSint64Sint64_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapSint64Sint64 { get { return mapSint64Sint64_; } } @@ -275,8 +289,9 @@ public TestMap Clone() { /// Field number for the "map_fixed32_fixed32" field. public const int MapFixed32Fixed32FieldNumber = 7; private static readonly pbc::MapField.Codec _map_mapFixed32Fixed32_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForFixed32(13), pb::FieldCodec.ForFixed32(21), 58); + = new pbc::MapField.Codec(pb::FieldCodec.ForFixed32(13, 0), pb::FieldCodec.ForFixed32(21, 0), 58); private readonly pbc::MapField mapFixed32Fixed32_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapFixed32Fixed32 { get { return mapFixed32Fixed32_; } } @@ -284,8 +299,9 @@ public TestMap Clone() { /// Field number for the "map_fixed64_fixed64" field. public const int MapFixed64Fixed64FieldNumber = 8; private static readonly pbc::MapField.Codec _map_mapFixed64Fixed64_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForFixed64(9), pb::FieldCodec.ForFixed64(17), 66); + = new pbc::MapField.Codec(pb::FieldCodec.ForFixed64(9, 0UL), pb::FieldCodec.ForFixed64(17, 0UL), 66); private readonly pbc::MapField mapFixed64Fixed64_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapFixed64Fixed64 { get { return mapFixed64Fixed64_; } } @@ -293,8 +309,9 @@ public TestMap Clone() { /// Field number for the "map_sfixed32_sfixed32" field. public const int MapSfixed32Sfixed32FieldNumber = 9; private static readonly pbc::MapField.Codec _map_mapSfixed32Sfixed32_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForSFixed32(13), pb::FieldCodec.ForSFixed32(21), 74); + = new pbc::MapField.Codec(pb::FieldCodec.ForSFixed32(13, 0), pb::FieldCodec.ForSFixed32(21, 0), 74); private readonly pbc::MapField mapSfixed32Sfixed32_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapSfixed32Sfixed32 { get { return mapSfixed32Sfixed32_; } } @@ -302,8 +319,9 @@ public TestMap Clone() { /// Field number for the "map_sfixed64_sfixed64" field. public const int MapSfixed64Sfixed64FieldNumber = 10; private static readonly pbc::MapField.Codec _map_mapSfixed64Sfixed64_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForSFixed64(9), pb::FieldCodec.ForSFixed64(17), 82); + = new pbc::MapField.Codec(pb::FieldCodec.ForSFixed64(9, 0L), pb::FieldCodec.ForSFixed64(17, 0L), 82); private readonly pbc::MapField mapSfixed64Sfixed64_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapSfixed64Sfixed64 { get { return mapSfixed64Sfixed64_; } } @@ -311,8 +329,9 @@ public TestMap Clone() { /// Field number for the "map_int32_float" field. public const int MapInt32FloatFieldNumber = 11; private static readonly pbc::MapField.Codec _map_mapInt32Float_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForFloat(21), 90); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForFloat(21, 0F), 90); private readonly pbc::MapField mapInt32Float_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapInt32Float { get { return mapInt32Float_; } } @@ -320,8 +339,9 @@ public TestMap Clone() { /// Field number for the "map_int32_double" field. public const int MapInt32DoubleFieldNumber = 12; private static readonly pbc::MapField.Codec _map_mapInt32Double_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForDouble(17), 98); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForDouble(17, 0D), 98); private readonly pbc::MapField mapInt32Double_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapInt32Double { get { return mapInt32Double_; } } @@ -329,8 +349,9 @@ public TestMap Clone() { /// Field number for the "map_bool_bool" field. public const int MapBoolBoolFieldNumber = 13; private static readonly pbc::MapField.Codec _map_mapBoolBool_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForBool(8), pb::FieldCodec.ForBool(16), 106); + = new pbc::MapField.Codec(pb::FieldCodec.ForBool(8, false), pb::FieldCodec.ForBool(16, false), 106); private readonly pbc::MapField mapBoolBool_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapBoolBool { get { return mapBoolBool_; } } @@ -338,8 +359,9 @@ public TestMap Clone() { /// Field number for the "map_string_string" field. public const int MapStringStringFieldNumber = 14; private static readonly pbc::MapField.Codec _map_mapStringString_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForString(18), 114); + = new pbc::MapField.Codec(pb::FieldCodec.ForString(10, ""), pb::FieldCodec.ForString(18, ""), 114); private readonly pbc::MapField mapStringString_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapStringString { get { return mapStringString_; } } @@ -347,8 +369,9 @@ public TestMap Clone() { /// Field number for the "map_int32_bytes" field. public const int MapInt32BytesFieldNumber = 15; private static readonly pbc::MapField.Codec _map_mapInt32Bytes_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForBytes(18), 122); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForBytes(18, pb::ByteString.Empty), 122); private readonly pbc::MapField mapInt32Bytes_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapInt32Bytes { get { return mapInt32Bytes_; } } @@ -356,8 +379,9 @@ public TestMap Clone() { /// Field number for the "map_int32_enum" field. public const int MapInt32EnumFieldNumber = 16; private static readonly pbc::MapField.Codec _map_mapInt32Enum_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::Google.Protobuf.TestProtos.MapEnum) x), 130); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::Google.Protobuf.TestProtos.MapEnum) x, global::Google.Protobuf.TestProtos.MapEnum.Foo), 130); private readonly pbc::MapField mapInt32Enum_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapInt32Enum { get { return mapInt32Enum_; } } @@ -365,16 +389,19 @@ public TestMap Clone() { /// Field number for the "map_int32_foreign_message" field. public const int MapInt32ForeignMessageFieldNumber = 17; private static readonly pbc::MapField.Codec _map_mapInt32ForeignMessage_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.TestProtos.ForeignMessage.Parser), 138); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.TestProtos.ForeignMessage.Parser), 138); private readonly pbc::MapField mapInt32ForeignMessage_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapInt32ForeignMessage { get { return mapInt32ForeignMessage_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestMap); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestMap other) { if (ReferenceEquals(other, null)) { return false; @@ -399,9 +426,10 @@ public bool Equals(TestMap other) { if (!MapInt32Bytes.Equals(other.MapInt32Bytes)) return false; if (!MapInt32Enum.Equals(other.MapInt32Enum)) return false; if (!MapInt32ForeignMessage.Equals(other.MapInt32ForeignMessage)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= MapInt32Int32.GetHashCode(); @@ -421,13 +449,18 @@ public override int GetHashCode() { hash ^= MapInt32Bytes.GetHashCode(); hash ^= MapInt32Enum.GetHashCode(); hash ^= MapInt32ForeignMessage.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { mapInt32Int32_.WriteTo(output, _map_mapInt32Int32_codec); mapInt64Int64_.WriteTo(output, _map_mapInt64Int64_codec); @@ -446,8 +479,12 @@ public void WriteTo(pb::CodedOutputStream output) { mapInt32Bytes_.WriteTo(output, _map_mapInt32Bytes_codec); mapInt32Enum_.WriteTo(output, _map_mapInt32Enum_codec); mapInt32ForeignMessage_.WriteTo(output, _map_mapInt32ForeignMessage_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += mapInt32Int32_.CalculateSize(_map_mapInt32Int32_codec); @@ -467,9 +504,13 @@ public int CalculateSize() { size += mapInt32Bytes_.CalculateSize(_map_mapInt32Bytes_codec); size += mapInt32Enum_.CalculateSize(_map_mapInt32Enum_codec); size += mapInt32ForeignMessage_.CalculateSize(_map_mapInt32ForeignMessage_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestMap other) { if (other == null) { return; @@ -491,14 +532,16 @@ public void MergeFrom(TestMap other) { mapInt32Bytes_.Add(other.mapInt32Bytes_); mapInt32Enum_.Add(other.mapInt32Enum_); mapInt32ForeignMessage_.Add(other.mapInt32ForeignMessage_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec); @@ -574,29 +617,36 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestMapSubmessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMapSubmessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3Reflection.Descriptor.MessageTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMapSubmessage() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMapSubmessage(TestMapSubmessage other) : this() { - TestMap = other.testMap_ != null ? other.TestMap.Clone() : null; + testMap_ = other.testMap_ != null ? other.testMap_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMapSubmessage Clone() { return new TestMapSubmessage(this); } @@ -604,6 +654,7 @@ public TestMapSubmessage Clone() { /// Field number for the "test_map" field. public const int TestMapFieldNumber = 1; private global::Google.Protobuf.TestProtos.TestMap testMap_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.TestMap TestMap { get { return testMap_; } set { @@ -611,10 +662,12 @@ public TestMapSubmessage Clone() { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestMapSubmessage); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestMapSubmessage other) { if (ReferenceEquals(other, null)) { return false; @@ -623,58 +676,74 @@ public bool Equals(TestMapSubmessage other) { return true; } if (!object.Equals(TestMap, other.TestMap)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (testMap_ != null) hash ^= TestMap.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (testMap_ != null) { output.WriteRawTag(10); output.WriteMessage(TestMap); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (testMap_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(TestMap); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestMapSubmessage other) { if (other == null) { return; } if (other.testMap_ != null) { if (testMap_ == null) { - testMap_ = new global::Google.Protobuf.TestProtos.TestMap(); + TestMap = new global::Google.Protobuf.TestProtos.TestMap(); } TestMap.MergeFrom(other.TestMap); } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { if (testMap_ == null) { - testMap_ = new global::Google.Protobuf.TestProtos.TestMap(); + TestMap = new global::Google.Protobuf.TestProtos.TestMap(); } - input.ReadMessage(testMap_); + input.ReadMessage(TestMap); break; } } @@ -683,29 +752,36 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestMessageMap : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMessageMap()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3Reflection.Descriptor.MessageTypes[2]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMessageMap() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMessageMap(TestMessageMap other) : this() { mapInt32Message_ = other.mapInt32Message_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMessageMap Clone() { return new TestMessageMap(this); } @@ -713,16 +789,19 @@ public TestMessageMap Clone() { /// Field number for the "map_int32_message" field. public const int MapInt32MessageFieldNumber = 1; private static readonly pbc::MapField.Codec _map_mapInt32Message_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.TestProtos.TestAllTypes.Parser), 10); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.TestProtos.TestAllTypes.Parser), 10); private readonly pbc::MapField mapInt32Message_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapInt32Message { get { return mapInt32Message_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestMessageMap); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestMessageMap other) { if (ReferenceEquals(other, null)) { return false; @@ -731,42 +810,58 @@ public bool Equals(TestMessageMap other) { return true; } if (!MapInt32Message.Equals(other.MapInt32Message)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= MapInt32Message.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { mapInt32Message_.WriteTo(output, _map_mapInt32Message_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += mapInt32Message_.CalculateSize(_map_mapInt32Message_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestMessageMap other) { if (other == null) { return; } mapInt32Message_.Add(other.mapInt32Message_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { mapInt32Message_.AddEntriesFrom(input, _map_mapInt32Message_codec); @@ -779,32 +874,39 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Two map fields share the same entry default instance. + /// Two map fields share the same entry default instance. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestSameTypeMap : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestSameTypeMap()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3Reflection.Descriptor.MessageTypes[3]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestSameTypeMap() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestSameTypeMap(TestSameTypeMap other) : this() { map1_ = other.map1_.Clone(); map2_ = other.map2_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestSameTypeMap Clone() { return new TestSameTypeMap(this); } @@ -812,8 +914,9 @@ public TestSameTypeMap Clone() { /// Field number for the "map1" field. public const int Map1FieldNumber = 1; private static readonly pbc::MapField.Codec _map_map1_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForInt32(16), 10); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForInt32(16, 0), 10); private readonly pbc::MapField map1_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField Map1 { get { return map1_; } } @@ -821,16 +924,19 @@ public TestSameTypeMap Clone() { /// Field number for the "map2" field. public const int Map2FieldNumber = 2; private static readonly pbc::MapField.Codec _map_map2_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForInt32(16), 18); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForInt32(16, 0), 18); private readonly pbc::MapField map2_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField Map2 { get { return map2_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestSameTypeMap); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestSameTypeMap other) { if (ReferenceEquals(other, null)) { return false; @@ -840,46 +946,62 @@ public bool Equals(TestSameTypeMap other) { } if (!Map1.Equals(other.Map1)) return false; if (!Map2.Equals(other.Map2)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= Map1.GetHashCode(); hash ^= Map2.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { map1_.WriteTo(output, _map_map1_codec); map2_.WriteTo(output, _map_map2_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += map1_.CalculateSize(_map_map1_codec); size += map2_.CalculateSize(_map_map2_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestSameTypeMap other) { if (other == null) { return; } map1_.Add(other.map1_); map2_.Add(other.map2_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { map1_.AddEntriesFrom(input, _map_map1_codec); @@ -895,25 +1017,30 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestArenaMap : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestArenaMap()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3Reflection.Descriptor.MessageTypes[4]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestArenaMap() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestArenaMap(TestArenaMap other) : this() { mapInt32Int32_ = other.mapInt32Int32_.Clone(); mapInt64Int64_ = other.mapInt64Int64_.Clone(); @@ -930,8 +1057,10 @@ public TestArenaMap(TestArenaMap other) : this() { mapBoolBool_ = other.mapBoolBool_.Clone(); mapInt32Enum_ = other.mapInt32Enum_.Clone(); mapInt32ForeignMessage_ = other.mapInt32ForeignMessage_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestArenaMap Clone() { return new TestArenaMap(this); } @@ -939,8 +1068,9 @@ public TestArenaMap Clone() { /// Field number for the "map_int32_int32" field. public const int MapInt32Int32FieldNumber = 1; private static readonly pbc::MapField.Codec _map_mapInt32Int32_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForInt32(16), 10); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForInt32(16, 0), 10); private readonly pbc::MapField mapInt32Int32_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapInt32Int32 { get { return mapInt32Int32_; } } @@ -948,8 +1078,9 @@ public TestArenaMap Clone() { /// Field number for the "map_int64_int64" field. public const int MapInt64Int64FieldNumber = 2; private static readonly pbc::MapField.Codec _map_mapInt64Int64_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt64(8), pb::FieldCodec.ForInt64(16), 18); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt64(8, 0L), pb::FieldCodec.ForInt64(16, 0L), 18); private readonly pbc::MapField mapInt64Int64_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapInt64Int64 { get { return mapInt64Int64_; } } @@ -957,8 +1088,9 @@ public TestArenaMap Clone() { /// Field number for the "map_uint32_uint32" field. public const int MapUint32Uint32FieldNumber = 3; private static readonly pbc::MapField.Codec _map_mapUint32Uint32_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForUInt32(8), pb::FieldCodec.ForUInt32(16), 26); + = new pbc::MapField.Codec(pb::FieldCodec.ForUInt32(8, 0), pb::FieldCodec.ForUInt32(16, 0), 26); private readonly pbc::MapField mapUint32Uint32_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapUint32Uint32 { get { return mapUint32Uint32_; } } @@ -966,8 +1098,9 @@ public TestArenaMap Clone() { /// Field number for the "map_uint64_uint64" field. public const int MapUint64Uint64FieldNumber = 4; private static readonly pbc::MapField.Codec _map_mapUint64Uint64_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForUInt64(8), pb::FieldCodec.ForUInt64(16), 34); + = new pbc::MapField.Codec(pb::FieldCodec.ForUInt64(8, 0UL), pb::FieldCodec.ForUInt64(16, 0UL), 34); private readonly pbc::MapField mapUint64Uint64_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapUint64Uint64 { get { return mapUint64Uint64_; } } @@ -975,8 +1108,9 @@ public TestArenaMap Clone() { /// Field number for the "map_sint32_sint32" field. public const int MapSint32Sint32FieldNumber = 5; private static readonly pbc::MapField.Codec _map_mapSint32Sint32_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForSInt32(8), pb::FieldCodec.ForSInt32(16), 42); + = new pbc::MapField.Codec(pb::FieldCodec.ForSInt32(8, 0), pb::FieldCodec.ForSInt32(16, 0), 42); private readonly pbc::MapField mapSint32Sint32_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapSint32Sint32 { get { return mapSint32Sint32_; } } @@ -984,8 +1118,9 @@ public TestArenaMap Clone() { /// Field number for the "map_sint64_sint64" field. public const int MapSint64Sint64FieldNumber = 6; private static readonly pbc::MapField.Codec _map_mapSint64Sint64_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForSInt64(8), pb::FieldCodec.ForSInt64(16), 50); + = new pbc::MapField.Codec(pb::FieldCodec.ForSInt64(8, 0L), pb::FieldCodec.ForSInt64(16, 0L), 50); private readonly pbc::MapField mapSint64Sint64_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapSint64Sint64 { get { return mapSint64Sint64_; } } @@ -993,8 +1128,9 @@ public TestArenaMap Clone() { /// Field number for the "map_fixed32_fixed32" field. public const int MapFixed32Fixed32FieldNumber = 7; private static readonly pbc::MapField.Codec _map_mapFixed32Fixed32_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForFixed32(13), pb::FieldCodec.ForFixed32(21), 58); + = new pbc::MapField.Codec(pb::FieldCodec.ForFixed32(13, 0), pb::FieldCodec.ForFixed32(21, 0), 58); private readonly pbc::MapField mapFixed32Fixed32_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapFixed32Fixed32 { get { return mapFixed32Fixed32_; } } @@ -1002,8 +1138,9 @@ public TestArenaMap Clone() { /// Field number for the "map_fixed64_fixed64" field. public const int MapFixed64Fixed64FieldNumber = 8; private static readonly pbc::MapField.Codec _map_mapFixed64Fixed64_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForFixed64(9), pb::FieldCodec.ForFixed64(17), 66); + = new pbc::MapField.Codec(pb::FieldCodec.ForFixed64(9, 0UL), pb::FieldCodec.ForFixed64(17, 0UL), 66); private readonly pbc::MapField mapFixed64Fixed64_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapFixed64Fixed64 { get { return mapFixed64Fixed64_; } } @@ -1011,8 +1148,9 @@ public TestArenaMap Clone() { /// Field number for the "map_sfixed32_sfixed32" field. public const int MapSfixed32Sfixed32FieldNumber = 9; private static readonly pbc::MapField.Codec _map_mapSfixed32Sfixed32_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForSFixed32(13), pb::FieldCodec.ForSFixed32(21), 74); + = new pbc::MapField.Codec(pb::FieldCodec.ForSFixed32(13, 0), pb::FieldCodec.ForSFixed32(21, 0), 74); private readonly pbc::MapField mapSfixed32Sfixed32_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapSfixed32Sfixed32 { get { return mapSfixed32Sfixed32_; } } @@ -1020,8 +1158,9 @@ public TestArenaMap Clone() { /// Field number for the "map_sfixed64_sfixed64" field. public const int MapSfixed64Sfixed64FieldNumber = 10; private static readonly pbc::MapField.Codec _map_mapSfixed64Sfixed64_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForSFixed64(9), pb::FieldCodec.ForSFixed64(17), 82); + = new pbc::MapField.Codec(pb::FieldCodec.ForSFixed64(9, 0L), pb::FieldCodec.ForSFixed64(17, 0L), 82); private readonly pbc::MapField mapSfixed64Sfixed64_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapSfixed64Sfixed64 { get { return mapSfixed64Sfixed64_; } } @@ -1029,8 +1168,9 @@ public TestArenaMap Clone() { /// Field number for the "map_int32_float" field. public const int MapInt32FloatFieldNumber = 11; private static readonly pbc::MapField.Codec _map_mapInt32Float_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForFloat(21), 90); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForFloat(21, 0F), 90); private readonly pbc::MapField mapInt32Float_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapInt32Float { get { return mapInt32Float_; } } @@ -1038,8 +1178,9 @@ public TestArenaMap Clone() { /// Field number for the "map_int32_double" field. public const int MapInt32DoubleFieldNumber = 12; private static readonly pbc::MapField.Codec _map_mapInt32Double_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForDouble(17), 98); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForDouble(17, 0D), 98); private readonly pbc::MapField mapInt32Double_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapInt32Double { get { return mapInt32Double_; } } @@ -1047,8 +1188,9 @@ public TestArenaMap Clone() { /// Field number for the "map_bool_bool" field. public const int MapBoolBoolFieldNumber = 13; private static readonly pbc::MapField.Codec _map_mapBoolBool_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForBool(8), pb::FieldCodec.ForBool(16), 106); + = new pbc::MapField.Codec(pb::FieldCodec.ForBool(8, false), pb::FieldCodec.ForBool(16, false), 106); private readonly pbc::MapField mapBoolBool_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapBoolBool { get { return mapBoolBool_; } } @@ -1056,8 +1198,9 @@ public TestArenaMap Clone() { /// Field number for the "map_int32_enum" field. public const int MapInt32EnumFieldNumber = 14; private static readonly pbc::MapField.Codec _map_mapInt32Enum_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::Google.Protobuf.TestProtos.MapEnum) x), 114); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::Google.Protobuf.TestProtos.MapEnum) x, global::Google.Protobuf.TestProtos.MapEnum.Foo), 114); private readonly pbc::MapField mapInt32Enum_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapInt32Enum { get { return mapInt32Enum_; } } @@ -1065,16 +1208,19 @@ public TestArenaMap Clone() { /// Field number for the "map_int32_foreign_message" field. public const int MapInt32ForeignMessageFieldNumber = 15; private static readonly pbc::MapField.Codec _map_mapInt32ForeignMessage_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.TestProtos.ForeignMessage.Parser), 122); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.TestProtos.ForeignMessage.Parser), 122); private readonly pbc::MapField mapInt32ForeignMessage_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField MapInt32ForeignMessage { get { return mapInt32ForeignMessage_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestArenaMap); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestArenaMap other) { if (ReferenceEquals(other, null)) { return false; @@ -1097,9 +1243,10 @@ public bool Equals(TestArenaMap other) { if (!MapBoolBool.Equals(other.MapBoolBool)) return false; if (!MapInt32Enum.Equals(other.MapInt32Enum)) return false; if (!MapInt32ForeignMessage.Equals(other.MapInt32ForeignMessage)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= MapInt32Int32.GetHashCode(); @@ -1117,13 +1264,18 @@ public override int GetHashCode() { hash ^= MapBoolBool.GetHashCode(); hash ^= MapInt32Enum.GetHashCode(); hash ^= MapInt32ForeignMessage.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { mapInt32Int32_.WriteTo(output, _map_mapInt32Int32_codec); mapInt64Int64_.WriteTo(output, _map_mapInt64Int64_codec); @@ -1140,8 +1292,12 @@ public void WriteTo(pb::CodedOutputStream output) { mapBoolBool_.WriteTo(output, _map_mapBoolBool_codec); mapInt32Enum_.WriteTo(output, _map_mapInt32Enum_codec); mapInt32ForeignMessage_.WriteTo(output, _map_mapInt32ForeignMessage_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += mapInt32Int32_.CalculateSize(_map_mapInt32Int32_codec); @@ -1159,9 +1315,13 @@ public int CalculateSize() { size += mapBoolBool_.CalculateSize(_map_mapBoolBool_codec); size += mapInt32Enum_.CalculateSize(_map_mapInt32Enum_codec); size += mapInt32ForeignMessage_.CalculateSize(_map_mapInt32ForeignMessage_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestArenaMap other) { if (other == null) { return; @@ -1181,14 +1341,16 @@ public void MergeFrom(TestArenaMap other) { mapBoolBool_.Add(other.mapBoolBool_); mapInt32Enum_.Add(other.mapInt32Enum_); mapInt32ForeignMessage_.Add(other.mapInt32ForeignMessage_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec); @@ -1257,32 +1419,39 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Previously, message containing enum called Type cannot be used as value of - /// map field. + /// Previously, message containing enum called Type cannot be used as value of + /// map field. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class MessageContainingEnumCalledType : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageContainingEnumCalledType()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3Reflection.Descriptor.MessageTypes[5]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MessageContainingEnumCalledType() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MessageContainingEnumCalledType(MessageContainingEnumCalledType other) : this() { type_ = other.type_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MessageContainingEnumCalledType Clone() { return new MessageContainingEnumCalledType(this); } @@ -1290,16 +1459,19 @@ public MessageContainingEnumCalledType Clone() { /// Field number for the "type" field. public const int TypeFieldNumber = 1; private static readonly pbc::MapField.Codec _map_type_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType.Parser), 10); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType.Parser), 10); private readonly pbc::MapField type_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField Type { get { return type_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as MessageContainingEnumCalledType); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(MessageContainingEnumCalledType other) { if (ReferenceEquals(other, null)) { return false; @@ -1308,42 +1480,58 @@ public bool Equals(MessageContainingEnumCalledType other) { return true; } if (!Type.Equals(other.Type)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= Type.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { type_.WriteTo(output, _map_type_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += type_.CalculateSize(_map_type_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(MessageContainingEnumCalledType other) { if (other == null) { return; } type_.Add(other.type_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { type_.AddEntriesFrom(input, _map_type_codec); @@ -1355,7 +1543,7 @@ public void MergeFrom(pb::CodedInputStream input) { #region Nested types /// Container for nested types declared in the MessageContainingEnumCalledType message type. - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { public enum Type { [pbr::OriginalName("TYPE_FOO")] Foo = 0, @@ -1367,31 +1555,38 @@ public enum Type { } /// - /// Previously, message cannot contain map field called "entry". + /// Previously, message cannot contain map field called "entry". /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class MessageContainingMapCalledEntry : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageContainingMapCalledEntry()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3Reflection.Descriptor.MessageTypes[6]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MessageContainingMapCalledEntry() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MessageContainingMapCalledEntry(MessageContainingMapCalledEntry other) : this() { entry_ = other.entry_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MessageContainingMapCalledEntry Clone() { return new MessageContainingMapCalledEntry(this); } @@ -1399,16 +1594,19 @@ public MessageContainingMapCalledEntry Clone() { /// Field number for the "entry" field. public const int EntryFieldNumber = 1; private static readonly pbc::MapField.Codec _map_entry_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForInt32(16), 10); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForInt32(16, 0), 10); private readonly pbc::MapField entry_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField Entry { get { return entry_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as MessageContainingMapCalledEntry); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(MessageContainingMapCalledEntry other) { if (ReferenceEquals(other, null)) { return false; @@ -1417,42 +1615,58 @@ public bool Equals(MessageContainingMapCalledEntry other) { return true; } if (!Entry.Equals(other.Entry)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= Entry.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { entry_.WriteTo(output, _map_entry_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += entry_.CalculateSize(_map_entry_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(MessageContainingMapCalledEntry other) { if (other == null) { return; } entry_.Add(other.entry_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { entry_.AddEntriesFrom(input, _map_entry_codec); diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs new file mode 100644 index 000000000000..822ff2681350 --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs @@ -0,0 +1,3804 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/test_messages_proto3.proto +// +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace ProtobufTestMessages.Proto3 { + + /// Holder for reflection information generated from google/protobuf/test_messages_proto3.proto + public static partial class TestMessagesProto3Reflection { + + #region Descriptor + /// File descriptor for google/protobuf/test_messages_proto3.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static TestMessagesProto3Reflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Cipnb29nbGUvcHJvdG9idWYvdGVzdF9tZXNzYWdlc19wcm90bzMucHJvdG8S", + "HXByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zGhlnb29nbGUvcHJvdG9i", + "dWYvYW55LnByb3RvGh5nb29nbGUvcHJvdG9idWYvZHVyYXRpb24ucHJvdG8a", + "IGdvb2dsZS9wcm90b2J1Zi9maWVsZF9tYXNrLnByb3RvGhxnb29nbGUvcHJv", + "dG9idWYvc3RydWN0LnByb3RvGh9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1w", + "LnByb3RvGh5nb29nbGUvcHJvdG9idWYvd3JhcHBlcnMucHJvdG8ipz0KElRl", + "c3RBbGxUeXBlc1Byb3RvMxIWCg5vcHRpb25hbF9pbnQzMhgBIAEoBRIWCg5v", + "cHRpb25hbF9pbnQ2NBgCIAEoAxIXCg9vcHRpb25hbF91aW50MzIYAyABKA0S", + "FwoPb3B0aW9uYWxfdWludDY0GAQgASgEEhcKD29wdGlvbmFsX3NpbnQzMhgF", + "IAEoERIXCg9vcHRpb25hbF9zaW50NjQYBiABKBISGAoQb3B0aW9uYWxfZml4", + "ZWQzMhgHIAEoBxIYChBvcHRpb25hbF9maXhlZDY0GAggASgGEhkKEW9wdGlv", + "bmFsX3NmaXhlZDMyGAkgASgPEhkKEW9wdGlvbmFsX3NmaXhlZDY0GAogASgQ", + "EhYKDm9wdGlvbmFsX2Zsb2F0GAsgASgCEhcKD29wdGlvbmFsX2RvdWJsZRgM", + "IAEoARIVCg1vcHRpb25hbF9ib29sGA0gASgIEhcKD29wdGlvbmFsX3N0cmlu", + "ZxgOIAEoCRIWCg5vcHRpb25hbF9ieXRlcxgPIAEoDBJgChdvcHRpb25hbF9u", + "ZXN0ZWRfbWVzc2FnZRgSIAEoCzI/LnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMu", + "cHJvdG8zLlRlc3RBbGxUeXBlc1Byb3RvMy5OZXN0ZWRNZXNzYWdlEk8KGG9w", + "dGlvbmFsX2ZvcmVpZ25fbWVzc2FnZRgTIAEoCzItLnByb3RvYnVmX3Rlc3Rf", + "bWVzc2FnZXMucHJvdG8zLkZvcmVpZ25NZXNzYWdlEloKFG9wdGlvbmFsX25l", + "c3RlZF9lbnVtGBUgASgOMjwucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90", + "bzMuVGVzdEFsbFR5cGVzUHJvdG8zLk5lc3RlZEVudW0SSQoVb3B0aW9uYWxf", + "Zm9yZWlnbl9lbnVtGBYgASgOMioucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5w", + "cm90bzMuRm9yZWlnbkVudW0SXAoVb3B0aW9uYWxfYWxpYXNlZF9lbnVtGBcg", + "ASgOMj0ucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5", + "cGVzUHJvdG8zLkFsaWFzZWRFbnVtEiEKFW9wdGlvbmFsX3N0cmluZ19waWVj", + "ZRgYIAEoCUICCAISGQoNb3B0aW9uYWxfY29yZBgZIAEoCUICCAESTAoRcmVj", + "dXJzaXZlX21lc3NhZ2UYGyABKAsyMS5wcm90b2J1Zl90ZXN0X21lc3NhZ2Vz", + "LnByb3RvMy5UZXN0QWxsVHlwZXNQcm90bzMSFgoOcmVwZWF0ZWRfaW50MzIY", + "HyADKAUSFgoOcmVwZWF0ZWRfaW50NjQYICADKAMSFwoPcmVwZWF0ZWRfdWlu", + "dDMyGCEgAygNEhcKD3JlcGVhdGVkX3VpbnQ2NBgiIAMoBBIXCg9yZXBlYXRl", + "ZF9zaW50MzIYIyADKBESFwoPcmVwZWF0ZWRfc2ludDY0GCQgAygSEhgKEHJl", + "cGVhdGVkX2ZpeGVkMzIYJSADKAcSGAoQcmVwZWF0ZWRfZml4ZWQ2NBgmIAMo", + "BhIZChFyZXBlYXRlZF9zZml4ZWQzMhgnIAMoDxIZChFyZXBlYXRlZF9zZml4", + "ZWQ2NBgoIAMoEBIWCg5yZXBlYXRlZF9mbG9hdBgpIAMoAhIXCg9yZXBlYXRl", + "ZF9kb3VibGUYKiADKAESFQoNcmVwZWF0ZWRfYm9vbBgrIAMoCBIXCg9yZXBl", + "YXRlZF9zdHJpbmcYLCADKAkSFgoOcmVwZWF0ZWRfYnl0ZXMYLSADKAwSYAoX", + "cmVwZWF0ZWRfbmVzdGVkX21lc3NhZ2UYMCADKAsyPy5wcm90b2J1Zl90ZXN0", + "X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXNQcm90bzMuTmVzdGVkTWVz", + "c2FnZRJPChhyZXBlYXRlZF9mb3JlaWduX21lc3NhZ2UYMSADKAsyLS5wcm90", + "b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMy5Gb3JlaWduTWVzc2FnZRJaChRy", + "ZXBlYXRlZF9uZXN0ZWRfZW51bRgzIAMoDjI8LnByb3RvYnVmX3Rlc3RfbWVz", + "c2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlc1Byb3RvMy5OZXN0ZWRFbnVtEkkK", + "FXJlcGVhdGVkX2ZvcmVpZ25fZW51bRg0IAMoDjIqLnByb3RvYnVmX3Rlc3Rf", + "bWVzc2FnZXMucHJvdG8zLkZvcmVpZ25FbnVtEiEKFXJlcGVhdGVkX3N0cmlu", + "Z19waWVjZRg2IAMoCUICCAISGQoNcmVwZWF0ZWRfY29yZBg3IAMoCUICCAES", + "XQoPbWFwX2ludDMyX2ludDMyGDggAygLMkQucHJvdG9idWZfdGVzdF9tZXNz", + "YWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzUHJvdG8zLk1hcEludDMySW50MzJF", + "bnRyeRJdCg9tYXBfaW50NjRfaW50NjQYOSADKAsyRC5wcm90b2J1Zl90ZXN0", + "X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXNQcm90bzMuTWFwSW50NjRJ", + "bnQ2NEVudHJ5EmEKEW1hcF91aW50MzJfdWludDMyGDogAygLMkYucHJvdG9i", + "dWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzUHJvdG8zLk1h", + "cFVpbnQzMlVpbnQzMkVudHJ5EmEKEW1hcF91aW50NjRfdWludDY0GDsgAygL", + "MkYucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVz", + "UHJvdG8zLk1hcFVpbnQ2NFVpbnQ2NEVudHJ5EmEKEW1hcF9zaW50MzJfc2lu", + "dDMyGDwgAygLMkYucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuVGVz", + "dEFsbFR5cGVzUHJvdG8zLk1hcFNpbnQzMlNpbnQzMkVudHJ5EmEKEW1hcF9z", + "aW50NjRfc2ludDY0GD0gAygLMkYucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5w", + "cm90bzMuVGVzdEFsbFR5cGVzUHJvdG8zLk1hcFNpbnQ2NFNpbnQ2NEVudHJ5", + "EmUKE21hcF9maXhlZDMyX2ZpeGVkMzIYPiADKAsySC5wcm90b2J1Zl90ZXN0", + "X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXNQcm90bzMuTWFwRml4ZWQz", + "MkZpeGVkMzJFbnRyeRJlChNtYXBfZml4ZWQ2NF9maXhlZDY0GD8gAygLMkgu", + "cHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzUHJv", + "dG8zLk1hcEZpeGVkNjRGaXhlZDY0RW50cnkSaQoVbWFwX3NmaXhlZDMyX3Nm", + "aXhlZDMyGEAgAygLMkoucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMu", + "VGVzdEFsbFR5cGVzUHJvdG8zLk1hcFNmaXhlZDMyU2ZpeGVkMzJFbnRyeRJp", + "ChVtYXBfc2ZpeGVkNjRfc2ZpeGVkNjQYQSADKAsySi5wcm90b2J1Zl90ZXN0", + "X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXNQcm90bzMuTWFwU2ZpeGVk", + "NjRTZml4ZWQ2NEVudHJ5El0KD21hcF9pbnQzMl9mbG9hdBhCIAMoCzJELnBy", + "b3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlc1Byb3Rv", + "My5NYXBJbnQzMkZsb2F0RW50cnkSXwoQbWFwX2ludDMyX2RvdWJsZRhDIAMo", + "CzJFLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBl", + "c1Byb3RvMy5NYXBJbnQzMkRvdWJsZUVudHJ5ElkKDW1hcF9ib29sX2Jvb2wY", + "RCADKAsyQi5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxs", + "VHlwZXNQcm90bzMuTWFwQm9vbEJvb2xFbnRyeRJhChFtYXBfc3RyaW5nX3N0", + "cmluZxhFIAMoCzJGLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLlRl", + "c3RBbGxUeXBlc1Byb3RvMy5NYXBTdHJpbmdTdHJpbmdFbnRyeRJfChBtYXBf", + "c3RyaW5nX2J5dGVzGEYgAygLMkUucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5w", + "cm90bzMuVGVzdEFsbFR5cGVzUHJvdG8zLk1hcFN0cmluZ0J5dGVzRW50cnkS", + "cAoZbWFwX3N0cmluZ19uZXN0ZWRfbWVzc2FnZRhHIAMoCzJNLnByb3RvYnVm", + "X3Rlc3RfbWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlc1Byb3RvMy5NYXBT", + "dHJpbmdOZXN0ZWRNZXNzYWdlRW50cnkScgoabWFwX3N0cmluZ19mb3JlaWdu", + "X21lc3NhZ2UYSCADKAsyTi5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3Rv", + "My5UZXN0QWxsVHlwZXNQcm90bzMuTWFwU3RyaW5nRm9yZWlnbk1lc3NhZ2VF", + "bnRyeRJqChZtYXBfc3RyaW5nX25lc3RlZF9lbnVtGEkgAygLMkoucHJvdG9i", + "dWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzUHJvdG8zLk1h", + "cFN0cmluZ05lc3RlZEVudW1FbnRyeRJsChdtYXBfc3RyaW5nX2ZvcmVpZ25f", + "ZW51bRhKIAMoCzJLLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLlRl", + "c3RBbGxUeXBlc1Byb3RvMy5NYXBTdHJpbmdGb3JlaWduRW51bUVudHJ5EhYK", + "DG9uZW9mX3VpbnQzMhhvIAEoDUgAEl8KFG9uZW9mX25lc3RlZF9tZXNzYWdl", + "GHAgASgLMj8ucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuVGVzdEFs", + "bFR5cGVzUHJvdG8zLk5lc3RlZE1lc3NhZ2VIABIWCgxvbmVvZl9zdHJpbmcY", + "cSABKAlIABIVCgtvbmVvZl9ieXRlcxhyIAEoDEgAEhQKCm9uZW9mX2Jvb2wY", + "cyABKAhIABIWCgxvbmVvZl91aW50NjQYdCABKARIABIVCgtvbmVvZl9mbG9h", + "dBh1IAEoAkgAEhYKDG9uZW9mX2RvdWJsZRh2IAEoAUgAElIKCm9uZW9mX2Vu", + "dW0YdyABKA4yPC5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMy5UZXN0", + "QWxsVHlwZXNQcm90bzMuTmVzdGVkRW51bUgAEjoKFW9wdGlvbmFsX2Jvb2xf", + "d3JhcHBlchjJASABKAsyGi5nb29nbGUucHJvdG9idWYuQm9vbFZhbHVlEjwK", + "Fm9wdGlvbmFsX2ludDMyX3dyYXBwZXIYygEgASgLMhsuZ29vZ2xlLnByb3Rv", + "YnVmLkludDMyVmFsdWUSPAoWb3B0aW9uYWxfaW50NjRfd3JhcHBlchjLASAB", + "KAsyGy5nb29nbGUucHJvdG9idWYuSW50NjRWYWx1ZRI+ChdvcHRpb25hbF91", + "aW50MzJfd3JhcHBlchjMASABKAsyHC5nb29nbGUucHJvdG9idWYuVUludDMy", + "VmFsdWUSPgoXb3B0aW9uYWxfdWludDY0X3dyYXBwZXIYzQEgASgLMhwuZ29v", + "Z2xlLnByb3RvYnVmLlVJbnQ2NFZhbHVlEjwKFm9wdGlvbmFsX2Zsb2F0X3dy", + "YXBwZXIYzgEgASgLMhsuZ29vZ2xlLnByb3RvYnVmLkZsb2F0VmFsdWUSPgoX", + "b3B0aW9uYWxfZG91YmxlX3dyYXBwZXIYzwEgASgLMhwuZ29vZ2xlLnByb3Rv", + "YnVmLkRvdWJsZVZhbHVlEj4KF29wdGlvbmFsX3N0cmluZ193cmFwcGVyGNAB", + "IAEoCzIcLmdvb2dsZS5wcm90b2J1Zi5TdHJpbmdWYWx1ZRI8ChZvcHRpb25h", + "bF9ieXRlc193cmFwcGVyGNEBIAEoCzIbLmdvb2dsZS5wcm90b2J1Zi5CeXRl", + "c1ZhbHVlEjoKFXJlcGVhdGVkX2Jvb2xfd3JhcHBlchjTASADKAsyGi5nb29n", + "bGUucHJvdG9idWYuQm9vbFZhbHVlEjwKFnJlcGVhdGVkX2ludDMyX3dyYXBw", + "ZXIY1AEgAygLMhsuZ29vZ2xlLnByb3RvYnVmLkludDMyVmFsdWUSPAoWcmVw", + "ZWF0ZWRfaW50NjRfd3JhcHBlchjVASADKAsyGy5nb29nbGUucHJvdG9idWYu", + "SW50NjRWYWx1ZRI+ChdyZXBlYXRlZF91aW50MzJfd3JhcHBlchjWASADKAsy", + "HC5nb29nbGUucHJvdG9idWYuVUludDMyVmFsdWUSPgoXcmVwZWF0ZWRfdWlu", + "dDY0X3dyYXBwZXIY1wEgAygLMhwuZ29vZ2xlLnByb3RvYnVmLlVJbnQ2NFZh", + "bHVlEjwKFnJlcGVhdGVkX2Zsb2F0X3dyYXBwZXIY2AEgAygLMhsuZ29vZ2xl", + "LnByb3RvYnVmLkZsb2F0VmFsdWUSPgoXcmVwZWF0ZWRfZG91YmxlX3dyYXBw", + "ZXIY2QEgAygLMhwuZ29vZ2xlLnByb3RvYnVmLkRvdWJsZVZhbHVlEj4KF3Jl", + "cGVhdGVkX3N0cmluZ193cmFwcGVyGNoBIAMoCzIcLmdvb2dsZS5wcm90b2J1", + "Zi5TdHJpbmdWYWx1ZRI8ChZyZXBlYXRlZF9ieXRlc193cmFwcGVyGNsBIAMo", + "CzIbLmdvb2dsZS5wcm90b2J1Zi5CeXRlc1ZhbHVlEjUKEW9wdGlvbmFsX2R1", + "cmF0aW9uGK0CIAEoCzIZLmdvb2dsZS5wcm90b2J1Zi5EdXJhdGlvbhI3ChJv", + "cHRpb25hbF90aW1lc3RhbXAYrgIgASgLMhouZ29vZ2xlLnByb3RvYnVmLlRp", + "bWVzdGFtcBI4ChNvcHRpb25hbF9maWVsZF9tYXNrGK8CIAEoCzIaLmdvb2ds", + "ZS5wcm90b2J1Zi5GaWVsZE1hc2sSMQoPb3B0aW9uYWxfc3RydWN0GLACIAEo", + "CzIXLmdvb2dsZS5wcm90b2J1Zi5TdHJ1Y3QSKwoMb3B0aW9uYWxfYW55GLEC", + "IAEoCzIULmdvb2dsZS5wcm90b2J1Zi5BbnkSLwoOb3B0aW9uYWxfdmFsdWUY", + "sgIgASgLMhYuZ29vZ2xlLnByb3RvYnVmLlZhbHVlEjUKEXJlcGVhdGVkX2R1", + "cmF0aW9uGLcCIAMoCzIZLmdvb2dsZS5wcm90b2J1Zi5EdXJhdGlvbhI3ChJy", + "ZXBlYXRlZF90aW1lc3RhbXAYuAIgAygLMhouZ29vZ2xlLnByb3RvYnVmLlRp", + "bWVzdGFtcBI3ChJyZXBlYXRlZF9maWVsZG1hc2sYuQIgAygLMhouZ29vZ2xl", + "LnByb3RvYnVmLkZpZWxkTWFzaxIxCg9yZXBlYXRlZF9zdHJ1Y3QYxAIgAygL", + "MhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVjdBIrCgxyZXBlYXRlZF9hbnkYuwIg", + "AygLMhQuZ29vZ2xlLnByb3RvYnVmLkFueRIvCg5yZXBlYXRlZF92YWx1ZRi8", + "AiADKAsyFi5nb29nbGUucHJvdG9idWYuVmFsdWUSOAoTcmVwZWF0ZWRfbGlz", + "dF92YWx1ZRi9AiADKAsyGi5nb29nbGUucHJvdG9idWYuTGlzdFZhbHVlEhMK", + "CmZpZWxkbmFtZTEYkQMgASgFEhQKC2ZpZWxkX25hbWUyGJIDIAEoBRIVCgxf", + "ZmllbGRfbmFtZTMYkwMgASgFEhYKDWZpZWxkX19uYW1lNF8YlAMgASgFEhQK", + "C2ZpZWxkMG5hbWU1GJUDIAEoBRIWCg1maWVsZF8wX25hbWU2GJYDIAEoBRIT", + "CgpmaWVsZE5hbWU3GJcDIAEoBRITCgpGaWVsZE5hbWU4GJgDIAEoBRIUCgtm", + "aWVsZF9OYW1lORiZAyABKAUSFQoMRmllbGRfTmFtZTEwGJoDIAEoBRIVCgxG", + "SUVMRF9OQU1FMTEYmwMgASgFEhUKDEZJRUxEX25hbWUxMhicAyABKAUSFwoO", + "X19maWVsZF9uYW1lMTMYnQMgASgFEhcKDl9fRmllbGRfbmFtZTE0GJ4DIAEo", + "BRIWCg1maWVsZF9fbmFtZTE1GJ8DIAEoBRIWCg1maWVsZF9fTmFtZTE2GKAD", + "IAEoBRIXCg5maWVsZF9uYW1lMTdfXxihAyABKAUSFwoORmllbGRfbmFtZTE4", + "X18YogMgASgFGmIKDU5lc3RlZE1lc3NhZ2USCQoBYRgBIAEoBRJGCgtjb3Jl", + "Y3Vyc2l2ZRgCIAEoCzIxLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8z", + "LlRlc3RBbGxUeXBlc1Byb3RvMxo0ChJNYXBJbnQzMkludDMyRW50cnkSCwoD", + "a2V5GAEgASgFEg0KBXZhbHVlGAIgASgFOgI4ARo0ChJNYXBJbnQ2NEludDY0", + "RW50cnkSCwoDa2V5GAEgASgDEg0KBXZhbHVlGAIgASgDOgI4ARo2ChRNYXBV", + "aW50MzJVaW50MzJFbnRyeRILCgNrZXkYASABKA0SDQoFdmFsdWUYAiABKA06", + "AjgBGjYKFE1hcFVpbnQ2NFVpbnQ2NEVudHJ5EgsKA2tleRgBIAEoBBINCgV2", + "YWx1ZRgCIAEoBDoCOAEaNgoUTWFwU2ludDMyU2ludDMyRW50cnkSCwoDa2V5", + "GAEgASgREg0KBXZhbHVlGAIgASgROgI4ARo2ChRNYXBTaW50NjRTaW50NjRF", + "bnRyeRILCgNrZXkYASABKBISDQoFdmFsdWUYAiABKBI6AjgBGjgKFk1hcEZp", + "eGVkMzJGaXhlZDMyRW50cnkSCwoDa2V5GAEgASgHEg0KBXZhbHVlGAIgASgH", + "OgI4ARo4ChZNYXBGaXhlZDY0Rml4ZWQ2NEVudHJ5EgsKA2tleRgBIAEoBhIN", + "CgV2YWx1ZRgCIAEoBjoCOAEaOgoYTWFwU2ZpeGVkMzJTZml4ZWQzMkVudHJ5", + "EgsKA2tleRgBIAEoDxINCgV2YWx1ZRgCIAEoDzoCOAEaOgoYTWFwU2ZpeGVk", + "NjRTZml4ZWQ2NEVudHJ5EgsKA2tleRgBIAEoEBINCgV2YWx1ZRgCIAEoEDoC", + "OAEaNAoSTWFwSW50MzJGbG9hdEVudHJ5EgsKA2tleRgBIAEoBRINCgV2YWx1", + "ZRgCIAEoAjoCOAEaNQoTTWFwSW50MzJEb3VibGVFbnRyeRILCgNrZXkYASAB", + "KAUSDQoFdmFsdWUYAiABKAE6AjgBGjIKEE1hcEJvb2xCb29sRW50cnkSCwoD", + "a2V5GAEgASgIEg0KBXZhbHVlGAIgASgIOgI4ARo2ChRNYXBTdHJpbmdTdHJp", + "bmdFbnRyeRILCgNrZXkYASABKAkSDQoFdmFsdWUYAiABKAk6AjgBGjUKE01h", + "cFN0cmluZ0J5dGVzRW50cnkSCwoDa2V5GAEgASgJEg0KBXZhbHVlGAIgASgM", + "OgI4ARp+ChtNYXBTdHJpbmdOZXN0ZWRNZXNzYWdlRW50cnkSCwoDa2V5GAEg", + "ASgJEk4KBXZhbHVlGAIgASgLMj8ucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5w", + "cm90bzMuVGVzdEFsbFR5cGVzUHJvdG8zLk5lc3RlZE1lc3NhZ2U6AjgBGm0K", + "HE1hcFN0cmluZ0ZvcmVpZ25NZXNzYWdlRW50cnkSCwoDa2V5GAEgASgJEjwK", + "BXZhbHVlGAIgASgLMi0ucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMu", + "Rm9yZWlnbk1lc3NhZ2U6AjgBGngKGE1hcFN0cmluZ05lc3RlZEVudW1FbnRy", + "eRILCgNrZXkYASABKAkSSwoFdmFsdWUYAiABKA4yPC5wcm90b2J1Zl90ZXN0", + "X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXNQcm90bzMuTmVzdGVkRW51", + "bToCOAEaZwoZTWFwU3RyaW5nRm9yZWlnbkVudW1FbnRyeRILCgNrZXkYASAB", + "KAkSOQoFdmFsdWUYAiABKA4yKi5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnBy", + "b3RvMy5Gb3JlaWduRW51bToCOAEiOQoKTmVzdGVkRW51bRIHCgNGT08QABIH", + "CgNCQVIQARIHCgNCQVoQAhIQCgNORUcQ////////////ASJZCgtBbGlhc2Vk", + "RW51bRINCglBTElBU19GT08QABINCglBTElBU19CQVIQARINCglBTElBU19C", + "QVoQAhIHCgNRVVgQAhIHCgNxdXgQAhIHCgNiQXoQAhoCEAFCDQoLb25lb2Zf", + "ZmllbGRKBgj1AxD/AyIbCg5Gb3JlaWduTWVzc2FnZRIJCgFjGAEgASgFKkAK", + "C0ZvcmVpZ25FbnVtEg8KC0ZPUkVJR05fRk9PEAASDwoLRk9SRUlHTl9CQVIQ", + "ARIPCgtGT1JFSUdOX0JBWhACQjgKKGNvbS5nb29nbGUucHJvdG9idWZfdGVz", + "dF9tZXNzYWdlcy5wcm90bzNIAfgBAaICBlByb3RvM2IGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.DurationReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.FieldMaskReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.StructReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.WrappersReflection.Descriptor, }, + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::ProtobufTestMessages.Proto3.ForeignEnum), }, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto3.TestAllTypesProto3), global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Parser, new[]{ "OptionalInt32", "OptionalInt64", "OptionalUint32", "OptionalUint64", "OptionalSint32", "OptionalSint64", "OptionalFixed32", "OptionalFixed64", "OptionalSfixed32", "OptionalSfixed64", "OptionalFloat", "OptionalDouble", "OptionalBool", "OptionalString", "OptionalBytes", "OptionalNestedMessage", "OptionalForeignMessage", "OptionalNestedEnum", "OptionalForeignEnum", "OptionalAliasedEnum", "OptionalStringPiece", "OptionalCord", "RecursiveMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedStringPiece", "RepeatedCord", "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapStringString", "MapStringBytes", "MapStringNestedMessage", "MapStringForeignMessage", "MapStringNestedEnum", "MapStringForeignEnum", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", "OneofBool", "OneofUint64", "OneofFloat", "OneofDouble", "OneofEnum", "OptionalBoolWrapper", "OptionalInt32Wrapper", "OptionalInt64Wrapper", "OptionalUint32Wrapper", "OptionalUint64Wrapper", "OptionalFloatWrapper", "OptionalDoubleWrapper", "OptionalStringWrapper", "OptionalBytesWrapper", "RepeatedBoolWrapper", "RepeatedInt32Wrapper", "RepeatedInt64Wrapper", "RepeatedUint32Wrapper", "RepeatedUint64Wrapper", "RepeatedFloatWrapper", "RepeatedDoubleWrapper", "RepeatedStringWrapper", "RepeatedBytesWrapper", "OptionalDuration", "OptionalTimestamp", "OptionalFieldMask", "OptionalStruct", "OptionalAny", "OptionalValue", "RepeatedDuration", "RepeatedTimestamp", "RepeatedFieldmask", "RepeatedStruct", "RepeatedAny", "RepeatedValue", "RepeatedListValue", "Fieldname1", "FieldName2", "FieldName3", "FieldName4", "Field0Name5", "Field0Name6", "FieldName7", "FieldName8", "FieldName9", "FieldName10", "FIELDNAME11", "FIELDName12", "FieldName13", "FieldName14", "FieldName15", "FieldName16", "FieldName17", "FieldName18" }, new[]{ "OneofField" }, new[]{ typeof(global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum), typeof(global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.AliasedEnum) }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage), global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage.Parser, new[]{ "A", "Corecursive" }, null, null, null, null), + null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, }), + new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto3.ForeignMessage), global::ProtobufTestMessages.Proto3.ForeignMessage.Parser, new[]{ "C" }, null, null, null, null) + })); + } + #endregion + + } + #region Enums + public enum ForeignEnum { + [pbr::OriginalName("FOREIGN_FOO")] ForeignFoo = 0, + [pbr::OriginalName("FOREIGN_BAR")] ForeignBar = 1, + [pbr::OriginalName("FOREIGN_BAZ")] ForeignBaz = 2, + } + + #endregion + + #region Messages + /// + /// This proto includes every type of field in both singular and repeated + /// forms. + /// + /// Also, crucially, all messages and enums in this file are eventually + /// submessages of this message. So for example, a fuzz test of TestAllTypes + /// could trigger bugs that occur in any message type in this file. We verify + /// this stays true in a unit test. + /// + public sealed partial class TestAllTypesProto3 : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestAllTypesProto3()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::ProtobufTestMessages.Proto3.TestMessagesProto3Reflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TestAllTypesProto3() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TestAllTypesProto3(TestAllTypesProto3 other) : this() { + optionalInt32_ = other.optionalInt32_; + optionalInt64_ = other.optionalInt64_; + optionalUint32_ = other.optionalUint32_; + optionalUint64_ = other.optionalUint64_; + optionalSint32_ = other.optionalSint32_; + optionalSint64_ = other.optionalSint64_; + optionalFixed32_ = other.optionalFixed32_; + optionalFixed64_ = other.optionalFixed64_; + optionalSfixed32_ = other.optionalSfixed32_; + optionalSfixed64_ = other.optionalSfixed64_; + optionalFloat_ = other.optionalFloat_; + optionalDouble_ = other.optionalDouble_; + optionalBool_ = other.optionalBool_; + optionalString_ = other.optionalString_; + optionalBytes_ = other.optionalBytes_; + optionalNestedMessage_ = other.optionalNestedMessage_ != null ? other.optionalNestedMessage_.Clone() : null; + optionalForeignMessage_ = other.optionalForeignMessage_ != null ? other.optionalForeignMessage_.Clone() : null; + optionalNestedEnum_ = other.optionalNestedEnum_; + optionalForeignEnum_ = other.optionalForeignEnum_; + optionalAliasedEnum_ = other.optionalAliasedEnum_; + optionalStringPiece_ = other.optionalStringPiece_; + optionalCord_ = other.optionalCord_; + recursiveMessage_ = other.recursiveMessage_ != null ? other.recursiveMessage_.Clone() : null; + repeatedInt32_ = other.repeatedInt32_.Clone(); + repeatedInt64_ = other.repeatedInt64_.Clone(); + repeatedUint32_ = other.repeatedUint32_.Clone(); + repeatedUint64_ = other.repeatedUint64_.Clone(); + repeatedSint32_ = other.repeatedSint32_.Clone(); + repeatedSint64_ = other.repeatedSint64_.Clone(); + repeatedFixed32_ = other.repeatedFixed32_.Clone(); + repeatedFixed64_ = other.repeatedFixed64_.Clone(); + repeatedSfixed32_ = other.repeatedSfixed32_.Clone(); + repeatedSfixed64_ = other.repeatedSfixed64_.Clone(); + repeatedFloat_ = other.repeatedFloat_.Clone(); + repeatedDouble_ = other.repeatedDouble_.Clone(); + repeatedBool_ = other.repeatedBool_.Clone(); + repeatedString_ = other.repeatedString_.Clone(); + repeatedBytes_ = other.repeatedBytes_.Clone(); + repeatedNestedMessage_ = other.repeatedNestedMessage_.Clone(); + repeatedForeignMessage_ = other.repeatedForeignMessage_.Clone(); + repeatedNestedEnum_ = other.repeatedNestedEnum_.Clone(); + repeatedForeignEnum_ = other.repeatedForeignEnum_.Clone(); + repeatedStringPiece_ = other.repeatedStringPiece_.Clone(); + repeatedCord_ = other.repeatedCord_.Clone(); + mapInt32Int32_ = other.mapInt32Int32_.Clone(); + mapInt64Int64_ = other.mapInt64Int64_.Clone(); + mapUint32Uint32_ = other.mapUint32Uint32_.Clone(); + mapUint64Uint64_ = other.mapUint64Uint64_.Clone(); + mapSint32Sint32_ = other.mapSint32Sint32_.Clone(); + mapSint64Sint64_ = other.mapSint64Sint64_.Clone(); + mapFixed32Fixed32_ = other.mapFixed32Fixed32_.Clone(); + mapFixed64Fixed64_ = other.mapFixed64Fixed64_.Clone(); + mapSfixed32Sfixed32_ = other.mapSfixed32Sfixed32_.Clone(); + mapSfixed64Sfixed64_ = other.mapSfixed64Sfixed64_.Clone(); + mapInt32Float_ = other.mapInt32Float_.Clone(); + mapInt32Double_ = other.mapInt32Double_.Clone(); + mapBoolBool_ = other.mapBoolBool_.Clone(); + mapStringString_ = other.mapStringString_.Clone(); + mapStringBytes_ = other.mapStringBytes_.Clone(); + mapStringNestedMessage_ = other.mapStringNestedMessage_.Clone(); + mapStringForeignMessage_ = other.mapStringForeignMessage_.Clone(); + mapStringNestedEnum_ = other.mapStringNestedEnum_.Clone(); + mapStringForeignEnum_ = other.mapStringForeignEnum_.Clone(); + OptionalBoolWrapper = other.OptionalBoolWrapper; + OptionalInt32Wrapper = other.OptionalInt32Wrapper; + OptionalInt64Wrapper = other.OptionalInt64Wrapper; + OptionalUint32Wrapper = other.OptionalUint32Wrapper; + OptionalUint64Wrapper = other.OptionalUint64Wrapper; + OptionalFloatWrapper = other.OptionalFloatWrapper; + OptionalDoubleWrapper = other.OptionalDoubleWrapper; + OptionalStringWrapper = other.OptionalStringWrapper; + OptionalBytesWrapper = other.OptionalBytesWrapper; + repeatedBoolWrapper_ = other.repeatedBoolWrapper_.Clone(); + repeatedInt32Wrapper_ = other.repeatedInt32Wrapper_.Clone(); + repeatedInt64Wrapper_ = other.repeatedInt64Wrapper_.Clone(); + repeatedUint32Wrapper_ = other.repeatedUint32Wrapper_.Clone(); + repeatedUint64Wrapper_ = other.repeatedUint64Wrapper_.Clone(); + repeatedFloatWrapper_ = other.repeatedFloatWrapper_.Clone(); + repeatedDoubleWrapper_ = other.repeatedDoubleWrapper_.Clone(); + repeatedStringWrapper_ = other.repeatedStringWrapper_.Clone(); + repeatedBytesWrapper_ = other.repeatedBytesWrapper_.Clone(); + optionalDuration_ = other.optionalDuration_ != null ? other.optionalDuration_.Clone() : null; + optionalTimestamp_ = other.optionalTimestamp_ != null ? other.optionalTimestamp_.Clone() : null; + optionalFieldMask_ = other.optionalFieldMask_ != null ? other.optionalFieldMask_.Clone() : null; + optionalStruct_ = other.optionalStruct_ != null ? other.optionalStruct_.Clone() : null; + optionalAny_ = other.optionalAny_ != null ? other.optionalAny_.Clone() : null; + optionalValue_ = other.optionalValue_ != null ? other.optionalValue_.Clone() : null; + repeatedDuration_ = other.repeatedDuration_.Clone(); + repeatedTimestamp_ = other.repeatedTimestamp_.Clone(); + repeatedFieldmask_ = other.repeatedFieldmask_.Clone(); + repeatedStruct_ = other.repeatedStruct_.Clone(); + repeatedAny_ = other.repeatedAny_.Clone(); + repeatedValue_ = other.repeatedValue_.Clone(); + repeatedListValue_ = other.repeatedListValue_.Clone(); + fieldname1_ = other.fieldname1_; + fieldName2_ = other.fieldName2_; + FieldName3_ = other.FieldName3_; + fieldName4_ = other.fieldName4_; + field0Name5_ = other.field0Name5_; + field0Name6_ = other.field0Name6_; + fieldName7_ = other.fieldName7_; + fieldName8_ = other.fieldName8_; + fieldName9_ = other.fieldName9_; + fieldName10_ = other.fieldName10_; + fIELDNAME11_ = other.fIELDNAME11_; + fIELDName12_ = other.fIELDName12_; + FieldName13_ = other.FieldName13_; + FieldName14_ = other.FieldName14_; + fieldName15_ = other.fieldName15_; + fieldName16_ = other.fieldName16_; + fieldName17_ = other.fieldName17_; + fieldName18_ = other.fieldName18_; + switch (other.OneofFieldCase) { + case OneofFieldOneofCase.OneofUint32: + OneofUint32 = other.OneofUint32; + break; + case OneofFieldOneofCase.OneofNestedMessage: + OneofNestedMessage = other.OneofNestedMessage.Clone(); + break; + case OneofFieldOneofCase.OneofString: + OneofString = other.OneofString; + break; + case OneofFieldOneofCase.OneofBytes: + OneofBytes = other.OneofBytes; + break; + case OneofFieldOneofCase.OneofBool: + OneofBool = other.OneofBool; + break; + case OneofFieldOneofCase.OneofUint64: + OneofUint64 = other.OneofUint64; + break; + case OneofFieldOneofCase.OneofFloat: + OneofFloat = other.OneofFloat; + break; + case OneofFieldOneofCase.OneofDouble: + OneofDouble = other.OneofDouble; + break; + case OneofFieldOneofCase.OneofEnum: + OneofEnum = other.OneofEnum; + break; + } + + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TestAllTypesProto3 Clone() { + return new TestAllTypesProto3(this); + } + + /// Field number for the "optional_int32" field. + public const int OptionalInt32FieldNumber = 1; + private int optionalInt32_; + /// + /// Singular + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int OptionalInt32 { + get { return optionalInt32_; } + set { + optionalInt32_ = value; + } + } + + /// Field number for the "optional_int64" field. + public const int OptionalInt64FieldNumber = 2; + private long optionalInt64_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long OptionalInt64 { + get { return optionalInt64_; } + set { + optionalInt64_ = value; + } + } + + /// Field number for the "optional_uint32" field. + public const int OptionalUint32FieldNumber = 3; + private uint optionalUint32_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint OptionalUint32 { + get { return optionalUint32_; } + set { + optionalUint32_ = value; + } + } + + /// Field number for the "optional_uint64" field. + public const int OptionalUint64FieldNumber = 4; + private ulong optionalUint64_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ulong OptionalUint64 { + get { return optionalUint64_; } + set { + optionalUint64_ = value; + } + } + + /// Field number for the "optional_sint32" field. + public const int OptionalSint32FieldNumber = 5; + private int optionalSint32_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int OptionalSint32 { + get { return optionalSint32_; } + set { + optionalSint32_ = value; + } + } + + /// Field number for the "optional_sint64" field. + public const int OptionalSint64FieldNumber = 6; + private long optionalSint64_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long OptionalSint64 { + get { return optionalSint64_; } + set { + optionalSint64_ = value; + } + } + + /// Field number for the "optional_fixed32" field. + public const int OptionalFixed32FieldNumber = 7; + private uint optionalFixed32_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint OptionalFixed32 { + get { return optionalFixed32_; } + set { + optionalFixed32_ = value; + } + } + + /// Field number for the "optional_fixed64" field. + public const int OptionalFixed64FieldNumber = 8; + private ulong optionalFixed64_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ulong OptionalFixed64 { + get { return optionalFixed64_; } + set { + optionalFixed64_ = value; + } + } + + /// Field number for the "optional_sfixed32" field. + public const int OptionalSfixed32FieldNumber = 9; + private int optionalSfixed32_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int OptionalSfixed32 { + get { return optionalSfixed32_; } + set { + optionalSfixed32_ = value; + } + } + + /// Field number for the "optional_sfixed64" field. + public const int OptionalSfixed64FieldNumber = 10; + private long optionalSfixed64_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long OptionalSfixed64 { + get { return optionalSfixed64_; } + set { + optionalSfixed64_ = value; + } + } + + /// Field number for the "optional_float" field. + public const int OptionalFloatFieldNumber = 11; + private float optionalFloat_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float OptionalFloat { + get { return optionalFloat_; } + set { + optionalFloat_ = value; + } + } + + /// Field number for the "optional_double" field. + public const int OptionalDoubleFieldNumber = 12; + private double optionalDouble_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double OptionalDouble { + get { return optionalDouble_; } + set { + optionalDouble_ = value; + } + } + + /// Field number for the "optional_bool" field. + public const int OptionalBoolFieldNumber = 13; + private bool optionalBool_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool OptionalBool { + get { return optionalBool_; } + set { + optionalBool_ = value; + } + } + + /// Field number for the "optional_string" field. + public const int OptionalStringFieldNumber = 14; + private string optionalString_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string OptionalString { + get { return optionalString_; } + set { + optionalString_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "optional_bytes" field. + public const int OptionalBytesFieldNumber = 15; + private pb::ByteString optionalBytes_ = pb::ByteString.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString OptionalBytes { + get { return optionalBytes_; } + set { + optionalBytes_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "optional_nested_message" field. + public const int OptionalNestedMessageFieldNumber = 18; + private global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage optionalNestedMessage_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage OptionalNestedMessage { + get { return optionalNestedMessage_; } + set { + optionalNestedMessage_ = value; + } + } + + /// Field number for the "optional_foreign_message" field. + public const int OptionalForeignMessageFieldNumber = 19; + private global::ProtobufTestMessages.Proto3.ForeignMessage optionalForeignMessage_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::ProtobufTestMessages.Proto3.ForeignMessage OptionalForeignMessage { + get { return optionalForeignMessage_; } + set { + optionalForeignMessage_ = value; + } + } + + /// Field number for the "optional_nested_enum" field. + public const int OptionalNestedEnumFieldNumber = 21; + private global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum optionalNestedEnum_ = global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum.Foo; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum OptionalNestedEnum { + get { return optionalNestedEnum_; } + set { + optionalNestedEnum_ = value; + } + } + + /// Field number for the "optional_foreign_enum" field. + public const int OptionalForeignEnumFieldNumber = 22; + private global::ProtobufTestMessages.Proto3.ForeignEnum optionalForeignEnum_ = global::ProtobufTestMessages.Proto3.ForeignEnum.ForeignFoo; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::ProtobufTestMessages.Proto3.ForeignEnum OptionalForeignEnum { + get { return optionalForeignEnum_; } + set { + optionalForeignEnum_ = value; + } + } + + /// Field number for the "optional_aliased_enum" field. + public const int OptionalAliasedEnumFieldNumber = 23; + private global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.AliasedEnum optionalAliasedEnum_ = global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.AliasedEnum.AliasFoo; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.AliasedEnum OptionalAliasedEnum { + get { return optionalAliasedEnum_; } + set { + optionalAliasedEnum_ = value; + } + } + + /// Field number for the "optional_string_piece" field. + public const int OptionalStringPieceFieldNumber = 24; + private string optionalStringPiece_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string OptionalStringPiece { + get { return optionalStringPiece_; } + set { + optionalStringPiece_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "optional_cord" field. + public const int OptionalCordFieldNumber = 25; + private string optionalCord_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string OptionalCord { + get { return optionalCord_; } + set { + optionalCord_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "recursive_message" field. + public const int RecursiveMessageFieldNumber = 27; + private global::ProtobufTestMessages.Proto3.TestAllTypesProto3 recursiveMessage_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::ProtobufTestMessages.Proto3.TestAllTypesProto3 RecursiveMessage { + get { return recursiveMessage_; } + set { + recursiveMessage_ = value; + } + } + + /// Field number for the "repeated_int32" field. + public const int RepeatedInt32FieldNumber = 31; + private static readonly pb::FieldCodec _repeated_repeatedInt32_codec + = pb::FieldCodec.ForInt32(250); + private readonly pbc::RepeatedField repeatedInt32_ = new pbc::RepeatedField(); + /// + /// Repeated + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedInt32 { + get { return repeatedInt32_; } + } + + /// Field number for the "repeated_int64" field. + public const int RepeatedInt64FieldNumber = 32; + private static readonly pb::FieldCodec _repeated_repeatedInt64_codec + = pb::FieldCodec.ForInt64(258); + private readonly pbc::RepeatedField repeatedInt64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedInt64 { + get { return repeatedInt64_; } + } + + /// Field number for the "repeated_uint32" field. + public const int RepeatedUint32FieldNumber = 33; + private static readonly pb::FieldCodec _repeated_repeatedUint32_codec + = pb::FieldCodec.ForUInt32(266); + private readonly pbc::RepeatedField repeatedUint32_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedUint32 { + get { return repeatedUint32_; } + } + + /// Field number for the "repeated_uint64" field. + public const int RepeatedUint64FieldNumber = 34; + private static readonly pb::FieldCodec _repeated_repeatedUint64_codec + = pb::FieldCodec.ForUInt64(274); + private readonly pbc::RepeatedField repeatedUint64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedUint64 { + get { return repeatedUint64_; } + } + + /// Field number for the "repeated_sint32" field. + public const int RepeatedSint32FieldNumber = 35; + private static readonly pb::FieldCodec _repeated_repeatedSint32_codec + = pb::FieldCodec.ForSInt32(282); + private readonly pbc::RepeatedField repeatedSint32_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedSint32 { + get { return repeatedSint32_; } + } + + /// Field number for the "repeated_sint64" field. + public const int RepeatedSint64FieldNumber = 36; + private static readonly pb::FieldCodec _repeated_repeatedSint64_codec + = pb::FieldCodec.ForSInt64(290); + private readonly pbc::RepeatedField repeatedSint64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedSint64 { + get { return repeatedSint64_; } + } + + /// Field number for the "repeated_fixed32" field. + public const int RepeatedFixed32FieldNumber = 37; + private static readonly pb::FieldCodec _repeated_repeatedFixed32_codec + = pb::FieldCodec.ForFixed32(298); + private readonly pbc::RepeatedField repeatedFixed32_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedFixed32 { + get { return repeatedFixed32_; } + } + + /// Field number for the "repeated_fixed64" field. + public const int RepeatedFixed64FieldNumber = 38; + private static readonly pb::FieldCodec _repeated_repeatedFixed64_codec + = pb::FieldCodec.ForFixed64(306); + private readonly pbc::RepeatedField repeatedFixed64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedFixed64 { + get { return repeatedFixed64_; } + } + + /// Field number for the "repeated_sfixed32" field. + public const int RepeatedSfixed32FieldNumber = 39; + private static readonly pb::FieldCodec _repeated_repeatedSfixed32_codec + = pb::FieldCodec.ForSFixed32(314); + private readonly pbc::RepeatedField repeatedSfixed32_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedSfixed32 { + get { return repeatedSfixed32_; } + } + + /// Field number for the "repeated_sfixed64" field. + public const int RepeatedSfixed64FieldNumber = 40; + private static readonly pb::FieldCodec _repeated_repeatedSfixed64_codec + = pb::FieldCodec.ForSFixed64(322); + private readonly pbc::RepeatedField repeatedSfixed64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedSfixed64 { + get { return repeatedSfixed64_; } + } + + /// Field number for the "repeated_float" field. + public const int RepeatedFloatFieldNumber = 41; + private static readonly pb::FieldCodec _repeated_repeatedFloat_codec + = pb::FieldCodec.ForFloat(330); + private readonly pbc::RepeatedField repeatedFloat_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedFloat { + get { return repeatedFloat_; } + } + + /// Field number for the "repeated_double" field. + public const int RepeatedDoubleFieldNumber = 42; + private static readonly pb::FieldCodec _repeated_repeatedDouble_codec + = pb::FieldCodec.ForDouble(338); + private readonly pbc::RepeatedField repeatedDouble_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedDouble { + get { return repeatedDouble_; } + } + + /// Field number for the "repeated_bool" field. + public const int RepeatedBoolFieldNumber = 43; + private static readonly pb::FieldCodec _repeated_repeatedBool_codec + = pb::FieldCodec.ForBool(346); + private readonly pbc::RepeatedField repeatedBool_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedBool { + get { return repeatedBool_; } + } + + /// Field number for the "repeated_string" field. + public const int RepeatedStringFieldNumber = 44; + private static readonly pb::FieldCodec _repeated_repeatedString_codec + = pb::FieldCodec.ForString(354); + private readonly pbc::RepeatedField repeatedString_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedString { + get { return repeatedString_; } + } + + /// Field number for the "repeated_bytes" field. + public const int RepeatedBytesFieldNumber = 45; + private static readonly pb::FieldCodec _repeated_repeatedBytes_codec + = pb::FieldCodec.ForBytes(362); + private readonly pbc::RepeatedField repeatedBytes_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedBytes { + get { return repeatedBytes_; } + } + + /// Field number for the "repeated_nested_message" field. + public const int RepeatedNestedMessageFieldNumber = 48; + private static readonly pb::FieldCodec _repeated_repeatedNestedMessage_codec + = pb::FieldCodec.ForMessage(386, global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage.Parser); + private readonly pbc::RepeatedField repeatedNestedMessage_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedNestedMessage { + get { return repeatedNestedMessage_; } + } + + /// Field number for the "repeated_foreign_message" field. + public const int RepeatedForeignMessageFieldNumber = 49; + private static readonly pb::FieldCodec _repeated_repeatedForeignMessage_codec + = pb::FieldCodec.ForMessage(394, global::ProtobufTestMessages.Proto3.ForeignMessage.Parser); + private readonly pbc::RepeatedField repeatedForeignMessage_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedForeignMessage { + get { return repeatedForeignMessage_; } + } + + /// Field number for the "repeated_nested_enum" field. + public const int RepeatedNestedEnumFieldNumber = 51; + private static readonly pb::FieldCodec _repeated_repeatedNestedEnum_codec + = pb::FieldCodec.ForEnum(410, x => (int) x, x => (global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum) x); + private readonly pbc::RepeatedField repeatedNestedEnum_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedNestedEnum { + get { return repeatedNestedEnum_; } + } + + /// Field number for the "repeated_foreign_enum" field. + public const int RepeatedForeignEnumFieldNumber = 52; + private static readonly pb::FieldCodec _repeated_repeatedForeignEnum_codec + = pb::FieldCodec.ForEnum(418, x => (int) x, x => (global::ProtobufTestMessages.Proto3.ForeignEnum) x); + private readonly pbc::RepeatedField repeatedForeignEnum_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedForeignEnum { + get { return repeatedForeignEnum_; } + } + + /// Field number for the "repeated_string_piece" field. + public const int RepeatedStringPieceFieldNumber = 54; + private static readonly pb::FieldCodec _repeated_repeatedStringPiece_codec + = pb::FieldCodec.ForString(434); + private readonly pbc::RepeatedField repeatedStringPiece_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedStringPiece { + get { return repeatedStringPiece_; } + } + + /// Field number for the "repeated_cord" field. + public const int RepeatedCordFieldNumber = 55; + private static readonly pb::FieldCodec _repeated_repeatedCord_codec + = pb::FieldCodec.ForString(442); + private readonly pbc::RepeatedField repeatedCord_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedCord { + get { return repeatedCord_; } + } + + /// Field number for the "map_int32_int32" field. + public const int MapInt32Int32FieldNumber = 56; + private static readonly pbc::MapField.Codec _map_mapInt32Int32_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForInt32(16, 0), 450); + private readonly pbc::MapField mapInt32Int32_ = new pbc::MapField(); + /// + /// Map + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField MapInt32Int32 { + get { return mapInt32Int32_; } + } + + /// Field number for the "map_int64_int64" field. + public const int MapInt64Int64FieldNumber = 57; + private static readonly pbc::MapField.Codec _map_mapInt64Int64_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt64(8, 0L), pb::FieldCodec.ForInt64(16, 0L), 458); + private readonly pbc::MapField mapInt64Int64_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField MapInt64Int64 { + get { return mapInt64Int64_; } + } + + /// Field number for the "map_uint32_uint32" field. + public const int MapUint32Uint32FieldNumber = 58; + private static readonly pbc::MapField.Codec _map_mapUint32Uint32_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForUInt32(8, 0), pb::FieldCodec.ForUInt32(16, 0), 466); + private readonly pbc::MapField mapUint32Uint32_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField MapUint32Uint32 { + get { return mapUint32Uint32_; } + } + + /// Field number for the "map_uint64_uint64" field. + public const int MapUint64Uint64FieldNumber = 59; + private static readonly pbc::MapField.Codec _map_mapUint64Uint64_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForUInt64(8, 0UL), pb::FieldCodec.ForUInt64(16, 0UL), 474); + private readonly pbc::MapField mapUint64Uint64_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField MapUint64Uint64 { + get { return mapUint64Uint64_; } + } + + /// Field number for the "map_sint32_sint32" field. + public const int MapSint32Sint32FieldNumber = 60; + private static readonly pbc::MapField.Codec _map_mapSint32Sint32_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForSInt32(8, 0), pb::FieldCodec.ForSInt32(16, 0), 482); + private readonly pbc::MapField mapSint32Sint32_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField MapSint32Sint32 { + get { return mapSint32Sint32_; } + } + + /// Field number for the "map_sint64_sint64" field. + public const int MapSint64Sint64FieldNumber = 61; + private static readonly pbc::MapField.Codec _map_mapSint64Sint64_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForSInt64(8, 0L), pb::FieldCodec.ForSInt64(16, 0L), 490); + private readonly pbc::MapField mapSint64Sint64_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField MapSint64Sint64 { + get { return mapSint64Sint64_; } + } + + /// Field number for the "map_fixed32_fixed32" field. + public const int MapFixed32Fixed32FieldNumber = 62; + private static readonly pbc::MapField.Codec _map_mapFixed32Fixed32_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForFixed32(13, 0), pb::FieldCodec.ForFixed32(21, 0), 498); + private readonly pbc::MapField mapFixed32Fixed32_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField MapFixed32Fixed32 { + get { return mapFixed32Fixed32_; } + } + + /// Field number for the "map_fixed64_fixed64" field. + public const int MapFixed64Fixed64FieldNumber = 63; + private static readonly pbc::MapField.Codec _map_mapFixed64Fixed64_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForFixed64(9, 0UL), pb::FieldCodec.ForFixed64(17, 0UL), 506); + private readonly pbc::MapField mapFixed64Fixed64_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField MapFixed64Fixed64 { + get { return mapFixed64Fixed64_; } + } + + /// Field number for the "map_sfixed32_sfixed32" field. + public const int MapSfixed32Sfixed32FieldNumber = 64; + private static readonly pbc::MapField.Codec _map_mapSfixed32Sfixed32_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForSFixed32(13, 0), pb::FieldCodec.ForSFixed32(21, 0), 514); + private readonly pbc::MapField mapSfixed32Sfixed32_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField MapSfixed32Sfixed32 { + get { return mapSfixed32Sfixed32_; } + } + + /// Field number for the "map_sfixed64_sfixed64" field. + public const int MapSfixed64Sfixed64FieldNumber = 65; + private static readonly pbc::MapField.Codec _map_mapSfixed64Sfixed64_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForSFixed64(9, 0L), pb::FieldCodec.ForSFixed64(17, 0L), 522); + private readonly pbc::MapField mapSfixed64Sfixed64_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField MapSfixed64Sfixed64 { + get { return mapSfixed64Sfixed64_; } + } + + /// Field number for the "map_int32_float" field. + public const int MapInt32FloatFieldNumber = 66; + private static readonly pbc::MapField.Codec _map_mapInt32Float_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForFloat(21, 0F), 530); + private readonly pbc::MapField mapInt32Float_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField MapInt32Float { + get { return mapInt32Float_; } + } + + /// Field number for the "map_int32_double" field. + public const int MapInt32DoubleFieldNumber = 67; + private static readonly pbc::MapField.Codec _map_mapInt32Double_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForDouble(17, 0D), 538); + private readonly pbc::MapField mapInt32Double_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField MapInt32Double { + get { return mapInt32Double_; } + } + + /// Field number for the "map_bool_bool" field. + public const int MapBoolBoolFieldNumber = 68; + private static readonly pbc::MapField.Codec _map_mapBoolBool_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForBool(8, false), pb::FieldCodec.ForBool(16, false), 546); + private readonly pbc::MapField mapBoolBool_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField MapBoolBool { + get { return mapBoolBool_; } + } + + /// Field number for the "map_string_string" field. + public const int MapStringStringFieldNumber = 69; + private static readonly pbc::MapField.Codec _map_mapStringString_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForString(10, ""), pb::FieldCodec.ForString(18, ""), 554); + private readonly pbc::MapField mapStringString_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField MapStringString { + get { return mapStringString_; } + } + + /// Field number for the "map_string_bytes" field. + public const int MapStringBytesFieldNumber = 70; + private static readonly pbc::MapField.Codec _map_mapStringBytes_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForString(10, ""), pb::FieldCodec.ForBytes(18, pb::ByteString.Empty), 562); + private readonly pbc::MapField mapStringBytes_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField MapStringBytes { + get { return mapStringBytes_; } + } + + /// Field number for the "map_string_nested_message" field. + public const int MapStringNestedMessageFieldNumber = 71; + private static readonly pbc::MapField.Codec _map_mapStringNestedMessage_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForString(10, ""), pb::FieldCodec.ForMessage(18, global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage.Parser), 570); + private readonly pbc::MapField mapStringNestedMessage_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField MapStringNestedMessage { + get { return mapStringNestedMessage_; } + } + + /// Field number for the "map_string_foreign_message" field. + public const int MapStringForeignMessageFieldNumber = 72; + private static readonly pbc::MapField.Codec _map_mapStringForeignMessage_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForString(10, ""), pb::FieldCodec.ForMessage(18, global::ProtobufTestMessages.Proto3.ForeignMessage.Parser), 578); + private readonly pbc::MapField mapStringForeignMessage_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField MapStringForeignMessage { + get { return mapStringForeignMessage_; } + } + + /// Field number for the "map_string_nested_enum" field. + public const int MapStringNestedEnumFieldNumber = 73; + private static readonly pbc::MapField.Codec _map_mapStringNestedEnum_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForString(10, ""), pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum) x, global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum.Foo), 586); + private readonly pbc::MapField mapStringNestedEnum_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField MapStringNestedEnum { + get { return mapStringNestedEnum_; } + } + + /// Field number for the "map_string_foreign_enum" field. + public const int MapStringForeignEnumFieldNumber = 74; + private static readonly pbc::MapField.Codec _map_mapStringForeignEnum_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForString(10, ""), pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::ProtobufTestMessages.Proto3.ForeignEnum) x, global::ProtobufTestMessages.Proto3.ForeignEnum.ForeignFoo), 594); + private readonly pbc::MapField mapStringForeignEnum_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField MapStringForeignEnum { + get { return mapStringForeignEnum_; } + } + + /// Field number for the "oneof_uint32" field. + public const int OneofUint32FieldNumber = 111; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint OneofUint32 { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint32 ? (uint) oneofField_ : 0; } + set { + oneofField_ = value; + oneofFieldCase_ = OneofFieldOneofCase.OneofUint32; + } + } + + /// Field number for the "oneof_nested_message" field. + public const int OneofNestedMessageFieldNumber = 112; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage OneofNestedMessage { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage ? (global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage) oneofField_ : null; } + set { + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.OneofNestedMessage; + } + } + + /// Field number for the "oneof_string" field. + public const int OneofStringFieldNumber = 113; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string OneofString { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofString ? (string) oneofField_ : ""; } + set { + oneofField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + oneofFieldCase_ = OneofFieldOneofCase.OneofString; + } + } + + /// Field number for the "oneof_bytes" field. + public const int OneofBytesFieldNumber = 114; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString OneofBytes { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBytes ? (pb::ByteString) oneofField_ : pb::ByteString.Empty; } + set { + oneofField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + oneofFieldCase_ = OneofFieldOneofCase.OneofBytes; + } + } + + /// Field number for the "oneof_bool" field. + public const int OneofBoolFieldNumber = 115; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool OneofBool { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBool ? (bool) oneofField_ : false; } + set { + oneofField_ = value; + oneofFieldCase_ = OneofFieldOneofCase.OneofBool; + } + } + + /// Field number for the "oneof_uint64" field. + public const int OneofUint64FieldNumber = 116; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ulong OneofUint64 { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint64 ? (ulong) oneofField_ : 0UL; } + set { + oneofField_ = value; + oneofFieldCase_ = OneofFieldOneofCase.OneofUint64; + } + } + + /// Field number for the "oneof_float" field. + public const int OneofFloatFieldNumber = 117; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float OneofFloat { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofFloat ? (float) oneofField_ : 0F; } + set { + oneofField_ = value; + oneofFieldCase_ = OneofFieldOneofCase.OneofFloat; + } + } + + /// Field number for the "oneof_double" field. + public const int OneofDoubleFieldNumber = 118; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double OneofDouble { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofDouble ? (double) oneofField_ : 0D; } + set { + oneofField_ = value; + oneofFieldCase_ = OneofFieldOneofCase.OneofDouble; + } + } + + /// Field number for the "oneof_enum" field. + public const int OneofEnumFieldNumber = 119; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum OneofEnum { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofEnum ? (global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum) oneofField_ : global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum.Foo; } + set { + oneofField_ = value; + oneofFieldCase_ = OneofFieldOneofCase.OneofEnum; + } + } + + /// Field number for the "optional_bool_wrapper" field. + public const int OptionalBoolWrapperFieldNumber = 201; + private static readonly pb::FieldCodec _single_optionalBoolWrapper_codec = pb::FieldCodec.ForStructWrapper(1610); + private bool? optionalBoolWrapper_; + /// + /// Well-known types + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool? OptionalBoolWrapper { + get { return optionalBoolWrapper_; } + set { + optionalBoolWrapper_ = value; + } + } + + + /// Field number for the "optional_int32_wrapper" field. + public const int OptionalInt32WrapperFieldNumber = 202; + private static readonly pb::FieldCodec _single_optionalInt32Wrapper_codec = pb::FieldCodec.ForStructWrapper(1618); + private int? optionalInt32Wrapper_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int? OptionalInt32Wrapper { + get { return optionalInt32Wrapper_; } + set { + optionalInt32Wrapper_ = value; + } + } + + + /// Field number for the "optional_int64_wrapper" field. + public const int OptionalInt64WrapperFieldNumber = 203; + private static readonly pb::FieldCodec _single_optionalInt64Wrapper_codec = pb::FieldCodec.ForStructWrapper(1626); + private long? optionalInt64Wrapper_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long? OptionalInt64Wrapper { + get { return optionalInt64Wrapper_; } + set { + optionalInt64Wrapper_ = value; + } + } + + + /// Field number for the "optional_uint32_wrapper" field. + public const int OptionalUint32WrapperFieldNumber = 204; + private static readonly pb::FieldCodec _single_optionalUint32Wrapper_codec = pb::FieldCodec.ForStructWrapper(1634); + private uint? optionalUint32Wrapper_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint? OptionalUint32Wrapper { + get { return optionalUint32Wrapper_; } + set { + optionalUint32Wrapper_ = value; + } + } + + + /// Field number for the "optional_uint64_wrapper" field. + public const int OptionalUint64WrapperFieldNumber = 205; + private static readonly pb::FieldCodec _single_optionalUint64Wrapper_codec = pb::FieldCodec.ForStructWrapper(1642); + private ulong? optionalUint64Wrapper_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ulong? OptionalUint64Wrapper { + get { return optionalUint64Wrapper_; } + set { + optionalUint64Wrapper_ = value; + } + } + + + /// Field number for the "optional_float_wrapper" field. + public const int OptionalFloatWrapperFieldNumber = 206; + private static readonly pb::FieldCodec _single_optionalFloatWrapper_codec = pb::FieldCodec.ForStructWrapper(1650); + private float? optionalFloatWrapper_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float? OptionalFloatWrapper { + get { return optionalFloatWrapper_; } + set { + optionalFloatWrapper_ = value; + } + } + + + /// Field number for the "optional_double_wrapper" field. + public const int OptionalDoubleWrapperFieldNumber = 207; + private static readonly pb::FieldCodec _single_optionalDoubleWrapper_codec = pb::FieldCodec.ForStructWrapper(1658); + private double? optionalDoubleWrapper_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double? OptionalDoubleWrapper { + get { return optionalDoubleWrapper_; } + set { + optionalDoubleWrapper_ = value; + } + } + + + /// Field number for the "optional_string_wrapper" field. + public const int OptionalStringWrapperFieldNumber = 208; + private static readonly pb::FieldCodec _single_optionalStringWrapper_codec = pb::FieldCodec.ForClassWrapper(1666); + private string optionalStringWrapper_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string OptionalStringWrapper { + get { return optionalStringWrapper_; } + set { + optionalStringWrapper_ = value; + } + } + + + /// Field number for the "optional_bytes_wrapper" field. + public const int OptionalBytesWrapperFieldNumber = 209; + private static readonly pb::FieldCodec _single_optionalBytesWrapper_codec = pb::FieldCodec.ForClassWrapper(1674); + private pb::ByteString optionalBytesWrapper_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString OptionalBytesWrapper { + get { return optionalBytesWrapper_; } + set { + optionalBytesWrapper_ = value; + } + } + + + /// Field number for the "repeated_bool_wrapper" field. + public const int RepeatedBoolWrapperFieldNumber = 211; + private static readonly pb::FieldCodec _repeated_repeatedBoolWrapper_codec + = pb::FieldCodec.ForStructWrapper(1690); + private readonly pbc::RepeatedField repeatedBoolWrapper_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedBoolWrapper { + get { return repeatedBoolWrapper_; } + } + + /// Field number for the "repeated_int32_wrapper" field. + public const int RepeatedInt32WrapperFieldNumber = 212; + private static readonly pb::FieldCodec _repeated_repeatedInt32Wrapper_codec + = pb::FieldCodec.ForStructWrapper(1698); + private readonly pbc::RepeatedField repeatedInt32Wrapper_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedInt32Wrapper { + get { return repeatedInt32Wrapper_; } + } + + /// Field number for the "repeated_int64_wrapper" field. + public const int RepeatedInt64WrapperFieldNumber = 213; + private static readonly pb::FieldCodec _repeated_repeatedInt64Wrapper_codec + = pb::FieldCodec.ForStructWrapper(1706); + private readonly pbc::RepeatedField repeatedInt64Wrapper_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedInt64Wrapper { + get { return repeatedInt64Wrapper_; } + } + + /// Field number for the "repeated_uint32_wrapper" field. + public const int RepeatedUint32WrapperFieldNumber = 214; + private static readonly pb::FieldCodec _repeated_repeatedUint32Wrapper_codec + = pb::FieldCodec.ForStructWrapper(1714); + private readonly pbc::RepeatedField repeatedUint32Wrapper_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedUint32Wrapper { + get { return repeatedUint32Wrapper_; } + } + + /// Field number for the "repeated_uint64_wrapper" field. + public const int RepeatedUint64WrapperFieldNumber = 215; + private static readonly pb::FieldCodec _repeated_repeatedUint64Wrapper_codec + = pb::FieldCodec.ForStructWrapper(1722); + private readonly pbc::RepeatedField repeatedUint64Wrapper_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedUint64Wrapper { + get { return repeatedUint64Wrapper_; } + } + + /// Field number for the "repeated_float_wrapper" field. + public const int RepeatedFloatWrapperFieldNumber = 216; + private static readonly pb::FieldCodec _repeated_repeatedFloatWrapper_codec + = pb::FieldCodec.ForStructWrapper(1730); + private readonly pbc::RepeatedField repeatedFloatWrapper_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedFloatWrapper { + get { return repeatedFloatWrapper_; } + } + + /// Field number for the "repeated_double_wrapper" field. + public const int RepeatedDoubleWrapperFieldNumber = 217; + private static readonly pb::FieldCodec _repeated_repeatedDoubleWrapper_codec + = pb::FieldCodec.ForStructWrapper(1738); + private readonly pbc::RepeatedField repeatedDoubleWrapper_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedDoubleWrapper { + get { return repeatedDoubleWrapper_; } + } + + /// Field number for the "repeated_string_wrapper" field. + public const int RepeatedStringWrapperFieldNumber = 218; + private static readonly pb::FieldCodec _repeated_repeatedStringWrapper_codec + = pb::FieldCodec.ForClassWrapper(1746); + private readonly pbc::RepeatedField repeatedStringWrapper_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedStringWrapper { + get { return repeatedStringWrapper_; } + } + + /// Field number for the "repeated_bytes_wrapper" field. + public const int RepeatedBytesWrapperFieldNumber = 219; + private static readonly pb::FieldCodec _repeated_repeatedBytesWrapper_codec + = pb::FieldCodec.ForClassWrapper(1754); + private readonly pbc::RepeatedField repeatedBytesWrapper_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedBytesWrapper { + get { return repeatedBytesWrapper_; } + } + + /// Field number for the "optional_duration" field. + public const int OptionalDurationFieldNumber = 301; + private global::Google.Protobuf.WellKnownTypes.Duration optionalDuration_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.WellKnownTypes.Duration OptionalDuration { + get { return optionalDuration_; } + set { + optionalDuration_ = value; + } + } + + /// Field number for the "optional_timestamp" field. + public const int OptionalTimestampFieldNumber = 302; + private global::Google.Protobuf.WellKnownTypes.Timestamp optionalTimestamp_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.WellKnownTypes.Timestamp OptionalTimestamp { + get { return optionalTimestamp_; } + set { + optionalTimestamp_ = value; + } + } + + /// Field number for the "optional_field_mask" field. + public const int OptionalFieldMaskFieldNumber = 303; + private global::Google.Protobuf.WellKnownTypes.FieldMask optionalFieldMask_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.WellKnownTypes.FieldMask OptionalFieldMask { + get { return optionalFieldMask_; } + set { + optionalFieldMask_ = value; + } + } + + /// Field number for the "optional_struct" field. + public const int OptionalStructFieldNumber = 304; + private global::Google.Protobuf.WellKnownTypes.Struct optionalStruct_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.WellKnownTypes.Struct OptionalStruct { + get { return optionalStruct_; } + set { + optionalStruct_ = value; + } + } + + /// Field number for the "optional_any" field. + public const int OptionalAnyFieldNumber = 305; + private global::Google.Protobuf.WellKnownTypes.Any optionalAny_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.WellKnownTypes.Any OptionalAny { + get { return optionalAny_; } + set { + optionalAny_ = value; + } + } + + /// Field number for the "optional_value" field. + public const int OptionalValueFieldNumber = 306; + private global::Google.Protobuf.WellKnownTypes.Value optionalValue_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.WellKnownTypes.Value OptionalValue { + get { return optionalValue_; } + set { + optionalValue_ = value; + } + } + + /// Field number for the "repeated_duration" field. + public const int RepeatedDurationFieldNumber = 311; + private static readonly pb::FieldCodec _repeated_repeatedDuration_codec + = pb::FieldCodec.ForMessage(2490, global::Google.Protobuf.WellKnownTypes.Duration.Parser); + private readonly pbc::RepeatedField repeatedDuration_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedDuration { + get { return repeatedDuration_; } + } + + /// Field number for the "repeated_timestamp" field. + public const int RepeatedTimestampFieldNumber = 312; + private static readonly pb::FieldCodec _repeated_repeatedTimestamp_codec + = pb::FieldCodec.ForMessage(2498, global::Google.Protobuf.WellKnownTypes.Timestamp.Parser); + private readonly pbc::RepeatedField repeatedTimestamp_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedTimestamp { + get { return repeatedTimestamp_; } + } + + /// Field number for the "repeated_fieldmask" field. + public const int RepeatedFieldmaskFieldNumber = 313; + private static readonly pb::FieldCodec _repeated_repeatedFieldmask_codec + = pb::FieldCodec.ForMessage(2506, global::Google.Protobuf.WellKnownTypes.FieldMask.Parser); + private readonly pbc::RepeatedField repeatedFieldmask_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedFieldmask { + get { return repeatedFieldmask_; } + } + + /// Field number for the "repeated_struct" field. + public const int RepeatedStructFieldNumber = 324; + private static readonly pb::FieldCodec _repeated_repeatedStruct_codec + = pb::FieldCodec.ForMessage(2594, global::Google.Protobuf.WellKnownTypes.Struct.Parser); + private readonly pbc::RepeatedField repeatedStruct_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedStruct { + get { return repeatedStruct_; } + } + + /// Field number for the "repeated_any" field. + public const int RepeatedAnyFieldNumber = 315; + private static readonly pb::FieldCodec _repeated_repeatedAny_codec + = pb::FieldCodec.ForMessage(2522, global::Google.Protobuf.WellKnownTypes.Any.Parser); + private readonly pbc::RepeatedField repeatedAny_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedAny { + get { return repeatedAny_; } + } + + /// Field number for the "repeated_value" field. + public const int RepeatedValueFieldNumber = 316; + private static readonly pb::FieldCodec _repeated_repeatedValue_codec + = pb::FieldCodec.ForMessage(2530, global::Google.Protobuf.WellKnownTypes.Value.Parser); + private readonly pbc::RepeatedField repeatedValue_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedValue { + get { return repeatedValue_; } + } + + /// Field number for the "repeated_list_value" field. + public const int RepeatedListValueFieldNumber = 317; + private static readonly pb::FieldCodec _repeated_repeatedListValue_codec + = pb::FieldCodec.ForMessage(2538, global::Google.Protobuf.WellKnownTypes.ListValue.Parser); + private readonly pbc::RepeatedField repeatedListValue_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedListValue { + get { return repeatedListValue_; } + } + + /// Field number for the "fieldname1" field. + public const int Fieldname1FieldNumber = 401; + private int fieldname1_; + /// + /// Test field-name-to-JSON-name convention. + /// (protobuf says names can be any valid C/C++ identifier.) + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Fieldname1 { + get { return fieldname1_; } + set { + fieldname1_ = value; + } + } + + /// Field number for the "field_name2" field. + public const int FieldName2FieldNumber = 402; + private int fieldName2_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName2 { + get { return fieldName2_; } + set { + fieldName2_ = value; + } + } + + /// Field number for the "_field_name3" field. + public const int FieldName3FieldNumber = 403; + private int FieldName3_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName3 { + get { return FieldName3_; } + set { + FieldName3_ = value; + } + } + + /// Field number for the "field__name4_" field. + public const int FieldName4FieldNumber = 404; + private int fieldName4_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName4 { + get { return fieldName4_; } + set { + fieldName4_ = value; + } + } + + /// Field number for the "field0name5" field. + public const int Field0Name5FieldNumber = 405; + private int field0Name5_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field0Name5 { + get { return field0Name5_; } + set { + field0Name5_ = value; + } + } + + /// Field number for the "field_0_name6" field. + public const int Field0Name6FieldNumber = 406; + private int field0Name6_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field0Name6 { + get { return field0Name6_; } + set { + field0Name6_ = value; + } + } + + /// Field number for the "fieldName7" field. + public const int FieldName7FieldNumber = 407; + private int fieldName7_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName7 { + get { return fieldName7_; } + set { + fieldName7_ = value; + } + } + + /// Field number for the "FieldName8" field. + public const int FieldName8FieldNumber = 408; + private int fieldName8_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName8 { + get { return fieldName8_; } + set { + fieldName8_ = value; + } + } + + /// Field number for the "field_Name9" field. + public const int FieldName9FieldNumber = 409; + private int fieldName9_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName9 { + get { return fieldName9_; } + set { + fieldName9_ = value; + } + } + + /// Field number for the "Field_Name10" field. + public const int FieldName10FieldNumber = 410; + private int fieldName10_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName10 { + get { return fieldName10_; } + set { + fieldName10_ = value; + } + } + + /// Field number for the "FIELD_NAME11" field. + public const int FIELDNAME11FieldNumber = 411; + private int fIELDNAME11_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FIELDNAME11 { + get { return fIELDNAME11_; } + set { + fIELDNAME11_ = value; + } + } + + /// Field number for the "FIELD_name12" field. + public const int FIELDName12FieldNumber = 412; + private int fIELDName12_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FIELDName12 { + get { return fIELDName12_; } + set { + fIELDName12_ = value; + } + } + + /// Field number for the "__field_name13" field. + public const int FieldName13FieldNumber = 413; + private int FieldName13_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName13 { + get { return FieldName13_; } + set { + FieldName13_ = value; + } + } + + /// Field number for the "__Field_name14" field. + public const int FieldName14FieldNumber = 414; + private int FieldName14_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName14 { + get { return FieldName14_; } + set { + FieldName14_ = value; + } + } + + /// Field number for the "field__name15" field. + public const int FieldName15FieldNumber = 415; + private int fieldName15_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName15 { + get { return fieldName15_; } + set { + fieldName15_ = value; + } + } + + /// Field number for the "field__Name16" field. + public const int FieldName16FieldNumber = 416; + private int fieldName16_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName16 { + get { return fieldName16_; } + set { + fieldName16_ = value; + } + } + + /// Field number for the "field_name17__" field. + public const int FieldName17FieldNumber = 417; + private int fieldName17_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName17 { + get { return fieldName17_; } + set { + fieldName17_ = value; + } + } + + /// Field number for the "Field_name18__" field. + public const int FieldName18FieldNumber = 418; + private int fieldName18_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName18 { + get { return fieldName18_; } + set { + fieldName18_ = value; + } + } + + private object oneofField_; + /// Enum of possible cases for the "oneof_field" oneof. + public enum OneofFieldOneofCase { + None = 0, + OneofUint32 = 111, + OneofNestedMessage = 112, + OneofString = 113, + OneofBytes = 114, + OneofBool = 115, + OneofUint64 = 116, + OneofFloat = 117, + OneofDouble = 118, + OneofEnum = 119, + } + private OneofFieldOneofCase oneofFieldCase_ = OneofFieldOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public OneofFieldOneofCase OneofFieldCase { + get { return oneofFieldCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearOneofField() { + oneofFieldCase_ = OneofFieldOneofCase.None; + oneofField_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as TestAllTypesProto3); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(TestAllTypesProto3 other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (OptionalInt32 != other.OptionalInt32) return false; + if (OptionalInt64 != other.OptionalInt64) return false; + if (OptionalUint32 != other.OptionalUint32) return false; + if (OptionalUint64 != other.OptionalUint64) return false; + if (OptionalSint32 != other.OptionalSint32) return false; + if (OptionalSint64 != other.OptionalSint64) return false; + if (OptionalFixed32 != other.OptionalFixed32) return false; + if (OptionalFixed64 != other.OptionalFixed64) return false; + if (OptionalSfixed32 != other.OptionalSfixed32) return false; + if (OptionalSfixed64 != other.OptionalSfixed64) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(OptionalFloat, other.OptionalFloat)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(OptionalDouble, other.OptionalDouble)) return false; + if (OptionalBool != other.OptionalBool) return false; + if (OptionalString != other.OptionalString) return false; + if (OptionalBytes != other.OptionalBytes) return false; + if (!object.Equals(OptionalNestedMessage, other.OptionalNestedMessage)) return false; + if (!object.Equals(OptionalForeignMessage, other.OptionalForeignMessage)) return false; + if (OptionalNestedEnum != other.OptionalNestedEnum) return false; + if (OptionalForeignEnum != other.OptionalForeignEnum) return false; + if (OptionalAliasedEnum != other.OptionalAliasedEnum) return false; + if (OptionalStringPiece != other.OptionalStringPiece) return false; + if (OptionalCord != other.OptionalCord) return false; + if (!object.Equals(RecursiveMessage, other.RecursiveMessage)) return false; + if(!repeatedInt32_.Equals(other.repeatedInt32_)) return false; + if(!repeatedInt64_.Equals(other.repeatedInt64_)) return false; + if(!repeatedUint32_.Equals(other.repeatedUint32_)) return false; + if(!repeatedUint64_.Equals(other.repeatedUint64_)) return false; + if(!repeatedSint32_.Equals(other.repeatedSint32_)) return false; + if(!repeatedSint64_.Equals(other.repeatedSint64_)) return false; + if(!repeatedFixed32_.Equals(other.repeatedFixed32_)) return false; + if(!repeatedFixed64_.Equals(other.repeatedFixed64_)) return false; + if(!repeatedSfixed32_.Equals(other.repeatedSfixed32_)) return false; + if(!repeatedSfixed64_.Equals(other.repeatedSfixed64_)) return false; + if(!repeatedFloat_.Equals(other.repeatedFloat_)) return false; + if(!repeatedDouble_.Equals(other.repeatedDouble_)) return false; + if(!repeatedBool_.Equals(other.repeatedBool_)) return false; + if(!repeatedString_.Equals(other.repeatedString_)) return false; + if(!repeatedBytes_.Equals(other.repeatedBytes_)) return false; + if(!repeatedNestedMessage_.Equals(other.repeatedNestedMessage_)) return false; + if(!repeatedForeignMessage_.Equals(other.repeatedForeignMessage_)) return false; + if(!repeatedNestedEnum_.Equals(other.repeatedNestedEnum_)) return false; + if(!repeatedForeignEnum_.Equals(other.repeatedForeignEnum_)) return false; + if(!repeatedStringPiece_.Equals(other.repeatedStringPiece_)) return false; + if(!repeatedCord_.Equals(other.repeatedCord_)) return false; + if (!MapInt32Int32.Equals(other.MapInt32Int32)) return false; + if (!MapInt64Int64.Equals(other.MapInt64Int64)) return false; + if (!MapUint32Uint32.Equals(other.MapUint32Uint32)) return false; + if (!MapUint64Uint64.Equals(other.MapUint64Uint64)) return false; + if (!MapSint32Sint32.Equals(other.MapSint32Sint32)) return false; + if (!MapSint64Sint64.Equals(other.MapSint64Sint64)) return false; + if (!MapFixed32Fixed32.Equals(other.MapFixed32Fixed32)) return false; + if (!MapFixed64Fixed64.Equals(other.MapFixed64Fixed64)) return false; + if (!MapSfixed32Sfixed32.Equals(other.MapSfixed32Sfixed32)) return false; + if (!MapSfixed64Sfixed64.Equals(other.MapSfixed64Sfixed64)) return false; + if (!MapInt32Float.Equals(other.MapInt32Float)) return false; + if (!MapInt32Double.Equals(other.MapInt32Double)) return false; + if (!MapBoolBool.Equals(other.MapBoolBool)) return false; + if (!MapStringString.Equals(other.MapStringString)) return false; + if (!MapStringBytes.Equals(other.MapStringBytes)) return false; + if (!MapStringNestedMessage.Equals(other.MapStringNestedMessage)) return false; + if (!MapStringForeignMessage.Equals(other.MapStringForeignMessage)) return false; + if (!MapStringNestedEnum.Equals(other.MapStringNestedEnum)) return false; + if (!MapStringForeignEnum.Equals(other.MapStringForeignEnum)) return false; + if (OneofUint32 != other.OneofUint32) return false; + if (!object.Equals(OneofNestedMessage, other.OneofNestedMessage)) return false; + if (OneofString != other.OneofString) return false; + if (OneofBytes != other.OneofBytes) return false; + if (OneofBool != other.OneofBool) return false; + if (OneofUint64 != other.OneofUint64) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(OneofFloat, other.OneofFloat)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(OneofDouble, other.OneofDouble)) return false; + if (OneofEnum != other.OneofEnum) return false; + if (OptionalBoolWrapper != other.OptionalBoolWrapper) return false; + if (OptionalInt32Wrapper != other.OptionalInt32Wrapper) return false; + if (OptionalInt64Wrapper != other.OptionalInt64Wrapper) return false; + if (OptionalUint32Wrapper != other.OptionalUint32Wrapper) return false; + if (OptionalUint64Wrapper != other.OptionalUint64Wrapper) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseNullableSingleEqualityComparer.Equals(OptionalFloatWrapper, other.OptionalFloatWrapper)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseNullableDoubleEqualityComparer.Equals(OptionalDoubleWrapper, other.OptionalDoubleWrapper)) return false; + if (OptionalStringWrapper != other.OptionalStringWrapper) return false; + if (OptionalBytesWrapper != other.OptionalBytesWrapper) return false; + if(!repeatedBoolWrapper_.Equals(other.repeatedBoolWrapper_)) return false; + if(!repeatedInt32Wrapper_.Equals(other.repeatedInt32Wrapper_)) return false; + if(!repeatedInt64Wrapper_.Equals(other.repeatedInt64Wrapper_)) return false; + if(!repeatedUint32Wrapper_.Equals(other.repeatedUint32Wrapper_)) return false; + if(!repeatedUint64Wrapper_.Equals(other.repeatedUint64Wrapper_)) return false; + if(!repeatedFloatWrapper_.Equals(other.repeatedFloatWrapper_)) return false; + if(!repeatedDoubleWrapper_.Equals(other.repeatedDoubleWrapper_)) return false; + if(!repeatedStringWrapper_.Equals(other.repeatedStringWrapper_)) return false; + if(!repeatedBytesWrapper_.Equals(other.repeatedBytesWrapper_)) return false; + if (!object.Equals(OptionalDuration, other.OptionalDuration)) return false; + if (!object.Equals(OptionalTimestamp, other.OptionalTimestamp)) return false; + if (!object.Equals(OptionalFieldMask, other.OptionalFieldMask)) return false; + if (!object.Equals(OptionalStruct, other.OptionalStruct)) return false; + if (!object.Equals(OptionalAny, other.OptionalAny)) return false; + if (!object.Equals(OptionalValue, other.OptionalValue)) return false; + if(!repeatedDuration_.Equals(other.repeatedDuration_)) return false; + if(!repeatedTimestamp_.Equals(other.repeatedTimestamp_)) return false; + if(!repeatedFieldmask_.Equals(other.repeatedFieldmask_)) return false; + if(!repeatedStruct_.Equals(other.repeatedStruct_)) return false; + if(!repeatedAny_.Equals(other.repeatedAny_)) return false; + if(!repeatedValue_.Equals(other.repeatedValue_)) return false; + if(!repeatedListValue_.Equals(other.repeatedListValue_)) return false; + if (Fieldname1 != other.Fieldname1) return false; + if (FieldName2 != other.FieldName2) return false; + if (FieldName3 != other.FieldName3) return false; + if (FieldName4 != other.FieldName4) return false; + if (Field0Name5 != other.Field0Name5) return false; + if (Field0Name6 != other.Field0Name6) return false; + if (FieldName7 != other.FieldName7) return false; + if (FieldName8 != other.FieldName8) return false; + if (FieldName9 != other.FieldName9) return false; + if (FieldName10 != other.FieldName10) return false; + if (FIELDNAME11 != other.FIELDNAME11) return false; + if (FIELDName12 != other.FIELDName12) return false; + if (FieldName13 != other.FieldName13) return false; + if (FieldName14 != other.FieldName14) return false; + if (FieldName15 != other.FieldName15) return false; + if (FieldName16 != other.FieldName16) return false; + if (FieldName17 != other.FieldName17) return false; + if (FieldName18 != other.FieldName18) return false; + if (OneofFieldCase != other.OneofFieldCase) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (OptionalInt32 != 0) hash ^= OptionalInt32.GetHashCode(); + if (OptionalInt64 != 0L) hash ^= OptionalInt64.GetHashCode(); + if (OptionalUint32 != 0) hash ^= OptionalUint32.GetHashCode(); + if (OptionalUint64 != 0UL) hash ^= OptionalUint64.GetHashCode(); + if (OptionalSint32 != 0) hash ^= OptionalSint32.GetHashCode(); + if (OptionalSint64 != 0L) hash ^= OptionalSint64.GetHashCode(); + if (OptionalFixed32 != 0) hash ^= OptionalFixed32.GetHashCode(); + if (OptionalFixed64 != 0UL) hash ^= OptionalFixed64.GetHashCode(); + if (OptionalSfixed32 != 0) hash ^= OptionalSfixed32.GetHashCode(); + if (OptionalSfixed64 != 0L) hash ^= OptionalSfixed64.GetHashCode(); + if (OptionalFloat != 0F) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(OptionalFloat); + if (OptionalDouble != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(OptionalDouble); + if (OptionalBool != false) hash ^= OptionalBool.GetHashCode(); + if (OptionalString.Length != 0) hash ^= OptionalString.GetHashCode(); + if (OptionalBytes.Length != 0) hash ^= OptionalBytes.GetHashCode(); + if (optionalNestedMessage_ != null) hash ^= OptionalNestedMessage.GetHashCode(); + if (optionalForeignMessage_ != null) hash ^= OptionalForeignMessage.GetHashCode(); + if (OptionalNestedEnum != global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum.Foo) hash ^= OptionalNestedEnum.GetHashCode(); + if (OptionalForeignEnum != global::ProtobufTestMessages.Proto3.ForeignEnum.ForeignFoo) hash ^= OptionalForeignEnum.GetHashCode(); + if (OptionalAliasedEnum != global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.AliasedEnum.AliasFoo) hash ^= OptionalAliasedEnum.GetHashCode(); + if (OptionalStringPiece.Length != 0) hash ^= OptionalStringPiece.GetHashCode(); + if (OptionalCord.Length != 0) hash ^= OptionalCord.GetHashCode(); + if (recursiveMessage_ != null) hash ^= RecursiveMessage.GetHashCode(); + hash ^= repeatedInt32_.GetHashCode(); + hash ^= repeatedInt64_.GetHashCode(); + hash ^= repeatedUint32_.GetHashCode(); + hash ^= repeatedUint64_.GetHashCode(); + hash ^= repeatedSint32_.GetHashCode(); + hash ^= repeatedSint64_.GetHashCode(); + hash ^= repeatedFixed32_.GetHashCode(); + hash ^= repeatedFixed64_.GetHashCode(); + hash ^= repeatedSfixed32_.GetHashCode(); + hash ^= repeatedSfixed64_.GetHashCode(); + hash ^= repeatedFloat_.GetHashCode(); + hash ^= repeatedDouble_.GetHashCode(); + hash ^= repeatedBool_.GetHashCode(); + hash ^= repeatedString_.GetHashCode(); + hash ^= repeatedBytes_.GetHashCode(); + hash ^= repeatedNestedMessage_.GetHashCode(); + hash ^= repeatedForeignMessage_.GetHashCode(); + hash ^= repeatedNestedEnum_.GetHashCode(); + hash ^= repeatedForeignEnum_.GetHashCode(); + hash ^= repeatedStringPiece_.GetHashCode(); + hash ^= repeatedCord_.GetHashCode(); + hash ^= MapInt32Int32.GetHashCode(); + hash ^= MapInt64Int64.GetHashCode(); + hash ^= MapUint32Uint32.GetHashCode(); + hash ^= MapUint64Uint64.GetHashCode(); + hash ^= MapSint32Sint32.GetHashCode(); + hash ^= MapSint64Sint64.GetHashCode(); + hash ^= MapFixed32Fixed32.GetHashCode(); + hash ^= MapFixed64Fixed64.GetHashCode(); + hash ^= MapSfixed32Sfixed32.GetHashCode(); + hash ^= MapSfixed64Sfixed64.GetHashCode(); + hash ^= MapInt32Float.GetHashCode(); + hash ^= MapInt32Double.GetHashCode(); + hash ^= MapBoolBool.GetHashCode(); + hash ^= MapStringString.GetHashCode(); + hash ^= MapStringBytes.GetHashCode(); + hash ^= MapStringNestedMessage.GetHashCode(); + hash ^= MapStringForeignMessage.GetHashCode(); + hash ^= MapStringNestedEnum.GetHashCode(); + hash ^= MapStringForeignEnum.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) hash ^= OneofUint32.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) hash ^= OneofNestedMessage.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) hash ^= OneofString.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) hash ^= OneofBytes.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofBool) hash ^= OneofBool.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint64) hash ^= OneofUint64.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(OneofFloat); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(OneofDouble); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) hash ^= OneofEnum.GetHashCode(); + if (optionalBoolWrapper_ != null) hash ^= OptionalBoolWrapper.GetHashCode(); + if (optionalInt32Wrapper_ != null) hash ^= OptionalInt32Wrapper.GetHashCode(); + if (optionalInt64Wrapper_ != null) hash ^= OptionalInt64Wrapper.GetHashCode(); + if (optionalUint32Wrapper_ != null) hash ^= OptionalUint32Wrapper.GetHashCode(); + if (optionalUint64Wrapper_ != null) hash ^= OptionalUint64Wrapper.GetHashCode(); + if (optionalFloatWrapper_ != null) hash ^= pbc::ProtobufEqualityComparers.BitwiseNullableSingleEqualityComparer.GetHashCode(OptionalFloatWrapper); + if (optionalDoubleWrapper_ != null) hash ^= pbc::ProtobufEqualityComparers.BitwiseNullableDoubleEqualityComparer.GetHashCode(OptionalDoubleWrapper); + if (optionalStringWrapper_ != null) hash ^= OptionalStringWrapper.GetHashCode(); + if (optionalBytesWrapper_ != null) hash ^= OptionalBytesWrapper.GetHashCode(); + hash ^= repeatedBoolWrapper_.GetHashCode(); + hash ^= repeatedInt32Wrapper_.GetHashCode(); + hash ^= repeatedInt64Wrapper_.GetHashCode(); + hash ^= repeatedUint32Wrapper_.GetHashCode(); + hash ^= repeatedUint64Wrapper_.GetHashCode(); + hash ^= repeatedFloatWrapper_.GetHashCode(); + hash ^= repeatedDoubleWrapper_.GetHashCode(); + hash ^= repeatedStringWrapper_.GetHashCode(); + hash ^= repeatedBytesWrapper_.GetHashCode(); + if (optionalDuration_ != null) hash ^= OptionalDuration.GetHashCode(); + if (optionalTimestamp_ != null) hash ^= OptionalTimestamp.GetHashCode(); + if (optionalFieldMask_ != null) hash ^= OptionalFieldMask.GetHashCode(); + if (optionalStruct_ != null) hash ^= OptionalStruct.GetHashCode(); + if (optionalAny_ != null) hash ^= OptionalAny.GetHashCode(); + if (optionalValue_ != null) hash ^= OptionalValue.GetHashCode(); + hash ^= repeatedDuration_.GetHashCode(); + hash ^= repeatedTimestamp_.GetHashCode(); + hash ^= repeatedFieldmask_.GetHashCode(); + hash ^= repeatedStruct_.GetHashCode(); + hash ^= repeatedAny_.GetHashCode(); + hash ^= repeatedValue_.GetHashCode(); + hash ^= repeatedListValue_.GetHashCode(); + if (Fieldname1 != 0) hash ^= Fieldname1.GetHashCode(); + if (FieldName2 != 0) hash ^= FieldName2.GetHashCode(); + if (FieldName3 != 0) hash ^= FieldName3.GetHashCode(); + if (FieldName4 != 0) hash ^= FieldName4.GetHashCode(); + if (Field0Name5 != 0) hash ^= Field0Name5.GetHashCode(); + if (Field0Name6 != 0) hash ^= Field0Name6.GetHashCode(); + if (FieldName7 != 0) hash ^= FieldName7.GetHashCode(); + if (FieldName8 != 0) hash ^= FieldName8.GetHashCode(); + if (FieldName9 != 0) hash ^= FieldName9.GetHashCode(); + if (FieldName10 != 0) hash ^= FieldName10.GetHashCode(); + if (FIELDNAME11 != 0) hash ^= FIELDNAME11.GetHashCode(); + if (FIELDName12 != 0) hash ^= FIELDName12.GetHashCode(); + if (FieldName13 != 0) hash ^= FieldName13.GetHashCode(); + if (FieldName14 != 0) hash ^= FieldName14.GetHashCode(); + if (FieldName15 != 0) hash ^= FieldName15.GetHashCode(); + if (FieldName16 != 0) hash ^= FieldName16.GetHashCode(); + if (FieldName17 != 0) hash ^= FieldName17.GetHashCode(); + if (FieldName18 != 0) hash ^= FieldName18.GetHashCode(); + hash ^= (int) oneofFieldCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (OptionalInt32 != 0) { + output.WriteRawTag(8); + output.WriteInt32(OptionalInt32); + } + if (OptionalInt64 != 0L) { + output.WriteRawTag(16); + output.WriteInt64(OptionalInt64); + } + if (OptionalUint32 != 0) { + output.WriteRawTag(24); + output.WriteUInt32(OptionalUint32); + } + if (OptionalUint64 != 0UL) { + output.WriteRawTag(32); + output.WriteUInt64(OptionalUint64); + } + if (OptionalSint32 != 0) { + output.WriteRawTag(40); + output.WriteSInt32(OptionalSint32); + } + if (OptionalSint64 != 0L) { + output.WriteRawTag(48); + output.WriteSInt64(OptionalSint64); + } + if (OptionalFixed32 != 0) { + output.WriteRawTag(61); + output.WriteFixed32(OptionalFixed32); + } + if (OptionalFixed64 != 0UL) { + output.WriteRawTag(65); + output.WriteFixed64(OptionalFixed64); + } + if (OptionalSfixed32 != 0) { + output.WriteRawTag(77); + output.WriteSFixed32(OptionalSfixed32); + } + if (OptionalSfixed64 != 0L) { + output.WriteRawTag(81); + output.WriteSFixed64(OptionalSfixed64); + } + if (OptionalFloat != 0F) { + output.WriteRawTag(93); + output.WriteFloat(OptionalFloat); + } + if (OptionalDouble != 0D) { + output.WriteRawTag(97); + output.WriteDouble(OptionalDouble); + } + if (OptionalBool != false) { + output.WriteRawTag(104); + output.WriteBool(OptionalBool); + } + if (OptionalString.Length != 0) { + output.WriteRawTag(114); + output.WriteString(OptionalString); + } + if (OptionalBytes.Length != 0) { + output.WriteRawTag(122); + output.WriteBytes(OptionalBytes); + } + if (optionalNestedMessage_ != null) { + output.WriteRawTag(146, 1); + output.WriteMessage(OptionalNestedMessage); + } + if (optionalForeignMessage_ != null) { + output.WriteRawTag(154, 1); + output.WriteMessage(OptionalForeignMessage); + } + if (OptionalNestedEnum != global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum.Foo) { + output.WriteRawTag(168, 1); + output.WriteEnum((int) OptionalNestedEnum); + } + if (OptionalForeignEnum != global::ProtobufTestMessages.Proto3.ForeignEnum.ForeignFoo) { + output.WriteRawTag(176, 1); + output.WriteEnum((int) OptionalForeignEnum); + } + if (OptionalAliasedEnum != global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.AliasedEnum.AliasFoo) { + output.WriteRawTag(184, 1); + output.WriteEnum((int) OptionalAliasedEnum); + } + if (OptionalStringPiece.Length != 0) { + output.WriteRawTag(194, 1); + output.WriteString(OptionalStringPiece); + } + if (OptionalCord.Length != 0) { + output.WriteRawTag(202, 1); + output.WriteString(OptionalCord); + } + if (recursiveMessage_ != null) { + output.WriteRawTag(218, 1); + output.WriteMessage(RecursiveMessage); + } + repeatedInt32_.WriteTo(output, _repeated_repeatedInt32_codec); + repeatedInt64_.WriteTo(output, _repeated_repeatedInt64_codec); + repeatedUint32_.WriteTo(output, _repeated_repeatedUint32_codec); + repeatedUint64_.WriteTo(output, _repeated_repeatedUint64_codec); + repeatedSint32_.WriteTo(output, _repeated_repeatedSint32_codec); + repeatedSint64_.WriteTo(output, _repeated_repeatedSint64_codec); + repeatedFixed32_.WriteTo(output, _repeated_repeatedFixed32_codec); + repeatedFixed64_.WriteTo(output, _repeated_repeatedFixed64_codec); + repeatedSfixed32_.WriteTo(output, _repeated_repeatedSfixed32_codec); + repeatedSfixed64_.WriteTo(output, _repeated_repeatedSfixed64_codec); + repeatedFloat_.WriteTo(output, _repeated_repeatedFloat_codec); + repeatedDouble_.WriteTo(output, _repeated_repeatedDouble_codec); + repeatedBool_.WriteTo(output, _repeated_repeatedBool_codec); + repeatedString_.WriteTo(output, _repeated_repeatedString_codec); + repeatedBytes_.WriteTo(output, _repeated_repeatedBytes_codec); + repeatedNestedMessage_.WriteTo(output, _repeated_repeatedNestedMessage_codec); + repeatedForeignMessage_.WriteTo(output, _repeated_repeatedForeignMessage_codec); + repeatedNestedEnum_.WriteTo(output, _repeated_repeatedNestedEnum_codec); + repeatedForeignEnum_.WriteTo(output, _repeated_repeatedForeignEnum_codec); + repeatedStringPiece_.WriteTo(output, _repeated_repeatedStringPiece_codec); + repeatedCord_.WriteTo(output, _repeated_repeatedCord_codec); + mapInt32Int32_.WriteTo(output, _map_mapInt32Int32_codec); + mapInt64Int64_.WriteTo(output, _map_mapInt64Int64_codec); + mapUint32Uint32_.WriteTo(output, _map_mapUint32Uint32_codec); + mapUint64Uint64_.WriteTo(output, _map_mapUint64Uint64_codec); + mapSint32Sint32_.WriteTo(output, _map_mapSint32Sint32_codec); + mapSint64Sint64_.WriteTo(output, _map_mapSint64Sint64_codec); + mapFixed32Fixed32_.WriteTo(output, _map_mapFixed32Fixed32_codec); + mapFixed64Fixed64_.WriteTo(output, _map_mapFixed64Fixed64_codec); + mapSfixed32Sfixed32_.WriteTo(output, _map_mapSfixed32Sfixed32_codec); + mapSfixed64Sfixed64_.WriteTo(output, _map_mapSfixed64Sfixed64_codec); + mapInt32Float_.WriteTo(output, _map_mapInt32Float_codec); + mapInt32Double_.WriteTo(output, _map_mapInt32Double_codec); + mapBoolBool_.WriteTo(output, _map_mapBoolBool_codec); + mapStringString_.WriteTo(output, _map_mapStringString_codec); + mapStringBytes_.WriteTo(output, _map_mapStringBytes_codec); + mapStringNestedMessage_.WriteTo(output, _map_mapStringNestedMessage_codec); + mapStringForeignMessage_.WriteTo(output, _map_mapStringForeignMessage_codec); + mapStringNestedEnum_.WriteTo(output, _map_mapStringNestedEnum_codec); + mapStringForeignEnum_.WriteTo(output, _map_mapStringForeignEnum_codec); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { + output.WriteRawTag(248, 6); + output.WriteUInt32(OneofUint32); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { + output.WriteRawTag(130, 7); + output.WriteMessage(OneofNestedMessage); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) { + output.WriteRawTag(138, 7); + output.WriteString(OneofString); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { + output.WriteRawTag(146, 7); + output.WriteBytes(OneofBytes); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofBool) { + output.WriteRawTag(152, 7); + output.WriteBool(OneofBool); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint64) { + output.WriteRawTag(160, 7); + output.WriteUInt64(OneofUint64); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) { + output.WriteRawTag(173, 7); + output.WriteFloat(OneofFloat); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) { + output.WriteRawTag(177, 7); + output.WriteDouble(OneofDouble); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) { + output.WriteRawTag(184, 7); + output.WriteEnum((int) OneofEnum); + } + if (optionalBoolWrapper_ != null) { + _single_optionalBoolWrapper_codec.WriteTagAndValue(output, OptionalBoolWrapper); + } + if (optionalInt32Wrapper_ != null) { + _single_optionalInt32Wrapper_codec.WriteTagAndValue(output, OptionalInt32Wrapper); + } + if (optionalInt64Wrapper_ != null) { + _single_optionalInt64Wrapper_codec.WriteTagAndValue(output, OptionalInt64Wrapper); + } + if (optionalUint32Wrapper_ != null) { + _single_optionalUint32Wrapper_codec.WriteTagAndValue(output, OptionalUint32Wrapper); + } + if (optionalUint64Wrapper_ != null) { + _single_optionalUint64Wrapper_codec.WriteTagAndValue(output, OptionalUint64Wrapper); + } + if (optionalFloatWrapper_ != null) { + _single_optionalFloatWrapper_codec.WriteTagAndValue(output, OptionalFloatWrapper); + } + if (optionalDoubleWrapper_ != null) { + _single_optionalDoubleWrapper_codec.WriteTagAndValue(output, OptionalDoubleWrapper); + } + if (optionalStringWrapper_ != null) { + _single_optionalStringWrapper_codec.WriteTagAndValue(output, OptionalStringWrapper); + } + if (optionalBytesWrapper_ != null) { + _single_optionalBytesWrapper_codec.WriteTagAndValue(output, OptionalBytesWrapper); + } + repeatedBoolWrapper_.WriteTo(output, _repeated_repeatedBoolWrapper_codec); + repeatedInt32Wrapper_.WriteTo(output, _repeated_repeatedInt32Wrapper_codec); + repeatedInt64Wrapper_.WriteTo(output, _repeated_repeatedInt64Wrapper_codec); + repeatedUint32Wrapper_.WriteTo(output, _repeated_repeatedUint32Wrapper_codec); + repeatedUint64Wrapper_.WriteTo(output, _repeated_repeatedUint64Wrapper_codec); + repeatedFloatWrapper_.WriteTo(output, _repeated_repeatedFloatWrapper_codec); + repeatedDoubleWrapper_.WriteTo(output, _repeated_repeatedDoubleWrapper_codec); + repeatedStringWrapper_.WriteTo(output, _repeated_repeatedStringWrapper_codec); + repeatedBytesWrapper_.WriteTo(output, _repeated_repeatedBytesWrapper_codec); + if (optionalDuration_ != null) { + output.WriteRawTag(234, 18); + output.WriteMessage(OptionalDuration); + } + if (optionalTimestamp_ != null) { + output.WriteRawTag(242, 18); + output.WriteMessage(OptionalTimestamp); + } + if (optionalFieldMask_ != null) { + output.WriteRawTag(250, 18); + output.WriteMessage(OptionalFieldMask); + } + if (optionalStruct_ != null) { + output.WriteRawTag(130, 19); + output.WriteMessage(OptionalStruct); + } + if (optionalAny_ != null) { + output.WriteRawTag(138, 19); + output.WriteMessage(OptionalAny); + } + if (optionalValue_ != null) { + output.WriteRawTag(146, 19); + output.WriteMessage(OptionalValue); + } + repeatedDuration_.WriteTo(output, _repeated_repeatedDuration_codec); + repeatedTimestamp_.WriteTo(output, _repeated_repeatedTimestamp_codec); + repeatedFieldmask_.WriteTo(output, _repeated_repeatedFieldmask_codec); + repeatedAny_.WriteTo(output, _repeated_repeatedAny_codec); + repeatedValue_.WriteTo(output, _repeated_repeatedValue_codec); + repeatedListValue_.WriteTo(output, _repeated_repeatedListValue_codec); + repeatedStruct_.WriteTo(output, _repeated_repeatedStruct_codec); + if (Fieldname1 != 0) { + output.WriteRawTag(136, 25); + output.WriteInt32(Fieldname1); + } + if (FieldName2 != 0) { + output.WriteRawTag(144, 25); + output.WriteInt32(FieldName2); + } + if (FieldName3 != 0) { + output.WriteRawTag(152, 25); + output.WriteInt32(FieldName3); + } + if (FieldName4 != 0) { + output.WriteRawTag(160, 25); + output.WriteInt32(FieldName4); + } + if (Field0Name5 != 0) { + output.WriteRawTag(168, 25); + output.WriteInt32(Field0Name5); + } + if (Field0Name6 != 0) { + output.WriteRawTag(176, 25); + output.WriteInt32(Field0Name6); + } + if (FieldName7 != 0) { + output.WriteRawTag(184, 25); + output.WriteInt32(FieldName7); + } + if (FieldName8 != 0) { + output.WriteRawTag(192, 25); + output.WriteInt32(FieldName8); + } + if (FieldName9 != 0) { + output.WriteRawTag(200, 25); + output.WriteInt32(FieldName9); + } + if (FieldName10 != 0) { + output.WriteRawTag(208, 25); + output.WriteInt32(FieldName10); + } + if (FIELDNAME11 != 0) { + output.WriteRawTag(216, 25); + output.WriteInt32(FIELDNAME11); + } + if (FIELDName12 != 0) { + output.WriteRawTag(224, 25); + output.WriteInt32(FIELDName12); + } + if (FieldName13 != 0) { + output.WriteRawTag(232, 25); + output.WriteInt32(FieldName13); + } + if (FieldName14 != 0) { + output.WriteRawTag(240, 25); + output.WriteInt32(FieldName14); + } + if (FieldName15 != 0) { + output.WriteRawTag(248, 25); + output.WriteInt32(FieldName15); + } + if (FieldName16 != 0) { + output.WriteRawTag(128, 26); + output.WriteInt32(FieldName16); + } + if (FieldName17 != 0) { + output.WriteRawTag(136, 26); + output.WriteInt32(FieldName17); + } + if (FieldName18 != 0) { + output.WriteRawTag(144, 26); + output.WriteInt32(FieldName18); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (OptionalInt32 != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(OptionalInt32); + } + if (OptionalInt64 != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(OptionalInt64); + } + if (OptionalUint32 != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(OptionalUint32); + } + if (OptionalUint64 != 0UL) { + size += 1 + pb::CodedOutputStream.ComputeUInt64Size(OptionalUint64); + } + if (OptionalSint32 != 0) { + size += 1 + pb::CodedOutputStream.ComputeSInt32Size(OptionalSint32); + } + if (OptionalSint64 != 0L) { + size += 1 + pb::CodedOutputStream.ComputeSInt64Size(OptionalSint64); + } + if (OptionalFixed32 != 0) { + size += 1 + 4; + } + if (OptionalFixed64 != 0UL) { + size += 1 + 8; + } + if (OptionalSfixed32 != 0) { + size += 1 + 4; + } + if (OptionalSfixed64 != 0L) { + size += 1 + 8; + } + if (OptionalFloat != 0F) { + size += 1 + 4; + } + if (OptionalDouble != 0D) { + size += 1 + 8; + } + if (OptionalBool != false) { + size += 1 + 1; + } + if (OptionalString.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(OptionalString); + } + if (OptionalBytes.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(OptionalBytes); + } + if (optionalNestedMessage_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalNestedMessage); + } + if (optionalForeignMessage_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalForeignMessage); + } + if (OptionalNestedEnum != global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum.Foo) { + size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OptionalNestedEnum); + } + if (OptionalForeignEnum != global::ProtobufTestMessages.Proto3.ForeignEnum.ForeignFoo) { + size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OptionalForeignEnum); + } + if (OptionalAliasedEnum != global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.AliasedEnum.AliasFoo) { + size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OptionalAliasedEnum); + } + if (OptionalStringPiece.Length != 0) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(OptionalStringPiece); + } + if (OptionalCord.Length != 0) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(OptionalCord); + } + if (recursiveMessage_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(RecursiveMessage); + } + size += repeatedInt32_.CalculateSize(_repeated_repeatedInt32_codec); + size += repeatedInt64_.CalculateSize(_repeated_repeatedInt64_codec); + size += repeatedUint32_.CalculateSize(_repeated_repeatedUint32_codec); + size += repeatedUint64_.CalculateSize(_repeated_repeatedUint64_codec); + size += repeatedSint32_.CalculateSize(_repeated_repeatedSint32_codec); + size += repeatedSint64_.CalculateSize(_repeated_repeatedSint64_codec); + size += repeatedFixed32_.CalculateSize(_repeated_repeatedFixed32_codec); + size += repeatedFixed64_.CalculateSize(_repeated_repeatedFixed64_codec); + size += repeatedSfixed32_.CalculateSize(_repeated_repeatedSfixed32_codec); + size += repeatedSfixed64_.CalculateSize(_repeated_repeatedSfixed64_codec); + size += repeatedFloat_.CalculateSize(_repeated_repeatedFloat_codec); + size += repeatedDouble_.CalculateSize(_repeated_repeatedDouble_codec); + size += repeatedBool_.CalculateSize(_repeated_repeatedBool_codec); + size += repeatedString_.CalculateSize(_repeated_repeatedString_codec); + size += repeatedBytes_.CalculateSize(_repeated_repeatedBytes_codec); + size += repeatedNestedMessage_.CalculateSize(_repeated_repeatedNestedMessage_codec); + size += repeatedForeignMessage_.CalculateSize(_repeated_repeatedForeignMessage_codec); + size += repeatedNestedEnum_.CalculateSize(_repeated_repeatedNestedEnum_codec); + size += repeatedForeignEnum_.CalculateSize(_repeated_repeatedForeignEnum_codec); + size += repeatedStringPiece_.CalculateSize(_repeated_repeatedStringPiece_codec); + size += repeatedCord_.CalculateSize(_repeated_repeatedCord_codec); + size += mapInt32Int32_.CalculateSize(_map_mapInt32Int32_codec); + size += mapInt64Int64_.CalculateSize(_map_mapInt64Int64_codec); + size += mapUint32Uint32_.CalculateSize(_map_mapUint32Uint32_codec); + size += mapUint64Uint64_.CalculateSize(_map_mapUint64Uint64_codec); + size += mapSint32Sint32_.CalculateSize(_map_mapSint32Sint32_codec); + size += mapSint64Sint64_.CalculateSize(_map_mapSint64Sint64_codec); + size += mapFixed32Fixed32_.CalculateSize(_map_mapFixed32Fixed32_codec); + size += mapFixed64Fixed64_.CalculateSize(_map_mapFixed64Fixed64_codec); + size += mapSfixed32Sfixed32_.CalculateSize(_map_mapSfixed32Sfixed32_codec); + size += mapSfixed64Sfixed64_.CalculateSize(_map_mapSfixed64Sfixed64_codec); + size += mapInt32Float_.CalculateSize(_map_mapInt32Float_codec); + size += mapInt32Double_.CalculateSize(_map_mapInt32Double_codec); + size += mapBoolBool_.CalculateSize(_map_mapBoolBool_codec); + size += mapStringString_.CalculateSize(_map_mapStringString_codec); + size += mapStringBytes_.CalculateSize(_map_mapStringBytes_codec); + size += mapStringNestedMessage_.CalculateSize(_map_mapStringNestedMessage_codec); + size += mapStringForeignMessage_.CalculateSize(_map_mapStringForeignMessage_codec); + size += mapStringNestedEnum_.CalculateSize(_map_mapStringNestedEnum_codec); + size += mapStringForeignEnum_.CalculateSize(_map_mapStringForeignEnum_codec); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { + size += 2 + pb::CodedOutputStream.ComputeUInt32Size(OneofUint32); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OneofNestedMessage); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(OneofString); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { + size += 2 + pb::CodedOutputStream.ComputeBytesSize(OneofBytes); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofBool) { + size += 2 + 1; + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint64) { + size += 2 + pb::CodedOutputStream.ComputeUInt64Size(OneofUint64); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) { + size += 2 + 4; + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) { + size += 2 + 8; + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) { + size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OneofEnum); + } + if (optionalBoolWrapper_ != null) { + size += _single_optionalBoolWrapper_codec.CalculateSizeWithTag(OptionalBoolWrapper); + } + if (optionalInt32Wrapper_ != null) { + size += _single_optionalInt32Wrapper_codec.CalculateSizeWithTag(OptionalInt32Wrapper); + } + if (optionalInt64Wrapper_ != null) { + size += _single_optionalInt64Wrapper_codec.CalculateSizeWithTag(OptionalInt64Wrapper); + } + if (optionalUint32Wrapper_ != null) { + size += _single_optionalUint32Wrapper_codec.CalculateSizeWithTag(OptionalUint32Wrapper); + } + if (optionalUint64Wrapper_ != null) { + size += _single_optionalUint64Wrapper_codec.CalculateSizeWithTag(OptionalUint64Wrapper); + } + if (optionalFloatWrapper_ != null) { + size += _single_optionalFloatWrapper_codec.CalculateSizeWithTag(OptionalFloatWrapper); + } + if (optionalDoubleWrapper_ != null) { + size += _single_optionalDoubleWrapper_codec.CalculateSizeWithTag(OptionalDoubleWrapper); + } + if (optionalStringWrapper_ != null) { + size += _single_optionalStringWrapper_codec.CalculateSizeWithTag(OptionalStringWrapper); + } + if (optionalBytesWrapper_ != null) { + size += _single_optionalBytesWrapper_codec.CalculateSizeWithTag(OptionalBytesWrapper); + } + size += repeatedBoolWrapper_.CalculateSize(_repeated_repeatedBoolWrapper_codec); + size += repeatedInt32Wrapper_.CalculateSize(_repeated_repeatedInt32Wrapper_codec); + size += repeatedInt64Wrapper_.CalculateSize(_repeated_repeatedInt64Wrapper_codec); + size += repeatedUint32Wrapper_.CalculateSize(_repeated_repeatedUint32Wrapper_codec); + size += repeatedUint64Wrapper_.CalculateSize(_repeated_repeatedUint64Wrapper_codec); + size += repeatedFloatWrapper_.CalculateSize(_repeated_repeatedFloatWrapper_codec); + size += repeatedDoubleWrapper_.CalculateSize(_repeated_repeatedDoubleWrapper_codec); + size += repeatedStringWrapper_.CalculateSize(_repeated_repeatedStringWrapper_codec); + size += repeatedBytesWrapper_.CalculateSize(_repeated_repeatedBytesWrapper_codec); + if (optionalDuration_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalDuration); + } + if (optionalTimestamp_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalTimestamp); + } + if (optionalFieldMask_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalFieldMask); + } + if (optionalStruct_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalStruct); + } + if (optionalAny_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalAny); + } + if (optionalValue_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalValue); + } + size += repeatedDuration_.CalculateSize(_repeated_repeatedDuration_codec); + size += repeatedTimestamp_.CalculateSize(_repeated_repeatedTimestamp_codec); + size += repeatedFieldmask_.CalculateSize(_repeated_repeatedFieldmask_codec); + size += repeatedStruct_.CalculateSize(_repeated_repeatedStruct_codec); + size += repeatedAny_.CalculateSize(_repeated_repeatedAny_codec); + size += repeatedValue_.CalculateSize(_repeated_repeatedValue_codec); + size += repeatedListValue_.CalculateSize(_repeated_repeatedListValue_codec); + if (Fieldname1 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Fieldname1); + } + if (FieldName2 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName2); + } + if (FieldName3 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName3); + } + if (FieldName4 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName4); + } + if (Field0Name5 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field0Name5); + } + if (Field0Name6 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field0Name6); + } + if (FieldName7 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName7); + } + if (FieldName8 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName8); + } + if (FieldName9 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName9); + } + if (FieldName10 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName10); + } + if (FIELDNAME11 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FIELDNAME11); + } + if (FIELDName12 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FIELDName12); + } + if (FieldName13 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName13); + } + if (FieldName14 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName14); + } + if (FieldName15 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName15); + } + if (FieldName16 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName16); + } + if (FieldName17 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName17); + } + if (FieldName18 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName18); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(TestAllTypesProto3 other) { + if (other == null) { + return; + } + 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.Length != 0) { + OptionalString = other.OptionalString; + } + if (other.OptionalBytes.Length != 0) { + OptionalBytes = other.OptionalBytes; + } + if (other.optionalNestedMessage_ != null) { + if (optionalNestedMessage_ == null) { + OptionalNestedMessage = new global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage(); + } + OptionalNestedMessage.MergeFrom(other.OptionalNestedMessage); + } + if (other.optionalForeignMessage_ != null) { + if (optionalForeignMessage_ == null) { + OptionalForeignMessage = new global::ProtobufTestMessages.Proto3.ForeignMessage(); + } + OptionalForeignMessage.MergeFrom(other.OptionalForeignMessage); + } + if (other.OptionalNestedEnum != global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum.Foo) { + OptionalNestedEnum = other.OptionalNestedEnum; + } + if (other.OptionalForeignEnum != global::ProtobufTestMessages.Proto3.ForeignEnum.ForeignFoo) { + OptionalForeignEnum = other.OptionalForeignEnum; + } + if (other.OptionalAliasedEnum != global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.AliasedEnum.AliasFoo) { + OptionalAliasedEnum = other.OptionalAliasedEnum; + } + if (other.OptionalStringPiece.Length != 0) { + OptionalStringPiece = other.OptionalStringPiece; + } + if (other.OptionalCord.Length != 0) { + OptionalCord = other.OptionalCord; + } + if (other.recursiveMessage_ != null) { + if (recursiveMessage_ == null) { + RecursiveMessage = new global::ProtobufTestMessages.Proto3.TestAllTypesProto3(); + } + RecursiveMessage.MergeFrom(other.RecursiveMessage); + } + repeatedInt32_.Add(other.repeatedInt32_); + repeatedInt64_.Add(other.repeatedInt64_); + repeatedUint32_.Add(other.repeatedUint32_); + repeatedUint64_.Add(other.repeatedUint64_); + repeatedSint32_.Add(other.repeatedSint32_); + repeatedSint64_.Add(other.repeatedSint64_); + repeatedFixed32_.Add(other.repeatedFixed32_); + repeatedFixed64_.Add(other.repeatedFixed64_); + repeatedSfixed32_.Add(other.repeatedSfixed32_); + repeatedSfixed64_.Add(other.repeatedSfixed64_); + repeatedFloat_.Add(other.repeatedFloat_); + repeatedDouble_.Add(other.repeatedDouble_); + repeatedBool_.Add(other.repeatedBool_); + repeatedString_.Add(other.repeatedString_); + repeatedBytes_.Add(other.repeatedBytes_); + repeatedNestedMessage_.Add(other.repeatedNestedMessage_); + repeatedForeignMessage_.Add(other.repeatedForeignMessage_); + repeatedNestedEnum_.Add(other.repeatedNestedEnum_); + repeatedForeignEnum_.Add(other.repeatedForeignEnum_); + repeatedStringPiece_.Add(other.repeatedStringPiece_); + repeatedCord_.Add(other.repeatedCord_); + mapInt32Int32_.Add(other.mapInt32Int32_); + mapInt64Int64_.Add(other.mapInt64Int64_); + mapUint32Uint32_.Add(other.mapUint32Uint32_); + mapUint64Uint64_.Add(other.mapUint64Uint64_); + mapSint32Sint32_.Add(other.mapSint32Sint32_); + mapSint64Sint64_.Add(other.mapSint64Sint64_); + mapFixed32Fixed32_.Add(other.mapFixed32Fixed32_); + mapFixed64Fixed64_.Add(other.mapFixed64Fixed64_); + mapSfixed32Sfixed32_.Add(other.mapSfixed32Sfixed32_); + mapSfixed64Sfixed64_.Add(other.mapSfixed64Sfixed64_); + mapInt32Float_.Add(other.mapInt32Float_); + mapInt32Double_.Add(other.mapInt32Double_); + mapBoolBool_.Add(other.mapBoolBool_); + mapStringString_.Add(other.mapStringString_); + mapStringBytes_.Add(other.mapStringBytes_); + mapStringNestedMessage_.Add(other.mapStringNestedMessage_); + mapStringForeignMessage_.Add(other.mapStringForeignMessage_); + mapStringNestedEnum_.Add(other.mapStringNestedEnum_); + mapStringForeignEnum_.Add(other.mapStringForeignEnum_); + if (other.optionalBoolWrapper_ != null) { + if (optionalBoolWrapper_ == null || other.OptionalBoolWrapper != false) { + OptionalBoolWrapper = other.OptionalBoolWrapper; + } + } + if (other.optionalInt32Wrapper_ != null) { + if (optionalInt32Wrapper_ == null || other.OptionalInt32Wrapper != 0) { + OptionalInt32Wrapper = other.OptionalInt32Wrapper; + } + } + if (other.optionalInt64Wrapper_ != null) { + if (optionalInt64Wrapper_ == null || other.OptionalInt64Wrapper != 0L) { + OptionalInt64Wrapper = other.OptionalInt64Wrapper; + } + } + if (other.optionalUint32Wrapper_ != null) { + if (optionalUint32Wrapper_ == null || other.OptionalUint32Wrapper != 0) { + OptionalUint32Wrapper = other.OptionalUint32Wrapper; + } + } + if (other.optionalUint64Wrapper_ != null) { + if (optionalUint64Wrapper_ == null || other.OptionalUint64Wrapper != 0UL) { + OptionalUint64Wrapper = other.OptionalUint64Wrapper; + } + } + if (other.optionalFloatWrapper_ != null) { + if (optionalFloatWrapper_ == null || other.OptionalFloatWrapper != 0F) { + OptionalFloatWrapper = other.OptionalFloatWrapper; + } + } + if (other.optionalDoubleWrapper_ != null) { + if (optionalDoubleWrapper_ == null || other.OptionalDoubleWrapper != 0D) { + OptionalDoubleWrapper = other.OptionalDoubleWrapper; + } + } + if (other.optionalStringWrapper_ != null) { + if (optionalStringWrapper_ == null || other.OptionalStringWrapper != "") { + OptionalStringWrapper = other.OptionalStringWrapper; + } + } + if (other.optionalBytesWrapper_ != null) { + if (optionalBytesWrapper_ == null || other.OptionalBytesWrapper != pb::ByteString.Empty) { + OptionalBytesWrapper = other.OptionalBytesWrapper; + } + } + repeatedBoolWrapper_.Add(other.repeatedBoolWrapper_); + repeatedInt32Wrapper_.Add(other.repeatedInt32Wrapper_); + repeatedInt64Wrapper_.Add(other.repeatedInt64Wrapper_); + repeatedUint32Wrapper_.Add(other.repeatedUint32Wrapper_); + repeatedUint64Wrapper_.Add(other.repeatedUint64Wrapper_); + repeatedFloatWrapper_.Add(other.repeatedFloatWrapper_); + repeatedDoubleWrapper_.Add(other.repeatedDoubleWrapper_); + repeatedStringWrapper_.Add(other.repeatedStringWrapper_); + repeatedBytesWrapper_.Add(other.repeatedBytesWrapper_); + if (other.optionalDuration_ != null) { + if (optionalDuration_ == null) { + OptionalDuration = new global::Google.Protobuf.WellKnownTypes.Duration(); + } + OptionalDuration.MergeFrom(other.OptionalDuration); + } + if (other.optionalTimestamp_ != null) { + if (optionalTimestamp_ == null) { + OptionalTimestamp = new global::Google.Protobuf.WellKnownTypes.Timestamp(); + } + OptionalTimestamp.MergeFrom(other.OptionalTimestamp); + } + if (other.optionalFieldMask_ != null) { + if (optionalFieldMask_ == null) { + OptionalFieldMask = new global::Google.Protobuf.WellKnownTypes.FieldMask(); + } + OptionalFieldMask.MergeFrom(other.OptionalFieldMask); + } + if (other.optionalStruct_ != null) { + if (optionalStruct_ == null) { + OptionalStruct = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + OptionalStruct.MergeFrom(other.OptionalStruct); + } + if (other.optionalAny_ != null) { + if (optionalAny_ == null) { + OptionalAny = new global::Google.Protobuf.WellKnownTypes.Any(); + } + OptionalAny.MergeFrom(other.OptionalAny); + } + if (other.optionalValue_ != null) { + if (optionalValue_ == null) { + OptionalValue = new global::Google.Protobuf.WellKnownTypes.Value(); + } + OptionalValue.MergeFrom(other.OptionalValue); + } + repeatedDuration_.Add(other.repeatedDuration_); + repeatedTimestamp_.Add(other.repeatedTimestamp_); + repeatedFieldmask_.Add(other.repeatedFieldmask_); + repeatedStruct_.Add(other.repeatedStruct_); + repeatedAny_.Add(other.repeatedAny_); + repeatedValue_.Add(other.repeatedValue_); + repeatedListValue_.Add(other.repeatedListValue_); + if (other.Fieldname1 != 0) { + Fieldname1 = other.Fieldname1; + } + if (other.FieldName2 != 0) { + FieldName2 = other.FieldName2; + } + if (other.FieldName3 != 0) { + FieldName3 = other.FieldName3; + } + if (other.FieldName4 != 0) { + FieldName4 = other.FieldName4; + } + if (other.Field0Name5 != 0) { + Field0Name5 = other.Field0Name5; + } + if (other.Field0Name6 != 0) { + Field0Name6 = other.Field0Name6; + } + if (other.FieldName7 != 0) { + FieldName7 = other.FieldName7; + } + if (other.FieldName8 != 0) { + FieldName8 = other.FieldName8; + } + if (other.FieldName9 != 0) { + FieldName9 = other.FieldName9; + } + if (other.FieldName10 != 0) { + FieldName10 = other.FieldName10; + } + if (other.FIELDNAME11 != 0) { + FIELDNAME11 = other.FIELDNAME11; + } + if (other.FIELDName12 != 0) { + FIELDName12 = other.FIELDName12; + } + if (other.FieldName13 != 0) { + FieldName13 = other.FieldName13; + } + if (other.FieldName14 != 0) { + FieldName14 = other.FieldName14; + } + if (other.FieldName15 != 0) { + FieldName15 = other.FieldName15; + } + if (other.FieldName16 != 0) { + FieldName16 = other.FieldName16; + } + if (other.FieldName17 != 0) { + FieldName17 = other.FieldName17; + } + if (other.FieldName18 != 0) { + FieldName18 = other.FieldName18; + } + switch (other.OneofFieldCase) { + case OneofFieldOneofCase.OneofUint32: + OneofUint32 = other.OneofUint32; + break; + case OneofFieldOneofCase.OneofNestedMessage: + if (OneofNestedMessage == null) { + OneofNestedMessage = new global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage(); + } + OneofNestedMessage.MergeFrom(other.OneofNestedMessage); + break; + case OneofFieldOneofCase.OneofString: + OneofString = other.OneofString; + break; + case OneofFieldOneofCase.OneofBytes: + OneofBytes = other.OneofBytes; + break; + case OneofFieldOneofCase.OneofBool: + OneofBool = other.OneofBool; + break; + case OneofFieldOneofCase.OneofUint64: + OneofUint64 = other.OneofUint64; + break; + case OneofFieldOneofCase.OneofFloat: + OneofFloat = other.OneofFloat; + break; + case OneofFieldOneofCase.OneofDouble: + OneofDouble = other.OneofDouble; + break; + case OneofFieldOneofCase.OneofEnum: + OneofEnum = other.OneofEnum; + break; + } + + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + OptionalInt32 = input.ReadInt32(); + break; + } + case 16: { + OptionalInt64 = input.ReadInt64(); + break; + } + case 24: { + OptionalUint32 = input.ReadUInt32(); + break; + } + case 32: { + OptionalUint64 = input.ReadUInt64(); + break; + } + case 40: { + OptionalSint32 = input.ReadSInt32(); + break; + } + case 48: { + OptionalSint64 = input.ReadSInt64(); + break; + } + case 61: { + OptionalFixed32 = input.ReadFixed32(); + break; + } + case 65: { + OptionalFixed64 = input.ReadFixed64(); + break; + } + case 77: { + OptionalSfixed32 = input.ReadSFixed32(); + break; + } + case 81: { + OptionalSfixed64 = input.ReadSFixed64(); + break; + } + case 93: { + OptionalFloat = input.ReadFloat(); + break; + } + case 97: { + OptionalDouble = input.ReadDouble(); + break; + } + case 104: { + OptionalBool = input.ReadBool(); + break; + } + case 114: { + OptionalString = input.ReadString(); + break; + } + case 122: { + OptionalBytes = input.ReadBytes(); + break; + } + case 146: { + if (optionalNestedMessage_ == null) { + OptionalNestedMessage = new global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage(); + } + input.ReadMessage(OptionalNestedMessage); + break; + } + case 154: { + if (optionalForeignMessage_ == null) { + OptionalForeignMessage = new global::ProtobufTestMessages.Proto3.ForeignMessage(); + } + input.ReadMessage(OptionalForeignMessage); + break; + } + case 168: { + OptionalNestedEnum = (global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum) input.ReadEnum(); + break; + } + case 176: { + OptionalForeignEnum = (global::ProtobufTestMessages.Proto3.ForeignEnum) input.ReadEnum(); + break; + } + case 184: { + OptionalAliasedEnum = (global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.AliasedEnum) input.ReadEnum(); + break; + } + case 194: { + OptionalStringPiece = input.ReadString(); + break; + } + case 202: { + OptionalCord = input.ReadString(); + break; + } + case 218: { + if (recursiveMessage_ == null) { + RecursiveMessage = new global::ProtobufTestMessages.Proto3.TestAllTypesProto3(); + } + input.ReadMessage(RecursiveMessage); + break; + } + case 250: + case 248: { + repeatedInt32_.AddEntriesFrom(input, _repeated_repeatedInt32_codec); + break; + } + case 258: + case 256: { + repeatedInt64_.AddEntriesFrom(input, _repeated_repeatedInt64_codec); + break; + } + case 266: + case 264: { + repeatedUint32_.AddEntriesFrom(input, _repeated_repeatedUint32_codec); + break; + } + case 274: + case 272: { + repeatedUint64_.AddEntriesFrom(input, _repeated_repeatedUint64_codec); + break; + } + case 282: + case 280: { + repeatedSint32_.AddEntriesFrom(input, _repeated_repeatedSint32_codec); + break; + } + case 290: + case 288: { + repeatedSint64_.AddEntriesFrom(input, _repeated_repeatedSint64_codec); + break; + } + case 298: + case 301: { + repeatedFixed32_.AddEntriesFrom(input, _repeated_repeatedFixed32_codec); + break; + } + case 306: + case 305: { + repeatedFixed64_.AddEntriesFrom(input, _repeated_repeatedFixed64_codec); + break; + } + case 314: + case 317: { + repeatedSfixed32_.AddEntriesFrom(input, _repeated_repeatedSfixed32_codec); + break; + } + case 322: + case 321: { + repeatedSfixed64_.AddEntriesFrom(input, _repeated_repeatedSfixed64_codec); + break; + } + case 330: + case 333: { + repeatedFloat_.AddEntriesFrom(input, _repeated_repeatedFloat_codec); + break; + } + case 338: + case 337: { + repeatedDouble_.AddEntriesFrom(input, _repeated_repeatedDouble_codec); + break; + } + case 346: + case 344: { + repeatedBool_.AddEntriesFrom(input, _repeated_repeatedBool_codec); + break; + } + case 354: { + repeatedString_.AddEntriesFrom(input, _repeated_repeatedString_codec); + break; + } + case 362: { + repeatedBytes_.AddEntriesFrom(input, _repeated_repeatedBytes_codec); + break; + } + case 386: { + repeatedNestedMessage_.AddEntriesFrom(input, _repeated_repeatedNestedMessage_codec); + break; + } + case 394: { + repeatedForeignMessage_.AddEntriesFrom(input, _repeated_repeatedForeignMessage_codec); + break; + } + case 410: + case 408: { + repeatedNestedEnum_.AddEntriesFrom(input, _repeated_repeatedNestedEnum_codec); + break; + } + case 418: + case 416: { + repeatedForeignEnum_.AddEntriesFrom(input, _repeated_repeatedForeignEnum_codec); + break; + } + case 434: { + repeatedStringPiece_.AddEntriesFrom(input, _repeated_repeatedStringPiece_codec); + break; + } + case 442: { + repeatedCord_.AddEntriesFrom(input, _repeated_repeatedCord_codec); + break; + } + case 450: { + mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec); + break; + } + case 458: { + mapInt64Int64_.AddEntriesFrom(input, _map_mapInt64Int64_codec); + break; + } + case 466: { + mapUint32Uint32_.AddEntriesFrom(input, _map_mapUint32Uint32_codec); + break; + } + case 474: { + mapUint64Uint64_.AddEntriesFrom(input, _map_mapUint64Uint64_codec); + break; + } + case 482: { + mapSint32Sint32_.AddEntriesFrom(input, _map_mapSint32Sint32_codec); + break; + } + case 490: { + mapSint64Sint64_.AddEntriesFrom(input, _map_mapSint64Sint64_codec); + break; + } + case 498: { + mapFixed32Fixed32_.AddEntriesFrom(input, _map_mapFixed32Fixed32_codec); + break; + } + case 506: { + mapFixed64Fixed64_.AddEntriesFrom(input, _map_mapFixed64Fixed64_codec); + break; + } + case 514: { + mapSfixed32Sfixed32_.AddEntriesFrom(input, _map_mapSfixed32Sfixed32_codec); + break; + } + case 522: { + mapSfixed64Sfixed64_.AddEntriesFrom(input, _map_mapSfixed64Sfixed64_codec); + break; + } + case 530: { + mapInt32Float_.AddEntriesFrom(input, _map_mapInt32Float_codec); + break; + } + case 538: { + mapInt32Double_.AddEntriesFrom(input, _map_mapInt32Double_codec); + break; + } + case 546: { + mapBoolBool_.AddEntriesFrom(input, _map_mapBoolBool_codec); + break; + } + case 554: { + mapStringString_.AddEntriesFrom(input, _map_mapStringString_codec); + break; + } + case 562: { + mapStringBytes_.AddEntriesFrom(input, _map_mapStringBytes_codec); + break; + } + case 570: { + mapStringNestedMessage_.AddEntriesFrom(input, _map_mapStringNestedMessage_codec); + break; + } + case 578: { + mapStringForeignMessage_.AddEntriesFrom(input, _map_mapStringForeignMessage_codec); + break; + } + case 586: { + mapStringNestedEnum_.AddEntriesFrom(input, _map_mapStringNestedEnum_codec); + break; + } + case 594: { + mapStringForeignEnum_.AddEntriesFrom(input, _map_mapStringForeignEnum_codec); + break; + } + case 888: { + OneofUint32 = input.ReadUInt32(); + break; + } + case 898: { + global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage subBuilder = new global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { + subBuilder.MergeFrom(OneofNestedMessage); + } + input.ReadMessage(subBuilder); + OneofNestedMessage = subBuilder; + break; + } + case 906: { + OneofString = input.ReadString(); + break; + } + case 914: { + OneofBytes = input.ReadBytes(); + break; + } + case 920: { + OneofBool = input.ReadBool(); + break; + } + case 928: { + OneofUint64 = input.ReadUInt64(); + break; + } + case 941: { + OneofFloat = input.ReadFloat(); + break; + } + case 945: { + OneofDouble = input.ReadDouble(); + break; + } + case 952: { + oneofField_ = input.ReadEnum(); + oneofFieldCase_ = OneofFieldOneofCase.OneofEnum; + break; + } + case 1610: { + bool? value = _single_optionalBoolWrapper_codec.Read(input); + if (optionalBoolWrapper_ == null || value != false) { + OptionalBoolWrapper = value; + } + break; + } + case 1618: { + int? value = _single_optionalInt32Wrapper_codec.Read(input); + if (optionalInt32Wrapper_ == null || value != 0) { + OptionalInt32Wrapper = value; + } + break; + } + case 1626: { + long? value = _single_optionalInt64Wrapper_codec.Read(input); + if (optionalInt64Wrapper_ == null || value != 0L) { + OptionalInt64Wrapper = value; + } + break; + } + case 1634: { + uint? value = _single_optionalUint32Wrapper_codec.Read(input); + if (optionalUint32Wrapper_ == null || value != 0) { + OptionalUint32Wrapper = value; + } + break; + } + case 1642: { + ulong? value = _single_optionalUint64Wrapper_codec.Read(input); + if (optionalUint64Wrapper_ == null || value != 0UL) { + OptionalUint64Wrapper = value; + } + break; + } + case 1650: { + float? value = _single_optionalFloatWrapper_codec.Read(input); + if (optionalFloatWrapper_ == null || value != 0F) { + OptionalFloatWrapper = value; + } + break; + } + case 1658: { + double? value = _single_optionalDoubleWrapper_codec.Read(input); + if (optionalDoubleWrapper_ == null || value != 0D) { + OptionalDoubleWrapper = value; + } + break; + } + case 1666: { + string value = _single_optionalStringWrapper_codec.Read(input); + if (optionalStringWrapper_ == null || value != "") { + OptionalStringWrapper = value; + } + break; + } + case 1674: { + pb::ByteString value = _single_optionalBytesWrapper_codec.Read(input); + if (optionalBytesWrapper_ == null || value != pb::ByteString.Empty) { + OptionalBytesWrapper = value; + } + break; + } + case 1690: { + repeatedBoolWrapper_.AddEntriesFrom(input, _repeated_repeatedBoolWrapper_codec); + break; + } + case 1698: { + repeatedInt32Wrapper_.AddEntriesFrom(input, _repeated_repeatedInt32Wrapper_codec); + break; + } + case 1706: { + repeatedInt64Wrapper_.AddEntriesFrom(input, _repeated_repeatedInt64Wrapper_codec); + break; + } + case 1714: { + repeatedUint32Wrapper_.AddEntriesFrom(input, _repeated_repeatedUint32Wrapper_codec); + break; + } + case 1722: { + repeatedUint64Wrapper_.AddEntriesFrom(input, _repeated_repeatedUint64Wrapper_codec); + break; + } + case 1730: { + repeatedFloatWrapper_.AddEntriesFrom(input, _repeated_repeatedFloatWrapper_codec); + break; + } + case 1738: { + repeatedDoubleWrapper_.AddEntriesFrom(input, _repeated_repeatedDoubleWrapper_codec); + break; + } + case 1746: { + repeatedStringWrapper_.AddEntriesFrom(input, _repeated_repeatedStringWrapper_codec); + break; + } + case 1754: { + repeatedBytesWrapper_.AddEntriesFrom(input, _repeated_repeatedBytesWrapper_codec); + break; + } + case 2410: { + if (optionalDuration_ == null) { + OptionalDuration = new global::Google.Protobuf.WellKnownTypes.Duration(); + } + input.ReadMessage(OptionalDuration); + break; + } + case 2418: { + if (optionalTimestamp_ == null) { + OptionalTimestamp = new global::Google.Protobuf.WellKnownTypes.Timestamp(); + } + input.ReadMessage(OptionalTimestamp); + break; + } + case 2426: { + if (optionalFieldMask_ == null) { + OptionalFieldMask = new global::Google.Protobuf.WellKnownTypes.FieldMask(); + } + input.ReadMessage(OptionalFieldMask); + break; + } + case 2434: { + if (optionalStruct_ == null) { + OptionalStruct = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + input.ReadMessage(OptionalStruct); + break; + } + case 2442: { + if (optionalAny_ == null) { + OptionalAny = new global::Google.Protobuf.WellKnownTypes.Any(); + } + input.ReadMessage(OptionalAny); + break; + } + case 2450: { + if (optionalValue_ == null) { + OptionalValue = new global::Google.Protobuf.WellKnownTypes.Value(); + } + input.ReadMessage(OptionalValue); + break; + } + case 2490: { + repeatedDuration_.AddEntriesFrom(input, _repeated_repeatedDuration_codec); + break; + } + case 2498: { + repeatedTimestamp_.AddEntriesFrom(input, _repeated_repeatedTimestamp_codec); + break; + } + case 2506: { + repeatedFieldmask_.AddEntriesFrom(input, _repeated_repeatedFieldmask_codec); + break; + } + case 2522: { + repeatedAny_.AddEntriesFrom(input, _repeated_repeatedAny_codec); + break; + } + case 2530: { + repeatedValue_.AddEntriesFrom(input, _repeated_repeatedValue_codec); + break; + } + case 2538: { + repeatedListValue_.AddEntriesFrom(input, _repeated_repeatedListValue_codec); + break; + } + case 2594: { + repeatedStruct_.AddEntriesFrom(input, _repeated_repeatedStruct_codec); + break; + } + case 3208: { + Fieldname1 = input.ReadInt32(); + break; + } + case 3216: { + FieldName2 = input.ReadInt32(); + break; + } + case 3224: { + FieldName3 = input.ReadInt32(); + break; + } + case 3232: { + FieldName4 = input.ReadInt32(); + break; + } + case 3240: { + Field0Name5 = input.ReadInt32(); + break; + } + case 3248: { + Field0Name6 = input.ReadInt32(); + break; + } + case 3256: { + FieldName7 = input.ReadInt32(); + break; + } + case 3264: { + FieldName8 = input.ReadInt32(); + break; + } + case 3272: { + FieldName9 = input.ReadInt32(); + break; + } + case 3280: { + FieldName10 = input.ReadInt32(); + break; + } + case 3288: { + FIELDNAME11 = input.ReadInt32(); + break; + } + case 3296: { + FIELDName12 = input.ReadInt32(); + break; + } + case 3304: { + FieldName13 = input.ReadInt32(); + break; + } + case 3312: { + FieldName14 = input.ReadInt32(); + break; + } + case 3320: { + FieldName15 = input.ReadInt32(); + break; + } + case 3328: { + FieldName16 = input.ReadInt32(); + break; + } + case 3336: { + FieldName17 = input.ReadInt32(); + break; + } + case 3344: { + FieldName18 = input.ReadInt32(); + break; + } + } + } + } + + #region Nested types + /// Container for nested types declared in the TestAllTypesProto3 message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + public enum NestedEnum { + [pbr::OriginalName("FOO")] Foo = 0, + [pbr::OriginalName("BAR")] Bar = 1, + [pbr::OriginalName("BAZ")] Baz = 2, + /// + /// Intentionally negative. + /// + [pbr::OriginalName("NEG")] Neg = -1, + } + + public enum AliasedEnum { + [pbr::OriginalName("ALIAS_FOO")] AliasFoo = 0, + [pbr::OriginalName("ALIAS_BAR")] AliasBar = 1, + [pbr::OriginalName("ALIAS_BAZ")] AliasBaz = 2, + [pbr::OriginalName("QUX", PreferredAlias = false)] Qux = 2, + [pbr::OriginalName("qux", PreferredAlias = false)] Qux_ = 2, + [pbr::OriginalName("bAz", PreferredAlias = false)] BAz = 2, + } + + public sealed partial class NestedMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Descriptor.NestedTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedMessage(NestedMessage other) : this() { + a_ = other.a_; + corecursive_ = other.corecursive_ != null ? other.corecursive_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedMessage Clone() { + return new NestedMessage(this); + } + + /// Field number for the "a" field. + public const int AFieldNumber = 1; + private int a_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int A { + get { return a_; } + set { + a_ = value; + } + } + + /// Field number for the "corecursive" field. + public const int CorecursiveFieldNumber = 2; + private global::ProtobufTestMessages.Proto3.TestAllTypesProto3 corecursive_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::ProtobufTestMessages.Proto3.TestAllTypesProto3 Corecursive { + get { return corecursive_; } + set { + corecursive_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as NestedMessage); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(NestedMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (A != other.A) return false; + if (!object.Equals(Corecursive, other.Corecursive)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (A != 0) hash ^= A.GetHashCode(); + if (corecursive_ != null) hash ^= Corecursive.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (A != 0) { + output.WriteRawTag(8); + output.WriteInt32(A); + } + if (corecursive_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Corecursive); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (A != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(A); + } + if (corecursive_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Corecursive); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(NestedMessage other) { + if (other == null) { + return; + } + if (other.A != 0) { + A = other.A; + } + if (other.corecursive_ != null) { + if (corecursive_ == null) { + Corecursive = new global::ProtobufTestMessages.Proto3.TestAllTypesProto3(); + } + Corecursive.MergeFrom(other.Corecursive); + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + A = input.ReadInt32(); + break; + } + case 18: { + if (corecursive_ == null) { + Corecursive = new global::ProtobufTestMessages.Proto3.TestAllTypesProto3(); + } + input.ReadMessage(Corecursive); + break; + } + } + } + } + + } + + } + #endregion + + } + + public sealed partial class ForeignMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ForeignMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::ProtobufTestMessages.Proto3.TestMessagesProto3Reflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ForeignMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ForeignMessage(ForeignMessage other) : this() { + c_ = other.c_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ForeignMessage Clone() { + return new ForeignMessage(this); + } + + /// Field number for the "c" field. + public const int CFieldNumber = 1; + private int c_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int C { + get { return c_; } + set { + c_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ForeignMessage); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ForeignMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (C != other.C) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (C != 0) hash ^= C.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (C != 0) { + output.WriteRawTag(8); + output.WriteInt32(C); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (C != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(C); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ForeignMessage other) { + if (other == null) { + return; + } + if (other.C != 0) { + C = other.C; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + C = input.ReadInt32(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs new file mode 100644 index 000000000000..6b19b5cce362 --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs @@ -0,0 +1,2962 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: unittest_custom_options_proto3.proto +// +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace UnitTest.Issues.TestProtos { + + /// Holder for reflection information generated from unittest_custom_options_proto3.proto + public static partial class UnittestCustomOptionsProto3Reflection { + + #region Descriptor + /// File descriptor for unittest_custom_options_proto3.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static UnittestCustomOptionsProto3Reflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CiR1bml0dGVzdF9jdXN0b21fb3B0aW9uc19wcm90bzMucHJvdG8SEXByb3Rv", + "YnVmX3VuaXR0ZXN0GiBnb29nbGUvcHJvdG9idWYvZGVzY3JpcHRvci5wcm90", + "byLXAQocVGVzdE1lc3NhZ2VXaXRoQ3VzdG9tT3B0aW9ucxIeCgZmaWVsZDEY", + "ASABKAlCDggBweDDHS3hdQoCAAAAEhUKC29uZW9mX2ZpZWxkGAIgASgFSAAi", + "UwoGQW5FbnVtEhYKEkFORU5VTV9VTlNQRUNJRklFRBAAEg8KC0FORU5VTV9W", + "QUwxEAESFgoLQU5FTlVNX1ZBTDIQAhoFsIb6BXsaCMX2yR3r/P//OhAIAODp", + "wh3I//////////8BQhkKB0FuT25lb2YSDviswx2d//////////8BIhgKFkN1", + "c3RvbU9wdGlvbkZvb1JlcXVlc3QiGQoXQ3VzdG9tT3B0aW9uRm9vUmVzcG9u", + "c2UiHgocQ3VzdG9tT3B0aW9uRm9vQ2xpZW50TWVzc2FnZSIeChxDdXN0b21P", + "cHRpb25Gb29TZXJ2ZXJNZXNzYWdlIo8BChpEdW1teU1lc3NhZ2VDb250YWlu", + "aW5nRW51bSJxCgxUZXN0RW51bVR5cGUSIAocVEVTVF9PUFRJT05fRU5VTV9V", + "TlNQRUNJRklFRBAAEhoKFlRFU1RfT1BUSU9OX0VOVU1fVFlQRTEQFhIjChZU", + "RVNUX09QVElPTl9FTlVNX1RZUEUyEOn//////////wEiIQofRHVtbXlNZXNz", + "YWdlSW52YWxpZEFzT3B0aW9uVHlwZSKKAQocQ3VzdG9tT3B0aW9uTWluSW50", + "ZWdlclZhbHVlczpq0N6yHQDoxrIdgICAgPj/////AbC8sh2AgICAgICAgIAB", + "gJOyHQD49bAdAIDEsB3/////D/iXsB3///////////8BnfWvHQAAAACR7q8d", + "AAAAAAAAAACtja8dAAAAgJnWqB0AAAAAAAAAgCKRAQocQ3VzdG9tT3B0aW9u", + "TWF4SW50ZWdlclZhbHVlczpx0N6yHQHoxrId/////wewvLId//////////9/", + "gJOyHf////8P+PWwHf///////////wGAxLAd/v///w/4l7Ad/v//////////", + "AZ31rx3/////ke6vHf//////////rY2vHf///3+Z1qgd/////////38ibgoX", + "Q3VzdG9tT3B0aW9uT3RoZXJWYWx1ZXM6U+jGsh2c//////////8B9d+jHeeH", + "RUHp3KId+1mMQsrA8z+q3KIdDkhlbGxvLCAiV29ybGQistmiHQtIZWxsbwBX", + "b3JsZIjZoh3p//////////8BIjQKHFNldHRpbmdSZWFsc0Zyb21Qb3NpdGl2", + "ZUludHM6FPXfox0AAEBB6dyiHQAAAAAAQGNAIjQKHFNldHRpbmdSZWFsc0Zy", + "b21OZWdhdGl2ZUludHM6FPXfox0AAEDB6dyiHQAAAAAAQGPAIksKEkNvbXBs", + "ZXhPcHRpb25UeXBlMRILCgNmb28YASABKAUSDAoEZm9vMhgCIAEoBRIMCgRm", + "b28zGAMgASgFEgwKBGZvbzQYBCADKAUigQMKEkNvbXBsZXhPcHRpb25UeXBl", + "MhIyCgNiYXIYASABKAsyJS5wcm90b2J1Zl91bml0dGVzdC5Db21wbGV4T3B0", + "aW9uVHlwZTESCwoDYmF6GAIgASgFEkYKBGZyZWQYAyABKAsyOC5wcm90b2J1", + "Zl91bml0dGVzdC5Db21wbGV4T3B0aW9uVHlwZTIuQ29tcGxleE9wdGlvblR5", + "cGU0EkgKBmJhcm5leRgEIAMoCzI4LnByb3RvYnVmX3VuaXR0ZXN0LkNvbXBs", + "ZXhPcHRpb25UeXBlMi5Db21wbGV4T3B0aW9uVHlwZTQalwEKEkNvbXBsZXhP", + "cHRpb25UeXBlNBINCgV3YWxkbxgBIAEoBTJyCgxjb21wbGV4X29wdDQSHy5n", + "b29nbGUucHJvdG9idWYuTWVzc2FnZU9wdGlvbnMYivXRAyABKAsyOC5wcm90", + "b2J1Zl91bml0dGVzdC5Db21wbGV4T3B0aW9uVHlwZTIuQ29tcGxleE9wdGlv", + "blR5cGU0IiEKEkNvbXBsZXhPcHRpb25UeXBlMxILCgNxdXgYASABKAUibAoV", + "VmFyaW91c0NvbXBsZXhPcHRpb25zOlOi4pUdAggqouKVHQIgY6LilR0CIFiq", + "/ZAdAxDbB6r9kB0FCgMI5wXSqI8dAwizD6r9kB0FGgMIwQKq/ZAdBCICCGWq", + "/ZAdBSIDCNQB+t6QHQIICSJMCglBZ2dyZWdhdGUSCQoBaRgBIAEoBRIJCgFz", + "GAIgASgJEikKA3N1YhgDIAEoCzIcLnByb3RvYnVmX3VuaXR0ZXN0LkFnZ3Jl", + "Z2F0ZSJZChBBZ2dyZWdhdGVNZXNzYWdlEikKCWZpZWxkbmFtZRgBIAEoBUIW", + "8qGHOxESD0ZpZWxkQW5ub3RhdGlvbjoawtGGOxUIZRIRTWVzc2FnZUFubm90", + "YXRpb24ilwEKEE5lc3RlZE9wdGlvblR5cGUaOwoNTmVzdGVkTWVzc2FnZRIi", + "CgxuZXN0ZWRfZmllbGQYASABKAVCDMHgwx3qAwAAAAAAADoG4OnCHekHIkYK", + "Ck5lc3RlZEVudW0SDwoLVU5TUEVDSUZJRUQQABIdChFORVNURURfRU5VTV9W", + "QUxVRRABGgawhvoF7AcaCMX2yR3rAwAAKlIKCk1ldGhvZE9wdDESGgoWTUVU", + "SE9ET1BUMV9VTlNQRUNJRklFRBAAEhMKD01FVEhPRE9QVDFfVkFMMRABEhMK", + "D01FVEhPRE9QVDFfVkFMMhACKl4KDUFnZ3JlZ2F0ZUVudW0SDwoLVU5TUEVD", + "SUZJRUQQABIlCgVWQUxVRRABGhrK/Ik7FRITRW51bVZhbHVlQW5ub3RhdGlv", + "bhoVkpWIOxASDkVudW1Bbm5vdGF0aW9uMo4BChxUZXN0U2VydmljZVdpdGhD", + "dXN0b21PcHRpb25zEmMKA0ZvbxIpLnByb3RvYnVmX3VuaXR0ZXN0LkN1c3Rv", + "bU9wdGlvbkZvb1JlcXVlc3QaKi5wcm90b2J1Zl91bml0dGVzdC5DdXN0b21P", + "cHRpb25Gb29SZXNwb25zZSIF4PqMHgIaCZCyix7T24DLSTKZAQoQQWdncmVn", + "YXRlU2VydmljZRJrCgZNZXRob2QSIy5wcm90b2J1Zl91bml0dGVzdC5BZ2dy", + "ZWdhdGVNZXNzYWdlGiMucHJvdG9idWZfdW5pdHRlc3QuQWdncmVnYXRlTWVz", + "c2FnZSIXysiWOxISEE1ldGhvZEFubm90YXRpb24aGMr7jjsTEhFTZXJ2aWNl", + "QW5ub3RhdGlvbjoyCglmaWxlX29wdDESHC5nb29nbGUucHJvdG9idWYuRmls", + "ZU9wdGlvbnMYjp3YAyABKAQ6OAoMbWVzc2FnZV9vcHQxEh8uZ29vZ2xlLnBy", + "b3RvYnVmLk1lc3NhZ2VPcHRpb25zGJyt2AMgASgFOjQKCmZpZWxkX29wdDES", + "HS5nb29nbGUucHJvdG9idWYuRmllbGRPcHRpb25zGIi82AMgASgGOjQKCm9u", + "ZW9mX29wdDESHS5nb29nbGUucHJvdG9idWYuT25lb2ZPcHRpb25zGM+12AMg", + "ASgFOjIKCWVudW1fb3B0MRIcLmdvb2dsZS5wcm90b2J1Zi5FbnVtT3B0aW9u", + "cxjontkDIAEoDzo8Cg9lbnVtX3ZhbHVlX29wdDESIS5nb29nbGUucHJvdG9i", + "dWYuRW51bVZhbHVlT3B0aW9ucxjmoF8gASgFOjgKDHNlcnZpY2Vfb3B0MRIf", + "Lmdvb2dsZS5wcm90b2J1Zi5TZXJ2aWNlT3B0aW9ucxiituEDIAEoEjpVCgtt", + "ZXRob2Rfb3B0MRIeLmdvb2dsZS5wcm90b2J1Zi5NZXRob2RPcHRpb25zGKzP", + "4QMgASgOMh0ucHJvdG9idWZfdW5pdHRlc3QuTWV0aG9kT3B0MTo0Cghib29s", + "X29wdBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxjqq9YDIAEo", + "CDo1CglpbnQzMl9vcHQSHy5nb29nbGUucHJvdG9idWYuTWVzc2FnZU9wdGlv", + "bnMY7ajWAyABKAU6NQoJaW50NjRfb3B0Eh8uZ29vZ2xlLnByb3RvYnVmLk1l", + "c3NhZ2VPcHRpb25zGMan1gMgASgDOjYKCnVpbnQzMl9vcHQSHy5nb29nbGUu", + "cHJvdG9idWYuTWVzc2FnZU9wdGlvbnMYsKLWAyABKA06NgoKdWludDY0X29w", + "dBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxjfjtYDIAEoBDo2", + "CgpzaW50MzJfb3B0Eh8uZ29vZ2xlLnByb3RvYnVmLk1lc3NhZ2VPcHRpb25z", + "GMCI1gMgASgROjYKCnNpbnQ2NF9vcHQSHy5nb29nbGUucHJvdG9idWYuTWVz", + "c2FnZU9wdGlvbnMY/4LWAyABKBI6NwoLZml4ZWQzMl9vcHQSHy5nb29nbGUu", + "cHJvdG9idWYuTWVzc2FnZU9wdGlvbnMY0/7VAyABKAc6NwoLZml4ZWQ2NF9v", + "cHQSHy5nb29nbGUucHJvdG9idWYuTWVzc2FnZU9wdGlvbnMY4v3VAyABKAY6", + "OAoMc2ZpeGVkMzJfb3B0Eh8uZ29vZ2xlLnByb3RvYnVmLk1lc3NhZ2VPcHRp", + "b25zGNXx1QMgASgPOjgKDHNmaXhlZDY0X29wdBIfLmdvb2dsZS5wcm90b2J1", + "Zi5NZXNzYWdlT3B0aW9ucxjjitUDIAEoEDo1CglmbG9hdF9vcHQSHy5nb29n", + "bGUucHJvdG9idWYuTWVzc2FnZU9wdGlvbnMY/rvUAyABKAI6NgoKZG91Ymxl", + "X29wdBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxjNq9QDIAEo", + "ATo2CgpzdHJpbmdfb3B0Eh8uZ29vZ2xlLnByb3RvYnVmLk1lc3NhZ2VPcHRp", + "b25zGMWr1AMgASgJOjUKCWJ5dGVzX29wdBIfLmdvb2dsZS5wcm90b2J1Zi5N", + "ZXNzYWdlT3B0aW9ucxiWq9QDIAEoDDpwCghlbnVtX29wdBIfLmdvb2dsZS5w", + "cm90b2J1Zi5NZXNzYWdlT3B0aW9ucxiRq9QDIAEoDjI6LnByb3RvYnVmX3Vu", + "aXR0ZXN0LkR1bW15TWVzc2FnZUNvbnRhaW5pbmdFbnVtLlRlc3RFbnVtVHlw", + "ZTpwChBtZXNzYWdlX3R5cGVfb3B0Eh8uZ29vZ2xlLnByb3RvYnVmLk1lc3Nh", + "Z2VPcHRpb25zGK/y0wMgASgLMjIucHJvdG9idWZfdW5pdHRlc3QuRHVtbXlN", + "ZXNzYWdlSW52YWxpZEFzT3B0aW9uVHlwZTpfCgxjb21wbGV4X29wdDESHy5n", + "b29nbGUucHJvdG9idWYuTWVzc2FnZU9wdGlvbnMYpNzSAyABKAsyJS5wcm90", + "b2J1Zl91bml0dGVzdC5Db21wbGV4T3B0aW9uVHlwZTE6XwoMY29tcGxleF9v", + "cHQyEh8uZ29vZ2xlLnByb3RvYnVmLk1lc3NhZ2VPcHRpb25zGNWP0gMgASgL", + "MiUucHJvdG9idWZfdW5pdHRlc3QuQ29tcGxleE9wdGlvblR5cGUyOl8KDGNv", + "bXBsZXhfb3B0MxIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxjv", + "i9IDIAEoCzIlLnByb3RvYnVmX3VuaXR0ZXN0LkNvbXBsZXhPcHRpb25UeXBl", + "MzpOCgdmaWxlb3B0EhwuZ29vZ2xlLnByb3RvYnVmLkZpbGVPcHRpb25zGM/d", + "sAcgASgLMhwucHJvdG9idWZfdW5pdHRlc3QuQWdncmVnYXRlOlAKBm1zZ29w", + "dBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxiY6rAHIAEoCzIc", + "LnByb3RvYnVmX3VuaXR0ZXN0LkFnZ3JlZ2F0ZTpQCghmaWVsZG9wdBIdLmdv", + "b2dsZS5wcm90b2J1Zi5GaWVsZE9wdGlvbnMYnvSwByABKAsyHC5wcm90b2J1", + "Zl91bml0dGVzdC5BZ2dyZWdhdGU6TgoHZW51bW9wdBIcLmdvb2dsZS5wcm90", + "b2J1Zi5FbnVtT3B0aW9ucxjSgrEHIAEoCzIcLnByb3RvYnVmX3VuaXR0ZXN0", + "LkFnZ3JlZ2F0ZTpWCgplbnVtdmFsb3B0EiEuZ29vZ2xlLnByb3RvYnVmLkVu", + "dW1WYWx1ZU9wdGlvbnMYyZ+xByABKAsyHC5wcm90b2J1Zl91bml0dGVzdC5B", + "Z2dyZWdhdGU6VAoKc2VydmljZW9wdBIfLmdvb2dsZS5wcm90b2J1Zi5TZXJ2", + "aWNlT3B0aW9ucxi577EHIAEoCzIcLnByb3RvYnVmX3VuaXR0ZXN0LkFnZ3Jl", + "Z2F0ZTpSCgltZXRob2RvcHQSHi5nb29nbGUucHJvdG9idWYuTWV0aG9kT3B0", + "aW9ucxiJ6bIHIAEoCzIcLnByb3RvYnVmX3VuaXR0ZXN0LkFnZ3JlZ2F0ZUJV", + "qgIaVW5pdFRlc3QuSXNzdWVzLlRlc3RQcm90b3Pw6MEd6q3A5ST67IU7Kghk", + "Eg5GaWxlQW5ub3RhdGlvbhoWEhROZXN0ZWRGaWxlQW5ub3RhdGlvbmIGcHJv", + "dG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor, }, + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::UnitTest.Issues.TestProtos.MethodOpt1), typeof(global::UnitTest.Issues.TestProtos.AggregateEnum), }, new pb::Extension[] { UnittestCustomOptionsProto3Extensions.FileOpt1, UnittestCustomOptionsProto3Extensions.MessageOpt1, UnittestCustomOptionsProto3Extensions.FieldOpt1, UnittestCustomOptionsProto3Extensions.OneofOpt1, UnittestCustomOptionsProto3Extensions.EnumOpt1, UnittestCustomOptionsProto3Extensions.EnumValueOpt1, UnittestCustomOptionsProto3Extensions.ServiceOpt1, UnittestCustomOptionsProto3Extensions.MethodOpt1, UnittestCustomOptionsProto3Extensions.BoolOpt, UnittestCustomOptionsProto3Extensions.Int32Opt, UnittestCustomOptionsProto3Extensions.Int64Opt, UnittestCustomOptionsProto3Extensions.Uint32Opt, UnittestCustomOptionsProto3Extensions.Uint64Opt, UnittestCustomOptionsProto3Extensions.Sint32Opt, UnittestCustomOptionsProto3Extensions.Sint64Opt, UnittestCustomOptionsProto3Extensions.Fixed32Opt, UnittestCustomOptionsProto3Extensions.Fixed64Opt, UnittestCustomOptionsProto3Extensions.Sfixed32Opt, UnittestCustomOptionsProto3Extensions.Sfixed64Opt, UnittestCustomOptionsProto3Extensions.FloatOpt, UnittestCustomOptionsProto3Extensions.DoubleOpt, UnittestCustomOptionsProto3Extensions.StringOpt, UnittestCustomOptionsProto3Extensions.BytesOpt, UnittestCustomOptionsProto3Extensions.EnumOpt, UnittestCustomOptionsProto3Extensions.MessageTypeOpt, UnittestCustomOptionsProto3Extensions.ComplexOpt1, UnittestCustomOptionsProto3Extensions.ComplexOpt2, UnittestCustomOptionsProto3Extensions.ComplexOpt3, UnittestCustomOptionsProto3Extensions.Fileopt, UnittestCustomOptionsProto3Extensions.Msgopt, UnittestCustomOptionsProto3Extensions.Fieldopt, UnittestCustomOptionsProto3Extensions.Enumopt, UnittestCustomOptionsProto3Extensions.Enumvalopt, UnittestCustomOptionsProto3Extensions.Serviceopt, UnittestCustomOptionsProto3Extensions.Methodopt }, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.TestMessageWithCustomOptions), global::UnitTest.Issues.TestProtos.TestMessageWithCustomOptions.Parser, new[]{ "Field1", "OneofField" }, new[]{ "AnOneof" }, new[]{ typeof(global::UnitTest.Issues.TestProtos.TestMessageWithCustomOptions.Types.AnEnum) }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.CustomOptionFooRequest), global::UnitTest.Issues.TestProtos.CustomOptionFooRequest.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.CustomOptionFooResponse), global::UnitTest.Issues.TestProtos.CustomOptionFooResponse.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.CustomOptionFooClientMessage), global::UnitTest.Issues.TestProtos.CustomOptionFooClientMessage.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.CustomOptionFooServerMessage), global::UnitTest.Issues.TestProtos.CustomOptionFooServerMessage.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.DummyMessageContainingEnum), global::UnitTest.Issues.TestProtos.DummyMessageContainingEnum.Parser, null, null, new[]{ typeof(global::UnitTest.Issues.TestProtos.DummyMessageContainingEnum.Types.TestEnumType) }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.DummyMessageInvalidAsOptionType), global::UnitTest.Issues.TestProtos.DummyMessageInvalidAsOptionType.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.CustomOptionMinIntegerValues), global::UnitTest.Issues.TestProtos.CustomOptionMinIntegerValues.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.CustomOptionMaxIntegerValues), global::UnitTest.Issues.TestProtos.CustomOptionMaxIntegerValues.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.CustomOptionOtherValues), global::UnitTest.Issues.TestProtos.CustomOptionOtherValues.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.SettingRealsFromPositiveInts), global::UnitTest.Issues.TestProtos.SettingRealsFromPositiveInts.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.SettingRealsFromNegativeInts), global::UnitTest.Issues.TestProtos.SettingRealsFromNegativeInts.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.ComplexOptionType1), global::UnitTest.Issues.TestProtos.ComplexOptionType1.Parser, new[]{ "Foo", "Foo2", "Foo3", "Foo4" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.ComplexOptionType2), global::UnitTest.Issues.TestProtos.ComplexOptionType2.Parser, new[]{ "Bar", "Baz", "Fred", "Barney" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4), global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4.Parser, new[]{ "Waldo" }, null, null, new pb::Extension[] { global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4.Extensions.ComplexOpt4 }, null)}), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.ComplexOptionType3), global::UnitTest.Issues.TestProtos.ComplexOptionType3.Parser, new[]{ "Qux" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.VariousComplexOptions), global::UnitTest.Issues.TestProtos.VariousComplexOptions.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.Aggregate), global::UnitTest.Issues.TestProtos.Aggregate.Parser, new[]{ "I", "S", "Sub" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.AggregateMessage), global::UnitTest.Issues.TestProtos.AggregateMessage.Parser, new[]{ "Fieldname" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.NestedOptionType), global::UnitTest.Issues.TestProtos.NestedOptionType.Parser, null, null, new[]{ typeof(global::UnitTest.Issues.TestProtos.NestedOptionType.Types.NestedEnum) }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.NestedOptionType.Types.NestedMessage), global::UnitTest.Issues.TestProtos.NestedOptionType.Types.NestedMessage.Parser, new[]{ "NestedField" }, null, null, null, null)}) + })); + } + #endregion + + } + /// Holder for extension identifiers generated from the top level of unittest_custom_options_proto3.proto + internal static partial class UnittestCustomOptionsProto3Extensions { + public static readonly pb::Extension FileOpt1 = + new pb::Extension(7736974, pb::FieldCodec.ForUInt64(61895792, 0UL)); + public static readonly pb::Extension MessageOpt1 = + new pb::Extension(7739036, pb::FieldCodec.ForInt32(61912288, 0)); + public static readonly pb::Extension FieldOpt1 = + new pb::Extension(7740936, pb::FieldCodec.ForFixed64(61927489, 0UL)); + public static readonly pb::Extension OneofOpt1 = + new pb::Extension(7740111, pb::FieldCodec.ForInt32(61920888, 0)); + public static readonly pb::Extension EnumOpt1 = + new pb::Extension(7753576, pb::FieldCodec.ForSFixed32(62028613, 0)); + public static readonly pb::Extension EnumValueOpt1 = + new pb::Extension(1560678, pb::FieldCodec.ForInt32(12485424, 0)); + public static readonly pb::Extension ServiceOpt1 = + new pb::Extension(7887650, pb::FieldCodec.ForSInt64(63101200, 0L)); + public static readonly pb::Extension MethodOpt1 = + new pb::Extension(7890860, pb::FieldCodec.ForEnum(63126880, x => (int) x, x => (global::UnitTest.Issues.TestProtos.MethodOpt1) x, global::UnitTest.Issues.TestProtos.MethodOpt1.Unspecified)); + public static readonly pb::Extension BoolOpt = + new pb::Extension(7706090, pb::FieldCodec.ForBool(61648720, false)); + public static readonly pb::Extension Int32Opt = + new pb::Extension(7705709, pb::FieldCodec.ForInt32(61645672, 0)); + public static readonly pb::Extension Int64Opt = + new pb::Extension(7705542, pb::FieldCodec.ForInt64(61644336, 0L)); + public static readonly pb::Extension Uint32Opt = + new pb::Extension(7704880, pb::FieldCodec.ForUInt32(61639040, 0)); + public static readonly pb::Extension Uint64Opt = + new pb::Extension(7702367, pb::FieldCodec.ForUInt64(61618936, 0UL)); + public static readonly pb::Extension Sint32Opt = + new pb::Extension(7701568, pb::FieldCodec.ForSInt32(61612544, 0)); + public static readonly pb::Extension Sint64Opt = + new pb::Extension(7700863, pb::FieldCodec.ForSInt64(61606904, 0L)); + public static readonly pb::Extension Fixed32Opt = + new pb::Extension(7700307, pb::FieldCodec.ForFixed32(61602461, 0)); + public static readonly pb::Extension Fixed64Opt = + new pb::Extension(7700194, pb::FieldCodec.ForFixed64(61601553, 0UL)); + public static readonly pb::Extension Sfixed32Opt = + new pb::Extension(7698645, pb::FieldCodec.ForSFixed32(61589165, 0)); + public static readonly pb::Extension Sfixed64Opt = + new pb::Extension(7685475, pb::FieldCodec.ForSFixed64(61483801, 0L)); + public static readonly pb::Extension FloatOpt = + new pb::Extension(7675390, pb::FieldCodec.ForFloat(61403125, 0F)); + public static readonly pb::Extension DoubleOpt = + new pb::Extension(7673293, pb::FieldCodec.ForDouble(61386345, 0D)); + public static readonly pb::Extension StringOpt = + new pb::Extension(7673285, pb::FieldCodec.ForString(61386282, "")); + public static readonly pb::Extension BytesOpt = + new pb::Extension(7673238, pb::FieldCodec.ForBytes(61385906, pb::ByteString.Empty)); + public static readonly pb::Extension EnumOpt = + new pb::Extension(7673233, pb::FieldCodec.ForEnum(61385864, x => (int) x, x => (global::UnitTest.Issues.TestProtos.DummyMessageContainingEnum.Types.TestEnumType) x, global::UnitTest.Issues.TestProtos.DummyMessageContainingEnum.Types.TestEnumType.TestOptionEnumUnspecified)); + public static readonly pb::Extension MessageTypeOpt = + new pb::Extension(7665967, pb::FieldCodec.ForMessage(61327738, global::UnitTest.Issues.TestProtos.DummyMessageInvalidAsOptionType.Parser)); + public static readonly pb::Extension ComplexOpt1 = + new pb::Extension(7646756, pb::FieldCodec.ForMessage(61174050, global::UnitTest.Issues.TestProtos.ComplexOptionType1.Parser)); + public static readonly pb::Extension ComplexOpt2 = + new pb::Extension(7636949, pb::FieldCodec.ForMessage(61095594, global::UnitTest.Issues.TestProtos.ComplexOptionType2.Parser)); + public static readonly pb::Extension ComplexOpt3 = + new pb::Extension(7636463, pb::FieldCodec.ForMessage(61091706, global::UnitTest.Issues.TestProtos.ComplexOptionType3.Parser)); + public static readonly pb::Extension Fileopt = + new pb::Extension(15478479, pb::FieldCodec.ForMessage(123827834, global::UnitTest.Issues.TestProtos.Aggregate.Parser)); + public static readonly pb::Extension Msgopt = + new pb::Extension(15480088, pb::FieldCodec.ForMessage(123840706, global::UnitTest.Issues.TestProtos.Aggregate.Parser)); + public static readonly pb::Extension Fieldopt = + new pb::Extension(15481374, pb::FieldCodec.ForMessage(123850994, global::UnitTest.Issues.TestProtos.Aggregate.Parser)); + public static readonly pb::Extension Enumopt = + new pb::Extension(15483218, pb::FieldCodec.ForMessage(123865746, global::UnitTest.Issues.TestProtos.Aggregate.Parser)); + public static readonly pb::Extension Enumvalopt = + new pb::Extension(15486921, pb::FieldCodec.ForMessage(123895370, global::UnitTest.Issues.TestProtos.Aggregate.Parser)); + public static readonly pb::Extension Serviceopt = + new pb::Extension(15497145, pb::FieldCodec.ForMessage(123977162, global::UnitTest.Issues.TestProtos.Aggregate.Parser)); + public static readonly pb::Extension Methodopt = + new pb::Extension(15512713, pb::FieldCodec.ForMessage(124101706, global::UnitTest.Issues.TestProtos.Aggregate.Parser)); + } + + #region Enums + public enum MethodOpt1 { + [pbr::OriginalName("METHODOPT1_UNSPECIFIED")] Unspecified = 0, + [pbr::OriginalName("METHODOPT1_VAL1")] Val1 = 1, + [pbr::OriginalName("METHODOPT1_VAL2")] Val2 = 2, + } + + public enum AggregateEnum { + [pbr::OriginalName("UNSPECIFIED")] Unspecified = 0, + [pbr::OriginalName("VALUE")] Value = 1, + } + + #endregion + + #region Messages + /// + /// A test message with custom options at all possible locations (and also some + /// regular options, to make sure they interact nicely). + /// + public sealed partial class TestMessageWithCustomOptions : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMessageWithCustomOptions()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TestMessageWithCustomOptions() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TestMessageWithCustomOptions(TestMessageWithCustomOptions other) : this() { + field1_ = other.field1_; + switch (other.AnOneofCase) { + case AnOneofOneofCase.OneofField: + OneofField = other.OneofField; + break; + } + + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TestMessageWithCustomOptions Clone() { + return new TestMessageWithCustomOptions(this); + } + + /// Field number for the "field1" field. + public const int Field1FieldNumber = 1; + private string field1_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Field1 { + get { return field1_; } + set { + field1_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "oneof_field" field. + public const int OneofFieldFieldNumber = 2; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int OneofField { + get { return anOneofCase_ == AnOneofOneofCase.OneofField ? (int) anOneof_ : 0; } + set { + anOneof_ = value; + anOneofCase_ = AnOneofOneofCase.OneofField; + } + } + + private object anOneof_; + /// Enum of possible cases for the "AnOneof" oneof. + public enum AnOneofOneofCase { + None = 0, + OneofField = 2, + } + private AnOneofOneofCase anOneofCase_ = AnOneofOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AnOneofOneofCase AnOneofCase { + get { return anOneofCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearAnOneof() { + anOneofCase_ = AnOneofOneofCase.None; + anOneof_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as TestMessageWithCustomOptions); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(TestMessageWithCustomOptions other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Field1 != other.Field1) return false; + if (OneofField != other.OneofField) return false; + if (AnOneofCase != other.AnOneofCase) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Field1.Length != 0) hash ^= Field1.GetHashCode(); + if (anOneofCase_ == AnOneofOneofCase.OneofField) hash ^= OneofField.GetHashCode(); + hash ^= (int) anOneofCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Field1.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Field1); + } + if (anOneofCase_ == AnOneofOneofCase.OneofField) { + output.WriteRawTag(16); + output.WriteInt32(OneofField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Field1.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Field1); + } + if (anOneofCase_ == AnOneofOneofCase.OneofField) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(OneofField); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(TestMessageWithCustomOptions other) { + if (other == null) { + return; + } + if (other.Field1.Length != 0) { + Field1 = other.Field1; + } + switch (other.AnOneofCase) { + case AnOneofOneofCase.OneofField: + OneofField = other.OneofField; + break; + } + + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Field1 = input.ReadString(); + break; + } + case 16: { + OneofField = input.ReadInt32(); + break; + } + } + } + } + + #region Nested types + /// Container for nested types declared in the TestMessageWithCustomOptions message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + public enum AnEnum { + [pbr::OriginalName("ANENUM_UNSPECIFIED")] Unspecified = 0, + [pbr::OriginalName("ANENUM_VAL1")] Val1 = 1, + [pbr::OriginalName("ANENUM_VAL2")] Val2 = 2, + } + + } + #endregion + + } + + /// + /// A test RPC service with custom options at all possible locations (and also + /// some regular options, to make sure they interact nicely). + /// + public sealed partial class CustomOptionFooRequest : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionFooRequest()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionFooRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionFooRequest(CustomOptionFooRequest other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionFooRequest Clone() { + return new CustomOptionFooRequest(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as CustomOptionFooRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(CustomOptionFooRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(CustomOptionFooRequest other) { + if (other == null) { + return; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + } + } + } + + } + + public sealed partial class CustomOptionFooResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionFooResponse()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[2]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionFooResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionFooResponse(CustomOptionFooResponse other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionFooResponse Clone() { + return new CustomOptionFooResponse(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as CustomOptionFooResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(CustomOptionFooResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(CustomOptionFooResponse other) { + if (other == null) { + return; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + } + } + } + + } + + public sealed partial class CustomOptionFooClientMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionFooClientMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[3]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionFooClientMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionFooClientMessage(CustomOptionFooClientMessage other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionFooClientMessage Clone() { + return new CustomOptionFooClientMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as CustomOptionFooClientMessage); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(CustomOptionFooClientMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(CustomOptionFooClientMessage other) { + if (other == null) { + return; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + } + } + } + + } + + public sealed partial class CustomOptionFooServerMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionFooServerMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[4]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionFooServerMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionFooServerMessage(CustomOptionFooServerMessage other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionFooServerMessage Clone() { + return new CustomOptionFooServerMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as CustomOptionFooServerMessage); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(CustomOptionFooServerMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(CustomOptionFooServerMessage other) { + if (other == null) { + return; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + } + } + } + + } + + public sealed partial class DummyMessageContainingEnum : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DummyMessageContainingEnum()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[5]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DummyMessageContainingEnum() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DummyMessageContainingEnum(DummyMessageContainingEnum other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DummyMessageContainingEnum Clone() { + return new DummyMessageContainingEnum(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DummyMessageContainingEnum); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DummyMessageContainingEnum other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DummyMessageContainingEnum other) { + if (other == null) { + return; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + } + } + } + + #region Nested types + /// Container for nested types declared in the DummyMessageContainingEnum message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + public enum TestEnumType { + [pbr::OriginalName("TEST_OPTION_ENUM_UNSPECIFIED")] TestOptionEnumUnspecified = 0, + [pbr::OriginalName("TEST_OPTION_ENUM_TYPE1")] TestOptionEnumType1 = 22, + [pbr::OriginalName("TEST_OPTION_ENUM_TYPE2")] TestOptionEnumType2 = -23, + } + + } + #endregion + + } + + public sealed partial class DummyMessageInvalidAsOptionType : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DummyMessageInvalidAsOptionType()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[6]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DummyMessageInvalidAsOptionType() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DummyMessageInvalidAsOptionType(DummyMessageInvalidAsOptionType other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DummyMessageInvalidAsOptionType Clone() { + return new DummyMessageInvalidAsOptionType(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DummyMessageInvalidAsOptionType); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DummyMessageInvalidAsOptionType other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DummyMessageInvalidAsOptionType other) { + if (other == null) { + return; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + } + } + } + + } + + public sealed partial class CustomOptionMinIntegerValues : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionMinIntegerValues()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[7]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionMinIntegerValues() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionMinIntegerValues(CustomOptionMinIntegerValues other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionMinIntegerValues Clone() { + return new CustomOptionMinIntegerValues(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as CustomOptionMinIntegerValues); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(CustomOptionMinIntegerValues other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(CustomOptionMinIntegerValues other) { + if (other == null) { + return; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + } + } + } + + } + + public sealed partial class CustomOptionMaxIntegerValues : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionMaxIntegerValues()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[8]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionMaxIntegerValues() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionMaxIntegerValues(CustomOptionMaxIntegerValues other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionMaxIntegerValues Clone() { + return new CustomOptionMaxIntegerValues(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as CustomOptionMaxIntegerValues); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(CustomOptionMaxIntegerValues other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(CustomOptionMaxIntegerValues other) { + if (other == null) { + return; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + } + } + } + + } + + public sealed partial class CustomOptionOtherValues : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionOtherValues()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[9]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionOtherValues() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionOtherValues(CustomOptionOtherValues other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CustomOptionOtherValues Clone() { + return new CustomOptionOtherValues(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as CustomOptionOtherValues); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(CustomOptionOtherValues other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(CustomOptionOtherValues other) { + if (other == null) { + return; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + } + } + } + + } + + public sealed partial class SettingRealsFromPositiveInts : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SettingRealsFromPositiveInts()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[10]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SettingRealsFromPositiveInts() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SettingRealsFromPositiveInts(SettingRealsFromPositiveInts other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SettingRealsFromPositiveInts Clone() { + return new SettingRealsFromPositiveInts(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as SettingRealsFromPositiveInts); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(SettingRealsFromPositiveInts other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(SettingRealsFromPositiveInts other) { + if (other == null) { + return; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + } + } + } + + } + + public sealed partial class SettingRealsFromNegativeInts : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SettingRealsFromNegativeInts()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[11]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SettingRealsFromNegativeInts() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SettingRealsFromNegativeInts(SettingRealsFromNegativeInts other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SettingRealsFromNegativeInts Clone() { + return new SettingRealsFromNegativeInts(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as SettingRealsFromNegativeInts); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(SettingRealsFromNegativeInts other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(SettingRealsFromNegativeInts other) { + if (other == null) { + return; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + } + } + } + + } + + public sealed partial class ComplexOptionType1 : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ComplexOptionType1()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[12]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ComplexOptionType1() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ComplexOptionType1(ComplexOptionType1 other) : this() { + foo_ = other.foo_; + foo2_ = other.foo2_; + foo3_ = other.foo3_; + foo4_ = other.foo4_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ComplexOptionType1 Clone() { + return new ComplexOptionType1(this); + } + + /// Field number for the "foo" field. + public const int FooFieldNumber = 1; + private int foo_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Foo { + get { return foo_; } + set { + foo_ = value; + } + } + + /// Field number for the "foo2" field. + public const int Foo2FieldNumber = 2; + private int foo2_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Foo2 { + get { return foo2_; } + set { + foo2_ = value; + } + } + + /// Field number for the "foo3" field. + public const int Foo3FieldNumber = 3; + private int foo3_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Foo3 { + get { return foo3_; } + set { + foo3_ = value; + } + } + + /// Field number for the "foo4" field. + public const int Foo4FieldNumber = 4; + private static readonly pb::FieldCodec _repeated_foo4_codec + = pb::FieldCodec.ForInt32(34); + private readonly pbc::RepeatedField foo4_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Foo4 { + get { return foo4_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ComplexOptionType1); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ComplexOptionType1 other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Foo != other.Foo) return false; + if (Foo2 != other.Foo2) return false; + if (Foo3 != other.Foo3) return false; + if(!foo4_.Equals(other.foo4_)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Foo != 0) hash ^= Foo.GetHashCode(); + if (Foo2 != 0) hash ^= Foo2.GetHashCode(); + if (Foo3 != 0) hash ^= Foo3.GetHashCode(); + hash ^= foo4_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Foo != 0) { + output.WriteRawTag(8); + output.WriteInt32(Foo); + } + if (Foo2 != 0) { + output.WriteRawTag(16); + output.WriteInt32(Foo2); + } + if (Foo3 != 0) { + output.WriteRawTag(24); + output.WriteInt32(Foo3); + } + foo4_.WriteTo(output, _repeated_foo4_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Foo != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Foo); + } + if (Foo2 != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Foo2); + } + if (Foo3 != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Foo3); + } + size += foo4_.CalculateSize(_repeated_foo4_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ComplexOptionType1 other) { + if (other == null) { + return; + } + if (other.Foo != 0) { + Foo = other.Foo; + } + if (other.Foo2 != 0) { + Foo2 = other.Foo2; + } + if (other.Foo3 != 0) { + Foo3 = other.Foo3; + } + foo4_.Add(other.foo4_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + Foo = input.ReadInt32(); + break; + } + case 16: { + Foo2 = input.ReadInt32(); + break; + } + case 24: { + Foo3 = input.ReadInt32(); + break; + } + case 34: + case 32: { + foo4_.AddEntriesFrom(input, _repeated_foo4_codec); + break; + } + } + } + } + + } + + public sealed partial class ComplexOptionType2 : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ComplexOptionType2()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[13]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ComplexOptionType2() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ComplexOptionType2(ComplexOptionType2 other) : this() { + bar_ = other.bar_ != null ? other.bar_.Clone() : null; + baz_ = other.baz_; + fred_ = other.fred_ != null ? other.fred_.Clone() : null; + barney_ = other.barney_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ComplexOptionType2 Clone() { + return new ComplexOptionType2(this); + } + + /// Field number for the "bar" field. + public const int BarFieldNumber = 1; + private global::UnitTest.Issues.TestProtos.ComplexOptionType1 bar_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::UnitTest.Issues.TestProtos.ComplexOptionType1 Bar { + get { return bar_; } + set { + bar_ = value; + } + } + + /// Field number for the "baz" field. + public const int BazFieldNumber = 2; + private int baz_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Baz { + get { return baz_; } + set { + baz_ = value; + } + } + + /// Field number for the "fred" field. + public const int FredFieldNumber = 3; + private global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4 fred_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4 Fred { + get { return fred_; } + set { + fred_ = value; + } + } + + /// Field number for the "barney" field. + public const int BarneyFieldNumber = 4; + private static readonly pb::FieldCodec _repeated_barney_codec + = pb::FieldCodec.ForMessage(34, global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4.Parser); + private readonly pbc::RepeatedField barney_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Barney { + get { return barney_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ComplexOptionType2); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ComplexOptionType2 other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(Bar, other.Bar)) return false; + if (Baz != other.Baz) return false; + if (!object.Equals(Fred, other.Fred)) return false; + if(!barney_.Equals(other.barney_)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (bar_ != null) hash ^= Bar.GetHashCode(); + if (Baz != 0) hash ^= Baz.GetHashCode(); + if (fred_ != null) hash ^= Fred.GetHashCode(); + hash ^= barney_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (bar_ != null) { + output.WriteRawTag(10); + output.WriteMessage(Bar); + } + if (Baz != 0) { + output.WriteRawTag(16); + output.WriteInt32(Baz); + } + if (fred_ != null) { + output.WriteRawTag(26); + output.WriteMessage(Fred); + } + barney_.WriteTo(output, _repeated_barney_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (bar_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Bar); + } + if (Baz != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Baz); + } + if (fred_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Fred); + } + size += barney_.CalculateSize(_repeated_barney_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ComplexOptionType2 other) { + if (other == null) { + return; + } + if (other.bar_ != null) { + if (bar_ == null) { + Bar = new global::UnitTest.Issues.TestProtos.ComplexOptionType1(); + } + Bar.MergeFrom(other.Bar); + } + if (other.Baz != 0) { + Baz = other.Baz; + } + if (other.fred_ != null) { + if (fred_ == null) { + Fred = new global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4(); + } + Fred.MergeFrom(other.Fred); + } + barney_.Add(other.barney_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + if (bar_ == null) { + Bar = new global::UnitTest.Issues.TestProtos.ComplexOptionType1(); + } + input.ReadMessage(Bar); + break; + } + case 16: { + Baz = input.ReadInt32(); + break; + } + case 26: { + if (fred_ == null) { + Fred = new global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4(); + } + input.ReadMessage(Fred); + break; + } + case 34: { + barney_.AddEntriesFrom(input, _repeated_barney_codec); + break; + } + } + } + } + + #region Nested types + /// Container for nested types declared in the ComplexOptionType2 message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + public sealed partial class ComplexOptionType4 : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ComplexOptionType4()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.ComplexOptionType2.Descriptor.NestedTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ComplexOptionType4() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ComplexOptionType4(ComplexOptionType4 other) : this() { + waldo_ = other.waldo_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ComplexOptionType4 Clone() { + return new ComplexOptionType4(this); + } + + /// Field number for the "waldo" field. + public const int WaldoFieldNumber = 1; + private int waldo_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Waldo { + get { return waldo_; } + set { + waldo_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ComplexOptionType4); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ComplexOptionType4 other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Waldo != other.Waldo) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Waldo != 0) hash ^= Waldo.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Waldo != 0) { + output.WriteRawTag(8); + output.WriteInt32(Waldo); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Waldo != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Waldo); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ComplexOptionType4 other) { + if (other == null) { + return; + } + if (other.Waldo != 0) { + Waldo = other.Waldo; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + Waldo = input.ReadInt32(); + break; + } + } + } + } + + #region Extensions + /// Container for extensions for other messages declared in the ComplexOptionType4 message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + internal static partial class Extensions { + public static readonly pb::Extension ComplexOpt4 = + new pb::Extension(7633546, pb::FieldCodec.ForMessage(61068370, global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4.Parser)); + } + #endregion + + } + + } + #endregion + + } + + public sealed partial class ComplexOptionType3 : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ComplexOptionType3()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[14]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ComplexOptionType3() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ComplexOptionType3(ComplexOptionType3 other) : this() { + qux_ = other.qux_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ComplexOptionType3 Clone() { + return new ComplexOptionType3(this); + } + + /// Field number for the "qux" field. + public const int QuxFieldNumber = 1; + private int qux_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Qux { + get { return qux_; } + set { + qux_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ComplexOptionType3); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ComplexOptionType3 other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Qux != other.Qux) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Qux != 0) hash ^= Qux.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Qux != 0) { + output.WriteRawTag(8); + output.WriteInt32(Qux); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Qux != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Qux); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ComplexOptionType3 other) { + if (other == null) { + return; + } + if (other.Qux != 0) { + Qux = other.Qux; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + Qux = input.ReadInt32(); + break; + } + } + } + } + + } + + /// + /// Note that we try various different ways of naming the same extension. + /// + public sealed partial class VariousComplexOptions : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new VariousComplexOptions()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[15]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public VariousComplexOptions() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public VariousComplexOptions(VariousComplexOptions other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public VariousComplexOptions Clone() { + return new VariousComplexOptions(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as VariousComplexOptions); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(VariousComplexOptions other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(VariousComplexOptions other) { + if (other == null) { + return; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + } + } + } + + } + + /// + /// A helper type used to test aggregate option parsing + /// + public sealed partial class Aggregate : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Aggregate()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[16]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Aggregate() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Aggregate(Aggregate other) : this() { + i_ = other.i_; + s_ = other.s_; + sub_ = other.sub_ != null ? other.sub_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Aggregate Clone() { + return new Aggregate(this); + } + + /// Field number for the "i" field. + public const int IFieldNumber = 1; + private int i_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int I { + get { return i_; } + set { + i_ = value; + } + } + + /// Field number for the "s" field. + public const int SFieldNumber = 2; + private string s_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string S { + get { return s_; } + set { + s_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "sub" field. + public const int SubFieldNumber = 3; + private global::UnitTest.Issues.TestProtos.Aggregate sub_; + /// + /// A nested object + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::UnitTest.Issues.TestProtos.Aggregate Sub { + get { return sub_; } + set { + sub_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Aggregate); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Aggregate other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (I != other.I) return false; + if (S != other.S) return false; + if (!object.Equals(Sub, other.Sub)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (I != 0) hash ^= I.GetHashCode(); + if (S.Length != 0) hash ^= S.GetHashCode(); + if (sub_ != null) hash ^= Sub.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (I != 0) { + output.WriteRawTag(8); + output.WriteInt32(I); + } + if (S.Length != 0) { + output.WriteRawTag(18); + output.WriteString(S); + } + if (sub_ != null) { + output.WriteRawTag(26); + output.WriteMessage(Sub); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (I != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(I); + } + if (S.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(S); + } + if (sub_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Sub); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Aggregate other) { + if (other == null) { + return; + } + if (other.I != 0) { + I = other.I; + } + if (other.S.Length != 0) { + S = other.S; + } + if (other.sub_ != null) { + if (sub_ == null) { + Sub = new global::UnitTest.Issues.TestProtos.Aggregate(); + } + Sub.MergeFrom(other.Sub); + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + I = input.ReadInt32(); + break; + } + case 18: { + S = input.ReadString(); + break; + } + case 26: { + if (sub_ == null) { + Sub = new global::UnitTest.Issues.TestProtos.Aggregate(); + } + input.ReadMessage(Sub); + break; + } + } + } + } + + } + + public sealed partial class AggregateMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AggregateMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[17]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AggregateMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AggregateMessage(AggregateMessage other) : this() { + fieldname_ = other.fieldname_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public AggregateMessage Clone() { + return new AggregateMessage(this); + } + + /// Field number for the "fieldname" field. + public const int FieldnameFieldNumber = 1; + private int fieldname_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Fieldname { + get { return fieldname_; } + set { + fieldname_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as AggregateMessage); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(AggregateMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Fieldname != other.Fieldname) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Fieldname != 0) hash ^= Fieldname.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Fieldname != 0) { + output.WriteRawTag(8); + output.WriteInt32(Fieldname); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Fieldname != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Fieldname); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(AggregateMessage other) { + if (other == null) { + return; + } + if (other.Fieldname != 0) { + Fieldname = other.Fieldname; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + Fieldname = input.ReadInt32(); + break; + } + } + } + } + + } + + /// + /// Test custom options for nested type. + /// + public sealed partial class NestedOptionType : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedOptionType()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[18]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedOptionType() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedOptionType(NestedOptionType other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedOptionType Clone() { + return new NestedOptionType(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as NestedOptionType); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(NestedOptionType other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(NestedOptionType other) { + if (other == null) { + return; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + } + } + } + + #region Nested types + /// Container for nested types declared in the NestedOptionType message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + public enum NestedEnum { + [pbr::OriginalName("UNSPECIFIED")] Unspecified = 0, + [pbr::OriginalName("NESTED_ENUM_VALUE")] Value = 1, + } + + public sealed partial class NestedMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.NestedOptionType.Descriptor.NestedTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedMessage(NestedMessage other) : this() { + nestedField_ = other.nestedField_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedMessage Clone() { + return new NestedMessage(this); + } + + /// Field number for the "nested_field" field. + public const int NestedFieldFieldNumber = 1; + private int nestedField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int NestedField { + get { return nestedField_; } + set { + nestedField_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as NestedMessage); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(NestedMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (NestedField != other.NestedField) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (NestedField != 0) hash ^= NestedField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (NestedField != 0) { + output.WriteRawTag(8); + output.WriteInt32(NestedField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (NestedField != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(NestedField); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(NestedMessage other) { + if (other == null) { + return; + } + if (other.NestedField != 0) { + NestedField = other.NestedField; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + NestedField = input.ReadInt32(); + break; + } + } + } + } + + } + + } + #endregion + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs index 263e17c0214c..19a1a34634f9 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs @@ -1,5 +1,7 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/unittest_import_proto3.proto +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: unittest_import_proto3.proto +// #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -9,12 +11,11 @@ using scg = global::System.Collections.Generic; namespace Google.Protobuf.TestProtos { - /// Holder for reflection information generated from google/protobuf/unittest_import_proto3.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + /// Holder for reflection information generated from unittest_import_proto3.proto public static partial class UnittestImportProto3Reflection { #region Descriptor - /// File descriptor for google/protobuf/unittest_import_proto3.proto + /// File descriptor for unittest_import_proto3.proto public static pbr::FileDescriptor Descriptor { get { return descriptor; } } @@ -23,18 +24,16 @@ public static partial class UnittestImportProto3Reflection { static UnittestImportProto3Reflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "Cixnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfaW1wb3J0X3Byb3RvMy5wcm90", - "bxIYcHJvdG9idWZfdW5pdHRlc3RfaW1wb3J0GjNnb29nbGUvcHJvdG9idWYv", - "dW5pdHRlc3RfaW1wb3J0X3B1YmxpY19wcm90bzMucHJvdG8iGgoNSW1wb3J0", - "TWVzc2FnZRIJCgFkGAEgASgFKlkKCkltcG9ydEVudW0SGwoXSU1QT1JUX0VO", - "VU1fVU5TUEVDSUZJRUQQABIOCgpJTVBPUlRfRk9PEAcSDgoKSU1QT1JUX0JB", - "UhAIEg4KCklNUE9SVF9CQVoQCUI8Chhjb20uZ29vZ2xlLnByb3RvYnVmLnRl", - "c3RIAfgBAaoCGkdvb2dsZS5Qcm90b2J1Zi5UZXN0UHJvdG9zUABiBnByb3Rv", - "Mw==")); + "Chx1bml0dGVzdF9pbXBvcnRfcHJvdG8zLnByb3RvEhhwcm90b2J1Zl91bml0", + "dGVzdF9pbXBvcnQaI3VuaXR0ZXN0X2ltcG9ydF9wdWJsaWNfcHJvdG8zLnBy", + "b3RvIhoKDUltcG9ydE1lc3NhZ2USCQoBZBgBIAEoBSpZCgpJbXBvcnRFbnVt", + "EhsKF0lNUE9SVF9FTlVNX1VOU1BFQ0lGSUVEEAASDgoKSU1QT1JUX0ZPTxAH", + "Eg4KCklNUE9SVF9CQVIQCBIOCgpJTVBPUlRfQkFaEAlCHaoCGkdvb2dsZS5Q", + "cm90b2J1Zi5UZXN0UHJvdG9zUABiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Google.Protobuf.TestProtos.UnittestImportPublicProto3Reflection.Descriptor, }, - new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.TestProtos.ImportEnum), }, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.ImportMessage), global::Google.Protobuf.TestProtos.ImportMessage.Parser, new[]{ "D" }, null, null, null) + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.TestProtos.ImportEnum), }, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.ImportMessage), global::Google.Protobuf.TestProtos.ImportMessage.Parser, new[]{ "D" }, null, null, null, null) })); } #endregion @@ -51,29 +50,36 @@ public enum ImportEnum { #endregion #region Messages - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class ImportMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ImportMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestImportProto3Reflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ImportMessage() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ImportMessage(ImportMessage other) : this() { d_ = other.d_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ImportMessage Clone() { return new ImportMessage(this); } @@ -81,6 +87,7 @@ public ImportMessage Clone() { /// Field number for the "d" field. public const int DFieldNumber = 1; private int d_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int D { get { return d_; } set { @@ -88,10 +95,12 @@ public int D { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ImportMessage); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(ImportMessage other) { if (ReferenceEquals(other, null)) { return false; @@ -100,34 +109,48 @@ public bool Equals(ImportMessage other) { return true; } if (D != other.D) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (D != 0) hash ^= D.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (D != 0) { output.WriteRawTag(8); output.WriteInt32(D); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (D != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(D); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(ImportMessage other) { if (other == null) { return; @@ -135,14 +158,16 @@ public void MergeFrom(ImportMessage other) { if (other.D != 0) { D = other.D; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { D = input.ReadInt32(); diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs index b471a8cf1aa7..a45565546989 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs @@ -1,5 +1,7 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/unittest_import_public_proto3.proto +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: unittest_import_public_proto3.proto +// #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -9,12 +11,11 @@ using scg = global::System.Collections.Generic; namespace Google.Protobuf.TestProtos { - /// Holder for reflection information generated from google/protobuf/unittest_import_public_proto3.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + /// Holder for reflection information generated from unittest_import_public_proto3.proto public static partial class UnittestImportPublicProto3Reflection { #region Descriptor - /// File descriptor for google/protobuf/unittest_import_public_proto3.proto + /// File descriptor for unittest_import_public_proto3.proto public static pbr::FileDescriptor Descriptor { get { return descriptor; } } @@ -23,43 +24,50 @@ public static partial class UnittestImportPublicProto3Reflection { static UnittestImportPublicProto3Reflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "CjNnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfaW1wb3J0X3B1YmxpY19wcm90", - "bzMucHJvdG8SGHByb3RvYnVmX3VuaXR0ZXN0X2ltcG9ydCIgChNQdWJsaWNJ", - "bXBvcnRNZXNzYWdlEgkKAWUYASABKAVCNwoYY29tLmdvb2dsZS5wcm90b2J1", - "Zi50ZXN0qgIaR29vZ2xlLlByb3RvYnVmLlRlc3RQcm90b3NiBnByb3RvMw==")); + "CiN1bml0dGVzdF9pbXBvcnRfcHVibGljX3Byb3RvMy5wcm90bxIYcHJvdG9i", + "dWZfdW5pdHRlc3RfaW1wb3J0IiAKE1B1YmxpY0ltcG9ydE1lc3NhZ2USCQoB", + "ZRgBIAEoBUIdqgIaR29vZ2xlLlByb3RvYnVmLlRlc3RQcm90b3NiBnByb3Rv", + "Mw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.PublicImportMessage), global::Google.Protobuf.TestProtos.PublicImportMessage.Parser, new[]{ "E" }, null, null, null) + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.PublicImportMessage), global::Google.Protobuf.TestProtos.PublicImportMessage.Parser, new[]{ "E" }, null, null, null, null) })); } #endregion } #region Messages - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class PublicImportMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PublicImportMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestImportPublicProto3Reflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public PublicImportMessage() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public PublicImportMessage(PublicImportMessage other) : this() { e_ = other.e_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public PublicImportMessage Clone() { return new PublicImportMessage(this); } @@ -67,6 +75,7 @@ public PublicImportMessage Clone() { /// Field number for the "e" field. public const int EFieldNumber = 1; private int e_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int E { get { return e_; } set { @@ -74,10 +83,12 @@ public int E { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as PublicImportMessage); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(PublicImportMessage other) { if (ReferenceEquals(other, null)) { return false; @@ -86,34 +97,48 @@ public bool Equals(PublicImportMessage other) { return true; } if (E != other.E) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (E != 0) hash ^= E.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (E != 0) { output.WriteRawTag(8); output.WriteInt32(E); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (E != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(E); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(PublicImportMessage other) { if (other == null) { return; @@ -121,14 +146,16 @@ public void MergeFrom(PublicImportMessage other) { if (other.E != 0) { E = other.E; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { E = input.ReadInt32(); diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs index 7d4451b0931f..f3f40c6a70cf 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs @@ -1,5 +1,7 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: unittest_issues.proto +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: unittest_issues.proto +// #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -10,7 +12,6 @@ namespace UnitTest.Issues.TestProtos { /// Holder for reflection information generated from unittest_issues.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class UnittestIssuesReflection { #region Descriptor @@ -43,22 +44,26 @@ static UnittestIssuesReflection() { "MV9pbnQzMhgFIAEoBUgAEhQKDHBsYWluX3N0cmluZxgBIAEoCRISCghvMl9p", "bnQzMhgGIAEoBUgBEhMKCW8yX3N0cmluZxgDIAEoCUgBQgQKAm8xQgQKAm8y", "IksKDFRlc3RKc29uTmFtZRIMCgRuYW1lGAEgASgJEhkKC2Rlc2NyaXB0aW9u", - "GAIgASgJUgRkZXNjEhIKBGd1aWQYAyABKAlSBGV4aWQqVQoMTmVnYXRpdmVF", - "bnVtEhYKEk5FR0FUSVZFX0VOVU1fWkVSTxAAEhYKCUZpdmVCZWxvdxD7////", - "//////8BEhUKCE1pbnVzT25lEP///////////wEqLgoORGVwcmVjYXRlZEVu", - "dW0SEwoPREVQUkVDQVRFRF9aRVJPEAASBwoDb25lEAFCH0gBqgIaVW5pdFRl", - "c3QuSXNzdWVzLlRlc3RQcm90b3NiBnByb3RvMw==")); + "GAIgASgJUgRkZXNjEhIKBGd1aWQYAyABKAlSBGV4aWQifwoMT25lb2ZNZXJn", + "aW5nEg4KBHRleHQYASABKAlIABI2CgZuZXN0ZWQYAiABKAsyJC51bml0dGVz", + "dF9pc3N1ZXMuT25lb2ZNZXJnaW5nLk5lc3RlZEgAGh4KBk5lc3RlZBIJCgF4", + "GAEgASgFEgkKAXkYAiABKAVCBwoFdmFsdWUqVQoMTmVnYXRpdmVFbnVtEhYK", + "Ek5FR0FUSVZFX0VOVU1fWkVSTxAAEhYKCUZpdmVCZWxvdxD7//////////8B", + "EhUKCE1pbnVzT25lEP///////////wEqLgoORGVwcmVjYXRlZEVudW0SEwoP", + "REVQUkVDQVRFRF9aRVJPEAASBwoDb25lEAFCHaoCGlVuaXRUZXN0Lklzc3Vl", + "cy5UZXN0UHJvdG9zYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(new[] {typeof(global::UnitTest.Issues.TestProtos.NegativeEnum), typeof(global::UnitTest.Issues.TestProtos.DeprecatedEnum), }, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.Issue307), global::UnitTest.Issues.TestProtos.Issue307.Parser, null, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce), global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce.Parser, null, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce.Types.NestedTwice), global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce.Types.NestedTwice.Parser, null, null, null, null)})}), - new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.NegativeEnumMessage), global::UnitTest.Issues.TestProtos.NegativeEnumMessage.Parser, new[]{ "Value", "Values", "PackedValues" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.DeprecatedChild), global::UnitTest.Issues.TestProtos.DeprecatedChild.Parser, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.DeprecatedFieldsMessage), global::UnitTest.Issues.TestProtos.DeprecatedFieldsMessage.Parser, new[]{ "PrimitiveValue", "PrimitiveArray", "MessageValue", "MessageArray", "EnumValue", "EnumArray" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.ItemField), global::UnitTest.Issues.TestProtos.ItemField.Parser, new[]{ "Item" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.ReservedNames), global::UnitTest.Issues.TestProtos.ReservedNames.Parser, new[]{ "Types_", "Descriptor_" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.ReservedNames.Types.SomeNestedType), global::UnitTest.Issues.TestProtos.ReservedNames.Types.SomeNestedType.Parser, null, null, null, null)}), - new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.TestJsonFieldOrdering), global::UnitTest.Issues.TestProtos.TestJsonFieldOrdering.Parser, new[]{ "PlainInt32", "O1String", "O1Int32", "PlainString", "O2Int32", "O2String" }, new[]{ "O1", "O2" }, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.TestJsonName), global::UnitTest.Issues.TestProtos.TestJsonName.Parser, new[]{ "Name", "Description", "Guid" }, null, null, null) + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::UnitTest.Issues.TestProtos.NegativeEnum), typeof(global::UnitTest.Issues.TestProtos.DeprecatedEnum), }, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.Issue307), global::UnitTest.Issues.TestProtos.Issue307.Parser, null, null, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce), global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce.Parser, null, null, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce.Types.NestedTwice), global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce.Types.NestedTwice.Parser, null, null, null, null, null)})}), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.NegativeEnumMessage), global::UnitTest.Issues.TestProtos.NegativeEnumMessage.Parser, new[]{ "Value", "Values", "PackedValues" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.DeprecatedChild), global::UnitTest.Issues.TestProtos.DeprecatedChild.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.DeprecatedFieldsMessage), global::UnitTest.Issues.TestProtos.DeprecatedFieldsMessage.Parser, new[]{ "PrimitiveValue", "PrimitiveArray", "MessageValue", "MessageArray", "EnumValue", "EnumArray" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.ItemField), global::UnitTest.Issues.TestProtos.ItemField.Parser, new[]{ "Item" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.ReservedNames), global::UnitTest.Issues.TestProtos.ReservedNames.Parser, new[]{ "Types_", "Descriptor_" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.ReservedNames.Types.SomeNestedType), global::UnitTest.Issues.TestProtos.ReservedNames.Types.SomeNestedType.Parser, null, null, null, null, null)}), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.TestJsonFieldOrdering), global::UnitTest.Issues.TestProtos.TestJsonFieldOrdering.Parser, new[]{ "PlainInt32", "O1String", "O1Int32", "PlainString", "O2Int32", "O2String" }, new[]{ "O1", "O2" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.TestJsonName), global::UnitTest.Issues.TestProtos.TestJsonName.Parser, new[]{ "Name", "Description", "Guid" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.OneofMerging), global::UnitTest.Issues.TestProtos.OneofMerging.Parser, new[]{ "Text", "Nested" }, new[]{ "Value" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.OneofMerging.Types.Nested), global::UnitTest.Issues.TestProtos.OneofMerging.Types.Nested.Parser, new[]{ "X", "Y" }, null, null, null, null)}) })); } #endregion @@ -80,39 +85,48 @@ public enum DeprecatedEnum { #region Messages /// - /// Issue 307: when generating doubly-nested types, any references - /// should be of the form A.Types.B.Types.C. + /// Issue 307: when generating doubly-nested types, any references + /// should be of the form A.Types.B.Types.C. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Issue307 : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Issue307()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::UnitTest.Issues.TestProtos.UnittestIssuesReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Issue307() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Issue307(Issue307 other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Issue307 Clone() { return new Issue307(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Issue307); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Issue307 other) { if (ReferenceEquals(other, null)) { return false; @@ -120,38 +134,54 @@ public bool Equals(Issue307 other) { if (ReferenceEquals(other, this)) { return true; } - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Issue307 other) { if (other == null) { return; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; } } @@ -159,38 +189,47 @@ public void MergeFrom(pb::CodedInputStream input) { #region Nested types /// Container for nested types declared in the Issue307 message type. - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class NestedOnce : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedOnce()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::UnitTest.Issues.TestProtos.Issue307.Descriptor.NestedTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NestedOnce() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NestedOnce(NestedOnce other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NestedOnce Clone() { return new NestedOnce(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as NestedOnce); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(NestedOnce other) { if (ReferenceEquals(other, null)) { return false; @@ -198,38 +237,54 @@ public bool Equals(NestedOnce other) { if (ReferenceEquals(other, this)) { return true; } - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(NestedOnce other) { if (other == null) { return; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; } } @@ -237,38 +292,47 @@ public void MergeFrom(pb::CodedInputStream input) { #region Nested types /// Container for nested types declared in the NestedOnce message type. - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class NestedTwice : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedTwice()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce.Descriptor.NestedTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NestedTwice() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NestedTwice(NestedTwice other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NestedTwice Clone() { return new NestedTwice(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as NestedTwice); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(NestedTwice other) { if (ReferenceEquals(other, null)) { return false; @@ -276,38 +340,54 @@ public bool Equals(NestedTwice other) { if (ReferenceEquals(other, this)) { return true; } - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(NestedTwice other) { if (other == null) { return; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; } } @@ -325,38 +405,46 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class NegativeEnumMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NegativeEnumMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::UnitTest.Issues.TestProtos.UnittestIssuesReflection.Descriptor.MessageTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NegativeEnumMessage() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NegativeEnumMessage(NegativeEnumMessage other) : this() { value_ = other.value_; values_ = other.values_.Clone(); packedValues_ = other.packedValues_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NegativeEnumMessage Clone() { return new NegativeEnumMessage(this); } /// Field number for the "value" field. public const int ValueFieldNumber = 1; - private global::UnitTest.Issues.TestProtos.NegativeEnum value_ = 0; + private global::UnitTest.Issues.TestProtos.NegativeEnum value_ = global::UnitTest.Issues.TestProtos.NegativeEnum.Zero; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::UnitTest.Issues.TestProtos.NegativeEnum Value { get { return value_; } set { @@ -369,6 +457,7 @@ public NegativeEnumMessage Clone() { private static readonly pb::FieldCodec _repeated_values_codec = pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::UnitTest.Issues.TestProtos.NegativeEnum) x); private readonly pbc::RepeatedField values_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Values { get { return values_; } } @@ -378,14 +467,17 @@ public NegativeEnumMessage Clone() { private static readonly pb::FieldCodec _repeated_packedValues_codec = pb::FieldCodec.ForEnum(26, x => (int) x, x => (global::UnitTest.Issues.TestProtos.NegativeEnum) x); private readonly pbc::RepeatedField packedValues_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField PackedValues { get { return packedValues_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as NegativeEnumMessage); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(NegativeEnumMessage other) { if (ReferenceEquals(other, null)) { return false; @@ -396,60 +488,76 @@ public bool Equals(NegativeEnumMessage other) { if (Value != other.Value) return false; if(!values_.Equals(other.values_)) return false; if(!packedValues_.Equals(other.packedValues_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (Value != 0) hash ^= Value.GetHashCode(); + if (Value != global::UnitTest.Issues.TestProtos.NegativeEnum.Zero) hash ^= Value.GetHashCode(); hash ^= values_.GetHashCode(); hash ^= packedValues_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (Value != 0) { + if (Value != global::UnitTest.Issues.TestProtos.NegativeEnum.Zero) { output.WriteRawTag(8); output.WriteEnum((int) Value); } values_.WriteTo(output, _repeated_values_codec); packedValues_.WriteTo(output, _repeated_packedValues_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (Value != 0) { + if (Value != global::UnitTest.Issues.TestProtos.NegativeEnum.Zero) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Value); } size += values_.CalculateSize(_repeated_values_codec); size += packedValues_.CalculateSize(_repeated_packedValues_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(NegativeEnumMessage other) { if (other == null) { return; } - if (other.Value != 0) { + if (other.Value != global::UnitTest.Issues.TestProtos.NegativeEnum.Zero) { Value = other.Value; } values_.Add(other.values_); packedValues_.Add(other.packedValues_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { - value_ = (global::UnitTest.Issues.TestProtos.NegativeEnum) input.ReadEnum(); + Value = (global::UnitTest.Issues.TestProtos.NegativeEnum) input.ReadEnum(); break; } case 18: @@ -468,36 +576,45 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class DeprecatedChild : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DeprecatedChild()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::UnitTest.Issues.TestProtos.UnittestIssuesReflection.Descriptor.MessageTypes[2]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public DeprecatedChild() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public DeprecatedChild(DeprecatedChild other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public DeprecatedChild Clone() { return new DeprecatedChild(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as DeprecatedChild); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(DeprecatedChild other) { if (ReferenceEquals(other, null)) { return false; @@ -505,38 +622,54 @@ public bool Equals(DeprecatedChild other) { if (ReferenceEquals(other, this)) { return true; } - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(DeprecatedChild other) { if (other == null) { return; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; } } @@ -544,34 +677,41 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class DeprecatedFieldsMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DeprecatedFieldsMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::UnitTest.Issues.TestProtos.UnittestIssuesReflection.Descriptor.MessageTypes[3]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public DeprecatedFieldsMessage() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public DeprecatedFieldsMessage(DeprecatedFieldsMessage other) : this() { primitiveValue_ = other.primitiveValue_; primitiveArray_ = other.primitiveArray_.Clone(); - MessageValue = other.messageValue_ != null ? other.MessageValue.Clone() : null; + messageValue_ = other.messageValue_ != null ? other.messageValue_.Clone() : null; messageArray_ = other.messageArray_.Clone(); enumValue_ = other.enumValue_; enumArray_ = other.enumArray_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public DeprecatedFieldsMessage Clone() { return new DeprecatedFieldsMessage(this); } @@ -579,7 +719,8 @@ public DeprecatedFieldsMessage Clone() { /// Field number for the "PrimitiveValue" field. public const int PrimitiveValueFieldNumber = 1; private int primitiveValue_; - [global::System.ObsoleteAttribute()] + [global::System.ObsoleteAttribute] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int PrimitiveValue { get { return primitiveValue_; } set { @@ -592,7 +733,8 @@ public int PrimitiveValue { private static readonly pb::FieldCodec _repeated_primitiveArray_codec = pb::FieldCodec.ForInt32(18); private readonly pbc::RepeatedField primitiveArray_ = new pbc::RepeatedField(); - [global::System.ObsoleteAttribute()] + [global::System.ObsoleteAttribute] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField PrimitiveArray { get { return primitiveArray_; } } @@ -600,7 +742,8 @@ public int PrimitiveValue { /// Field number for the "MessageValue" field. public const int MessageValueFieldNumber = 3; private global::UnitTest.Issues.TestProtos.DeprecatedChild messageValue_; - [global::System.ObsoleteAttribute()] + [global::System.ObsoleteAttribute] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::UnitTest.Issues.TestProtos.DeprecatedChild MessageValue { get { return messageValue_; } set { @@ -613,15 +756,17 @@ public int PrimitiveValue { private static readonly pb::FieldCodec _repeated_messageArray_codec = pb::FieldCodec.ForMessage(34, global::UnitTest.Issues.TestProtos.DeprecatedChild.Parser); private readonly pbc::RepeatedField messageArray_ = new pbc::RepeatedField(); - [global::System.ObsoleteAttribute()] + [global::System.ObsoleteAttribute] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField MessageArray { get { return messageArray_; } } /// Field number for the "EnumValue" field. public const int EnumValueFieldNumber = 5; - private global::UnitTest.Issues.TestProtos.DeprecatedEnum enumValue_ = 0; - [global::System.ObsoleteAttribute()] + private global::UnitTest.Issues.TestProtos.DeprecatedEnum enumValue_ = global::UnitTest.Issues.TestProtos.DeprecatedEnum.DeprecatedZero; + [global::System.ObsoleteAttribute] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::UnitTest.Issues.TestProtos.DeprecatedEnum EnumValue { get { return enumValue_; } set { @@ -634,15 +779,18 @@ public int PrimitiveValue { private static readonly pb::FieldCodec _repeated_enumArray_codec = pb::FieldCodec.ForEnum(50, x => (int) x, x => (global::UnitTest.Issues.TestProtos.DeprecatedEnum) x); private readonly pbc::RepeatedField enumArray_ = new pbc::RepeatedField(); - [global::System.ObsoleteAttribute()] + [global::System.ObsoleteAttribute] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField EnumArray { get { return enumArray_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as DeprecatedFieldsMessage); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(DeprecatedFieldsMessage other) { if (ReferenceEquals(other, null)) { return false; @@ -656,24 +804,30 @@ public bool Equals(DeprecatedFieldsMessage other) { if(!messageArray_.Equals(other.messageArray_)) return false; if (EnumValue != other.EnumValue) return false; if(!enumArray_.Equals(other.enumArray_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (PrimitiveValue != 0) hash ^= PrimitiveValue.GetHashCode(); hash ^= primitiveArray_.GetHashCode(); if (messageValue_ != null) hash ^= MessageValue.GetHashCode(); hash ^= messageArray_.GetHashCode(); - if (EnumValue != 0) hash ^= EnumValue.GetHashCode(); + if (EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DeprecatedZero) hash ^= EnumValue.GetHashCode(); hash ^= enumArray_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (PrimitiveValue != 0) { output.WriteRawTag(8); @@ -685,13 +839,17 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteMessage(MessageValue); } messageArray_.WriteTo(output, _repeated_messageArray_codec); - if (EnumValue != 0) { + if (EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DeprecatedZero) { output.WriteRawTag(40); output.WriteEnum((int) EnumValue); } enumArray_.WriteTo(output, _repeated_enumArray_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (PrimitiveValue != 0) { @@ -702,13 +860,17 @@ public int CalculateSize() { size += 1 + pb::CodedOutputStream.ComputeMessageSize(MessageValue); } size += messageArray_.CalculateSize(_repeated_messageArray_codec); - if (EnumValue != 0) { + if (EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DeprecatedZero) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) EnumValue); } size += enumArray_.CalculateSize(_repeated_enumArray_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(DeprecatedFieldsMessage other) { if (other == null) { return; @@ -719,23 +881,25 @@ public void MergeFrom(DeprecatedFieldsMessage other) { primitiveArray_.Add(other.primitiveArray_); if (other.messageValue_ != null) { if (messageValue_ == null) { - messageValue_ = new global::UnitTest.Issues.TestProtos.DeprecatedChild(); + MessageValue = new global::UnitTest.Issues.TestProtos.DeprecatedChild(); } MessageValue.MergeFrom(other.MessageValue); } messageArray_.Add(other.messageArray_); - if (other.EnumValue != 0) { + if (other.EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DeprecatedZero) { EnumValue = other.EnumValue; } enumArray_.Add(other.enumArray_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { PrimitiveValue = input.ReadInt32(); @@ -748,9 +912,9 @@ public void MergeFrom(pb::CodedInputStream input) { } case 26: { if (messageValue_ == null) { - messageValue_ = new global::UnitTest.Issues.TestProtos.DeprecatedChild(); + MessageValue = new global::UnitTest.Issues.TestProtos.DeprecatedChild(); } - input.ReadMessage(messageValue_); + input.ReadMessage(MessageValue); break; } case 34: { @@ -758,7 +922,7 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 40: { - enumValue_ = (global::UnitTest.Issues.TestProtos.DeprecatedEnum) input.ReadEnum(); + EnumValue = (global::UnitTest.Issues.TestProtos.DeprecatedEnum) input.ReadEnum(); break; } case 50: @@ -773,31 +937,38 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Issue 45: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=45 + /// Issue 45: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=45 /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class ItemField : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ItemField()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::UnitTest.Issues.TestProtos.UnittestIssuesReflection.Descriptor.MessageTypes[4]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ItemField() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ItemField(ItemField other) : this() { item_ = other.item_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ItemField Clone() { return new ItemField(this); } @@ -805,6 +976,7 @@ public ItemField Clone() { /// Field number for the "item" field. public const int ItemFieldNumber = 1; private int item_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Item { get { return item_; } set { @@ -812,10 +984,12 @@ public int Item { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ItemField); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(ItemField other) { if (ReferenceEquals(other, null)) { return false; @@ -824,34 +998,48 @@ public bool Equals(ItemField other) { return true; } if (Item != other.Item) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Item != 0) hash ^= Item.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Item != 0) { output.WriteRawTag(8); output.WriteInt32(Item); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Item != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(Item); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(ItemField other) { if (other == null) { return; @@ -859,14 +1047,16 @@ public void MergeFrom(ItemField other) { if (other.Item != 0) { Item = other.Item; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { Item = input.ReadInt32(); @@ -878,30 +1068,37 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class ReservedNames : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ReservedNames()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::UnitTest.Issues.TestProtos.UnittestIssuesReflection.Descriptor.MessageTypes[5]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ReservedNames() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ReservedNames(ReservedNames other) : this() { types_ = other.types_; descriptor_ = other.descriptor_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ReservedNames Clone() { return new ReservedNames(this); } @@ -909,6 +1106,7 @@ public ReservedNames Clone() { /// Field number for the "types" field. public const int Types_FieldNumber = 1; private int types_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Types_ { get { return types_; } set { @@ -919,6 +1117,7 @@ public int Types_ { /// Field number for the "descriptor" field. public const int Descriptor_FieldNumber = 2; private int descriptor_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Descriptor_ { get { return descriptor_; } set { @@ -926,10 +1125,12 @@ public int Descriptor_ { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ReservedNames); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(ReservedNames other) { if (ReferenceEquals(other, null)) { return false; @@ -939,20 +1140,26 @@ public bool Equals(ReservedNames other) { } if (Types_ != other.Types_) return false; if (Descriptor_ != other.Descriptor_) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Types_ != 0) hash ^= Types_.GetHashCode(); if (Descriptor_ != 0) hash ^= Descriptor_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Types_ != 0) { output.WriteRawTag(8); @@ -962,8 +1169,12 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(16); output.WriteInt32(Descriptor_); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Types_ != 0) { @@ -972,9 +1183,13 @@ public int CalculateSize() { if (Descriptor_ != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(Descriptor_); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(ReservedNames other) { if (other == null) { return; @@ -985,14 +1200,16 @@ public void MergeFrom(ReservedNames other) { if (other.Descriptor_ != 0) { Descriptor_ = other.Descriptor_; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { Types_ = input.ReadInt32(); @@ -1008,41 +1225,50 @@ public void MergeFrom(pb::CodedInputStream input) { #region Nested types /// Container for nested types declared in the ReservedNames message type. - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { /// - /// Force a nested type called Types + /// Force a nested type called Types /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class SomeNestedType : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SomeNestedType()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::UnitTest.Issues.TestProtos.ReservedNames.Descriptor.NestedTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public SomeNestedType() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public SomeNestedType(SomeNestedType other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public SomeNestedType Clone() { return new SomeNestedType(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as SomeNestedType); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(SomeNestedType other) { if (ReferenceEquals(other, null)) { return false; @@ -1050,38 +1276,54 @@ public bool Equals(SomeNestedType other) { if (ReferenceEquals(other, this)) { return true; } - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(SomeNestedType other) { if (other == null) { return; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; } } @@ -1095,36 +1337,41 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// These fields are deliberately not declared in numeric - /// order, and the oneof fields aren't contiguous either. - /// This allows for reasonably robust tests of JSON output - /// ordering. - /// TestFieldOrderings in unittest_proto3.proto is similar, - /// but doesn't include oneofs. - /// TODO: Consider adding oneofs to TestFieldOrderings, although - /// that will require fixing other tests in multiple platforms. - /// Alternatively, consider just adding this to - /// unittest_proto3.proto if multiple platforms want it. + /// These fields are deliberately not declared in numeric + /// order, and the oneof fields aren't contiguous either. + /// This allows for reasonably robust tests of JSON output + /// ordering. + /// TestFieldOrderings in unittest_proto3.proto is similar, + /// but doesn't include oneofs. + /// TODO: Consider adding oneofs to TestFieldOrderings, although + /// that will require fixing other tests in multiple platforms. + /// Alternatively, consider just adding this to + /// unittest_proto3.proto if multiple platforms want it. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestJsonFieldOrdering : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestJsonFieldOrdering()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::UnitTest.Issues.TestProtos.UnittestIssuesReflection.Descriptor.MessageTypes[6]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestJsonFieldOrdering() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestJsonFieldOrdering(TestJsonFieldOrdering other) : this() { plainInt32_ = other.plainInt32_; plainString_ = other.plainString_; @@ -1146,8 +1393,10 @@ public TestJsonFieldOrdering(TestJsonFieldOrdering other) : this() { break; } + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestJsonFieldOrdering Clone() { return new TestJsonFieldOrdering(this); } @@ -1155,6 +1404,7 @@ public TestJsonFieldOrdering Clone() { /// Field number for the "plain_int32" field. public const int PlainInt32FieldNumber = 4; private int plainInt32_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int PlainInt32 { get { return plainInt32_; } set { @@ -1164,6 +1414,7 @@ public int PlainInt32 { /// Field number for the "o1_string" field. public const int O1StringFieldNumber = 2; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string O1String { get { return o1Case_ == O1OneofCase.O1String ? (string) o1_ : ""; } set { @@ -1174,6 +1425,7 @@ public string O1String { /// Field number for the "o1_int32" field. public const int O1Int32FieldNumber = 5; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int O1Int32 { get { return o1Case_ == O1OneofCase.O1Int32 ? (int) o1_ : 0; } set { @@ -1185,6 +1437,7 @@ public int O1Int32 { /// Field number for the "plain_string" field. public const int PlainStringFieldNumber = 1; private string plainString_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string PlainString { get { return plainString_; } set { @@ -1194,6 +1447,7 @@ public string PlainString { /// Field number for the "o2_int32" field. public const int O2Int32FieldNumber = 6; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int O2Int32 { get { return o2Case_ == O2OneofCase.O2Int32 ? (int) o2_ : 0; } set { @@ -1204,6 +1458,7 @@ public int O2Int32 { /// Field number for the "o2_string" field. public const int O2StringFieldNumber = 3; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string O2String { get { return o2Case_ == O2OneofCase.O2String ? (string) o2_ : ""; } set { @@ -1220,10 +1475,12 @@ public enum O1OneofCase { O1Int32 = 5, } private O1OneofCase o1Case_ = O1OneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public O1OneofCase O1Case { get { return o1Case_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void ClearO1() { o1Case_ = O1OneofCase.None; o1_ = null; @@ -1237,19 +1494,23 @@ public enum O2OneofCase { O2String = 3, } private O2OneofCase o2Case_ = O2OneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public O2OneofCase O2Case { get { return o2Case_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void ClearO2() { o2Case_ = O2OneofCase.None; o2_ = null; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestJsonFieldOrdering); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestJsonFieldOrdering other) { if (ReferenceEquals(other, null)) { return false; @@ -1265,9 +1526,10 @@ public bool Equals(TestJsonFieldOrdering other) { if (O2String != other.O2String) return false; if (O1Case != other.O1Case) return false; if (O2Case != other.O2Case) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (PlainInt32 != 0) hash ^= PlainInt32.GetHashCode(); @@ -1278,13 +1540,18 @@ public override int GetHashCode() { if (o2Case_ == O2OneofCase.O2String) hash ^= O2String.GetHashCode(); hash ^= (int) o1Case_; hash ^= (int) o2Case_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (PlainString.Length != 0) { output.WriteRawTag(10); @@ -1310,8 +1577,12 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(48); output.WriteInt32(O2Int32); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (PlainInt32 != 0) { @@ -1332,9 +1603,13 @@ public int CalculateSize() { if (o2Case_ == O2OneofCase.O2String) { size += 1 + pb::CodedOutputStream.ComputeStringSize(O2String); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestJsonFieldOrdering other) { if (other == null) { return; @@ -1363,14 +1638,16 @@ public void MergeFrom(TestJsonFieldOrdering other) { break; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { PlainString = input.ReadString(); @@ -1402,31 +1679,38 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestJsonName : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestJsonName()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::UnitTest.Issues.TestProtos.UnittestIssuesReflection.Descriptor.MessageTypes[7]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestJsonName() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestJsonName(TestJsonName other) : this() { name_ = other.name_; description_ = other.description_; guid_ = other.guid_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestJsonName Clone() { return new TestJsonName(this); } @@ -1435,8 +1719,9 @@ public TestJsonName Clone() { public const int NameFieldNumber = 1; private string name_ = ""; /// - /// Message for testing the effects for of the json_name option + /// Message for testing the effects for of the json_name option /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -1447,6 +1732,7 @@ public string Name { /// Field number for the "description" field. public const int DescriptionFieldNumber = 2; private string description_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Description { get { return description_; } set { @@ -1457,6 +1743,7 @@ public string Description { /// Field number for the "guid" field. public const int GuidFieldNumber = 3; private string guid_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Guid { get { return guid_; } set { @@ -1464,10 +1751,12 @@ public string Guid { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestJsonName); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestJsonName other) { if (ReferenceEquals(other, null)) { return false; @@ -1478,21 +1767,27 @@ public bool Equals(TestJsonName other) { if (Name != other.Name) return false; if (Description != other.Description) return false; if (Guid != other.Guid) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); if (Description.Length != 0) hash ^= Description.GetHashCode(); if (Guid.Length != 0) hash ^= Guid.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -1506,8 +1801,12 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(26); output.WriteString(Guid); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -1519,9 +1818,13 @@ public int CalculateSize() { if (Guid.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Guid); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestJsonName other) { if (other == null) { return; @@ -1535,14 +1838,16 @@ public void MergeFrom(TestJsonName other) { if (other.Guid.Length != 0) { Guid = other.Guid; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Name = input.ReadString(); @@ -1562,6 +1867,371 @@ public void MergeFrom(pb::CodedInputStream input) { } + /// + /// Issue 3200: When merging two messages which use the same + /// oneof case, which is itself a message type, the submessages should + /// be merged. + /// + public sealed partial class OneofMerging : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneofMerging()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestIssuesReflection.Descriptor.MessageTypes[8]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public OneofMerging() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public OneofMerging(OneofMerging other) : this() { + switch (other.ValueCase) { + case ValueOneofCase.Text: + Text = other.Text; + break; + case ValueOneofCase.Nested: + Nested = other.Nested.Clone(); + break; + } + + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public OneofMerging Clone() { + return new OneofMerging(this); + } + + /// Field number for the "text" field. + public const int TextFieldNumber = 1; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Text { + get { return valueCase_ == ValueOneofCase.Text ? (string) value_ : ""; } + set { + value_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + valueCase_ = ValueOneofCase.Text; + } + } + + /// Field number for the "nested" field. + public const int NestedFieldNumber = 2; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::UnitTest.Issues.TestProtos.OneofMerging.Types.Nested Nested { + get { return valueCase_ == ValueOneofCase.Nested ? (global::UnitTest.Issues.TestProtos.OneofMerging.Types.Nested) value_ : null; } + set { + value_ = value; + valueCase_ = value == null ? ValueOneofCase.None : ValueOneofCase.Nested; + } + } + + private object value_; + /// Enum of possible cases for the "value" oneof. + public enum ValueOneofCase { + None = 0, + Text = 1, + Nested = 2, + } + private ValueOneofCase valueCase_ = ValueOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ValueOneofCase ValueCase { + get { return valueCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearValue() { + valueCase_ = ValueOneofCase.None; + value_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as OneofMerging); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(OneofMerging other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Text != other.Text) return false; + if (!object.Equals(Nested, other.Nested)) return false; + if (ValueCase != other.ValueCase) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (valueCase_ == ValueOneofCase.Text) hash ^= Text.GetHashCode(); + if (valueCase_ == ValueOneofCase.Nested) hash ^= Nested.GetHashCode(); + hash ^= (int) valueCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (valueCase_ == ValueOneofCase.Text) { + output.WriteRawTag(10); + output.WriteString(Text); + } + if (valueCase_ == ValueOneofCase.Nested) { + output.WriteRawTag(18); + output.WriteMessage(Nested); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (valueCase_ == ValueOneofCase.Text) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Text); + } + if (valueCase_ == ValueOneofCase.Nested) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Nested); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(OneofMerging other) { + if (other == null) { + return; + } + switch (other.ValueCase) { + case ValueOneofCase.Text: + Text = other.Text; + break; + case ValueOneofCase.Nested: + if (Nested == null) { + Nested = new global::UnitTest.Issues.TestProtos.OneofMerging.Types.Nested(); + } + Nested.MergeFrom(other.Nested); + break; + } + + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Text = input.ReadString(); + break; + } + case 18: { + global::UnitTest.Issues.TestProtos.OneofMerging.Types.Nested subBuilder = new global::UnitTest.Issues.TestProtos.OneofMerging.Types.Nested(); + if (valueCase_ == ValueOneofCase.Nested) { + subBuilder.MergeFrom(Nested); + } + input.ReadMessage(subBuilder); + Nested = subBuilder; + break; + } + } + } + } + + #region Nested types + /// Container for nested types declared in the OneofMerging message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + public sealed partial class Nested : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Nested()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.OneofMerging.Descriptor.NestedTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Nested() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Nested(Nested other) : this() { + x_ = other.x_; + y_ = other.y_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Nested Clone() { + return new Nested(this); + } + + /// Field number for the "x" field. + public const int XFieldNumber = 1; + private int x_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int X { + get { return x_; } + set { + x_ = value; + } + } + + /// Field number for the "y" field. + public const int YFieldNumber = 2; + private int y_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Y { + get { return y_; } + set { + y_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Nested); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Nested other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (X != other.X) return false; + if (Y != other.Y) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (X != 0) hash ^= X.GetHashCode(); + if (Y != 0) hash ^= Y.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (X != 0) { + output.WriteRawTag(8); + output.WriteInt32(X); + } + if (Y != 0) { + output.WriteRawTag(16); + output.WriteInt32(Y); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (X != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(X); + } + if (Y != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Y); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Nested other) { + if (other == null) { + return; + } + if (other.X != 0) { + X = other.X; + } + if (other.Y != 0) { + Y = other.Y; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + X = input.ReadInt32(); + break; + } + case 16: { + Y = input.ReadInt32(); + break; + } + } + } + } + + } + + } + #endregion + + } + #endregion } diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs index b8d159bb5a96..2f489ad7430a 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs @@ -1,5 +1,7 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/unittest_proto3.proto +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: unittest_proto3.proto +// #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -9,12 +11,11 @@ using scg = global::System.Collections.Generic; namespace Google.Protobuf.TestProtos { - /// Holder for reflection information generated from google/protobuf/unittest_proto3.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + /// Holder for reflection information generated from unittest_proto3.proto public static partial class UnittestProto3Reflection { #region Descriptor - /// File descriptor for google/protobuf/unittest_proto3.proto + /// File descriptor for unittest_proto3.proto public static pbr::FileDescriptor Descriptor { get { return descriptor; } } @@ -23,169 +24,177 @@ public static partial class UnittestProto3Reflection { static UnittestProto3Reflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "CiVnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfcHJvdG8zLnByb3RvEhFwcm90", - "b2J1Zl91bml0dGVzdBosZ29vZ2xlL3Byb3RvYnVmL3VuaXR0ZXN0X2ltcG9y", - "dF9wcm90bzMucHJvdG8i8A8KDFRlc3RBbGxUeXBlcxIUCgxzaW5nbGVfaW50", - "MzIYASABKAUSFAoMc2luZ2xlX2ludDY0GAIgASgDEhUKDXNpbmdsZV91aW50", - "MzIYAyABKA0SFQoNc2luZ2xlX3VpbnQ2NBgEIAEoBBIVCg1zaW5nbGVfc2lu", - "dDMyGAUgASgREhUKDXNpbmdsZV9zaW50NjQYBiABKBISFgoOc2luZ2xlX2Zp", - "eGVkMzIYByABKAcSFgoOc2luZ2xlX2ZpeGVkNjQYCCABKAYSFwoPc2luZ2xl", - "X3NmaXhlZDMyGAkgASgPEhcKD3NpbmdsZV9zZml4ZWQ2NBgKIAEoEBIUCgxz", - "aW5nbGVfZmxvYXQYCyABKAISFQoNc2luZ2xlX2RvdWJsZRgMIAEoARITCgtz", - "aW5nbGVfYm9vbBgNIAEoCBIVCg1zaW5nbGVfc3RyaW5nGA4gASgJEhQKDHNp", - "bmdsZV9ieXRlcxgPIAEoDBJMChVzaW5nbGVfbmVzdGVkX21lc3NhZ2UYEiAB", - "KAsyLS5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsVHlwZXMuTmVzdGVkTWVz", - "c2FnZRJBChZzaW5nbGVfZm9yZWlnbl9tZXNzYWdlGBMgASgLMiEucHJvdG9i", - "dWZfdW5pdHRlc3QuRm9yZWlnbk1lc3NhZ2USRgoVc2luZ2xlX2ltcG9ydF9t", - "ZXNzYWdlGBQgASgLMicucHJvdG9idWZfdW5pdHRlc3RfaW1wb3J0LkltcG9y", - "dE1lc3NhZ2USRgoSc2luZ2xlX25lc3RlZF9lbnVtGBUgASgOMioucHJvdG9i", - "dWZfdW5pdHRlc3QuVGVzdEFsbFR5cGVzLk5lc3RlZEVudW0SOwoTc2luZ2xl", - "X2ZvcmVpZ25fZW51bRgWIAEoDjIeLnByb3RvYnVmX3VuaXR0ZXN0LkZvcmVp", - "Z25FbnVtEkAKEnNpbmdsZV9pbXBvcnRfZW51bRgXIAEoDjIkLnByb3RvYnVm", - "X3VuaXR0ZXN0X2ltcG9ydC5JbXBvcnRFbnVtElMKHHNpbmdsZV9wdWJsaWNf", - "aW1wb3J0X21lc3NhZ2UYGiABKAsyLS5wcm90b2J1Zl91bml0dGVzdF9pbXBv", - "cnQuUHVibGljSW1wb3J0TWVzc2FnZRIWCg5yZXBlYXRlZF9pbnQzMhgfIAMo", - "BRIWCg5yZXBlYXRlZF9pbnQ2NBggIAMoAxIXCg9yZXBlYXRlZF91aW50MzIY", - "ISADKA0SFwoPcmVwZWF0ZWRfdWludDY0GCIgAygEEhcKD3JlcGVhdGVkX3Np", - "bnQzMhgjIAMoERIXCg9yZXBlYXRlZF9zaW50NjQYJCADKBISGAoQcmVwZWF0", - "ZWRfZml4ZWQzMhglIAMoBxIYChByZXBlYXRlZF9maXhlZDY0GCYgAygGEhkK", - "EXJlcGVhdGVkX3NmaXhlZDMyGCcgAygPEhkKEXJlcGVhdGVkX3NmaXhlZDY0", - "GCggAygQEhYKDnJlcGVhdGVkX2Zsb2F0GCkgAygCEhcKD3JlcGVhdGVkX2Rv", - "dWJsZRgqIAMoARIVCg1yZXBlYXRlZF9ib29sGCsgAygIEhcKD3JlcGVhdGVk", - "X3N0cmluZxgsIAMoCRIWCg5yZXBlYXRlZF9ieXRlcxgtIAMoDBJOChdyZXBl", - "YXRlZF9uZXN0ZWRfbWVzc2FnZRgwIAMoCzItLnByb3RvYnVmX3VuaXR0ZXN0", - "LlRlc3RBbGxUeXBlcy5OZXN0ZWRNZXNzYWdlEkMKGHJlcGVhdGVkX2ZvcmVp", - "Z25fbWVzc2FnZRgxIAMoCzIhLnByb3RvYnVmX3VuaXR0ZXN0LkZvcmVpZ25N", - "ZXNzYWdlEkgKF3JlcGVhdGVkX2ltcG9ydF9tZXNzYWdlGDIgAygLMicucHJv", - "dG9idWZfdW5pdHRlc3RfaW1wb3J0LkltcG9ydE1lc3NhZ2USSAoUcmVwZWF0", - "ZWRfbmVzdGVkX2VudW0YMyADKA4yKi5wcm90b2J1Zl91bml0dGVzdC5UZXN0", - "QWxsVHlwZXMuTmVzdGVkRW51bRI9ChVyZXBlYXRlZF9mb3JlaWduX2VudW0Y", - "NCADKA4yHi5wcm90b2J1Zl91bml0dGVzdC5Gb3JlaWduRW51bRJCChRyZXBl", - "YXRlZF9pbXBvcnRfZW51bRg1IAMoDjIkLnByb3RvYnVmX3VuaXR0ZXN0X2lt", - "cG9ydC5JbXBvcnRFbnVtElUKHnJlcGVhdGVkX3B1YmxpY19pbXBvcnRfbWVz", - "c2FnZRg2IAMoCzItLnByb3RvYnVmX3VuaXR0ZXN0X2ltcG9ydC5QdWJsaWNJ", - "bXBvcnRNZXNzYWdlEhYKDG9uZW9mX3VpbnQzMhhvIAEoDUgAEk0KFG9uZW9m", - "X25lc3RlZF9tZXNzYWdlGHAgASgLMi0ucHJvdG9idWZfdW5pdHRlc3QuVGVz", - "dEFsbFR5cGVzLk5lc3RlZE1lc3NhZ2VIABIWCgxvbmVvZl9zdHJpbmcYcSAB", - "KAlIABIVCgtvbmVvZl9ieXRlcxhyIAEoDEgAGhsKDU5lc3RlZE1lc3NhZ2US", - "CgoCYmIYASABKAUiVgoKTmVzdGVkRW51bRIbChdORVNURURfRU5VTV9VTlNQ", - "RUNJRklFRBAAEgcKA0ZPTxABEgcKA0JBUhACEgcKA0JBWhADEhAKA05FRxD/", - "//////////8BQg0KC29uZW9mX2ZpZWxkIrsBChJOZXN0ZWRUZXN0QWxsVHlw", - "ZXMSNAoFY2hpbGQYASABKAsyJS5wcm90b2J1Zl91bml0dGVzdC5OZXN0ZWRU", - "ZXN0QWxsVHlwZXMSMAoHcGF5bG9hZBgCIAEoCzIfLnByb3RvYnVmX3VuaXR0", - "ZXN0LlRlc3RBbGxUeXBlcxI9Cg5yZXBlYXRlZF9jaGlsZBgDIAMoCzIlLnBy", - "b3RvYnVmX3VuaXR0ZXN0Lk5lc3RlZFRlc3RBbGxUeXBlcyI0ChRUZXN0RGVw", - "cmVjYXRlZEZpZWxkcxIcChBkZXByZWNhdGVkX2ludDMyGAEgASgFQgIYASIb", - "Cg5Gb3JlaWduTWVzc2FnZRIJCgFjGAEgASgFIjAKElRlc3RSZXNlcnZlZEZp", - "ZWxkc0oECAIQA0oECA8QEEoECAkQDFIDYmFyUgNiYXoiWgoRVGVzdEZvcmVp", - "Z25OZXN0ZWQSRQoOZm9yZWlnbl9uZXN0ZWQYASABKAsyLS5wcm90b2J1Zl91", - "bml0dGVzdC5UZXN0QWxsVHlwZXMuTmVzdGVkTWVzc2FnZSI0ChhUZXN0UmVh", - "bGx5TGFyZ2VUYWdOdW1iZXISCQoBYRgBIAEoBRINCgJiYhj///9/IAEoBSJV", - "ChRUZXN0UmVjdXJzaXZlTWVzc2FnZRIyCgFhGAEgASgLMicucHJvdG9idWZf", - "dW5pdHRlc3QuVGVzdFJlY3Vyc2l2ZU1lc3NhZ2USCQoBaRgCIAEoBSJLChRU", - "ZXN0TXV0dWFsUmVjdXJzaW9uQRIzCgJiYhgBIAEoCzInLnByb3RvYnVmX3Vu", - "aXR0ZXN0LlRlc3RNdXR1YWxSZWN1cnNpb25CImIKFFRlc3RNdXR1YWxSZWN1", - "cnNpb25CEjIKAWEYASABKAsyJy5wcm90b2J1Zl91bml0dGVzdC5UZXN0TXV0", - "dWFsUmVjdXJzaW9uQRIWCg5vcHRpb25hbF9pbnQzMhgCIAEoBSLrAgoXVGVz", - "dENhbWVsQ2FzZUZpZWxkTmFtZXMSFgoOUHJpbWl0aXZlRmllbGQYASABKAUS", - "EwoLU3RyaW5nRmllbGQYAiABKAkSMQoJRW51bUZpZWxkGAMgASgOMh4ucHJv", - "dG9idWZfdW5pdHRlc3QuRm9yZWlnbkVudW0SNwoMTWVzc2FnZUZpZWxkGAQg", - "ASgLMiEucHJvdG9idWZfdW5pdHRlc3QuRm9yZWlnbk1lc3NhZ2USHgoWUmVw", - "ZWF0ZWRQcmltaXRpdmVGaWVsZBgHIAMoBRIbChNSZXBlYXRlZFN0cmluZ0Zp", - "ZWxkGAggAygJEjkKEVJlcGVhdGVkRW51bUZpZWxkGAkgAygOMh4ucHJvdG9i", - "dWZfdW5pdHRlc3QuRm9yZWlnbkVudW0SPwoUUmVwZWF0ZWRNZXNzYWdlRmll", - "bGQYCiADKAsyIS5wcm90b2J1Zl91bml0dGVzdC5Gb3JlaWduTWVzc2FnZSLH", - "AQoSVGVzdEZpZWxkT3JkZXJpbmdzEhEKCW15X3N0cmluZxgLIAEoCRIOCgZt", - "eV9pbnQYASABKAMSEAoIbXlfZmxvYXQYZSABKAISUwoVc2luZ2xlX25lc3Rl", - "ZF9tZXNzYWdlGMgBIAEoCzIzLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RGaWVs", - "ZE9yZGVyaW5ncy5OZXN0ZWRNZXNzYWdlGicKDU5lc3RlZE1lc3NhZ2USCgoC", - "b28YAiABKAMSCgoCYmIYASABKAUiSwoRU3BhcnNlRW51bU1lc3NhZ2USNgoL", - "c3BhcnNlX2VudW0YASABKA4yIS5wcm90b2J1Zl91bml0dGVzdC5UZXN0U3Bh", - "cnNlRW51bSIZCglPbmVTdHJpbmcSDAoEZGF0YRgBIAEoCSIaCgpNb3JlU3Ry", - "aW5nEgwKBGRhdGEYASADKAkiGAoIT25lQnl0ZXMSDAoEZGF0YRgBIAEoDCIZ", - "CglNb3JlQnl0ZXMSDAoEZGF0YRgBIAEoDCIcCgxJbnQzMk1lc3NhZ2USDAoE", - "ZGF0YRgBIAEoBSIdCg1VaW50MzJNZXNzYWdlEgwKBGRhdGEYASABKA0iHAoM", - "SW50NjRNZXNzYWdlEgwKBGRhdGEYASABKAMiHQoNVWludDY0TWVzc2FnZRIM", - "CgRkYXRhGAEgASgEIhsKC0Jvb2xNZXNzYWdlEgwKBGRhdGEYASABKAgicwoJ", - "VGVzdE9uZW9mEhEKB2Zvb19pbnQYASABKAVIABIUCgpmb29fc3RyaW5nGAIg", - "ASgJSAASNgoLZm9vX21lc3NhZ2UYAyABKAsyHy5wcm90b2J1Zl91bml0dGVz", - "dC5UZXN0QWxsVHlwZXNIAEIFCgNmb28iqgMKD1Rlc3RQYWNrZWRUeXBlcxIY", - "CgxwYWNrZWRfaW50MzIYWiADKAVCAhABEhgKDHBhY2tlZF9pbnQ2NBhbIAMo", - "A0ICEAESGQoNcGFja2VkX3VpbnQzMhhcIAMoDUICEAESGQoNcGFja2VkX3Vp", - "bnQ2NBhdIAMoBEICEAESGQoNcGFja2VkX3NpbnQzMhheIAMoEUICEAESGQoN", - "cGFja2VkX3NpbnQ2NBhfIAMoEkICEAESGgoOcGFja2VkX2ZpeGVkMzIYYCAD", - "KAdCAhABEhoKDnBhY2tlZF9maXhlZDY0GGEgAygGQgIQARIbCg9wYWNrZWRf", - "c2ZpeGVkMzIYYiADKA9CAhABEhsKD3BhY2tlZF9zZml4ZWQ2NBhjIAMoEEIC", - "EAESGAoMcGFja2VkX2Zsb2F0GGQgAygCQgIQARIZCg1wYWNrZWRfZG91Ymxl", - "GGUgAygBQgIQARIXCgtwYWNrZWRfYm9vbBhmIAMoCEICEAESNwoLcGFja2Vk", - "X2VudW0YZyADKA4yHi5wcm90b2J1Zl91bml0dGVzdC5Gb3JlaWduRW51bUIC", - "EAEiyAMKEVRlc3RVbnBhY2tlZFR5cGVzEhoKDnVucGFja2VkX2ludDMyGFog", - "AygFQgIQABIaCg51bnBhY2tlZF9pbnQ2NBhbIAMoA0ICEAASGwoPdW5wYWNr", - "ZWRfdWludDMyGFwgAygNQgIQABIbCg91bnBhY2tlZF91aW50NjQYXSADKARC", - "AhAAEhsKD3VucGFja2VkX3NpbnQzMhheIAMoEUICEAASGwoPdW5wYWNrZWRf", - "c2ludDY0GF8gAygSQgIQABIcChB1bnBhY2tlZF9maXhlZDMyGGAgAygHQgIQ", - "ABIcChB1bnBhY2tlZF9maXhlZDY0GGEgAygGQgIQABIdChF1bnBhY2tlZF9z", - "Zml4ZWQzMhhiIAMoD0ICEAASHQoRdW5wYWNrZWRfc2ZpeGVkNjQYYyADKBBC", - "AhAAEhoKDnVucGFja2VkX2Zsb2F0GGQgAygCQgIQABIbCg91bnBhY2tlZF9k", - "b3VibGUYZSADKAFCAhAAEhkKDXVucGFja2VkX2Jvb2wYZiADKAhCAhAAEjkK", - "DXVucGFja2VkX2VudW0YZyADKA4yHi5wcm90b2J1Zl91bml0dGVzdC5Gb3Jl", - "aWduRW51bUICEAAiwAEKI1Rlc3RSZXBlYXRlZFNjYWxhckRpZmZlcmVudFRh", - "Z1NpemVzEhgKEHJlcGVhdGVkX2ZpeGVkMzIYDCADKAcSFgoOcmVwZWF0ZWRf", - "aW50MzIYDSADKAUSGQoQcmVwZWF0ZWRfZml4ZWQ2NBj+DyADKAYSFwoOcmVw", - "ZWF0ZWRfaW50NjQY/w8gAygDEhgKDnJlcGVhdGVkX2Zsb2F0GP7/DyADKAIS", - "GQoPcmVwZWF0ZWRfdWludDY0GP//DyADKAQiKAobVGVzdENvbW1lbnRJbmpl", - "Y3Rpb25NZXNzYWdlEgkKAWEYASABKAkiDAoKRm9vUmVxdWVzdCINCgtGb29S", - "ZXNwb25zZSISChBGb29DbGllbnRNZXNzYWdlIhIKEEZvb1NlcnZlck1lc3Nh", - "Z2UiDAoKQmFyUmVxdWVzdCINCgtCYXJSZXNwb25zZSpZCgtGb3JlaWduRW51", - "bRIXChNGT1JFSUdOX1VOU1BFQ0lGSUVEEAASDwoLRk9SRUlHTl9GT08QBBIP", - "CgtGT1JFSUdOX0JBUhAFEg8KC0ZPUkVJR05fQkFaEAYqdQoUVGVzdEVudW1X", - "aXRoRHVwVmFsdWUSKAokVEVTVF9FTlVNX1dJVEhfRFVQX1ZBTFVFX1VOU1BF", - "Q0lGSUVEEAASCAoERk9PMRABEggKBEJBUjEQAhIHCgNCQVoQAxIICgRGT08y", - "EAESCAoEQkFSMhACGgIQASqdAQoOVGVzdFNwYXJzZUVudW0SIAocVEVTVF9T", - "UEFSU0VfRU5VTV9VTlNQRUNJRklFRBAAEgwKCFNQQVJTRV9BEHsSDgoIU1BB", - "UlNFX0IQpucDEg8KCFNQQVJTRV9DELKxgAYSFQoIU1BBUlNFX0QQ8f//////", - "////ARIVCghTUEFSU0VfRRC03vz///////8BEgwKCFNQQVJTRV9HEAIymQEK", - "C1Rlc3RTZXJ2aWNlEkQKA0ZvbxIdLnByb3RvYnVmX3VuaXR0ZXN0LkZvb1Jl", - "cXVlc3QaHi5wcm90b2J1Zl91bml0dGVzdC5Gb29SZXNwb25zZRJECgNCYXIS", - "HS5wcm90b2J1Zl91bml0dGVzdC5CYXJSZXF1ZXN0Gh4ucHJvdG9idWZfdW5p", - "dHRlc3QuQmFyUmVzcG9uc2VCOkINVW5pdHRlc3RQcm90b0gBgAEBiAEBkAEB", - "+AEBqgIaR29vZ2xlLlByb3RvYnVmLlRlc3RQcm90b3NiBnByb3RvMw==")); + "ChV1bml0dGVzdF9wcm90bzMucHJvdG8SEnByb3RvYnVmX3VuaXR0ZXN0Mxoc", + "dW5pdHRlc3RfaW1wb3J0X3Byb3RvMy5wcm90byL5DwoMVGVzdEFsbFR5cGVz", + "EhQKDHNpbmdsZV9pbnQzMhgBIAEoBRIUCgxzaW5nbGVfaW50NjQYAiABKAMS", + "FQoNc2luZ2xlX3VpbnQzMhgDIAEoDRIVCg1zaW5nbGVfdWludDY0GAQgASgE", + "EhUKDXNpbmdsZV9zaW50MzIYBSABKBESFQoNc2luZ2xlX3NpbnQ2NBgGIAEo", + "EhIWCg5zaW5nbGVfZml4ZWQzMhgHIAEoBxIWCg5zaW5nbGVfZml4ZWQ2NBgI", + "IAEoBhIXCg9zaW5nbGVfc2ZpeGVkMzIYCSABKA8SFwoPc2luZ2xlX3NmaXhl", + "ZDY0GAogASgQEhQKDHNpbmdsZV9mbG9hdBgLIAEoAhIVCg1zaW5nbGVfZG91", + "YmxlGAwgASgBEhMKC3NpbmdsZV9ib29sGA0gASgIEhUKDXNpbmdsZV9zdHJp", + "bmcYDiABKAkSFAoMc2luZ2xlX2J5dGVzGA8gASgMEk0KFXNpbmdsZV9uZXN0", + "ZWRfbWVzc2FnZRgSIAEoCzIuLnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0QWxs", + "VHlwZXMuTmVzdGVkTWVzc2FnZRJCChZzaW5nbGVfZm9yZWlnbl9tZXNzYWdl", + "GBMgASgLMiIucHJvdG9idWZfdW5pdHRlc3QzLkZvcmVpZ25NZXNzYWdlEkYK", + "FXNpbmdsZV9pbXBvcnRfbWVzc2FnZRgUIAEoCzInLnByb3RvYnVmX3VuaXR0", + "ZXN0X2ltcG9ydC5JbXBvcnRNZXNzYWdlEkcKEnNpbmdsZV9uZXN0ZWRfZW51", + "bRgVIAEoDjIrLnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0QWxsVHlwZXMuTmVz", + "dGVkRW51bRI8ChNzaW5nbGVfZm9yZWlnbl9lbnVtGBYgASgOMh8ucHJvdG9i", + "dWZfdW5pdHRlc3QzLkZvcmVpZ25FbnVtEkAKEnNpbmdsZV9pbXBvcnRfZW51", + "bRgXIAEoDjIkLnByb3RvYnVmX3VuaXR0ZXN0X2ltcG9ydC5JbXBvcnRFbnVt", + "ElMKHHNpbmdsZV9wdWJsaWNfaW1wb3J0X21lc3NhZ2UYGiABKAsyLS5wcm90", + "b2J1Zl91bml0dGVzdF9pbXBvcnQuUHVibGljSW1wb3J0TWVzc2FnZRIWCg5y", + "ZXBlYXRlZF9pbnQzMhgfIAMoBRIWCg5yZXBlYXRlZF9pbnQ2NBggIAMoAxIX", + "Cg9yZXBlYXRlZF91aW50MzIYISADKA0SFwoPcmVwZWF0ZWRfdWludDY0GCIg", + "AygEEhcKD3JlcGVhdGVkX3NpbnQzMhgjIAMoERIXCg9yZXBlYXRlZF9zaW50", + "NjQYJCADKBISGAoQcmVwZWF0ZWRfZml4ZWQzMhglIAMoBxIYChByZXBlYXRl", + "ZF9maXhlZDY0GCYgAygGEhkKEXJlcGVhdGVkX3NmaXhlZDMyGCcgAygPEhkK", + "EXJlcGVhdGVkX3NmaXhlZDY0GCggAygQEhYKDnJlcGVhdGVkX2Zsb2F0GCkg", + "AygCEhcKD3JlcGVhdGVkX2RvdWJsZRgqIAMoARIVCg1yZXBlYXRlZF9ib29s", + "GCsgAygIEhcKD3JlcGVhdGVkX3N0cmluZxgsIAMoCRIWCg5yZXBlYXRlZF9i", + "eXRlcxgtIAMoDBJPChdyZXBlYXRlZF9uZXN0ZWRfbWVzc2FnZRgwIAMoCzIu", + "LnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0QWxsVHlwZXMuTmVzdGVkTWVzc2Fn", + "ZRJEChhyZXBlYXRlZF9mb3JlaWduX21lc3NhZ2UYMSADKAsyIi5wcm90b2J1", + "Zl91bml0dGVzdDMuRm9yZWlnbk1lc3NhZ2USSAoXcmVwZWF0ZWRfaW1wb3J0", + "X21lc3NhZ2UYMiADKAsyJy5wcm90b2J1Zl91bml0dGVzdF9pbXBvcnQuSW1w", + "b3J0TWVzc2FnZRJJChRyZXBlYXRlZF9uZXN0ZWRfZW51bRgzIAMoDjIrLnBy", + "b3RvYnVmX3VuaXR0ZXN0My5UZXN0QWxsVHlwZXMuTmVzdGVkRW51bRI+ChVy", + "ZXBlYXRlZF9mb3JlaWduX2VudW0YNCADKA4yHy5wcm90b2J1Zl91bml0dGVz", + "dDMuRm9yZWlnbkVudW0SQgoUcmVwZWF0ZWRfaW1wb3J0X2VudW0YNSADKA4y", + "JC5wcm90b2J1Zl91bml0dGVzdF9pbXBvcnQuSW1wb3J0RW51bRJVCh5yZXBl", + "YXRlZF9wdWJsaWNfaW1wb3J0X21lc3NhZ2UYNiADKAsyLS5wcm90b2J1Zl91", + "bml0dGVzdF9pbXBvcnQuUHVibGljSW1wb3J0TWVzc2FnZRIWCgxvbmVvZl91", + "aW50MzIYbyABKA1IABJOChRvbmVvZl9uZXN0ZWRfbWVzc2FnZRhwIAEoCzIu", + "LnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0QWxsVHlwZXMuTmVzdGVkTWVzc2Fn", + "ZUgAEhYKDG9uZW9mX3N0cmluZxhxIAEoCUgAEhUKC29uZW9mX2J5dGVzGHIg", + "ASgMSAAaGwoNTmVzdGVkTWVzc2FnZRIKCgJiYhgBIAEoBSJWCgpOZXN0ZWRF", + "bnVtEhsKF05FU1RFRF9FTlVNX1VOU1BFQ0lGSUVEEAASBwoDRk9PEAESBwoD", + "QkFSEAISBwoDQkFaEAMSEAoDTkVHEP///////////wFCDQoLb25lb2ZfZmll", + "bGQivgEKEk5lc3RlZFRlc3RBbGxUeXBlcxI1CgVjaGlsZBgBIAEoCzImLnBy", + "b3RvYnVmX3VuaXR0ZXN0My5OZXN0ZWRUZXN0QWxsVHlwZXMSMQoHcGF5bG9h", + "ZBgCIAEoCzIgLnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0QWxsVHlwZXMSPgoO", + "cmVwZWF0ZWRfY2hpbGQYAyADKAsyJi5wcm90b2J1Zl91bml0dGVzdDMuTmVz", + "dGVkVGVzdEFsbFR5cGVzIjQKFFRlc3REZXByZWNhdGVkRmllbGRzEhwKEGRl", + "cHJlY2F0ZWRfaW50MzIYASABKAVCAhgBIhsKDkZvcmVpZ25NZXNzYWdlEgkK", + "AWMYASABKAUiMAoSVGVzdFJlc2VydmVkRmllbGRzSgQIAhADSgQIDxAQSgQI", + "CRAMUgNiYXJSA2JheiJbChFUZXN0Rm9yZWlnbk5lc3RlZBJGCg5mb3JlaWdu", + "X25lc3RlZBgBIAEoCzIuLnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0QWxsVHlw", + "ZXMuTmVzdGVkTWVzc2FnZSI0ChhUZXN0UmVhbGx5TGFyZ2VUYWdOdW1iZXIS", + "CQoBYRgBIAEoBRINCgJiYhj///9/IAEoBSJWChRUZXN0UmVjdXJzaXZlTWVz", + "c2FnZRIzCgFhGAEgASgLMigucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RSZWN1", + "cnNpdmVNZXNzYWdlEgkKAWkYAiABKAUiTAoUVGVzdE11dHVhbFJlY3Vyc2lv", + "bkESNAoCYmIYASABKAsyKC5wcm90b2J1Zl91bml0dGVzdDMuVGVzdE11dHVh", + "bFJlY3Vyc2lvbkIiYwoUVGVzdE11dHVhbFJlY3Vyc2lvbkISMwoBYRgBIAEo", + "CzIoLnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0TXV0dWFsUmVjdXJzaW9uQRIW", + "Cg5vcHRpb25hbF9pbnQzMhgCIAEoBSJNChJUZXN0RW51bUFsbG93QWxpYXMS", + "NwoFdmFsdWUYASABKA4yKC5wcm90b2J1Zl91bml0dGVzdDMuVGVzdEVudW1X", + "aXRoRHVwVmFsdWUi7wIKF1Rlc3RDYW1lbENhc2VGaWVsZE5hbWVzEhYKDlBy", + "aW1pdGl2ZUZpZWxkGAEgASgFEhMKC1N0cmluZ0ZpZWxkGAIgASgJEjIKCUVu", + "dW1GaWVsZBgDIAEoDjIfLnByb3RvYnVmX3VuaXR0ZXN0My5Gb3JlaWduRW51", + "bRI4CgxNZXNzYWdlRmllbGQYBCABKAsyIi5wcm90b2J1Zl91bml0dGVzdDMu", + "Rm9yZWlnbk1lc3NhZ2USHgoWUmVwZWF0ZWRQcmltaXRpdmVGaWVsZBgHIAMo", + "BRIbChNSZXBlYXRlZFN0cmluZ0ZpZWxkGAggAygJEjoKEVJlcGVhdGVkRW51", + "bUZpZWxkGAkgAygOMh8ucHJvdG9idWZfdW5pdHRlc3QzLkZvcmVpZ25FbnVt", + "EkAKFFJlcGVhdGVkTWVzc2FnZUZpZWxkGAogAygLMiIucHJvdG9idWZfdW5p", + "dHRlc3QzLkZvcmVpZ25NZXNzYWdlIsgBChJUZXN0RmllbGRPcmRlcmluZ3MS", + "EQoJbXlfc3RyaW5nGAsgASgJEg4KBm15X2ludBgBIAEoAxIQCghteV9mbG9h", + "dBhlIAEoAhJUChVzaW5nbGVfbmVzdGVkX21lc3NhZ2UYyAEgASgLMjQucHJv", + "dG9idWZfdW5pdHRlc3QzLlRlc3RGaWVsZE9yZGVyaW5ncy5OZXN0ZWRNZXNz", + "YWdlGicKDU5lc3RlZE1lc3NhZ2USCgoCb28YAiABKAMSCgoCYmIYASABKAUi", + "TAoRU3BhcnNlRW51bU1lc3NhZ2USNwoLc3BhcnNlX2VudW0YASABKA4yIi5w", + "cm90b2J1Zl91bml0dGVzdDMuVGVzdFNwYXJzZUVudW0iGQoJT25lU3RyaW5n", + "EgwKBGRhdGEYASABKAkiGgoKTW9yZVN0cmluZxIMCgRkYXRhGAEgAygJIhgK", + "CE9uZUJ5dGVzEgwKBGRhdGEYASABKAwiGQoJTW9yZUJ5dGVzEgwKBGRhdGEY", + "ASABKAwiHAoMSW50MzJNZXNzYWdlEgwKBGRhdGEYASABKAUiHQoNVWludDMy", + "TWVzc2FnZRIMCgRkYXRhGAEgASgNIhwKDEludDY0TWVzc2FnZRIMCgRkYXRh", + "GAEgASgDIh0KDVVpbnQ2NE1lc3NhZ2USDAoEZGF0YRgBIAEoBCIbCgtCb29s", + "TWVzc2FnZRIMCgRkYXRhGAEgASgIInQKCVRlc3RPbmVvZhIRCgdmb29faW50", + "GAEgASgFSAASFAoKZm9vX3N0cmluZxgCIAEoCUgAEjcKC2Zvb19tZXNzYWdl", + "GAMgASgLMiAucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RBbGxUeXBlc0gAQgUK", + "A2ZvbyKrAwoPVGVzdFBhY2tlZFR5cGVzEhgKDHBhY2tlZF9pbnQzMhhaIAMo", + "BUICEAESGAoMcGFja2VkX2ludDY0GFsgAygDQgIQARIZCg1wYWNrZWRfdWlu", + "dDMyGFwgAygNQgIQARIZCg1wYWNrZWRfdWludDY0GF0gAygEQgIQARIZCg1w", + "YWNrZWRfc2ludDMyGF4gAygRQgIQARIZCg1wYWNrZWRfc2ludDY0GF8gAygS", + "QgIQARIaCg5wYWNrZWRfZml4ZWQzMhhgIAMoB0ICEAESGgoOcGFja2VkX2Zp", + "eGVkNjQYYSADKAZCAhABEhsKD3BhY2tlZF9zZml4ZWQzMhhiIAMoD0ICEAES", + "GwoPcGFja2VkX3NmaXhlZDY0GGMgAygQQgIQARIYCgxwYWNrZWRfZmxvYXQY", + "ZCADKAJCAhABEhkKDXBhY2tlZF9kb3VibGUYZSADKAFCAhABEhcKC3BhY2tl", + "ZF9ib29sGGYgAygIQgIQARI4CgtwYWNrZWRfZW51bRhnIAMoDjIfLnByb3Rv", + "YnVmX3VuaXR0ZXN0My5Gb3JlaWduRW51bUICEAEiyQMKEVRlc3RVbnBhY2tl", + "ZFR5cGVzEhoKDnVucGFja2VkX2ludDMyGFogAygFQgIQABIaCg51bnBhY2tl", + "ZF9pbnQ2NBhbIAMoA0ICEAASGwoPdW5wYWNrZWRfdWludDMyGFwgAygNQgIQ", + "ABIbCg91bnBhY2tlZF91aW50NjQYXSADKARCAhAAEhsKD3VucGFja2VkX3Np", + "bnQzMhheIAMoEUICEAASGwoPdW5wYWNrZWRfc2ludDY0GF8gAygSQgIQABIc", + "ChB1bnBhY2tlZF9maXhlZDMyGGAgAygHQgIQABIcChB1bnBhY2tlZF9maXhl", + "ZDY0GGEgAygGQgIQABIdChF1bnBhY2tlZF9zZml4ZWQzMhhiIAMoD0ICEAAS", + "HQoRdW5wYWNrZWRfc2ZpeGVkNjQYYyADKBBCAhAAEhoKDnVucGFja2VkX2Zs", + "b2F0GGQgAygCQgIQABIbCg91bnBhY2tlZF9kb3VibGUYZSADKAFCAhAAEhkK", + "DXVucGFja2VkX2Jvb2wYZiADKAhCAhAAEjoKDXVucGFja2VkX2VudW0YZyAD", + "KA4yHy5wcm90b2J1Zl91bml0dGVzdDMuRm9yZWlnbkVudW1CAhAAIsABCiNU", + "ZXN0UmVwZWF0ZWRTY2FsYXJEaWZmZXJlbnRUYWdTaXplcxIYChByZXBlYXRl", + "ZF9maXhlZDMyGAwgAygHEhYKDnJlcGVhdGVkX2ludDMyGA0gAygFEhkKEHJl", + "cGVhdGVkX2ZpeGVkNjQY/g8gAygGEhcKDnJlcGVhdGVkX2ludDY0GP8PIAMo", + "AxIYCg5yZXBlYXRlZF9mbG9hdBj+/w8gAygCEhkKD3JlcGVhdGVkX3VpbnQ2", + "NBj//w8gAygEIigKG1Rlc3RDb21tZW50SW5qZWN0aW9uTWVzc2FnZRIJCgFh", + "GAEgASgJIgwKCkZvb1JlcXVlc3QiDQoLRm9vUmVzcG9uc2UiEgoQRm9vQ2xp", + "ZW50TWVzc2FnZSISChBGb29TZXJ2ZXJNZXNzYWdlIgwKCkJhclJlcXVlc3Qi", + "DQoLQmFyUmVzcG9uc2UiEgoQVGVzdEVtcHR5TWVzc2FnZSJwCg5Db21tZW50", + "TWVzc2FnZRIMCgR0ZXh0GAEgASgJGisKFE5lc3RlZENvbW1lbnRNZXNzYWdl", + "EhMKC25lc3RlZF90ZXh0GAEgASgJIiMKEU5lc3RlZENvbW1lbnRFbnVtEg4K", + "ClpFUk9fVkFMVUUQACpZCgtGb3JlaWduRW51bRIXChNGT1JFSUdOX1VOU1BF", + "Q0lGSUVEEAASDwoLRk9SRUlHTl9GT08QBBIPCgtGT1JFSUdOX0JBUhAFEg8K", + "C0ZPUkVJR05fQkFaEAYqdQoUVGVzdEVudW1XaXRoRHVwVmFsdWUSKAokVEVT", + "VF9FTlVNX1dJVEhfRFVQX1ZBTFVFX1VOU1BFQ0lGSUVEEAASCAoERk9PMRAB", + "EggKBEJBUjEQAhIHCgNCQVoQAxIICgRGT08yEAESCAoEQkFSMhACGgIQASqd", + "AQoOVGVzdFNwYXJzZUVudW0SIAocVEVTVF9TUEFSU0VfRU5VTV9VTlNQRUNJ", + "RklFRBAAEgwKCFNQQVJTRV9BEHsSDgoIU1BBUlNFX0IQpucDEg8KCFNQQVJT", + "RV9DELKxgAYSFQoIU1BBUlNFX0QQ8f//////////ARIVCghTUEFSU0VfRRC0", + "3vz///////8BEgwKCFNQQVJTRV9HEAIqHQoLQ29tbWVudEVudW0SDgoKWkVS", + "T19WQUxVRRAAMp0BCgtUZXN0U2VydmljZRJGCgNGb28SHi5wcm90b2J1Zl91", + "bml0dGVzdDMuRm9vUmVxdWVzdBofLnByb3RvYnVmX3VuaXR0ZXN0My5Gb29S", + "ZXNwb25zZRJGCgNCYXISHi5wcm90b2J1Zl91bml0dGVzdDMuQmFyUmVxdWVz", + "dBofLnByb3RvYnVmX3VuaXR0ZXN0My5CYXJSZXNwb25zZUIsQg1Vbml0dGVz", + "dFByb3RvqgIaR29vZ2xlLlByb3RvYnVmLlRlc3RQcm90b3NiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Google.Protobuf.TestProtos.UnittestImportProto3Reflection.Descriptor, }, - new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.TestProtos.ForeignEnum), typeof(global::Google.Protobuf.TestProtos.TestEnumWithDupValue), typeof(global::Google.Protobuf.TestProtos.TestSparseEnum), }, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestAllTypes), global::Google.Protobuf.TestProtos.TestAllTypes.Parser, new[]{ "SingleInt32", "SingleInt64", "SingleUint32", "SingleUint64", "SingleSint32", "SingleSint64", "SingleFixed32", "SingleFixed64", "SingleSfixed32", "SingleSfixed64", "SingleFloat", "SingleDouble", "SingleBool", "SingleString", "SingleBytes", "SingleNestedMessage", "SingleForeignMessage", "SingleImportMessage", "SingleNestedEnum", "SingleForeignEnum", "SingleImportEnum", "SinglePublicImportMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedImportMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedImportEnum", "RepeatedPublicImportMessage", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes" }, new[]{ "OneofField" }, new[]{ typeof(global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum) }, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage), global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage.Parser, new[]{ "Bb" }, null, null, null)}), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.NestedTestAllTypes), global::Google.Protobuf.TestProtos.NestedTestAllTypes.Parser, new[]{ "Child", "Payload", "RepeatedChild" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestDeprecatedFields), global::Google.Protobuf.TestProtos.TestDeprecatedFields.Parser, new[]{ "DeprecatedInt32" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.ForeignMessage), global::Google.Protobuf.TestProtos.ForeignMessage.Parser, new[]{ "C" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestReservedFields), global::Google.Protobuf.TestProtos.TestReservedFields.Parser, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestForeignNested), global::Google.Protobuf.TestProtos.TestForeignNested.Parser, new[]{ "ForeignNested" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestReallyLargeTagNumber), global::Google.Protobuf.TestProtos.TestReallyLargeTagNumber.Parser, new[]{ "A", "Bb" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestRecursiveMessage), global::Google.Protobuf.TestProtos.TestRecursiveMessage.Parser, new[]{ "A", "I" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestMutualRecursionA), global::Google.Protobuf.TestProtos.TestMutualRecursionA.Parser, new[]{ "Bb" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestMutualRecursionB), global::Google.Protobuf.TestProtos.TestMutualRecursionB.Parser, new[]{ "A", "OptionalInt32" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestCamelCaseFieldNames), global::Google.Protobuf.TestProtos.TestCamelCaseFieldNames.Parser, new[]{ "PrimitiveField", "StringField", "EnumField", "MessageField", "RepeatedPrimitiveField", "RepeatedStringField", "RepeatedEnumField", "RepeatedMessageField" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestFieldOrderings), global::Google.Protobuf.TestProtos.TestFieldOrderings.Parser, new[]{ "MyString", "MyInt", "MyFloat", "SingleNestedMessage" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage), global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage.Parser, new[]{ "Oo", "Bb" }, null, null, null)}), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.SparseEnumMessage), global::Google.Protobuf.TestProtos.SparseEnumMessage.Parser, new[]{ "SparseEnum" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.OneString), global::Google.Protobuf.TestProtos.OneString.Parser, new[]{ "Data" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.MoreString), global::Google.Protobuf.TestProtos.MoreString.Parser, new[]{ "Data" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.OneBytes), global::Google.Protobuf.TestProtos.OneBytes.Parser, new[]{ "Data" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.MoreBytes), global::Google.Protobuf.TestProtos.MoreBytes.Parser, new[]{ "Data" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.Int32Message), global::Google.Protobuf.TestProtos.Int32Message.Parser, new[]{ "Data" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.Uint32Message), global::Google.Protobuf.TestProtos.Uint32Message.Parser, new[]{ "Data" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.Int64Message), global::Google.Protobuf.TestProtos.Int64Message.Parser, new[]{ "Data" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.Uint64Message), global::Google.Protobuf.TestProtos.Uint64Message.Parser, new[]{ "Data" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.BoolMessage), global::Google.Protobuf.TestProtos.BoolMessage.Parser, new[]{ "Data" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestOneof), global::Google.Protobuf.TestProtos.TestOneof.Parser, new[]{ "FooInt", "FooString", "FooMessage" }, new[]{ "Foo" }, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestPackedTypes), global::Google.Protobuf.TestProtos.TestPackedTypes.Parser, new[]{ "PackedInt32", "PackedInt64", "PackedUint32", "PackedUint64", "PackedSint32", "PackedSint64", "PackedFixed32", "PackedFixed64", "PackedSfixed32", "PackedSfixed64", "PackedFloat", "PackedDouble", "PackedBool", "PackedEnum" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestUnpackedTypes), global::Google.Protobuf.TestProtos.TestUnpackedTypes.Parser, new[]{ "UnpackedInt32", "UnpackedInt64", "UnpackedUint32", "UnpackedUint64", "UnpackedSint32", "UnpackedSint64", "UnpackedFixed32", "UnpackedFixed64", "UnpackedSfixed32", "UnpackedSfixed64", "UnpackedFloat", "UnpackedDouble", "UnpackedBool", "UnpackedEnum" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestRepeatedScalarDifferentTagSizes), global::Google.Protobuf.TestProtos.TestRepeatedScalarDifferentTagSizes.Parser, new[]{ "RepeatedFixed32", "RepeatedInt32", "RepeatedFixed64", "RepeatedInt64", "RepeatedFloat", "RepeatedUint64" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestCommentInjectionMessage), global::Google.Protobuf.TestProtos.TestCommentInjectionMessage.Parser, new[]{ "A" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.FooRequest), global::Google.Protobuf.TestProtos.FooRequest.Parser, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.FooResponse), global::Google.Protobuf.TestProtos.FooResponse.Parser, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.FooClientMessage), global::Google.Protobuf.TestProtos.FooClientMessage.Parser, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.FooServerMessage), global::Google.Protobuf.TestProtos.FooServerMessage.Parser, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.BarRequest), global::Google.Protobuf.TestProtos.BarRequest.Parser, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.BarResponse), global::Google.Protobuf.TestProtos.BarResponse.Parser, null, null, null, null) + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.TestProtos.ForeignEnum), typeof(global::Google.Protobuf.TestProtos.TestEnumWithDupValue), typeof(global::Google.Protobuf.TestProtos.TestSparseEnum), typeof(global::Google.Protobuf.TestProtos.CommentEnum), }, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestAllTypes), global::Google.Protobuf.TestProtos.TestAllTypes.Parser, new[]{ "SingleInt32", "SingleInt64", "SingleUint32", "SingleUint64", "SingleSint32", "SingleSint64", "SingleFixed32", "SingleFixed64", "SingleSfixed32", "SingleSfixed64", "SingleFloat", "SingleDouble", "SingleBool", "SingleString", "SingleBytes", "SingleNestedMessage", "SingleForeignMessage", "SingleImportMessage", "SingleNestedEnum", "SingleForeignEnum", "SingleImportEnum", "SinglePublicImportMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedImportMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedImportEnum", "RepeatedPublicImportMessage", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes" }, new[]{ "OneofField" }, new[]{ typeof(global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum) }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage), global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage.Parser, new[]{ "Bb" }, null, null, null, null)}), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.NestedTestAllTypes), global::Google.Protobuf.TestProtos.NestedTestAllTypes.Parser, new[]{ "Child", "Payload", "RepeatedChild" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestDeprecatedFields), global::Google.Protobuf.TestProtos.TestDeprecatedFields.Parser, new[]{ "DeprecatedInt32" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.ForeignMessage), global::Google.Protobuf.TestProtos.ForeignMessage.Parser, new[]{ "C" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestReservedFields), global::Google.Protobuf.TestProtos.TestReservedFields.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestForeignNested), global::Google.Protobuf.TestProtos.TestForeignNested.Parser, new[]{ "ForeignNested" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestReallyLargeTagNumber), global::Google.Protobuf.TestProtos.TestReallyLargeTagNumber.Parser, new[]{ "A", "Bb" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestRecursiveMessage), global::Google.Protobuf.TestProtos.TestRecursiveMessage.Parser, new[]{ "A", "I" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestMutualRecursionA), global::Google.Protobuf.TestProtos.TestMutualRecursionA.Parser, new[]{ "Bb" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestMutualRecursionB), global::Google.Protobuf.TestProtos.TestMutualRecursionB.Parser, new[]{ "A", "OptionalInt32" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestEnumAllowAlias), global::Google.Protobuf.TestProtos.TestEnumAllowAlias.Parser, new[]{ "Value" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestCamelCaseFieldNames), global::Google.Protobuf.TestProtos.TestCamelCaseFieldNames.Parser, new[]{ "PrimitiveField", "StringField", "EnumField", "MessageField", "RepeatedPrimitiveField", "RepeatedStringField", "RepeatedEnumField", "RepeatedMessageField" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestFieldOrderings), global::Google.Protobuf.TestProtos.TestFieldOrderings.Parser, new[]{ "MyString", "MyInt", "MyFloat", "SingleNestedMessage" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage), global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage.Parser, new[]{ "Oo", "Bb" }, null, null, null, null)}), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.SparseEnumMessage), global::Google.Protobuf.TestProtos.SparseEnumMessage.Parser, new[]{ "SparseEnum" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.OneString), global::Google.Protobuf.TestProtos.OneString.Parser, new[]{ "Data" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.MoreString), global::Google.Protobuf.TestProtos.MoreString.Parser, new[]{ "Data" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.OneBytes), global::Google.Protobuf.TestProtos.OneBytes.Parser, new[]{ "Data" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.MoreBytes), global::Google.Protobuf.TestProtos.MoreBytes.Parser, new[]{ "Data" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.Int32Message), global::Google.Protobuf.TestProtos.Int32Message.Parser, new[]{ "Data" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.Uint32Message), global::Google.Protobuf.TestProtos.Uint32Message.Parser, new[]{ "Data" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.Int64Message), global::Google.Protobuf.TestProtos.Int64Message.Parser, new[]{ "Data" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.Uint64Message), global::Google.Protobuf.TestProtos.Uint64Message.Parser, new[]{ "Data" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.BoolMessage), global::Google.Protobuf.TestProtos.BoolMessage.Parser, new[]{ "Data" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestOneof), global::Google.Protobuf.TestProtos.TestOneof.Parser, new[]{ "FooInt", "FooString", "FooMessage" }, new[]{ "Foo" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestPackedTypes), global::Google.Protobuf.TestProtos.TestPackedTypes.Parser, new[]{ "PackedInt32", "PackedInt64", "PackedUint32", "PackedUint64", "PackedSint32", "PackedSint64", "PackedFixed32", "PackedFixed64", "PackedSfixed32", "PackedSfixed64", "PackedFloat", "PackedDouble", "PackedBool", "PackedEnum" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestUnpackedTypes), global::Google.Protobuf.TestProtos.TestUnpackedTypes.Parser, new[]{ "UnpackedInt32", "UnpackedInt64", "UnpackedUint32", "UnpackedUint64", "UnpackedSint32", "UnpackedSint64", "UnpackedFixed32", "UnpackedFixed64", "UnpackedSfixed32", "UnpackedSfixed64", "UnpackedFloat", "UnpackedDouble", "UnpackedBool", "UnpackedEnum" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestRepeatedScalarDifferentTagSizes), global::Google.Protobuf.TestProtos.TestRepeatedScalarDifferentTagSizes.Parser, new[]{ "RepeatedFixed32", "RepeatedInt32", "RepeatedFixed64", "RepeatedInt64", "RepeatedFloat", "RepeatedUint64" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestCommentInjectionMessage), global::Google.Protobuf.TestProtos.TestCommentInjectionMessage.Parser, new[]{ "A" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.FooRequest), global::Google.Protobuf.TestProtos.FooRequest.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.FooResponse), global::Google.Protobuf.TestProtos.FooResponse.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.FooClientMessage), global::Google.Protobuf.TestProtos.FooClientMessage.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.FooServerMessage), global::Google.Protobuf.TestProtos.FooServerMessage.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.BarRequest), global::Google.Protobuf.TestProtos.BarRequest.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.BarResponse), global::Google.Protobuf.TestProtos.BarResponse.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestEmptyMessage), global::Google.Protobuf.TestProtos.TestEmptyMessage.Parser, null, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.CommentMessage), global::Google.Protobuf.TestProtos.CommentMessage.Parser, new[]{ "Text" }, null, new[]{ typeof(global::Google.Protobuf.TestProtos.CommentMessage.Types.NestedCommentEnum) }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.CommentMessage.Types.NestedCommentMessage), global::Google.Protobuf.TestProtos.CommentMessage.Types.NestedCommentMessage.Parser, new[]{ "NestedText" }, null, null, null, null)}) })); } #endregion @@ -200,19 +209,19 @@ public enum ForeignEnum { } /// - /// Test an enum that has multiple values with the same number. + /// Test an enum that has multiple values with the same number. /// public enum TestEnumWithDupValue { [pbr::OriginalName("TEST_ENUM_WITH_DUP_VALUE_UNSPECIFIED")] Unspecified = 0, [pbr::OriginalName("FOO1")] Foo1 = 1, [pbr::OriginalName("BAR1")] Bar1 = 2, [pbr::OriginalName("BAZ")] Baz = 3, - [pbr::OriginalName("FOO2")] Foo2 = 1, - [pbr::OriginalName("BAR2")] Bar2 = 2, + [pbr::OriginalName("FOO2", PreferredAlias = false)] Foo2 = 1, + [pbr::OriginalName("BAR2", PreferredAlias = false)] Bar2 = 2, } /// - /// Test an enum with large, unordered values. + /// Test an enum with large, unordered values. /// public enum TestSparseEnum { [pbr::OriginalName("TEST_SPARSE_ENUM_UNSPECIFIED")] Unspecified = 0, @@ -222,38 +231,53 @@ public enum TestSparseEnum { [pbr::OriginalName("SPARSE_D")] SparseD = -15, [pbr::OriginalName("SPARSE_E")] SparseE = -53452, /// - /// In proto3, value 0 must be the first one specified - /// SPARSE_F = 0; + /// In proto3, value 0 must be the first one specified + /// SPARSE_F = 0; /// [pbr::OriginalName("SPARSE_G")] SparseG = 2, } + /// + /// Leading enum comment + /// + public enum CommentEnum { + /// + /// Zero value comment + /// + [pbr::OriginalName("ZERO_VALUE")] ZeroValue = 0, + } + #endregion #region Messages /// - /// This proto includes every type of field in both singular and repeated - /// forms. + /// This proto includes every type of field in both singular and repeated + /// forms. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestAllTypes : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestAllTypes()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestAllTypes() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestAllTypes(TestAllTypes other) : this() { singleInt32_ = other.singleInt32_; singleInt64_ = other.singleInt64_; @@ -270,13 +294,13 @@ public TestAllTypes(TestAllTypes other) : this() { singleBool_ = other.singleBool_; singleString_ = other.singleString_; singleBytes_ = other.singleBytes_; - SingleNestedMessage = other.singleNestedMessage_ != null ? other.SingleNestedMessage.Clone() : null; - SingleForeignMessage = other.singleForeignMessage_ != null ? other.SingleForeignMessage.Clone() : null; - SingleImportMessage = other.singleImportMessage_ != null ? other.SingleImportMessage.Clone() : null; + singleNestedMessage_ = other.singleNestedMessage_ != null ? other.singleNestedMessage_.Clone() : null; + singleForeignMessage_ = other.singleForeignMessage_ != null ? other.singleForeignMessage_.Clone() : null; + singleImportMessage_ = other.singleImportMessage_ != null ? other.singleImportMessage_.Clone() : null; singleNestedEnum_ = other.singleNestedEnum_; singleForeignEnum_ = other.singleForeignEnum_; singleImportEnum_ = other.singleImportEnum_; - SinglePublicImportMessage = other.singlePublicImportMessage_ != null ? other.SinglePublicImportMessage.Clone() : null; + singlePublicImportMessage_ = other.singlePublicImportMessage_ != null ? other.singlePublicImportMessage_.Clone() : null; repeatedInt32_ = other.repeatedInt32_.Clone(); repeatedInt64_ = other.repeatedInt64_.Clone(); repeatedUint32_ = other.repeatedUint32_.Clone(); @@ -314,8 +338,10 @@ public TestAllTypes(TestAllTypes other) : this() { break; } + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestAllTypes Clone() { return new TestAllTypes(this); } @@ -324,8 +350,9 @@ public TestAllTypes Clone() { public const int SingleInt32FieldNumber = 1; private int singleInt32_; /// - /// Singular + /// Singular /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int SingleInt32 { get { return singleInt32_; } set { @@ -336,6 +363,7 @@ public int SingleInt32 { /// Field number for the "single_int64" field. public const int SingleInt64FieldNumber = 2; private long singleInt64_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public long SingleInt64 { get { return singleInt64_; } set { @@ -346,6 +374,7 @@ public long SingleInt64 { /// Field number for the "single_uint32" field. public const int SingleUint32FieldNumber = 3; private uint singleUint32_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public uint SingleUint32 { get { return singleUint32_; } set { @@ -356,6 +385,7 @@ public uint SingleUint32 { /// Field number for the "single_uint64" field. public const int SingleUint64FieldNumber = 4; private ulong singleUint64_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ulong SingleUint64 { get { return singleUint64_; } set { @@ -366,6 +396,7 @@ public ulong SingleUint64 { /// Field number for the "single_sint32" field. public const int SingleSint32FieldNumber = 5; private int singleSint32_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int SingleSint32 { get { return singleSint32_; } set { @@ -376,6 +407,7 @@ public int SingleSint32 { /// Field number for the "single_sint64" field. public const int SingleSint64FieldNumber = 6; private long singleSint64_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public long SingleSint64 { get { return singleSint64_; } set { @@ -386,6 +418,7 @@ public long SingleSint64 { /// Field number for the "single_fixed32" field. public const int SingleFixed32FieldNumber = 7; private uint singleFixed32_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public uint SingleFixed32 { get { return singleFixed32_; } set { @@ -396,6 +429,7 @@ public uint SingleFixed32 { /// Field number for the "single_fixed64" field. public const int SingleFixed64FieldNumber = 8; private ulong singleFixed64_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ulong SingleFixed64 { get { return singleFixed64_; } set { @@ -406,6 +440,7 @@ public ulong SingleFixed64 { /// Field number for the "single_sfixed32" field. public const int SingleSfixed32FieldNumber = 9; private int singleSfixed32_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int SingleSfixed32 { get { return singleSfixed32_; } set { @@ -416,6 +451,7 @@ public int SingleSfixed32 { /// Field number for the "single_sfixed64" field. public const int SingleSfixed64FieldNumber = 10; private long singleSfixed64_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public long SingleSfixed64 { get { return singleSfixed64_; } set { @@ -426,6 +462,7 @@ public long SingleSfixed64 { /// Field number for the "single_float" field. public const int SingleFloatFieldNumber = 11; private float singleFloat_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public float SingleFloat { get { return singleFloat_; } set { @@ -436,6 +473,7 @@ public float SingleFloat { /// Field number for the "single_double" field. public const int SingleDoubleFieldNumber = 12; private double singleDouble_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public double SingleDouble { get { return singleDouble_; } set { @@ -446,6 +484,7 @@ public double SingleDouble { /// Field number for the "single_bool" field. public const int SingleBoolFieldNumber = 13; private bool singleBool_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool SingleBool { get { return singleBool_; } set { @@ -456,6 +495,7 @@ public bool SingleBool { /// Field number for the "single_string" field. public const int SingleStringFieldNumber = 14; private string singleString_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string SingleString { get { return singleString_; } set { @@ -466,6 +506,7 @@ public string SingleString { /// Field number for the "single_bytes" field. public const int SingleBytesFieldNumber = 15; private pb::ByteString singleBytes_ = pb::ByteString.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pb::ByteString SingleBytes { get { return singleBytes_; } set { @@ -476,6 +517,7 @@ public string SingleString { /// Field number for the "single_nested_message" field. public const int SingleNestedMessageFieldNumber = 18; private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage singleNestedMessage_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage SingleNestedMessage { get { return singleNestedMessage_; } set { @@ -486,6 +528,7 @@ public string SingleString { /// Field number for the "single_foreign_message" field. public const int SingleForeignMessageFieldNumber = 19; private global::Google.Protobuf.TestProtos.ForeignMessage singleForeignMessage_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.ForeignMessage SingleForeignMessage { get { return singleForeignMessage_; } set { @@ -496,6 +539,7 @@ public string SingleString { /// Field number for the "single_import_message" field. public const int SingleImportMessageFieldNumber = 20; private global::Google.Protobuf.TestProtos.ImportMessage singleImportMessage_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.ImportMessage SingleImportMessage { get { return singleImportMessage_; } set { @@ -505,7 +549,8 @@ public string SingleString { /// Field number for the "single_nested_enum" field. public const int SingleNestedEnumFieldNumber = 21; - private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum singleNestedEnum_ = 0; + private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum singleNestedEnum_ = global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.Unspecified; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum SingleNestedEnum { get { return singleNestedEnum_; } set { @@ -515,7 +560,8 @@ public string SingleString { /// Field number for the "single_foreign_enum" field. public const int SingleForeignEnumFieldNumber = 22; - private global::Google.Protobuf.TestProtos.ForeignEnum singleForeignEnum_ = 0; + private global::Google.Protobuf.TestProtos.ForeignEnum singleForeignEnum_ = global::Google.Protobuf.TestProtos.ForeignEnum.ForeignUnspecified; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.ForeignEnum SingleForeignEnum { get { return singleForeignEnum_; } set { @@ -525,7 +571,8 @@ public string SingleString { /// Field number for the "single_import_enum" field. public const int SingleImportEnumFieldNumber = 23; - private global::Google.Protobuf.TestProtos.ImportEnum singleImportEnum_ = 0; + private global::Google.Protobuf.TestProtos.ImportEnum singleImportEnum_ = global::Google.Protobuf.TestProtos.ImportEnum.Unspecified; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.ImportEnum SingleImportEnum { get { return singleImportEnum_; } set { @@ -537,8 +584,9 @@ public string SingleString { public const int SinglePublicImportMessageFieldNumber = 26; private global::Google.Protobuf.TestProtos.PublicImportMessage singlePublicImportMessage_; /// - /// Defined in unittest_import_public.proto + /// Defined in unittest_import_public.proto /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.PublicImportMessage SinglePublicImportMessage { get { return singlePublicImportMessage_; } set { @@ -552,8 +600,9 @@ public string SingleString { = pb::FieldCodec.ForInt32(250); private readonly pbc::RepeatedField repeatedInt32_ = new pbc::RepeatedField(); /// - /// Repeated + /// Repeated /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedInt32 { get { return repeatedInt32_; } } @@ -563,6 +612,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedInt64_codec = pb::FieldCodec.ForInt64(258); private readonly pbc::RepeatedField repeatedInt64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedInt64 { get { return repeatedInt64_; } } @@ -572,6 +622,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedUint32_codec = pb::FieldCodec.ForUInt32(266); private readonly pbc::RepeatedField repeatedUint32_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedUint32 { get { return repeatedUint32_; } } @@ -581,6 +632,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedUint64_codec = pb::FieldCodec.ForUInt64(274); private readonly pbc::RepeatedField repeatedUint64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedUint64 { get { return repeatedUint64_; } } @@ -590,6 +642,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedSint32_codec = pb::FieldCodec.ForSInt32(282); private readonly pbc::RepeatedField repeatedSint32_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedSint32 { get { return repeatedSint32_; } } @@ -599,6 +652,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedSint64_codec = pb::FieldCodec.ForSInt64(290); private readonly pbc::RepeatedField repeatedSint64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedSint64 { get { return repeatedSint64_; } } @@ -608,6 +662,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedFixed32_codec = pb::FieldCodec.ForFixed32(298); private readonly pbc::RepeatedField repeatedFixed32_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedFixed32 { get { return repeatedFixed32_; } } @@ -617,6 +672,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedFixed64_codec = pb::FieldCodec.ForFixed64(306); private readonly pbc::RepeatedField repeatedFixed64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedFixed64 { get { return repeatedFixed64_; } } @@ -626,6 +682,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedSfixed32_codec = pb::FieldCodec.ForSFixed32(314); private readonly pbc::RepeatedField repeatedSfixed32_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedSfixed32 { get { return repeatedSfixed32_; } } @@ -635,6 +692,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedSfixed64_codec = pb::FieldCodec.ForSFixed64(322); private readonly pbc::RepeatedField repeatedSfixed64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedSfixed64 { get { return repeatedSfixed64_; } } @@ -644,6 +702,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedFloat_codec = pb::FieldCodec.ForFloat(330); private readonly pbc::RepeatedField repeatedFloat_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedFloat { get { return repeatedFloat_; } } @@ -653,6 +712,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedDouble_codec = pb::FieldCodec.ForDouble(338); private readonly pbc::RepeatedField repeatedDouble_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedDouble { get { return repeatedDouble_; } } @@ -662,6 +722,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedBool_codec = pb::FieldCodec.ForBool(346); private readonly pbc::RepeatedField repeatedBool_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedBool { get { return repeatedBool_; } } @@ -671,6 +732,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedString_codec = pb::FieldCodec.ForString(354); private readonly pbc::RepeatedField repeatedString_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedString { get { return repeatedString_; } } @@ -680,6 +742,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedBytes_codec = pb::FieldCodec.ForBytes(362); private readonly pbc::RepeatedField repeatedBytes_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedBytes { get { return repeatedBytes_; } } @@ -689,6 +752,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedNestedMessage_codec = pb::FieldCodec.ForMessage(386, global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage.Parser); private readonly pbc::RepeatedField repeatedNestedMessage_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedNestedMessage { get { return repeatedNestedMessage_; } } @@ -698,6 +762,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedForeignMessage_codec = pb::FieldCodec.ForMessage(394, global::Google.Protobuf.TestProtos.ForeignMessage.Parser); private readonly pbc::RepeatedField repeatedForeignMessage_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedForeignMessage { get { return repeatedForeignMessage_; } } @@ -707,6 +772,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedImportMessage_codec = pb::FieldCodec.ForMessage(402, global::Google.Protobuf.TestProtos.ImportMessage.Parser); private readonly pbc::RepeatedField repeatedImportMessage_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedImportMessage { get { return repeatedImportMessage_; } } @@ -716,6 +782,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedNestedEnum_codec = pb::FieldCodec.ForEnum(410, x => (int) x, x => (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum) x); private readonly pbc::RepeatedField repeatedNestedEnum_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedNestedEnum { get { return repeatedNestedEnum_; } } @@ -725,6 +792,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedForeignEnum_codec = pb::FieldCodec.ForEnum(418, x => (int) x, x => (global::Google.Protobuf.TestProtos.ForeignEnum) x); private readonly pbc::RepeatedField repeatedForeignEnum_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedForeignEnum { get { return repeatedForeignEnum_; } } @@ -734,6 +802,7 @@ public string SingleString { private static readonly pb::FieldCodec _repeated_repeatedImportEnum_codec = pb::FieldCodec.ForEnum(426, x => (int) x, x => (global::Google.Protobuf.TestProtos.ImportEnum) x); private readonly pbc::RepeatedField repeatedImportEnum_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedImportEnum { get { return repeatedImportEnum_; } } @@ -744,14 +813,16 @@ public string SingleString { = pb::FieldCodec.ForMessage(434, global::Google.Protobuf.TestProtos.PublicImportMessage.Parser); private readonly pbc::RepeatedField repeatedPublicImportMessage_ = new pbc::RepeatedField(); /// - /// Defined in unittest_import_public.proto + /// Defined in unittest_import_public.proto /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedPublicImportMessage { get { return repeatedPublicImportMessage_; } } /// Field number for the "oneof_uint32" field. public const int OneofUint32FieldNumber = 111; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public uint OneofUint32 { get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint32 ? (uint) oneofField_ : 0; } set { @@ -762,6 +833,7 @@ public uint OneofUint32 { /// Field number for the "oneof_nested_message" field. public const int OneofNestedMessageFieldNumber = 112; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage OneofNestedMessage { get { return oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage ? (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage) oneofField_ : null; } set { @@ -772,6 +844,7 @@ public uint OneofUint32 { /// Field number for the "oneof_string" field. public const int OneofStringFieldNumber = 113; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string OneofString { get { return oneofFieldCase_ == OneofFieldOneofCase.OneofString ? (string) oneofField_ : ""; } set { @@ -782,6 +855,7 @@ public string OneofString { /// Field number for the "oneof_bytes" field. public const int OneofBytesFieldNumber = 114; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pb::ByteString OneofBytes { get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBytes ? (pb::ByteString) oneofField_ : pb::ByteString.Empty; } set { @@ -800,19 +874,23 @@ public enum OneofFieldOneofCase { OneofBytes = 114, } private OneofFieldOneofCase oneofFieldCase_ = OneofFieldOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public OneofFieldOneofCase OneofFieldCase { get { return oneofFieldCase_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void ClearOneofField() { oneofFieldCase_ = OneofFieldOneofCase.None; oneofField_ = null; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestAllTypes); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestAllTypes other) { if (ReferenceEquals(other, null)) { return false; @@ -830,8 +908,8 @@ public bool Equals(TestAllTypes other) { if (SingleFixed64 != other.SingleFixed64) return false; if (SingleSfixed32 != other.SingleSfixed32) return false; if (SingleSfixed64 != other.SingleSfixed64) return false; - if (SingleFloat != other.SingleFloat) return false; - if (SingleDouble != other.SingleDouble) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(SingleFloat, other.SingleFloat)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(SingleDouble, other.SingleDouble)) return false; if (SingleBool != other.SingleBool) return false; if (SingleString != other.SingleString) return false; if (SingleBytes != other.SingleBytes) return false; @@ -869,9 +947,10 @@ public bool Equals(TestAllTypes other) { if (OneofString != other.OneofString) return false; if (OneofBytes != other.OneofBytes) return false; if (OneofFieldCase != other.OneofFieldCase) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (SingleInt32 != 0) hash ^= SingleInt32.GetHashCode(); @@ -884,17 +963,17 @@ public override int GetHashCode() { if (SingleFixed64 != 0UL) hash ^= SingleFixed64.GetHashCode(); if (SingleSfixed32 != 0) hash ^= SingleSfixed32.GetHashCode(); if (SingleSfixed64 != 0L) hash ^= SingleSfixed64.GetHashCode(); - if (SingleFloat != 0F) hash ^= SingleFloat.GetHashCode(); - if (SingleDouble != 0D) hash ^= SingleDouble.GetHashCode(); + if (SingleFloat != 0F) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(SingleFloat); + if (SingleDouble != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(SingleDouble); if (SingleBool != false) hash ^= SingleBool.GetHashCode(); if (SingleString.Length != 0) hash ^= SingleString.GetHashCode(); if (SingleBytes.Length != 0) hash ^= SingleBytes.GetHashCode(); if (singleNestedMessage_ != null) hash ^= SingleNestedMessage.GetHashCode(); if (singleForeignMessage_ != null) hash ^= SingleForeignMessage.GetHashCode(); if (singleImportMessage_ != null) hash ^= SingleImportMessage.GetHashCode(); - if (SingleNestedEnum != 0) hash ^= SingleNestedEnum.GetHashCode(); - if (SingleForeignEnum != 0) hash ^= SingleForeignEnum.GetHashCode(); - if (SingleImportEnum != 0) hash ^= SingleImportEnum.GetHashCode(); + if (SingleNestedEnum != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.Unspecified) hash ^= SingleNestedEnum.GetHashCode(); + if (SingleForeignEnum != global::Google.Protobuf.TestProtos.ForeignEnum.ForeignUnspecified) hash ^= SingleForeignEnum.GetHashCode(); + if (SingleImportEnum != global::Google.Protobuf.TestProtos.ImportEnum.Unspecified) hash ^= SingleImportEnum.GetHashCode(); if (singlePublicImportMessage_ != null) hash ^= SinglePublicImportMessage.GetHashCode(); hash ^= repeatedInt32_.GetHashCode(); hash ^= repeatedInt64_.GetHashCode(); @@ -923,13 +1002,18 @@ public override int GetHashCode() { if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) hash ^= OneofString.GetHashCode(); if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) hash ^= OneofBytes.GetHashCode(); hash ^= (int) oneofFieldCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (SingleInt32 != 0) { output.WriteRawTag(8); @@ -1003,15 +1087,15 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(162, 1); output.WriteMessage(SingleImportMessage); } - if (SingleNestedEnum != 0) { + if (SingleNestedEnum != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.Unspecified) { output.WriteRawTag(168, 1); output.WriteEnum((int) SingleNestedEnum); } - if (SingleForeignEnum != 0) { + if (SingleForeignEnum != global::Google.Protobuf.TestProtos.ForeignEnum.ForeignUnspecified) { output.WriteRawTag(176, 1); output.WriteEnum((int) SingleForeignEnum); } - if (SingleImportEnum != 0) { + if (SingleImportEnum != global::Google.Protobuf.TestProtos.ImportEnum.Unspecified) { output.WriteRawTag(184, 1); output.WriteEnum((int) SingleImportEnum); } @@ -1057,8 +1141,12 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(146, 7); output.WriteBytes(OneofBytes); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (SingleInt32 != 0) { @@ -1115,13 +1203,13 @@ public int CalculateSize() { if (singleImportMessage_ != null) { size += 2 + pb::CodedOutputStream.ComputeMessageSize(SingleImportMessage); } - if (SingleNestedEnum != 0) { + if (SingleNestedEnum != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.Unspecified) { size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) SingleNestedEnum); } - if (SingleForeignEnum != 0) { + if (SingleForeignEnum != global::Google.Protobuf.TestProtos.ForeignEnum.ForeignUnspecified) { size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) SingleForeignEnum); } - if (SingleImportEnum != 0) { + if (SingleImportEnum != global::Google.Protobuf.TestProtos.ImportEnum.Unspecified) { size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) SingleImportEnum); } if (singlePublicImportMessage_ != null) { @@ -1161,9 +1249,13 @@ public int CalculateSize() { if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { size += 2 + pb::CodedOutputStream.ComputeBytesSize(OneofBytes); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestAllTypes other) { if (other == null) { return; @@ -1215,34 +1307,34 @@ public void MergeFrom(TestAllTypes other) { } if (other.singleNestedMessage_ != null) { if (singleNestedMessage_ == null) { - singleNestedMessage_ = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage(); + SingleNestedMessage = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage(); } SingleNestedMessage.MergeFrom(other.SingleNestedMessage); } if (other.singleForeignMessage_ != null) { if (singleForeignMessage_ == null) { - singleForeignMessage_ = new global::Google.Protobuf.TestProtos.ForeignMessage(); + SingleForeignMessage = new global::Google.Protobuf.TestProtos.ForeignMessage(); } SingleForeignMessage.MergeFrom(other.SingleForeignMessage); } if (other.singleImportMessage_ != null) { if (singleImportMessage_ == null) { - singleImportMessage_ = new global::Google.Protobuf.TestProtos.ImportMessage(); + SingleImportMessage = new global::Google.Protobuf.TestProtos.ImportMessage(); } SingleImportMessage.MergeFrom(other.SingleImportMessage); } - if (other.SingleNestedEnum != 0) { + if (other.SingleNestedEnum != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.Unspecified) { SingleNestedEnum = other.SingleNestedEnum; } - if (other.SingleForeignEnum != 0) { + if (other.SingleForeignEnum != global::Google.Protobuf.TestProtos.ForeignEnum.ForeignUnspecified) { SingleForeignEnum = other.SingleForeignEnum; } - if (other.SingleImportEnum != 0) { + if (other.SingleImportEnum != global::Google.Protobuf.TestProtos.ImportEnum.Unspecified) { SingleImportEnum = other.SingleImportEnum; } if (other.singlePublicImportMessage_ != null) { if (singlePublicImportMessage_ == null) { - singlePublicImportMessage_ = new global::Google.Protobuf.TestProtos.PublicImportMessage(); + SinglePublicImportMessage = new global::Google.Protobuf.TestProtos.PublicImportMessage(); } SinglePublicImportMessage.MergeFrom(other.SinglePublicImportMessage); } @@ -1273,7 +1365,10 @@ public void MergeFrom(TestAllTypes other) { OneofUint32 = other.OneofUint32; break; case OneofFieldOneofCase.OneofNestedMessage: - OneofNestedMessage = other.OneofNestedMessage; + if (OneofNestedMessage == null) { + OneofNestedMessage = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage(); + } + OneofNestedMessage.MergeFrom(other.OneofNestedMessage); break; case OneofFieldOneofCase.OneofString: OneofString = other.OneofString; @@ -1283,14 +1378,16 @@ public void MergeFrom(TestAllTypes other) { break; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { SingleInt32 = input.ReadInt32(); @@ -1354,42 +1451,42 @@ public void MergeFrom(pb::CodedInputStream input) { } case 146: { if (singleNestedMessage_ == null) { - singleNestedMessage_ = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage(); + SingleNestedMessage = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage(); } - input.ReadMessage(singleNestedMessage_); + input.ReadMessage(SingleNestedMessage); break; } case 154: { if (singleForeignMessage_ == null) { - singleForeignMessage_ = new global::Google.Protobuf.TestProtos.ForeignMessage(); + SingleForeignMessage = new global::Google.Protobuf.TestProtos.ForeignMessage(); } - input.ReadMessage(singleForeignMessage_); + input.ReadMessage(SingleForeignMessage); break; } case 162: { if (singleImportMessage_ == null) { - singleImportMessage_ = new global::Google.Protobuf.TestProtos.ImportMessage(); + SingleImportMessage = new global::Google.Protobuf.TestProtos.ImportMessage(); } - input.ReadMessage(singleImportMessage_); + input.ReadMessage(SingleImportMessage); break; } case 168: { - singleNestedEnum_ = (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum) input.ReadEnum(); + SingleNestedEnum = (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum) input.ReadEnum(); break; } case 176: { - singleForeignEnum_ = (global::Google.Protobuf.TestProtos.ForeignEnum) input.ReadEnum(); + SingleForeignEnum = (global::Google.Protobuf.TestProtos.ForeignEnum) input.ReadEnum(); break; } case 184: { - singleImportEnum_ = (global::Google.Protobuf.TestProtos.ImportEnum) input.ReadEnum(); + SingleImportEnum = (global::Google.Protobuf.TestProtos.ImportEnum) input.ReadEnum(); break; } case 210: { if (singlePublicImportMessage_ == null) { - singlePublicImportMessage_ = new global::Google.Protobuf.TestProtos.PublicImportMessage(); + SinglePublicImportMessage = new global::Google.Protobuf.TestProtos.PublicImportMessage(); } - input.ReadMessage(singlePublicImportMessage_); + input.ReadMessage(SinglePublicImportMessage); break; } case 250: @@ -1523,7 +1620,7 @@ public void MergeFrom(pb::CodedInputStream input) { #region Nested types /// Container for nested types declared in the TestAllTypes message type. - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { public enum NestedEnum { [pbr::OriginalName("NESTED_ENUM_UNSPECIFIED")] Unspecified = 0, @@ -1531,34 +1628,41 @@ public enum NestedEnum { [pbr::OriginalName("BAR")] Bar = 2, [pbr::OriginalName("BAZ")] Baz = 3, /// - /// Intentionally negative. + /// Intentionally negative. /// [pbr::OriginalName("NEG")] Neg = -1, } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class NestedMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.TestAllTypes.Descriptor.NestedTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NestedMessage() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NestedMessage(NestedMessage other) : this() { bb_ = other.bb_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NestedMessage Clone() { return new NestedMessage(this); } @@ -1567,10 +1671,11 @@ public NestedMessage Clone() { public const int BbFieldNumber = 1; private int bb_; /// - /// The field name "b" fails to compile in proto1 because it conflicts with - /// a local variable named "b" in one of the generated methods. Doh. - /// This file needs to compile in proto1 to test backwards-compatibility. + /// The field name "b" fails to compile in proto1 because it conflicts with + /// a local variable named "b" in one of the generated methods. Doh. + /// This file needs to compile in proto1 to test backwards-compatibility. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Bb { get { return bb_; } set { @@ -1578,10 +1683,12 @@ public int Bb { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as NestedMessage); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(NestedMessage other) { if (ReferenceEquals(other, null)) { return false; @@ -1590,34 +1697,48 @@ public bool Equals(NestedMessage other) { return true; } if (Bb != other.Bb) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Bb != 0) hash ^= Bb.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Bb != 0) { output.WriteRawTag(8); output.WriteInt32(Bb); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Bb != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(Bb); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(NestedMessage other) { if (other == null) { return; @@ -1625,14 +1746,16 @@ public void MergeFrom(NestedMessage other) { if (other.Bb != 0) { Bb = other.Bb; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { Bb = input.ReadInt32(); @@ -1650,33 +1773,40 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// This proto includes a recusively nested message. + /// This proto includes a recusively nested message. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class NestedTestAllTypes : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedTestAllTypes()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NestedTestAllTypes() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NestedTestAllTypes(NestedTestAllTypes other) : this() { - Child = other.child_ != null ? other.Child.Clone() : null; - Payload = other.payload_ != null ? other.Payload.Clone() : null; + child_ = other.child_ != null ? other.child_.Clone() : null; + payload_ = other.payload_ != null ? other.payload_.Clone() : null; repeatedChild_ = other.repeatedChild_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NestedTestAllTypes Clone() { return new NestedTestAllTypes(this); } @@ -1684,6 +1814,7 @@ public NestedTestAllTypes Clone() { /// Field number for the "child" field. public const int ChildFieldNumber = 1; private global::Google.Protobuf.TestProtos.NestedTestAllTypes child_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.NestedTestAllTypes Child { get { return child_; } set { @@ -1694,6 +1825,7 @@ public NestedTestAllTypes Clone() { /// Field number for the "payload" field. public const int PayloadFieldNumber = 2; private global::Google.Protobuf.TestProtos.TestAllTypes payload_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.TestAllTypes Payload { get { return payload_; } set { @@ -1706,14 +1838,17 @@ public NestedTestAllTypes Clone() { private static readonly pb::FieldCodec _repeated_repeatedChild_codec = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.TestProtos.NestedTestAllTypes.Parser); private readonly pbc::RepeatedField repeatedChild_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedChild { get { return repeatedChild_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as NestedTestAllTypes); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(NestedTestAllTypes other) { if (ReferenceEquals(other, null)) { return false; @@ -1724,21 +1859,27 @@ public bool Equals(NestedTestAllTypes other) { if (!object.Equals(Child, other.Child)) return false; if (!object.Equals(Payload, other.Payload)) return false; if(!repeatedChild_.Equals(other.repeatedChild_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (child_ != null) hash ^= Child.GetHashCode(); if (payload_ != null) hash ^= Payload.GetHashCode(); hash ^= repeatedChild_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (child_ != null) { output.WriteRawTag(10); @@ -1749,8 +1890,12 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteMessage(Payload); } repeatedChild_.WriteTo(output, _repeated_repeatedChild_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (child_ != null) { @@ -1760,47 +1905,53 @@ public int CalculateSize() { size += 1 + pb::CodedOutputStream.ComputeMessageSize(Payload); } size += repeatedChild_.CalculateSize(_repeated_repeatedChild_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(NestedTestAllTypes other) { if (other == null) { return; } if (other.child_ != null) { if (child_ == null) { - child_ = new global::Google.Protobuf.TestProtos.NestedTestAllTypes(); + Child = new global::Google.Protobuf.TestProtos.NestedTestAllTypes(); } Child.MergeFrom(other.Child); } if (other.payload_ != null) { if (payload_ == null) { - payload_ = new global::Google.Protobuf.TestProtos.TestAllTypes(); + Payload = new global::Google.Protobuf.TestProtos.TestAllTypes(); } Payload.MergeFrom(other.Payload); } repeatedChild_.Add(other.repeatedChild_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { if (child_ == null) { - child_ = new global::Google.Protobuf.TestProtos.NestedTestAllTypes(); + Child = new global::Google.Protobuf.TestProtos.NestedTestAllTypes(); } - input.ReadMessage(child_); + input.ReadMessage(Child); break; } case 18: { if (payload_ == null) { - payload_ = new global::Google.Protobuf.TestProtos.TestAllTypes(); + Payload = new global::Google.Protobuf.TestProtos.TestAllTypes(); } - input.ReadMessage(payload_); + input.ReadMessage(Payload); break; } case 26: { @@ -1813,29 +1964,36 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestDeprecatedFields : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestDeprecatedFields()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[2]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestDeprecatedFields() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestDeprecatedFields(TestDeprecatedFields other) : this() { deprecatedInt32_ = other.deprecatedInt32_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestDeprecatedFields Clone() { return new TestDeprecatedFields(this); } @@ -1843,7 +2001,8 @@ public TestDeprecatedFields Clone() { /// Field number for the "deprecated_int32" field. public const int DeprecatedInt32FieldNumber = 1; private int deprecatedInt32_; - [global::System.ObsoleteAttribute()] + [global::System.ObsoleteAttribute] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int DeprecatedInt32 { get { return deprecatedInt32_; } set { @@ -1851,10 +2010,12 @@ public int DeprecatedInt32 { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestDeprecatedFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestDeprecatedFields other) { if (ReferenceEquals(other, null)) { return false; @@ -1863,34 +2024,48 @@ public bool Equals(TestDeprecatedFields other) { return true; } if (DeprecatedInt32 != other.DeprecatedInt32) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (DeprecatedInt32 != 0) hash ^= DeprecatedInt32.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (DeprecatedInt32 != 0) { output.WriteRawTag(8); output.WriteInt32(DeprecatedInt32); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (DeprecatedInt32 != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(DeprecatedInt32); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestDeprecatedFields other) { if (other == null) { return; @@ -1898,14 +2073,16 @@ public void MergeFrom(TestDeprecatedFields other) { if (other.DeprecatedInt32 != 0) { DeprecatedInt32 = other.DeprecatedInt32; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { DeprecatedInt32 = input.ReadInt32(); @@ -1918,32 +2095,39 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Define these after TestAllTypes to make sure the compiler can handle - /// that. + /// Define these after TestAllTypes to make sure the compiler can handle + /// that. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class ForeignMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ForeignMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[3]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ForeignMessage() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ForeignMessage(ForeignMessage other) : this() { c_ = other.c_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ForeignMessage Clone() { return new ForeignMessage(this); } @@ -1951,6 +2135,7 @@ public ForeignMessage Clone() { /// Field number for the "c" field. public const int CFieldNumber = 1; private int c_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int C { get { return c_; } set { @@ -1958,10 +2143,12 @@ public int C { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ForeignMessage); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(ForeignMessage other) { if (ReferenceEquals(other, null)) { return false; @@ -1970,34 +2157,48 @@ public bool Equals(ForeignMessage other) { return true; } if (C != other.C) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (C != 0) hash ^= C.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (C != 0) { output.WriteRawTag(8); output.WriteInt32(C); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (C != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(C); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(ForeignMessage other) { if (other == null) { return; @@ -2005,14 +2206,16 @@ public void MergeFrom(ForeignMessage other) { if (other.C != 0) { C = other.C; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { C = input.ReadInt32(); @@ -2024,36 +2227,45 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestReservedFields : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestReservedFields()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[4]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestReservedFields() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestReservedFields(TestReservedFields other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestReservedFields Clone() { return new TestReservedFields(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestReservedFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestReservedFields other) { if (ReferenceEquals(other, null)) { return false; @@ -2061,38 +2273,54 @@ public bool Equals(TestReservedFields other) { if (ReferenceEquals(other, this)) { return true; } - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestReservedFields other) { if (other == null) { return; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; } } @@ -2101,31 +2329,38 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Test that we can use NestedMessage from outside TestAllTypes. + /// Test that we can use NestedMessage from outside TestAllTypes. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestForeignNested : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestForeignNested()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[5]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestForeignNested() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestForeignNested(TestForeignNested other) : this() { - ForeignNested = other.foreignNested_ != null ? other.ForeignNested.Clone() : null; + foreignNested_ = other.foreignNested_ != null ? other.foreignNested_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestForeignNested Clone() { return new TestForeignNested(this); } @@ -2133,6 +2368,7 @@ public TestForeignNested Clone() { /// Field number for the "foreign_nested" field. public const int ForeignNestedFieldNumber = 1; private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage foreignNested_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage ForeignNested { get { return foreignNested_; } set { @@ -2140,10 +2376,12 @@ public TestForeignNested Clone() { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestForeignNested); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestForeignNested other) { if (ReferenceEquals(other, null)) { return false; @@ -2152,58 +2390,74 @@ public bool Equals(TestForeignNested other) { return true; } if (!object.Equals(ForeignNested, other.ForeignNested)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (foreignNested_ != null) hash ^= ForeignNested.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (foreignNested_ != null) { output.WriteRawTag(10); output.WriteMessage(ForeignNested); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (foreignNested_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(ForeignNested); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestForeignNested other) { if (other == null) { return; } if (other.foreignNested_ != null) { if (foreignNested_ == null) { - foreignNested_ = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage(); + ForeignNested = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage(); } ForeignNested.MergeFrom(other.ForeignNested); } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { if (foreignNested_ == null) { - foreignNested_ = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage(); + ForeignNested = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage(); } - input.ReadMessage(foreignNested_); + input.ReadMessage(ForeignNested); break; } } @@ -2213,32 +2467,39 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Test that really large tag numbers don't break anything. + /// Test that really large tag numbers don't break anything. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestReallyLargeTagNumber : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestReallyLargeTagNumber()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[6]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestReallyLargeTagNumber() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestReallyLargeTagNumber(TestReallyLargeTagNumber other) : this() { a_ = other.a_; bb_ = other.bb_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestReallyLargeTagNumber Clone() { return new TestReallyLargeTagNumber(this); } @@ -2247,9 +2508,10 @@ public TestReallyLargeTagNumber Clone() { public const int AFieldNumber = 1; private int a_; /// - /// The largest possible tag number is 2^28 - 1, since the wire format uses - /// three bits to communicate wire type. + /// The largest possible tag number is 2^28 - 1, since the wire format uses + /// three bits to communicate wire type. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int A { get { return a_; } set { @@ -2260,6 +2522,7 @@ public int A { /// Field number for the "bb" field. public const int BbFieldNumber = 268435455; private int bb_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Bb { get { return bb_; } set { @@ -2267,10 +2530,12 @@ public int Bb { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestReallyLargeTagNumber); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestReallyLargeTagNumber other) { if (ReferenceEquals(other, null)) { return false; @@ -2280,20 +2545,26 @@ public bool Equals(TestReallyLargeTagNumber other) { } if (A != other.A) return false; if (Bb != other.Bb) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (A != 0) hash ^= A.GetHashCode(); if (Bb != 0) hash ^= Bb.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (A != 0) { output.WriteRawTag(8); @@ -2303,8 +2574,12 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(248, 255, 255, 255, 7); output.WriteInt32(Bb); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (A != 0) { @@ -2313,9 +2588,13 @@ public int CalculateSize() { if (Bb != 0) { size += 5 + pb::CodedOutputStream.ComputeInt32Size(Bb); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestReallyLargeTagNumber other) { if (other == null) { return; @@ -2326,14 +2605,16 @@ public void MergeFrom(TestReallyLargeTagNumber other) { if (other.Bb != 0) { Bb = other.Bb; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { A = input.ReadInt32(); @@ -2349,30 +2630,37 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestRecursiveMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRecursiveMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[7]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestRecursiveMessage() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestRecursiveMessage(TestRecursiveMessage other) : this() { - A = other.a_ != null ? other.A.Clone() : null; + a_ = other.a_ != null ? other.a_.Clone() : null; i_ = other.i_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestRecursiveMessage Clone() { return new TestRecursiveMessage(this); } @@ -2380,6 +2668,7 @@ public TestRecursiveMessage Clone() { /// Field number for the "a" field. public const int AFieldNumber = 1; private global::Google.Protobuf.TestProtos.TestRecursiveMessage a_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.TestRecursiveMessage A { get { return a_; } set { @@ -2390,6 +2679,7 @@ public TestRecursiveMessage Clone() { /// Field number for the "i" field. public const int IFieldNumber = 2; private int i_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int I { get { return i_; } set { @@ -2397,10 +2687,12 @@ public int I { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestRecursiveMessage); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestRecursiveMessage other) { if (ReferenceEquals(other, null)) { return false; @@ -2410,20 +2702,26 @@ public bool Equals(TestRecursiveMessage other) { } if (!object.Equals(A, other.A)) return false; if (I != other.I) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (a_ != null) hash ^= A.GetHashCode(); if (I != 0) hash ^= I.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (a_ != null) { output.WriteRawTag(10); @@ -2433,8 +2731,12 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(16); output.WriteInt32(I); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (a_ != null) { @@ -2443,36 +2745,42 @@ public int CalculateSize() { if (I != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(I); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestRecursiveMessage other) { if (other == null) { return; } if (other.a_ != null) { if (a_ == null) { - a_ = new global::Google.Protobuf.TestProtos.TestRecursiveMessage(); + A = new global::Google.Protobuf.TestProtos.TestRecursiveMessage(); } A.MergeFrom(other.A); } if (other.I != 0) { I = other.I; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { if (a_ == null) { - a_ = new global::Google.Protobuf.TestProtos.TestRecursiveMessage(); + A = new global::Google.Protobuf.TestProtos.TestRecursiveMessage(); } - input.ReadMessage(a_); + input.ReadMessage(A); break; } case 16: { @@ -2486,31 +2794,38 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Test that mutual recursion works. + /// Test that mutual recursion works. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestMutualRecursionA : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMutualRecursionA()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[8]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMutualRecursionA() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMutualRecursionA(TestMutualRecursionA other) : this() { - Bb = other.bb_ != null ? other.Bb.Clone() : null; + bb_ = other.bb_ != null ? other.bb_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMutualRecursionA Clone() { return new TestMutualRecursionA(this); } @@ -2518,6 +2833,7 @@ public TestMutualRecursionA Clone() { /// Field number for the "bb" field. public const int BbFieldNumber = 1; private global::Google.Protobuf.TestProtos.TestMutualRecursionB bb_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.TestMutualRecursionB Bb { get { return bb_; } set { @@ -2525,10 +2841,12 @@ public TestMutualRecursionA Clone() { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestMutualRecursionA); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestMutualRecursionA other) { if (ReferenceEquals(other, null)) { return false; @@ -2537,58 +2855,74 @@ public bool Equals(TestMutualRecursionA other) { return true; } if (!object.Equals(Bb, other.Bb)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (bb_ != null) hash ^= Bb.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (bb_ != null) { output.WriteRawTag(10); output.WriteMessage(Bb); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (bb_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(Bb); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestMutualRecursionA other) { if (other == null) { return; } if (other.bb_ != null) { if (bb_ == null) { - bb_ = new global::Google.Protobuf.TestProtos.TestMutualRecursionB(); + Bb = new global::Google.Protobuf.TestProtos.TestMutualRecursionB(); } Bb.MergeFrom(other.Bb); } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { if (bb_ == null) { - bb_ = new global::Google.Protobuf.TestProtos.TestMutualRecursionB(); + Bb = new global::Google.Protobuf.TestProtos.TestMutualRecursionB(); } - input.ReadMessage(bb_); + input.ReadMessage(Bb); break; } } @@ -2597,30 +2931,37 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestMutualRecursionB : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMutualRecursionB()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[9]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMutualRecursionB() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMutualRecursionB(TestMutualRecursionB other) : this() { - A = other.a_ != null ? other.A.Clone() : null; + a_ = other.a_ != null ? other.a_.Clone() : null; optionalInt32_ = other.optionalInt32_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMutualRecursionB Clone() { return new TestMutualRecursionB(this); } @@ -2628,6 +2969,7 @@ public TestMutualRecursionB Clone() { /// Field number for the "a" field. public const int AFieldNumber = 1; private global::Google.Protobuf.TestProtos.TestMutualRecursionA a_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.TestMutualRecursionA A { get { return a_; } set { @@ -2638,6 +2980,7 @@ public TestMutualRecursionB Clone() { /// Field number for the "optional_int32" field. public const int OptionalInt32FieldNumber = 2; private int optionalInt32_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int OptionalInt32 { get { return optionalInt32_; } set { @@ -2645,10 +2988,12 @@ public int OptionalInt32 { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestMutualRecursionB); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestMutualRecursionB other) { if (ReferenceEquals(other, null)) { return false; @@ -2658,20 +3003,26 @@ public bool Equals(TestMutualRecursionB other) { } if (!object.Equals(A, other.A)) return false; if (OptionalInt32 != other.OptionalInt32) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (a_ != null) hash ^= A.GetHashCode(); if (OptionalInt32 != 0) hash ^= OptionalInt32.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (a_ != null) { output.WriteRawTag(10); @@ -2681,8 +3032,12 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(16); output.WriteInt32(OptionalInt32); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (a_ != null) { @@ -2691,36 +3046,42 @@ public int CalculateSize() { if (OptionalInt32 != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(OptionalInt32); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestMutualRecursionB other) { if (other == null) { return; } if (other.a_ != null) { if (a_ == null) { - a_ = new global::Google.Protobuf.TestProtos.TestMutualRecursionA(); + A = new global::Google.Protobuf.TestProtos.TestMutualRecursionA(); } A.MergeFrom(other.A); } if (other.OptionalInt32 != 0) { OptionalInt32 = other.OptionalInt32; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { if (a_ == null) { - a_ = new global::Google.Protobuf.TestProtos.TestMutualRecursionA(); + A = new global::Google.Protobuf.TestProtos.TestMutualRecursionA(); } - input.ReadMessage(a_); + input.ReadMessage(A); break; } case 16: { @@ -2733,40 +3094,176 @@ public void MergeFrom(pb::CodedInputStream input) { } + public sealed partial class TestEnumAllowAlias : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestEnumAllowAlias()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[10]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TestEnumAllowAlias() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TestEnumAllowAlias(TestEnumAllowAlias other) : this() { + value_ = other.value_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TestEnumAllowAlias Clone() { + return new TestEnumAllowAlias(this); + } + + /// Field number for the "value" field. + public const int ValueFieldNumber = 1; + private global::Google.Protobuf.TestProtos.TestEnumWithDupValue value_ = global::Google.Protobuf.TestProtos.TestEnumWithDupValue.Unspecified; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.TestProtos.TestEnumWithDupValue Value { + get { return value_; } + set { + value_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as TestEnumAllowAlias); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(TestEnumAllowAlias other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Value != other.Value) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Value != global::Google.Protobuf.TestProtos.TestEnumWithDupValue.Unspecified) hash ^= Value.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Value != global::Google.Protobuf.TestProtos.TestEnumWithDupValue.Unspecified) { + output.WriteRawTag(8); + output.WriteEnum((int) Value); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Value != global::Google.Protobuf.TestProtos.TestEnumWithDupValue.Unspecified) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Value); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(TestEnumAllowAlias other) { + if (other == null) { + return; + } + if (other.Value != global::Google.Protobuf.TestProtos.TestEnumWithDupValue.Unspecified) { + Value = other.Value; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + Value = (global::Google.Protobuf.TestProtos.TestEnumWithDupValue) input.ReadEnum(); + break; + } + } + } + } + + } + /// - /// Test message with CamelCase field names. This violates Protocol Buffer - /// standard style. + /// Test message with CamelCase field names. This violates Protocol Buffer + /// standard style. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestCamelCaseFieldNames : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestCamelCaseFieldNames()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[10]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[11]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestCamelCaseFieldNames() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestCamelCaseFieldNames(TestCamelCaseFieldNames other) : this() { primitiveField_ = other.primitiveField_; stringField_ = other.stringField_; enumField_ = other.enumField_; - MessageField = other.messageField_ != null ? other.MessageField.Clone() : null; + messageField_ = other.messageField_ != null ? other.messageField_.Clone() : null; repeatedPrimitiveField_ = other.repeatedPrimitiveField_.Clone(); repeatedStringField_ = other.repeatedStringField_.Clone(); repeatedEnumField_ = other.repeatedEnumField_.Clone(); repeatedMessageField_ = other.repeatedMessageField_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestCamelCaseFieldNames Clone() { return new TestCamelCaseFieldNames(this); } @@ -2774,6 +3271,7 @@ public TestCamelCaseFieldNames Clone() { /// Field number for the "PrimitiveField" field. public const int PrimitiveFieldFieldNumber = 1; private int primitiveField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int PrimitiveField { get { return primitiveField_; } set { @@ -2784,6 +3282,7 @@ public int PrimitiveField { /// Field number for the "StringField" field. public const int StringFieldFieldNumber = 2; private string stringField_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string StringField { get { return stringField_; } set { @@ -2793,7 +3292,8 @@ public string StringField { /// Field number for the "EnumField" field. public const int EnumFieldFieldNumber = 3; - private global::Google.Protobuf.TestProtos.ForeignEnum enumField_ = 0; + private global::Google.Protobuf.TestProtos.ForeignEnum enumField_ = global::Google.Protobuf.TestProtos.ForeignEnum.ForeignUnspecified; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.ForeignEnum EnumField { get { return enumField_; } set { @@ -2804,6 +3304,7 @@ public string StringField { /// Field number for the "MessageField" field. public const int MessageFieldFieldNumber = 4; private global::Google.Protobuf.TestProtos.ForeignMessage messageField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.ForeignMessage MessageField { get { return messageField_; } set { @@ -2816,6 +3317,7 @@ public string StringField { private static readonly pb::FieldCodec _repeated_repeatedPrimitiveField_codec = pb::FieldCodec.ForInt32(58); private readonly pbc::RepeatedField repeatedPrimitiveField_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedPrimitiveField { get { return repeatedPrimitiveField_; } } @@ -2825,6 +3327,7 @@ public string StringField { private static readonly pb::FieldCodec _repeated_repeatedStringField_codec = pb::FieldCodec.ForString(66); private readonly pbc::RepeatedField repeatedStringField_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedStringField { get { return repeatedStringField_; } } @@ -2834,6 +3337,7 @@ public string StringField { private static readonly pb::FieldCodec _repeated_repeatedEnumField_codec = pb::FieldCodec.ForEnum(74, x => (int) x, x => (global::Google.Protobuf.TestProtos.ForeignEnum) x); private readonly pbc::RepeatedField repeatedEnumField_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedEnumField { get { return repeatedEnumField_; } } @@ -2843,14 +3347,17 @@ public string StringField { private static readonly pb::FieldCodec _repeated_repeatedMessageField_codec = pb::FieldCodec.ForMessage(82, global::Google.Protobuf.TestProtos.ForeignMessage.Parser); private readonly pbc::RepeatedField repeatedMessageField_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedMessageField { get { return repeatedMessageField_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestCamelCaseFieldNames); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestCamelCaseFieldNames other) { if (ReferenceEquals(other, null)) { return false; @@ -2866,26 +3373,32 @@ public bool Equals(TestCamelCaseFieldNames other) { if(!repeatedStringField_.Equals(other.repeatedStringField_)) return false; if(!repeatedEnumField_.Equals(other.repeatedEnumField_)) return false; if(!repeatedMessageField_.Equals(other.repeatedMessageField_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (PrimitiveField != 0) hash ^= PrimitiveField.GetHashCode(); if (StringField.Length != 0) hash ^= StringField.GetHashCode(); - if (EnumField != 0) hash ^= EnumField.GetHashCode(); + if (EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.ForeignUnspecified) hash ^= EnumField.GetHashCode(); if (messageField_ != null) hash ^= MessageField.GetHashCode(); hash ^= repeatedPrimitiveField_.GetHashCode(); hash ^= repeatedStringField_.GetHashCode(); hash ^= repeatedEnumField_.GetHashCode(); hash ^= repeatedMessageField_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (PrimitiveField != 0) { output.WriteRawTag(8); @@ -2895,7 +3408,7 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(18); output.WriteString(StringField); } - if (EnumField != 0) { + if (EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.ForeignUnspecified) { output.WriteRawTag(24); output.WriteEnum((int) EnumField); } @@ -2907,8 +3420,12 @@ public void WriteTo(pb::CodedOutputStream output) { repeatedStringField_.WriteTo(output, _repeated_repeatedStringField_codec); repeatedEnumField_.WriteTo(output, _repeated_repeatedEnumField_codec); repeatedMessageField_.WriteTo(output, _repeated_repeatedMessageField_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (PrimitiveField != 0) { @@ -2917,7 +3434,7 @@ public int CalculateSize() { if (StringField.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(StringField); } - if (EnumField != 0) { + if (EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.ForeignUnspecified) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) EnumField); } if (messageField_ != null) { @@ -2927,9 +3444,13 @@ public int CalculateSize() { size += repeatedStringField_.CalculateSize(_repeated_repeatedStringField_codec); size += repeatedEnumField_.CalculateSize(_repeated_repeatedEnumField_codec); size += repeatedMessageField_.CalculateSize(_repeated_repeatedMessageField_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestCamelCaseFieldNames other) { if (other == null) { return; @@ -2940,12 +3461,12 @@ public void MergeFrom(TestCamelCaseFieldNames other) { if (other.StringField.Length != 0) { StringField = other.StringField; } - if (other.EnumField != 0) { + if (other.EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.ForeignUnspecified) { EnumField = other.EnumField; } if (other.messageField_ != null) { if (messageField_ == null) { - messageField_ = new global::Google.Protobuf.TestProtos.ForeignMessage(); + MessageField = new global::Google.Protobuf.TestProtos.ForeignMessage(); } MessageField.MergeFrom(other.MessageField); } @@ -2953,14 +3474,16 @@ public void MergeFrom(TestCamelCaseFieldNames other) { repeatedStringField_.Add(other.repeatedStringField_); repeatedEnumField_.Add(other.repeatedEnumField_); repeatedMessageField_.Add(other.repeatedMessageField_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { PrimitiveField = input.ReadInt32(); @@ -2971,14 +3494,14 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 24: { - enumField_ = (global::Google.Protobuf.TestProtos.ForeignEnum) input.ReadEnum(); + EnumField = (global::Google.Protobuf.TestProtos.ForeignEnum) input.ReadEnum(); break; } case 34: { if (messageField_ == null) { - messageField_ = new global::Google.Protobuf.TestProtos.ForeignMessage(); + MessageField = new global::Google.Protobuf.TestProtos.ForeignMessage(); } - input.ReadMessage(messageField_); + input.ReadMessage(MessageField); break; } case 58: @@ -3006,35 +3529,42 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// We list fields out of order, to ensure that we're using field number and not - /// field index to determine serialization order. + /// We list fields out of order, to ensure that we're using field number and not + /// field index to determine serialization order. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestFieldOrderings : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestFieldOrderings()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[11]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[12]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestFieldOrderings() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestFieldOrderings(TestFieldOrderings other) : this() { myString_ = other.myString_; myInt_ = other.myInt_; myFloat_ = other.myFloat_; - SingleNestedMessage = other.singleNestedMessage_ != null ? other.SingleNestedMessage.Clone() : null; + singleNestedMessage_ = other.singleNestedMessage_ != null ? other.singleNestedMessage_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestFieldOrderings Clone() { return new TestFieldOrderings(this); } @@ -3042,6 +3572,7 @@ public TestFieldOrderings Clone() { /// Field number for the "my_string" field. public const int MyStringFieldNumber = 11; private string myString_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string MyString { get { return myString_; } set { @@ -3052,6 +3583,7 @@ public string MyString { /// Field number for the "my_int" field. public const int MyIntFieldNumber = 1; private long myInt_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public long MyInt { get { return myInt_; } set { @@ -3062,6 +3594,7 @@ public long MyInt { /// Field number for the "my_float" field. public const int MyFloatFieldNumber = 101; private float myFloat_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public float MyFloat { get { return myFloat_; } set { @@ -3072,6 +3605,7 @@ public float MyFloat { /// Field number for the "single_nested_message" field. public const int SingleNestedMessageFieldNumber = 200; private global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage singleNestedMessage_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage SingleNestedMessage { get { return singleNestedMessage_; } set { @@ -3079,10 +3613,12 @@ public float MyFloat { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestFieldOrderings); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestFieldOrderings other) { if (ReferenceEquals(other, null)) { return false; @@ -3092,24 +3628,30 @@ public bool Equals(TestFieldOrderings other) { } if (MyString != other.MyString) return false; if (MyInt != other.MyInt) return false; - if (MyFloat != other.MyFloat) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(MyFloat, other.MyFloat)) return false; if (!object.Equals(SingleNestedMessage, other.SingleNestedMessage)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (MyString.Length != 0) hash ^= MyString.GetHashCode(); if (MyInt != 0L) hash ^= MyInt.GetHashCode(); - if (MyFloat != 0F) hash ^= MyFloat.GetHashCode(); + if (MyFloat != 0F) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(MyFloat); if (singleNestedMessage_ != null) hash ^= SingleNestedMessage.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (MyInt != 0L) { output.WriteRawTag(8); @@ -3127,8 +3669,12 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(194, 12); output.WriteMessage(SingleNestedMessage); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (MyString.Length != 0) { @@ -3143,9 +3689,13 @@ public int CalculateSize() { if (singleNestedMessage_ != null) { size += 2 + pb::CodedOutputStream.ComputeMessageSize(SingleNestedMessage); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestFieldOrderings other) { if (other == null) { return; @@ -3161,18 +3711,20 @@ public void MergeFrom(TestFieldOrderings other) { } if (other.singleNestedMessage_ != null) { if (singleNestedMessage_ == null) { - singleNestedMessage_ = new global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage(); + SingleNestedMessage = new global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage(); } SingleNestedMessage.MergeFrom(other.SingleNestedMessage); } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { MyInt = input.ReadInt64(); @@ -3188,9 +3740,9 @@ public void MergeFrom(pb::CodedInputStream input) { } case 1602: { if (singleNestedMessage_ == null) { - singleNestedMessage_ = new global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage(); + SingleNestedMessage = new global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage(); } - input.ReadMessage(singleNestedMessage_); + input.ReadMessage(SingleNestedMessage); break; } } @@ -3199,32 +3751,39 @@ public void MergeFrom(pb::CodedInputStream input) { #region Nested types /// Container for nested types declared in the TestFieldOrderings message type. - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class NestedMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.TestFieldOrderings.Descriptor.NestedTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NestedMessage() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NestedMessage(NestedMessage other) : this() { oo_ = other.oo_; bb_ = other.bb_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NestedMessage Clone() { return new NestedMessage(this); } @@ -3232,6 +3791,7 @@ public NestedMessage Clone() { /// Field number for the "oo" field. public const int OoFieldNumber = 2; private long oo_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public long Oo { get { return oo_; } set { @@ -3243,10 +3803,11 @@ public long Oo { public const int BbFieldNumber = 1; private int bb_; /// - /// The field name "b" fails to compile in proto1 because it conflicts with - /// a local variable named "b" in one of the generated methods. Doh. - /// This file needs to compile in proto1 to test backwards-compatibility. + /// The field name "b" fails to compile in proto1 because it conflicts with + /// a local variable named "b" in one of the generated methods. Doh. + /// This file needs to compile in proto1 to test backwards-compatibility. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Bb { get { return bb_; } set { @@ -3254,10 +3815,12 @@ public int Bb { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as NestedMessage); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(NestedMessage other) { if (ReferenceEquals(other, null)) { return false; @@ -3267,20 +3830,26 @@ public bool Equals(NestedMessage other) { } if (Oo != other.Oo) return false; if (Bb != other.Bb) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Oo != 0L) hash ^= Oo.GetHashCode(); if (Bb != 0) hash ^= Bb.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Bb != 0) { output.WriteRawTag(8); @@ -3290,8 +3859,12 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(16); output.WriteInt64(Oo); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Oo != 0L) { @@ -3300,9 +3873,13 @@ public int CalculateSize() { if (Bb != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(Bb); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(NestedMessage other) { if (other == null) { return; @@ -3313,14 +3890,16 @@ public void MergeFrom(NestedMessage other) { if (other.Bb != 0) { Bb = other.Bb; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { Bb = input.ReadInt32(); @@ -3341,36 +3920,44 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class SparseEnumMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SparseEnumMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[12]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[13]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public SparseEnumMessage() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public SparseEnumMessage(SparseEnumMessage other) : this() { sparseEnum_ = other.sparseEnum_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public SparseEnumMessage Clone() { return new SparseEnumMessage(this); } /// Field number for the "sparse_enum" field. public const int SparseEnumFieldNumber = 1; - private global::Google.Protobuf.TestProtos.TestSparseEnum sparseEnum_ = 0; + private global::Google.Protobuf.TestProtos.TestSparseEnum sparseEnum_ = global::Google.Protobuf.TestProtos.TestSparseEnum.Unspecified; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.TestSparseEnum SparseEnum { get { return sparseEnum_; } set { @@ -3378,10 +3965,12 @@ public SparseEnumMessage Clone() { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as SparseEnumMessage); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(SparseEnumMessage other) { if (ReferenceEquals(other, null)) { return false; @@ -3390,52 +3979,68 @@ public bool Equals(SparseEnumMessage other) { return true; } if (SparseEnum != other.SparseEnum) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (SparseEnum != 0) hash ^= SparseEnum.GetHashCode(); + if (SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.Unspecified) hash ^= SparseEnum.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (SparseEnum != 0) { + if (SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.Unspecified) { output.WriteRawTag(8); output.WriteEnum((int) SparseEnum); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (SparseEnum != 0) { + if (SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.Unspecified) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) SparseEnum); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(SparseEnumMessage other) { if (other == null) { return; } - if (other.SparseEnum != 0) { + if (other.SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.Unspecified) { SparseEnum = other.SparseEnum; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { - sparseEnum_ = (global::Google.Protobuf.TestProtos.TestSparseEnum) input.ReadEnum(); + SparseEnum = (global::Google.Protobuf.TestProtos.TestSparseEnum) input.ReadEnum(); break; } } @@ -3445,31 +4050,38 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Test String and Bytes: string is for valid UTF-8 strings + /// Test String and Bytes: string is for valid UTF-8 strings /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class OneString : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneString()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[13]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[14]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public OneString() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public OneString(OneString other) : this() { data_ = other.data_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public OneString Clone() { return new OneString(this); } @@ -3477,6 +4089,7 @@ public OneString Clone() { /// Field number for the "data" field. public const int DataFieldNumber = 1; private string data_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Data { get { return data_; } set { @@ -3484,10 +4097,12 @@ public string Data { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as OneString); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(OneString other) { if (ReferenceEquals(other, null)) { return false; @@ -3496,34 +4111,48 @@ public bool Equals(OneString other) { return true; } if (Data != other.Data) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Data.Length != 0) hash ^= Data.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Data.Length != 0) { output.WriteRawTag(10); output.WriteString(Data); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Data.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Data); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(OneString other) { if (other == null) { return; @@ -3531,14 +4160,16 @@ public void MergeFrom(OneString other) { if (other.Data.Length != 0) { Data = other.Data; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Data = input.ReadString(); @@ -3550,29 +4181,36 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class MoreString : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MoreString()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[14]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[15]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MoreString() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MoreString(MoreString other) : this() { data_ = other.data_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MoreString Clone() { return new MoreString(this); } @@ -3582,14 +4220,17 @@ public MoreString Clone() { private static readonly pb::FieldCodec _repeated_data_codec = pb::FieldCodec.ForString(10); private readonly pbc::RepeatedField data_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Data { get { return data_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as MoreString); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(MoreString other) { if (ReferenceEquals(other, null)) { return false; @@ -3598,42 +4239,58 @@ public bool Equals(MoreString other) { return true; } if(!data_.Equals(other.data_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= data_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { data_.WriteTo(output, _repeated_data_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += data_.CalculateSize(_repeated_data_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(MoreString other) { if (other == null) { return; } data_.Add(other.data_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { data_.AddEntriesFrom(input, _repeated_data_codec); @@ -3645,29 +4302,36 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class OneBytes : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneBytes()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[15]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[16]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public OneBytes() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public OneBytes(OneBytes other) : this() { data_ = other.data_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public OneBytes Clone() { return new OneBytes(this); } @@ -3675,6 +4339,7 @@ public OneBytes Clone() { /// Field number for the "data" field. public const int DataFieldNumber = 1; private pb::ByteString data_ = pb::ByteString.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pb::ByteString Data { get { return data_; } set { @@ -3682,10 +4347,12 @@ public OneBytes Clone() { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as OneBytes); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(OneBytes other) { if (ReferenceEquals(other, null)) { return false; @@ -3694,34 +4361,48 @@ public bool Equals(OneBytes other) { return true; } if (Data != other.Data) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Data.Length != 0) hash ^= Data.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Data.Length != 0) { output.WriteRawTag(10); output.WriteBytes(Data); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Data.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeBytesSize(Data); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(OneBytes other) { if (other == null) { return; @@ -3729,14 +4410,16 @@ public void MergeFrom(OneBytes other) { if (other.Data.Length != 0) { Data = other.Data; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Data = input.ReadBytes(); @@ -3748,29 +4431,36 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class MoreBytes : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MoreBytes()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[16]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[17]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MoreBytes() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MoreBytes(MoreBytes other) : this() { data_ = other.data_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MoreBytes Clone() { return new MoreBytes(this); } @@ -3778,6 +4468,7 @@ public MoreBytes Clone() { /// Field number for the "data" field. public const int DataFieldNumber = 1; private pb::ByteString data_ = pb::ByteString.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pb::ByteString Data { get { return data_; } set { @@ -3785,10 +4476,12 @@ public MoreBytes Clone() { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as MoreBytes); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(MoreBytes other) { if (ReferenceEquals(other, null)) { return false; @@ -3797,34 +4490,48 @@ public bool Equals(MoreBytes other) { return true; } if (Data != other.Data) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Data.Length != 0) hash ^= Data.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Data.Length != 0) { output.WriteRawTag(10); output.WriteBytes(Data); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Data.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeBytesSize(Data); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(MoreBytes other) { if (other == null) { return; @@ -3832,14 +4539,16 @@ public void MergeFrom(MoreBytes other) { if (other.Data.Length != 0) { Data = other.Data; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Data = input.ReadBytes(); @@ -3852,31 +4561,38 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Test int32, uint32, int64, uint64, and bool are all compatible + /// Test int32, uint32, int64, uint64, and bool are all compatible /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Int32Message : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Int32Message()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[17]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[18]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Int32Message() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Int32Message(Int32Message other) : this() { data_ = other.data_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Int32Message Clone() { return new Int32Message(this); } @@ -3884,6 +4600,7 @@ public Int32Message Clone() { /// Field number for the "data" field. public const int DataFieldNumber = 1; private int data_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Data { get { return data_; } set { @@ -3891,10 +4608,12 @@ public int Data { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Int32Message); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Int32Message other) { if (ReferenceEquals(other, null)) { return false; @@ -3903,34 +4622,48 @@ public bool Equals(Int32Message other) { return true; } if (Data != other.Data) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Data != 0) hash ^= Data.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Data != 0) { output.WriteRawTag(8); output.WriteInt32(Data); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Data != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(Data); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Int32Message other) { if (other == null) { return; @@ -3938,14 +4671,16 @@ public void MergeFrom(Int32Message other) { if (other.Data != 0) { Data = other.Data; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { Data = input.ReadInt32(); @@ -3957,29 +4692,36 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Uint32Message : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Uint32Message()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[18]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[19]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Uint32Message() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Uint32Message(Uint32Message other) : this() { data_ = other.data_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Uint32Message Clone() { return new Uint32Message(this); } @@ -3987,6 +4729,7 @@ public Uint32Message Clone() { /// Field number for the "data" field. public const int DataFieldNumber = 1; private uint data_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public uint Data { get { return data_; } set { @@ -3994,10 +4737,12 @@ public uint Data { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Uint32Message); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Uint32Message other) { if (ReferenceEquals(other, null)) { return false; @@ -4006,34 +4751,48 @@ public bool Equals(Uint32Message other) { return true; } if (Data != other.Data) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Data != 0) hash ^= Data.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Data != 0) { output.WriteRawTag(8); output.WriteUInt32(Data); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Data != 0) { size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Data); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Uint32Message other) { if (other == null) { return; @@ -4041,14 +4800,16 @@ public void MergeFrom(Uint32Message other) { if (other.Data != 0) { Data = other.Data; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { Data = input.ReadUInt32(); @@ -4060,29 +4821,36 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Int64Message : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Int64Message()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[19]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[20]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Int64Message() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Int64Message(Int64Message other) : this() { data_ = other.data_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Int64Message Clone() { return new Int64Message(this); } @@ -4090,6 +4858,7 @@ public Int64Message Clone() { /// Field number for the "data" field. public const int DataFieldNumber = 1; private long data_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public long Data { get { return data_; } set { @@ -4097,10 +4866,12 @@ public long Data { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Int64Message); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Int64Message other) { if (ReferenceEquals(other, null)) { return false; @@ -4109,34 +4880,48 @@ public bool Equals(Int64Message other) { return true; } if (Data != other.Data) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Data != 0L) hash ^= Data.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Data != 0L) { output.WriteRawTag(8); output.WriteInt64(Data); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Data != 0L) { size += 1 + pb::CodedOutputStream.ComputeInt64Size(Data); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Int64Message other) { if (other == null) { return; @@ -4144,14 +4929,16 @@ public void MergeFrom(Int64Message other) { if (other.Data != 0L) { Data = other.Data; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { Data = input.ReadInt64(); @@ -4163,29 +4950,36 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Uint64Message : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Uint64Message()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[20]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[21]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Uint64Message() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Uint64Message(Uint64Message other) : this() { data_ = other.data_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Uint64Message Clone() { return new Uint64Message(this); } @@ -4193,6 +4987,7 @@ public Uint64Message Clone() { /// Field number for the "data" field. public const int DataFieldNumber = 1; private ulong data_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ulong Data { get { return data_; } set { @@ -4200,10 +4995,12 @@ public ulong Data { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Uint64Message); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Uint64Message other) { if (ReferenceEquals(other, null)) { return false; @@ -4212,34 +5009,48 @@ public bool Equals(Uint64Message other) { return true; } if (Data != other.Data) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Data != 0UL) hash ^= Data.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Data != 0UL) { output.WriteRawTag(8); output.WriteUInt64(Data); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Data != 0UL) { size += 1 + pb::CodedOutputStream.ComputeUInt64Size(Data); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Uint64Message other) { if (other == null) { return; @@ -4247,14 +5058,16 @@ public void MergeFrom(Uint64Message other) { if (other.Data != 0UL) { Data = other.Data; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { Data = input.ReadUInt64(); @@ -4266,29 +5079,36 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class BoolMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BoolMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[21]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[22]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public BoolMessage() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public BoolMessage(BoolMessage other) : this() { data_ = other.data_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public BoolMessage Clone() { return new BoolMessage(this); } @@ -4296,6 +5116,7 @@ public BoolMessage Clone() { /// Field number for the "data" field. public const int DataFieldNumber = 1; private bool data_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Data { get { return data_; } set { @@ -4303,10 +5124,12 @@ public bool Data { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as BoolMessage); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(BoolMessage other) { if (ReferenceEquals(other, null)) { return false; @@ -4315,34 +5138,48 @@ public bool Equals(BoolMessage other) { return true; } if (Data != other.Data) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Data != false) hash ^= Data.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Data != false) { output.WriteRawTag(8); output.WriteBool(Data); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Data != false) { size += 1 + 1; } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(BoolMessage other) { if (other == null) { return; @@ -4350,14 +5187,16 @@ public void MergeFrom(BoolMessage other) { if (other.Data != false) { Data = other.Data; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { Data = input.ReadBool(); @@ -4370,27 +5209,32 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Test oneofs. + /// Test oneofs. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestOneof : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestOneof()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[22]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[23]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestOneof() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestOneof(TestOneof other) : this() { switch (other.FooCase) { case FooOneofCase.FooInt: @@ -4404,14 +5248,17 @@ public TestOneof(TestOneof other) : this() { break; } + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestOneof Clone() { return new TestOneof(this); } /// Field number for the "foo_int" field. public const int FooIntFieldNumber = 1; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int FooInt { get { return fooCase_ == FooOneofCase.FooInt ? (int) foo_ : 0; } set { @@ -4422,6 +5269,7 @@ public int FooInt { /// Field number for the "foo_string" field. public const int FooStringFieldNumber = 2; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string FooString { get { return fooCase_ == FooOneofCase.FooString ? (string) foo_ : ""; } set { @@ -4432,6 +5280,7 @@ public string FooString { /// Field number for the "foo_message" field. public const int FooMessageFieldNumber = 3; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.TestProtos.TestAllTypes FooMessage { get { return fooCase_ == FooOneofCase.FooMessage ? (global::Google.Protobuf.TestProtos.TestAllTypes) foo_ : null; } set { @@ -4449,19 +5298,23 @@ public enum FooOneofCase { FooMessage = 3, } private FooOneofCase fooCase_ = FooOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FooOneofCase FooCase { get { return fooCase_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void ClearFoo() { fooCase_ = FooOneofCase.None; foo_ = null; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestOneof); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestOneof other) { if (ReferenceEquals(other, null)) { return false; @@ -4473,22 +5326,28 @@ public bool Equals(TestOneof other) { if (FooString != other.FooString) return false; if (!object.Equals(FooMessage, other.FooMessage)) return false; if (FooCase != other.FooCase) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (fooCase_ == FooOneofCase.FooInt) hash ^= FooInt.GetHashCode(); if (fooCase_ == FooOneofCase.FooString) hash ^= FooString.GetHashCode(); if (fooCase_ == FooOneofCase.FooMessage) hash ^= FooMessage.GetHashCode(); hash ^= (int) fooCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (fooCase_ == FooOneofCase.FooInt) { output.WriteRawTag(8); @@ -4502,8 +5361,12 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(26); output.WriteMessage(FooMessage); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (fooCase_ == FooOneofCase.FooInt) { @@ -4515,9 +5378,13 @@ public int CalculateSize() { if (fooCase_ == FooOneofCase.FooMessage) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(FooMessage); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestOneof other) { if (other == null) { return; @@ -4530,18 +5397,23 @@ public void MergeFrom(TestOneof other) { FooString = other.FooString; break; case FooOneofCase.FooMessage: - FooMessage = other.FooMessage; + if (FooMessage == null) { + FooMessage = new global::Google.Protobuf.TestProtos.TestAllTypes(); + } + FooMessage.MergeFrom(other.FooMessage); break; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { FooInt = input.ReadInt32(); @@ -4566,25 +5438,30 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestPackedTypes : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestPackedTypes()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[23]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[24]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestPackedTypes() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestPackedTypes(TestPackedTypes other) : this() { packedInt32_ = other.packedInt32_.Clone(); packedInt64_ = other.packedInt64_.Clone(); @@ -4600,8 +5477,10 @@ public TestPackedTypes(TestPackedTypes other) : this() { packedDouble_ = other.packedDouble_.Clone(); packedBool_ = other.packedBool_.Clone(); packedEnum_ = other.packedEnum_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestPackedTypes Clone() { return new TestPackedTypes(this); } @@ -4611,6 +5490,7 @@ public TestPackedTypes Clone() { private static readonly pb::FieldCodec _repeated_packedInt32_codec = pb::FieldCodec.ForInt32(722); private readonly pbc::RepeatedField packedInt32_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField PackedInt32 { get { return packedInt32_; } } @@ -4620,6 +5500,7 @@ public TestPackedTypes Clone() { private static readonly pb::FieldCodec _repeated_packedInt64_codec = pb::FieldCodec.ForInt64(730); private readonly pbc::RepeatedField packedInt64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField PackedInt64 { get { return packedInt64_; } } @@ -4629,6 +5510,7 @@ public TestPackedTypes Clone() { private static readonly pb::FieldCodec _repeated_packedUint32_codec = pb::FieldCodec.ForUInt32(738); private readonly pbc::RepeatedField packedUint32_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField PackedUint32 { get { return packedUint32_; } } @@ -4638,6 +5520,7 @@ public TestPackedTypes Clone() { private static readonly pb::FieldCodec _repeated_packedUint64_codec = pb::FieldCodec.ForUInt64(746); private readonly pbc::RepeatedField packedUint64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField PackedUint64 { get { return packedUint64_; } } @@ -4647,6 +5530,7 @@ public TestPackedTypes Clone() { private static readonly pb::FieldCodec _repeated_packedSint32_codec = pb::FieldCodec.ForSInt32(754); private readonly pbc::RepeatedField packedSint32_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField PackedSint32 { get { return packedSint32_; } } @@ -4656,6 +5540,7 @@ public TestPackedTypes Clone() { private static readonly pb::FieldCodec _repeated_packedSint64_codec = pb::FieldCodec.ForSInt64(762); private readonly pbc::RepeatedField packedSint64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField PackedSint64 { get { return packedSint64_; } } @@ -4665,6 +5550,7 @@ public TestPackedTypes Clone() { private static readonly pb::FieldCodec _repeated_packedFixed32_codec = pb::FieldCodec.ForFixed32(770); private readonly pbc::RepeatedField packedFixed32_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField PackedFixed32 { get { return packedFixed32_; } } @@ -4674,6 +5560,7 @@ public TestPackedTypes Clone() { private static readonly pb::FieldCodec _repeated_packedFixed64_codec = pb::FieldCodec.ForFixed64(778); private readonly pbc::RepeatedField packedFixed64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField PackedFixed64 { get { return packedFixed64_; } } @@ -4683,6 +5570,7 @@ public TestPackedTypes Clone() { private static readonly pb::FieldCodec _repeated_packedSfixed32_codec = pb::FieldCodec.ForSFixed32(786); private readonly pbc::RepeatedField packedSfixed32_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField PackedSfixed32 { get { return packedSfixed32_; } } @@ -4692,6 +5580,7 @@ public TestPackedTypes Clone() { private static readonly pb::FieldCodec _repeated_packedSfixed64_codec = pb::FieldCodec.ForSFixed64(794); private readonly pbc::RepeatedField packedSfixed64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField PackedSfixed64 { get { return packedSfixed64_; } } @@ -4701,6 +5590,7 @@ public TestPackedTypes Clone() { private static readonly pb::FieldCodec _repeated_packedFloat_codec = pb::FieldCodec.ForFloat(802); private readonly pbc::RepeatedField packedFloat_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField PackedFloat { get { return packedFloat_; } } @@ -4710,6 +5600,7 @@ public TestPackedTypes Clone() { private static readonly pb::FieldCodec _repeated_packedDouble_codec = pb::FieldCodec.ForDouble(810); private readonly pbc::RepeatedField packedDouble_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField PackedDouble { get { return packedDouble_; } } @@ -4719,6 +5610,7 @@ public TestPackedTypes Clone() { private static readonly pb::FieldCodec _repeated_packedBool_codec = pb::FieldCodec.ForBool(818); private readonly pbc::RepeatedField packedBool_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField PackedBool { get { return packedBool_; } } @@ -4728,14 +5620,17 @@ public TestPackedTypes Clone() { private static readonly pb::FieldCodec _repeated_packedEnum_codec = pb::FieldCodec.ForEnum(826, x => (int) x, x => (global::Google.Protobuf.TestProtos.ForeignEnum) x); private readonly pbc::RepeatedField packedEnum_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField PackedEnum { get { return packedEnum_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestPackedTypes); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestPackedTypes other) { if (ReferenceEquals(other, null)) { return false; @@ -4757,9 +5652,10 @@ public bool Equals(TestPackedTypes other) { if(!packedDouble_.Equals(other.packedDouble_)) return false; if(!packedBool_.Equals(other.packedBool_)) return false; if(!packedEnum_.Equals(other.packedEnum_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= packedInt32_.GetHashCode(); @@ -4776,13 +5672,18 @@ public override int GetHashCode() { hash ^= packedDouble_.GetHashCode(); hash ^= packedBool_.GetHashCode(); hash ^= packedEnum_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { packedInt32_.WriteTo(output, _repeated_packedInt32_codec); packedInt64_.WriteTo(output, _repeated_packedInt64_codec); @@ -4798,8 +5699,12 @@ public void WriteTo(pb::CodedOutputStream output) { packedDouble_.WriteTo(output, _repeated_packedDouble_codec); packedBool_.WriteTo(output, _repeated_packedBool_codec); packedEnum_.WriteTo(output, _repeated_packedEnum_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += packedInt32_.CalculateSize(_repeated_packedInt32_codec); @@ -4816,9 +5721,13 @@ public int CalculateSize() { size += packedDouble_.CalculateSize(_repeated_packedDouble_codec); size += packedBool_.CalculateSize(_repeated_packedBool_codec); size += packedEnum_.CalculateSize(_repeated_packedEnum_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestPackedTypes other) { if (other == null) { return; @@ -4837,14 +5746,16 @@ public void MergeFrom(TestPackedTypes other) { packedDouble_.Add(other.packedDouble_); packedBool_.Add(other.packedBool_); packedEnum_.Add(other.packedEnum_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 722: case 720: { @@ -4923,28 +5834,33 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// A message with the same fields as TestPackedTypes, but without packing. Used - /// to test packed <-> unpacked wire compatibility. + /// A message with the same fields as TestPackedTypes, but without packing. Used + /// to test packed <-> unpacked wire compatibility. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestUnpackedTypes : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestUnpackedTypes()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[24]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[25]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestUnpackedTypes() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestUnpackedTypes(TestUnpackedTypes other) : this() { unpackedInt32_ = other.unpackedInt32_.Clone(); unpackedInt64_ = other.unpackedInt64_.Clone(); @@ -4960,8 +5876,10 @@ public TestUnpackedTypes(TestUnpackedTypes other) : this() { unpackedDouble_ = other.unpackedDouble_.Clone(); unpackedBool_ = other.unpackedBool_.Clone(); unpackedEnum_ = other.unpackedEnum_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestUnpackedTypes Clone() { return new TestUnpackedTypes(this); } @@ -4971,6 +5889,7 @@ public TestUnpackedTypes Clone() { private static readonly pb::FieldCodec _repeated_unpackedInt32_codec = pb::FieldCodec.ForInt32(720); private readonly pbc::RepeatedField unpackedInt32_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UnpackedInt32 { get { return unpackedInt32_; } } @@ -4980,6 +5899,7 @@ public TestUnpackedTypes Clone() { private static readonly pb::FieldCodec _repeated_unpackedInt64_codec = pb::FieldCodec.ForInt64(728); private readonly pbc::RepeatedField unpackedInt64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UnpackedInt64 { get { return unpackedInt64_; } } @@ -4989,6 +5909,7 @@ public TestUnpackedTypes Clone() { private static readonly pb::FieldCodec _repeated_unpackedUint32_codec = pb::FieldCodec.ForUInt32(736); private readonly pbc::RepeatedField unpackedUint32_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UnpackedUint32 { get { return unpackedUint32_; } } @@ -4998,6 +5919,7 @@ public TestUnpackedTypes Clone() { private static readonly pb::FieldCodec _repeated_unpackedUint64_codec = pb::FieldCodec.ForUInt64(744); private readonly pbc::RepeatedField unpackedUint64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UnpackedUint64 { get { return unpackedUint64_; } } @@ -5007,6 +5929,7 @@ public TestUnpackedTypes Clone() { private static readonly pb::FieldCodec _repeated_unpackedSint32_codec = pb::FieldCodec.ForSInt32(752); private readonly pbc::RepeatedField unpackedSint32_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UnpackedSint32 { get { return unpackedSint32_; } } @@ -5016,6 +5939,7 @@ public TestUnpackedTypes Clone() { private static readonly pb::FieldCodec _repeated_unpackedSint64_codec = pb::FieldCodec.ForSInt64(760); private readonly pbc::RepeatedField unpackedSint64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UnpackedSint64 { get { return unpackedSint64_; } } @@ -5025,6 +5949,7 @@ public TestUnpackedTypes Clone() { private static readonly pb::FieldCodec _repeated_unpackedFixed32_codec = pb::FieldCodec.ForFixed32(773); private readonly pbc::RepeatedField unpackedFixed32_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UnpackedFixed32 { get { return unpackedFixed32_; } } @@ -5034,6 +5959,7 @@ public TestUnpackedTypes Clone() { private static readonly pb::FieldCodec _repeated_unpackedFixed64_codec = pb::FieldCodec.ForFixed64(777); private readonly pbc::RepeatedField unpackedFixed64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UnpackedFixed64 { get { return unpackedFixed64_; } } @@ -5043,6 +5969,7 @@ public TestUnpackedTypes Clone() { private static readonly pb::FieldCodec _repeated_unpackedSfixed32_codec = pb::FieldCodec.ForSFixed32(789); private readonly pbc::RepeatedField unpackedSfixed32_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UnpackedSfixed32 { get { return unpackedSfixed32_; } } @@ -5052,6 +5979,7 @@ public TestUnpackedTypes Clone() { private static readonly pb::FieldCodec _repeated_unpackedSfixed64_codec = pb::FieldCodec.ForSFixed64(793); private readonly pbc::RepeatedField unpackedSfixed64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UnpackedSfixed64 { get { return unpackedSfixed64_; } } @@ -5061,6 +5989,7 @@ public TestUnpackedTypes Clone() { private static readonly pb::FieldCodec _repeated_unpackedFloat_codec = pb::FieldCodec.ForFloat(805); private readonly pbc::RepeatedField unpackedFloat_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UnpackedFloat { get { return unpackedFloat_; } } @@ -5070,6 +5999,7 @@ public TestUnpackedTypes Clone() { private static readonly pb::FieldCodec _repeated_unpackedDouble_codec = pb::FieldCodec.ForDouble(809); private readonly pbc::RepeatedField unpackedDouble_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UnpackedDouble { get { return unpackedDouble_; } } @@ -5079,6 +6009,7 @@ public TestUnpackedTypes Clone() { private static readonly pb::FieldCodec _repeated_unpackedBool_codec = pb::FieldCodec.ForBool(816); private readonly pbc::RepeatedField unpackedBool_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UnpackedBool { get { return unpackedBool_; } } @@ -5088,14 +6019,17 @@ public TestUnpackedTypes Clone() { private static readonly pb::FieldCodec _repeated_unpackedEnum_codec = pb::FieldCodec.ForEnum(824, x => (int) x, x => (global::Google.Protobuf.TestProtos.ForeignEnum) x); private readonly pbc::RepeatedField unpackedEnum_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UnpackedEnum { get { return unpackedEnum_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestUnpackedTypes); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestUnpackedTypes other) { if (ReferenceEquals(other, null)) { return false; @@ -5117,9 +6051,10 @@ public bool Equals(TestUnpackedTypes other) { if(!unpackedDouble_.Equals(other.unpackedDouble_)) return false; if(!unpackedBool_.Equals(other.unpackedBool_)) return false; if(!unpackedEnum_.Equals(other.unpackedEnum_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= unpackedInt32_.GetHashCode(); @@ -5136,13 +6071,18 @@ public override int GetHashCode() { hash ^= unpackedDouble_.GetHashCode(); hash ^= unpackedBool_.GetHashCode(); hash ^= unpackedEnum_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { unpackedInt32_.WriteTo(output, _repeated_unpackedInt32_codec); unpackedInt64_.WriteTo(output, _repeated_unpackedInt64_codec); @@ -5158,8 +6098,12 @@ public void WriteTo(pb::CodedOutputStream output) { unpackedDouble_.WriteTo(output, _repeated_unpackedDouble_codec); unpackedBool_.WriteTo(output, _repeated_unpackedBool_codec); unpackedEnum_.WriteTo(output, _repeated_unpackedEnum_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += unpackedInt32_.CalculateSize(_repeated_unpackedInt32_codec); @@ -5176,9 +6120,13 @@ public int CalculateSize() { size += unpackedDouble_.CalculateSize(_repeated_unpackedDouble_codec); size += unpackedBool_.CalculateSize(_repeated_unpackedBool_codec); size += unpackedEnum_.CalculateSize(_repeated_unpackedEnum_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestUnpackedTypes other) { if (other == null) { return; @@ -5197,14 +6145,16 @@ public void MergeFrom(TestUnpackedTypes other) { unpackedDouble_.Add(other.unpackedDouble_); unpackedBool_.Add(other.unpackedBool_); unpackedEnum_.Add(other.unpackedEnum_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 722: case 720: { @@ -5282,25 +6232,30 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestRepeatedScalarDifferentTagSizes : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRepeatedScalarDifferentTagSizes()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[25]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[26]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestRepeatedScalarDifferentTagSizes() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestRepeatedScalarDifferentTagSizes(TestRepeatedScalarDifferentTagSizes other) : this() { repeatedFixed32_ = other.repeatedFixed32_.Clone(); repeatedInt32_ = other.repeatedInt32_.Clone(); @@ -5308,8 +6263,10 @@ public TestRepeatedScalarDifferentTagSizes(TestRepeatedScalarDifferentTagSizes o repeatedInt64_ = other.repeatedInt64_.Clone(); repeatedFloat_ = other.repeatedFloat_.Clone(); repeatedUint64_ = other.repeatedUint64_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestRepeatedScalarDifferentTagSizes Clone() { return new TestRepeatedScalarDifferentTagSizes(this); } @@ -5320,10 +6277,11 @@ public TestRepeatedScalarDifferentTagSizes Clone() { = pb::FieldCodec.ForFixed32(98); private readonly pbc::RepeatedField repeatedFixed32_ = new pbc::RepeatedField(); /// - /// Parsing repeated fixed size values used to fail. This message needs to be - /// used in order to get a tag of the right size; all of the repeated fields - /// in TestAllTypes didn't trigger the check. + /// Parsing repeated fixed size values used to fail. This message needs to be + /// used in order to get a tag of the right size; all of the repeated fields + /// in TestAllTypes didn't trigger the check. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedFixed32 { get { return repeatedFixed32_; } } @@ -5334,8 +6292,9 @@ public TestRepeatedScalarDifferentTagSizes Clone() { = pb::FieldCodec.ForInt32(106); private readonly pbc::RepeatedField repeatedInt32_ = new pbc::RepeatedField(); /// - /// Check for a varint type, just for good measure. + /// Check for a varint type, just for good measure. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedInt32 { get { return repeatedInt32_; } } @@ -5346,8 +6305,9 @@ public TestRepeatedScalarDifferentTagSizes Clone() { = pb::FieldCodec.ForFixed64(16370); private readonly pbc::RepeatedField repeatedFixed64_ = new pbc::RepeatedField(); /// - /// These have two-byte tags. + /// These have two-byte tags. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedFixed64 { get { return repeatedFixed64_; } } @@ -5357,6 +6317,7 @@ public TestRepeatedScalarDifferentTagSizes Clone() { private static readonly pb::FieldCodec _repeated_repeatedInt64_codec = pb::FieldCodec.ForInt64(16378); private readonly pbc::RepeatedField repeatedInt64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedInt64 { get { return repeatedInt64_; } } @@ -5367,8 +6328,9 @@ public TestRepeatedScalarDifferentTagSizes Clone() { = pb::FieldCodec.ForFloat(2097138); private readonly pbc::RepeatedField repeatedFloat_ = new pbc::RepeatedField(); /// - /// Three byte tags. + /// Three byte tags. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedFloat { get { return repeatedFloat_; } } @@ -5378,14 +6340,17 @@ public TestRepeatedScalarDifferentTagSizes Clone() { private static readonly pb::FieldCodec _repeated_repeatedUint64_codec = pb::FieldCodec.ForUInt64(2097146); private readonly pbc::RepeatedField repeatedUint64_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField RepeatedUint64 { get { return repeatedUint64_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestRepeatedScalarDifferentTagSizes); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestRepeatedScalarDifferentTagSizes other) { if (ReferenceEquals(other, null)) { return false; @@ -5399,9 +6364,10 @@ public bool Equals(TestRepeatedScalarDifferentTagSizes other) { if(!repeatedInt64_.Equals(other.repeatedInt64_)) return false; if(!repeatedFloat_.Equals(other.repeatedFloat_)) return false; if(!repeatedUint64_.Equals(other.repeatedUint64_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= repeatedFixed32_.GetHashCode(); @@ -5410,13 +6376,18 @@ public override int GetHashCode() { hash ^= repeatedInt64_.GetHashCode(); hash ^= repeatedFloat_.GetHashCode(); hash ^= repeatedUint64_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { repeatedFixed32_.WriteTo(output, _repeated_repeatedFixed32_codec); repeatedInt32_.WriteTo(output, _repeated_repeatedInt32_codec); @@ -5424,8 +6395,12 @@ public void WriteTo(pb::CodedOutputStream output) { repeatedInt64_.WriteTo(output, _repeated_repeatedInt64_codec); repeatedFloat_.WriteTo(output, _repeated_repeatedFloat_codec); repeatedUint64_.WriteTo(output, _repeated_repeatedUint64_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += repeatedFixed32_.CalculateSize(_repeated_repeatedFixed32_codec); @@ -5434,9 +6409,13 @@ public int CalculateSize() { size += repeatedInt64_.CalculateSize(_repeated_repeatedInt64_codec); size += repeatedFloat_.CalculateSize(_repeated_repeatedFloat_codec); size += repeatedUint64_.CalculateSize(_repeated_repeatedUint64_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestRepeatedScalarDifferentTagSizes other) { if (other == null) { return; @@ -5447,14 +6426,16 @@ public void MergeFrom(TestRepeatedScalarDifferentTagSizes other) { repeatedInt64_.Add(other.repeatedInt64_); repeatedFloat_.Add(other.repeatedFloat_); repeatedUint64_.Add(other.repeatedUint64_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 98: case 101: { @@ -5492,29 +6473,36 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestCommentInjectionMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestCommentInjectionMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[26]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[27]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestCommentInjectionMessage() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestCommentInjectionMessage(TestCommentInjectionMessage other) : this() { a_ = other.a_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestCommentInjectionMessage Clone() { return new TestCommentInjectionMessage(this); } @@ -5523,8 +6511,9 @@ public TestCommentInjectionMessage Clone() { public const int AFieldNumber = 1; private string a_ = ""; /// - /// */ <- This should not close the generated doc comment + /// */ <- This should not close the generated doc comment /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string A { get { return a_; } set { @@ -5532,10 +6521,12 @@ public string A { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestCommentInjectionMessage); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestCommentInjectionMessage other) { if (ReferenceEquals(other, null)) { return false; @@ -5544,34 +6535,48 @@ public bool Equals(TestCommentInjectionMessage other) { return true; } if (A != other.A) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (A.Length != 0) hash ^= A.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (A.Length != 0) { output.WriteRawTag(10); output.WriteString(A); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (A.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(A); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestCommentInjectionMessage other) { if (other == null) { return; @@ -5579,14 +6584,16 @@ public void MergeFrom(TestCommentInjectionMessage other) { if (other.A.Length != 0) { A = other.A; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { A = input.ReadString(); @@ -5599,38 +6606,47 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Test that RPC services work. + /// Test that RPC services work. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class FooRequest : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooRequest()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[27]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[28]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FooRequest() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FooRequest(FooRequest other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FooRequest Clone() { return new FooRequest(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as FooRequest); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(FooRequest other) { if (ReferenceEquals(other, null)) { return false; @@ -5638,38 +6654,54 @@ public bool Equals(FooRequest other) { if (ReferenceEquals(other, this)) { return true; } - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(FooRequest other) { if (other == null) { return; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; } } @@ -5677,36 +6709,45 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class FooResponse : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooResponse()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[28]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[29]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FooResponse() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FooResponse(FooResponse other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FooResponse Clone() { return new FooResponse(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as FooResponse); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(FooResponse other) { if (ReferenceEquals(other, null)) { return false; @@ -5714,38 +6755,54 @@ public bool Equals(FooResponse other) { if (ReferenceEquals(other, this)) { return true; } - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(FooResponse other) { if (other == null) { return; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; } } @@ -5753,36 +6810,45 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class FooClientMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooClientMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[29]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[30]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FooClientMessage() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FooClientMessage(FooClientMessage other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FooClientMessage Clone() { return new FooClientMessage(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as FooClientMessage); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(FooClientMessage other) { if (ReferenceEquals(other, null)) { return false; @@ -5790,38 +6856,54 @@ public bool Equals(FooClientMessage other) { if (ReferenceEquals(other, this)) { return true; } - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(FooClientMessage other) { if (other == null) { return; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; } } @@ -5829,36 +6911,45 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class FooServerMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooServerMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[30]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[31]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FooServerMessage() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FooServerMessage(FooServerMessage other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FooServerMessage Clone() { return new FooServerMessage(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as FooServerMessage); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(FooServerMessage other) { if (ReferenceEquals(other, null)) { return false; @@ -5866,38 +6957,54 @@ public bool Equals(FooServerMessage other) { if (ReferenceEquals(other, this)) { return true; } - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(FooServerMessage other) { if (other == null) { return; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; } } @@ -5905,36 +7012,45 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class BarRequest : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarRequest()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[31]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[32]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public BarRequest() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public BarRequest(BarRequest other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public BarRequest Clone() { return new BarRequest(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as BarRequest); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(BarRequest other) { if (ReferenceEquals(other, null)) { return false; @@ -5942,38 +7058,54 @@ public bool Equals(BarRequest other) { if (ReferenceEquals(other, this)) { return true; } - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(BarRequest other) { if (other == null) { return; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; } } @@ -5981,36 +7113,45 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class BarResponse : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarResponse()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[32]; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[33]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public BarResponse() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public BarResponse(BarResponse other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public BarResponse Clone() { return new BarResponse(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as BarResponse); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(BarResponse other) { if (ReferenceEquals(other, null)) { return false; @@ -6018,42 +7159,446 @@ public bool Equals(BarResponse other) { if (ReferenceEquals(other, this)) { return true; } - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(BarResponse other) { if (other == null) { return; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + } + } + } + + } + + public sealed partial class TestEmptyMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestEmptyMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[34]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TestEmptyMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TestEmptyMessage(TestEmptyMessage other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TestEmptyMessage Clone() { + return new TestEmptyMessage(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as TestEmptyMessage); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(TestEmptyMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(TestEmptyMessage other) { + if (other == null) { + return; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + } + } + } + + } + + /// + /// This is a leading comment + /// + public sealed partial class CommentMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CommentMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor.MessageTypes[35]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CommentMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CommentMessage(CommentMessage other) : this() { + text_ = other.text_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CommentMessage Clone() { + return new CommentMessage(this); + } + + /// Field number for the "text" field. + public const int TextFieldNumber = 1; + private string text_ = ""; + /// + /// Leading field comment + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Text { + get { return text_; } + set { + text_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as CommentMessage); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(CommentMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Text != other.Text) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Text.Length != 0) hash ^= Text.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Text.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Text); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Text.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Text); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(CommentMessage other) { + if (other == null) { + return; + } + if (other.Text.Length != 0) { + Text = other.Text; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Text = input.ReadString(); break; + } + } + } + } + + #region Nested types + /// Container for nested types declared in the CommentMessage message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + /// + /// Leading nested enum comment + /// + public enum NestedCommentEnum { + /// + /// Zero value comment + /// + [pbr::OriginalName("ZERO_VALUE")] ZeroValue = 0, + } + + /// + /// Leading nested message comment + /// + public sealed partial class NestedCommentMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedCommentMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.CommentMessage.Descriptor.NestedTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedCommentMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedCommentMessage(NestedCommentMessage other) : this() { + nestedText_ = other.nestedText_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedCommentMessage Clone() { + return new NestedCommentMessage(this); + } + + /// Field number for the "nested_text" field. + public const int NestedTextFieldNumber = 1; + private string nestedText_ = ""; + /// + /// Leading nested message field comment + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string NestedText { + get { return nestedText_; } + set { + nestedText_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as NestedCommentMessage); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(NestedCommentMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (NestedText != other.NestedText) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (NestedText.Length != 0) hash ^= NestedText.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (NestedText.Length != 0) { + output.WriteRawTag(10); + output.WriteString(NestedText); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (NestedText.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(NestedText); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(NestedCommentMessage other) { + if (other == null) { + return; + } + if (other.NestedText.Length != 0) { + NestedText = other.NestedText; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + NestedText = input.ReadString(); + break; + } + } + } + } + } + } + #endregion } diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs index ae12f4a4b9c3..90b338436bc9 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs @@ -1,5 +1,7 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/unittest_well_known_types.proto +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/unittest_well_known_types.proto +// #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -10,7 +12,6 @@ namespace Google.Protobuf.TestProtos { /// Holder for reflection information generated from google/protobuf/unittest_well_known_types.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class UnittestWellKnownTypesReflection { #region Descriptor @@ -162,11 +163,11 @@ static UnittestWellKnownTypesReflection() { "dFByb3Rvc2IGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.ApiReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.DurationReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.EmptyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.FieldMaskReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.SourceContextReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.StructReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TypeReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.WrappersReflection.Descriptor, }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestWellKnownTypes), global::Google.Protobuf.TestProtos.TestWellKnownTypes.Parser, new[]{ "AnyField", "ApiField", "DurationField", "EmptyField", "FieldMaskField", "SourceContextField", "StructField", "TimestampField", "TypeField", "DoubleField", "FloatField", "Int64Field", "Uint64Field", "Int32Field", "Uint32Field", "BoolField", "StringField", "BytesField", "ValueField" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.RepeatedWellKnownTypes), global::Google.Protobuf.TestProtos.RepeatedWellKnownTypes.Parser, new[]{ "AnyField", "ApiField", "DurationField", "EmptyField", "FieldMaskField", "SourceContextField", "StructField", "TimestampField", "TypeField", "DoubleField", "FloatField", "Int64Field", "Uint64Field", "Int32Field", "Uint32Field", "BoolField", "StringField", "BytesField" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.OneofWellKnownTypes), global::Google.Protobuf.TestProtos.OneofWellKnownTypes.Parser, new[]{ "AnyField", "ApiField", "DurationField", "EmptyField", "FieldMaskField", "SourceContextField", "StructField", "TimestampField", "TypeField", "DoubleField", "FloatField", "Int64Field", "Uint64Field", "Int32Field", "Uint32Field", "BoolField", "StringField", "BytesField" }, new[]{ "OneofField" }, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.MapWellKnownTypes), global::Google.Protobuf.TestProtos.MapWellKnownTypes.Parser, new[]{ "AnyField", "ApiField", "DurationField", "EmptyField", "FieldMaskField", "SourceContextField", "StructField", "TimestampField", "TypeField", "DoubleField", "FloatField", "Int64Field", "Uint64Field", "Int32Field", "Uint32Field", "BoolField", "StringField", "BytesField" }, null, null, new pbr::GeneratedClrTypeInfo[] { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, }) + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestWellKnownTypes), global::Google.Protobuf.TestProtos.TestWellKnownTypes.Parser, new[]{ "AnyField", "ApiField", "DurationField", "EmptyField", "FieldMaskField", "SourceContextField", "StructField", "TimestampField", "TypeField", "DoubleField", "FloatField", "Int64Field", "Uint64Field", "Int32Field", "Uint32Field", "BoolField", "StringField", "BytesField", "ValueField" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.RepeatedWellKnownTypes), global::Google.Protobuf.TestProtos.RepeatedWellKnownTypes.Parser, new[]{ "AnyField", "ApiField", "DurationField", "EmptyField", "FieldMaskField", "SourceContextField", "StructField", "TimestampField", "TypeField", "DoubleField", "FloatField", "Int64Field", "Uint64Field", "Int32Field", "Uint32Field", "BoolField", "StringField", "BytesField" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.OneofWellKnownTypes), global::Google.Protobuf.TestProtos.OneofWellKnownTypes.Parser, new[]{ "AnyField", "ApiField", "DurationField", "EmptyField", "FieldMaskField", "SourceContextField", "StructField", "TimestampField", "TypeField", "DoubleField", "FloatField", "Int64Field", "Uint64Field", "Int32Field", "Uint32Field", "BoolField", "StringField", "BytesField" }, new[]{ "OneofField" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.MapWellKnownTypes), global::Google.Protobuf.TestProtos.MapWellKnownTypes.Parser, new[]{ "AnyField", "ApiField", "DurationField", "EmptyField", "FieldMaskField", "SourceContextField", "StructField", "TimestampField", "TypeField", "DoubleField", "FloatField", "Int64Field", "Uint64Field", "Int32Field", "Uint32Field", "BoolField", "StringField", "BytesField" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, }) })); } #endregion @@ -174,39 +175,44 @@ static UnittestWellKnownTypesReflection() { } #region Messages /// - /// Test that we can include all well-known types. - /// Each wrapper type is included separately, as languages - /// map handle different wrappers in different ways. + /// Test that we can include all well-known types. + /// Each wrapper type is included separately, as languages + /// map handle different wrappers in different ways. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class TestWellKnownTypes : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestWellKnownTypes()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestWellKnownTypesReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestWellKnownTypes() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestWellKnownTypes(TestWellKnownTypes other) : this() { - AnyField = other.anyField_ != null ? other.AnyField.Clone() : null; - ApiField = other.apiField_ != null ? other.ApiField.Clone() : null; - DurationField = other.durationField_ != null ? other.DurationField.Clone() : null; - EmptyField = other.emptyField_ != null ? other.EmptyField.Clone() : null; - FieldMaskField = other.fieldMaskField_ != null ? other.FieldMaskField.Clone() : null; - SourceContextField = other.sourceContextField_ != null ? other.SourceContextField.Clone() : null; - StructField = other.structField_ != null ? other.StructField.Clone() : null; - TimestampField = other.timestampField_ != null ? other.TimestampField.Clone() : null; - TypeField = other.typeField_ != null ? other.TypeField.Clone() : null; + anyField_ = other.anyField_ != null ? other.anyField_.Clone() : null; + apiField_ = other.apiField_ != null ? other.apiField_.Clone() : null; + durationField_ = other.durationField_ != null ? other.durationField_.Clone() : null; + emptyField_ = other.emptyField_ != null ? other.emptyField_.Clone() : null; + fieldMaskField_ = other.fieldMaskField_ != null ? other.fieldMaskField_.Clone() : null; + sourceContextField_ = other.sourceContextField_ != null ? other.sourceContextField_.Clone() : null; + structField_ = other.structField_ != null ? other.structField_.Clone() : null; + timestampField_ = other.timestampField_ != null ? other.timestampField_.Clone() : null; + typeField_ = other.typeField_ != null ? other.typeField_.Clone() : null; DoubleField = other.DoubleField; FloatField = other.FloatField; Int64Field = other.Int64Field; @@ -216,9 +222,11 @@ public TestWellKnownTypes(TestWellKnownTypes other) : this() { BoolField = other.BoolField; StringField = other.StringField; BytesField = other.BytesField; - ValueField = other.valueField_ != null ? other.ValueField.Clone() : null; + valueField_ = other.valueField_ != null ? other.valueField_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestWellKnownTypes Clone() { return new TestWellKnownTypes(this); } @@ -226,6 +234,7 @@ public TestWellKnownTypes Clone() { /// Field number for the "any_field" field. public const int AnyFieldFieldNumber = 1; private global::Google.Protobuf.WellKnownTypes.Any anyField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Any AnyField { get { return anyField_; } set { @@ -236,6 +245,7 @@ public TestWellKnownTypes Clone() { /// Field number for the "api_field" field. public const int ApiFieldFieldNumber = 2; private global::Google.Protobuf.WellKnownTypes.Api apiField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Api ApiField { get { return apiField_; } set { @@ -246,6 +256,7 @@ public TestWellKnownTypes Clone() { /// Field number for the "duration_field" field. public const int DurationFieldFieldNumber = 3; private global::Google.Protobuf.WellKnownTypes.Duration durationField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Duration DurationField { get { return durationField_; } set { @@ -256,6 +267,7 @@ public TestWellKnownTypes Clone() { /// Field number for the "empty_field" field. public const int EmptyFieldFieldNumber = 4; private global::Google.Protobuf.WellKnownTypes.Empty emptyField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Empty EmptyField { get { return emptyField_; } set { @@ -266,6 +278,7 @@ public TestWellKnownTypes Clone() { /// Field number for the "field_mask_field" field. public const int FieldMaskFieldFieldNumber = 5; private global::Google.Protobuf.WellKnownTypes.FieldMask fieldMaskField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.FieldMask FieldMaskField { get { return fieldMaskField_; } set { @@ -276,6 +289,7 @@ public TestWellKnownTypes Clone() { /// Field number for the "source_context_field" field. public const int SourceContextFieldFieldNumber = 6; private global::Google.Protobuf.WellKnownTypes.SourceContext sourceContextField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.SourceContext SourceContextField { get { return sourceContextField_; } set { @@ -286,6 +300,7 @@ public TestWellKnownTypes Clone() { /// Field number for the "struct_field" field. public const int StructFieldFieldNumber = 7; private global::Google.Protobuf.WellKnownTypes.Struct structField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Struct StructField { get { return structField_; } set { @@ -296,6 +311,7 @@ public TestWellKnownTypes Clone() { /// Field number for the "timestamp_field" field. public const int TimestampFieldFieldNumber = 8; private global::Google.Protobuf.WellKnownTypes.Timestamp timestampField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Timestamp TimestampField { get { return timestampField_; } set { @@ -306,6 +322,7 @@ public TestWellKnownTypes Clone() { /// Field number for the "type_field" field. public const int TypeFieldFieldNumber = 9; private global::Google.Protobuf.WellKnownTypes.Type typeField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Type TypeField { get { return typeField_; } set { @@ -317,6 +334,7 @@ public TestWellKnownTypes Clone() { public const int DoubleFieldFieldNumber = 10; private static readonly pb::FieldCodec _single_doubleField_codec = pb::FieldCodec.ForStructWrapper(82); private double? doubleField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public double? DoubleField { get { return doubleField_; } set { @@ -324,10 +342,12 @@ public double? DoubleField { } } + /// Field number for the "float_field" field. public const int FloatFieldFieldNumber = 11; private static readonly pb::FieldCodec _single_floatField_codec = pb::FieldCodec.ForStructWrapper(90); private float? floatField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public float? FloatField { get { return floatField_; } set { @@ -335,10 +355,12 @@ public float? FloatField { } } + /// Field number for the "int64_field" field. public const int Int64FieldFieldNumber = 12; private static readonly pb::FieldCodec _single_int64Field_codec = pb::FieldCodec.ForStructWrapper(98); private long? int64Field_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public long? Int64Field { get { return int64Field_; } set { @@ -346,10 +368,12 @@ public long? Int64Field { } } + /// Field number for the "uint64_field" field. public const int Uint64FieldFieldNumber = 13; private static readonly pb::FieldCodec _single_uint64Field_codec = pb::FieldCodec.ForStructWrapper(106); private ulong? uint64Field_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ulong? Uint64Field { get { return uint64Field_; } set { @@ -357,10 +381,12 @@ public ulong? Uint64Field { } } + /// Field number for the "int32_field" field. public const int Int32FieldFieldNumber = 14; private static readonly pb::FieldCodec _single_int32Field_codec = pb::FieldCodec.ForStructWrapper(114); private int? int32Field_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int? Int32Field { get { return int32Field_; } set { @@ -368,10 +394,12 @@ public int? Int32Field { } } + /// Field number for the "uint32_field" field. public const int Uint32FieldFieldNumber = 15; private static readonly pb::FieldCodec _single_uint32Field_codec = pb::FieldCodec.ForStructWrapper(122); private uint? uint32Field_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public uint? Uint32Field { get { return uint32Field_; } set { @@ -379,10 +407,12 @@ public uint? Uint32Field { } } + /// Field number for the "bool_field" field. public const int BoolFieldFieldNumber = 16; private static readonly pb::FieldCodec _single_boolField_codec = pb::FieldCodec.ForStructWrapper(130); private bool? boolField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool? BoolField { get { return boolField_; } set { @@ -390,10 +420,12 @@ public bool? BoolField { } } + /// Field number for the "string_field" field. public const int StringFieldFieldNumber = 17; private static readonly pb::FieldCodec _single_stringField_codec = pb::FieldCodec.ForClassWrapper(138); private string stringField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string StringField { get { return stringField_; } set { @@ -401,10 +433,12 @@ public string StringField { } } + /// Field number for the "bytes_field" field. public const int BytesFieldFieldNumber = 18; private static readonly pb::FieldCodec _single_bytesField_codec = pb::FieldCodec.ForClassWrapper(146); private pb::ByteString bytesField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pb::ByteString BytesField { get { return bytesField_; } set { @@ -412,12 +446,14 @@ public string StringField { } } + /// Field number for the "value_field" field. public const int ValueFieldFieldNumber = 19; private global::Google.Protobuf.WellKnownTypes.Value valueField_; /// - /// Part of struct, but useful to be able to test separately + /// Part of struct, but useful to be able to test separately /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Value ValueField { get { return valueField_; } set { @@ -425,10 +461,12 @@ public string StringField { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as TestWellKnownTypes); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(TestWellKnownTypes other) { if (ReferenceEquals(other, null)) { return false; @@ -445,8 +483,8 @@ public bool Equals(TestWellKnownTypes other) { if (!object.Equals(StructField, other.StructField)) return false; if (!object.Equals(TimestampField, other.TimestampField)) return false; if (!object.Equals(TypeField, other.TypeField)) return false; - if (DoubleField != other.DoubleField) return false; - if (FloatField != other.FloatField) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseNullableDoubleEqualityComparer.Equals(DoubleField, other.DoubleField)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseNullableSingleEqualityComparer.Equals(FloatField, other.FloatField)) return false; if (Int64Field != other.Int64Field) return false; if (Uint64Field != other.Uint64Field) return false; if (Int32Field != other.Int32Field) return false; @@ -455,9 +493,10 @@ public bool Equals(TestWellKnownTypes other) { if (StringField != other.StringField) return false; if (BytesField != other.BytesField) return false; if (!object.Equals(ValueField, other.ValueField)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (anyField_ != null) hash ^= AnyField.GetHashCode(); @@ -469,8 +508,8 @@ public override int GetHashCode() { if (structField_ != null) hash ^= StructField.GetHashCode(); if (timestampField_ != null) hash ^= TimestampField.GetHashCode(); if (typeField_ != null) hash ^= TypeField.GetHashCode(); - if (doubleField_ != null) hash ^= DoubleField.GetHashCode(); - if (floatField_ != null) hash ^= FloatField.GetHashCode(); + if (doubleField_ != null) hash ^= pbc::ProtobufEqualityComparers.BitwiseNullableDoubleEqualityComparer.GetHashCode(DoubleField); + if (floatField_ != null) hash ^= pbc::ProtobufEqualityComparers.BitwiseNullableSingleEqualityComparer.GetHashCode(FloatField); if (int64Field_ != null) hash ^= Int64Field.GetHashCode(); if (uint64Field_ != null) hash ^= Uint64Field.GetHashCode(); if (int32Field_ != null) hash ^= Int32Field.GetHashCode(); @@ -479,13 +518,18 @@ public override int GetHashCode() { if (stringField_ != null) hash ^= StringField.GetHashCode(); if (bytesField_ != null) hash ^= BytesField.GetHashCode(); if (valueField_ != null) hash ^= ValueField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (anyField_ != null) { output.WriteRawTag(10); @@ -554,8 +598,12 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(154, 1); output.WriteMessage(ValueField); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (anyField_ != null) { @@ -615,64 +663,68 @@ public int CalculateSize() { if (valueField_ != null) { size += 2 + pb::CodedOutputStream.ComputeMessageSize(ValueField); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(TestWellKnownTypes other) { if (other == null) { return; } if (other.anyField_ != null) { if (anyField_ == null) { - anyField_ = new global::Google.Protobuf.WellKnownTypes.Any(); + AnyField = new global::Google.Protobuf.WellKnownTypes.Any(); } AnyField.MergeFrom(other.AnyField); } if (other.apiField_ != null) { if (apiField_ == null) { - apiField_ = new global::Google.Protobuf.WellKnownTypes.Api(); + ApiField = new global::Google.Protobuf.WellKnownTypes.Api(); } ApiField.MergeFrom(other.ApiField); } if (other.durationField_ != null) { if (durationField_ == null) { - durationField_ = new global::Google.Protobuf.WellKnownTypes.Duration(); + DurationField = new global::Google.Protobuf.WellKnownTypes.Duration(); } DurationField.MergeFrom(other.DurationField); } if (other.emptyField_ != null) { if (emptyField_ == null) { - emptyField_ = new global::Google.Protobuf.WellKnownTypes.Empty(); + EmptyField = new global::Google.Protobuf.WellKnownTypes.Empty(); } EmptyField.MergeFrom(other.EmptyField); } if (other.fieldMaskField_ != null) { if (fieldMaskField_ == null) { - fieldMaskField_ = new global::Google.Protobuf.WellKnownTypes.FieldMask(); + FieldMaskField = new global::Google.Protobuf.WellKnownTypes.FieldMask(); } FieldMaskField.MergeFrom(other.FieldMaskField); } if (other.sourceContextField_ != null) { if (sourceContextField_ == null) { - sourceContextField_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + SourceContextField = new global::Google.Protobuf.WellKnownTypes.SourceContext(); } SourceContextField.MergeFrom(other.SourceContextField); } if (other.structField_ != null) { if (structField_ == null) { - structField_ = new global::Google.Protobuf.WellKnownTypes.Struct(); + StructField = new global::Google.Protobuf.WellKnownTypes.Struct(); } StructField.MergeFrom(other.StructField); } if (other.timestampField_ != null) { if (timestampField_ == null) { - timestampField_ = new global::Google.Protobuf.WellKnownTypes.Timestamp(); + TimestampField = new global::Google.Protobuf.WellKnownTypes.Timestamp(); } TimestampField.MergeFrom(other.TimestampField); } if (other.typeField_ != null) { if (typeField_ == null) { - typeField_ = new global::Google.Protobuf.WellKnownTypes.Type(); + TypeField = new global::Google.Protobuf.WellKnownTypes.Type(); } TypeField.MergeFrom(other.TypeField); } @@ -723,80 +775,82 @@ public void MergeFrom(TestWellKnownTypes other) { } if (other.valueField_ != null) { if (valueField_ == null) { - valueField_ = new global::Google.Protobuf.WellKnownTypes.Value(); + ValueField = new global::Google.Protobuf.WellKnownTypes.Value(); } ValueField.MergeFrom(other.ValueField); } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { if (anyField_ == null) { - anyField_ = new global::Google.Protobuf.WellKnownTypes.Any(); + AnyField = new global::Google.Protobuf.WellKnownTypes.Any(); } - input.ReadMessage(anyField_); + input.ReadMessage(AnyField); break; } case 18: { if (apiField_ == null) { - apiField_ = new global::Google.Protobuf.WellKnownTypes.Api(); + ApiField = new global::Google.Protobuf.WellKnownTypes.Api(); } - input.ReadMessage(apiField_); + input.ReadMessage(ApiField); break; } case 26: { if (durationField_ == null) { - durationField_ = new global::Google.Protobuf.WellKnownTypes.Duration(); + DurationField = new global::Google.Protobuf.WellKnownTypes.Duration(); } - input.ReadMessage(durationField_); + input.ReadMessage(DurationField); break; } case 34: { if (emptyField_ == null) { - emptyField_ = new global::Google.Protobuf.WellKnownTypes.Empty(); + EmptyField = new global::Google.Protobuf.WellKnownTypes.Empty(); } - input.ReadMessage(emptyField_); + input.ReadMessage(EmptyField); break; } case 42: { if (fieldMaskField_ == null) { - fieldMaskField_ = new global::Google.Protobuf.WellKnownTypes.FieldMask(); + FieldMaskField = new global::Google.Protobuf.WellKnownTypes.FieldMask(); } - input.ReadMessage(fieldMaskField_); + input.ReadMessage(FieldMaskField); break; } case 50: { if (sourceContextField_ == null) { - sourceContextField_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + SourceContextField = new global::Google.Protobuf.WellKnownTypes.SourceContext(); } - input.ReadMessage(sourceContextField_); + input.ReadMessage(SourceContextField); break; } case 58: { if (structField_ == null) { - structField_ = new global::Google.Protobuf.WellKnownTypes.Struct(); + StructField = new global::Google.Protobuf.WellKnownTypes.Struct(); } - input.ReadMessage(structField_); + input.ReadMessage(StructField); break; } case 66: { if (timestampField_ == null) { - timestampField_ = new global::Google.Protobuf.WellKnownTypes.Timestamp(); + TimestampField = new global::Google.Protobuf.WellKnownTypes.Timestamp(); } - input.ReadMessage(timestampField_); + input.ReadMessage(TimestampField); break; } case 74: { if (typeField_ == null) { - typeField_ = new global::Google.Protobuf.WellKnownTypes.Type(); + TypeField = new global::Google.Protobuf.WellKnownTypes.Type(); } - input.ReadMessage(typeField_); + input.ReadMessage(TypeField); break; } case 82: { @@ -864,9 +918,9 @@ public void MergeFrom(pb::CodedInputStream input) { } case 154: { if (valueField_ == null) { - valueField_ = new global::Google.Protobuf.WellKnownTypes.Value(); + ValueField = new global::Google.Protobuf.WellKnownTypes.Value(); } - input.ReadMessage(valueField_); + input.ReadMessage(ValueField); break; } } @@ -876,27 +930,32 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// A repeated field for each well-known type. + /// A repeated field for each well-known type. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class RepeatedWellKnownTypes : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RepeatedWellKnownTypes()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestWellKnownTypesReflection.Descriptor.MessageTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RepeatedWellKnownTypes() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RepeatedWellKnownTypes(RepeatedWellKnownTypes other) : this() { anyField_ = other.anyField_.Clone(); apiField_ = other.apiField_.Clone(); @@ -916,8 +975,10 @@ public RepeatedWellKnownTypes(RepeatedWellKnownTypes other) : this() { boolField_ = other.boolField_.Clone(); stringField_ = other.stringField_.Clone(); bytesField_ = other.bytesField_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RepeatedWellKnownTypes Clone() { return new RepeatedWellKnownTypes(this); } @@ -927,6 +988,7 @@ public RepeatedWellKnownTypes Clone() { private static readonly pb::FieldCodec _repeated_anyField_codec = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.WellKnownTypes.Any.Parser); private readonly pbc::RepeatedField anyField_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField AnyField { get { return anyField_; } } @@ -936,6 +998,7 @@ public RepeatedWellKnownTypes Clone() { private static readonly pb::FieldCodec _repeated_apiField_codec = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Api.Parser); private readonly pbc::RepeatedField apiField_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField ApiField { get { return apiField_; } } @@ -945,6 +1008,7 @@ public RepeatedWellKnownTypes Clone() { private static readonly pb::FieldCodec _repeated_durationField_codec = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.WellKnownTypes.Duration.Parser); private readonly pbc::RepeatedField durationField_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField DurationField { get { return durationField_; } } @@ -954,6 +1018,7 @@ public RepeatedWellKnownTypes Clone() { private static readonly pb::FieldCodec _repeated_emptyField_codec = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.WellKnownTypes.Empty.Parser); private readonly pbc::RepeatedField emptyField_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField EmptyField { get { return emptyField_; } } @@ -963,6 +1028,7 @@ public RepeatedWellKnownTypes Clone() { private static readonly pb::FieldCodec _repeated_fieldMaskField_codec = pb::FieldCodec.ForMessage(42, global::Google.Protobuf.WellKnownTypes.FieldMask.Parser); private readonly pbc::RepeatedField fieldMaskField_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField FieldMaskField { get { return fieldMaskField_; } } @@ -972,6 +1038,7 @@ public RepeatedWellKnownTypes Clone() { private static readonly pb::FieldCodec _repeated_sourceContextField_codec = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.WellKnownTypes.SourceContext.Parser); private readonly pbc::RepeatedField sourceContextField_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField SourceContextField { get { return sourceContextField_; } } @@ -981,6 +1048,7 @@ public RepeatedWellKnownTypes Clone() { private static readonly pb::FieldCodec _repeated_structField_codec = pb::FieldCodec.ForMessage(58, global::Google.Protobuf.WellKnownTypes.Struct.Parser); private readonly pbc::RepeatedField structField_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField StructField { get { return structField_; } } @@ -990,6 +1058,7 @@ public RepeatedWellKnownTypes Clone() { private static readonly pb::FieldCodec _repeated_timestampField_codec = pb::FieldCodec.ForMessage(66, global::Google.Protobuf.WellKnownTypes.Timestamp.Parser); private readonly pbc::RepeatedField timestampField_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField TimestampField { get { return timestampField_; } } @@ -999,6 +1068,7 @@ public RepeatedWellKnownTypes Clone() { private static readonly pb::FieldCodec _repeated_typeField_codec = pb::FieldCodec.ForMessage(74, global::Google.Protobuf.WellKnownTypes.Type.Parser); private readonly pbc::RepeatedField typeField_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField TypeField { get { return typeField_; } } @@ -1009,8 +1079,9 @@ public RepeatedWellKnownTypes Clone() { = pb::FieldCodec.ForStructWrapper(82); private readonly pbc::RepeatedField doubleField_ = new pbc::RepeatedField(); /// - /// These don't actually make a lot of sense, but they're not prohibited... + /// These don't actually make a lot of sense, but they're not prohibited... /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField DoubleField { get { return doubleField_; } } @@ -1020,6 +1091,7 @@ public RepeatedWellKnownTypes Clone() { private static readonly pb::FieldCodec _repeated_floatField_codec = pb::FieldCodec.ForStructWrapper(90); private readonly pbc::RepeatedField floatField_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField FloatField { get { return floatField_; } } @@ -1029,6 +1101,7 @@ public RepeatedWellKnownTypes Clone() { private static readonly pb::FieldCodec _repeated_int64Field_codec = pb::FieldCodec.ForStructWrapper(98); private readonly pbc::RepeatedField int64Field_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Int64Field { get { return int64Field_; } } @@ -1038,6 +1111,7 @@ public RepeatedWellKnownTypes Clone() { private static readonly pb::FieldCodec _repeated_uint64Field_codec = pb::FieldCodec.ForStructWrapper(106); private readonly pbc::RepeatedField uint64Field_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Uint64Field { get { return uint64Field_; } } @@ -1047,6 +1121,7 @@ public RepeatedWellKnownTypes Clone() { private static readonly pb::FieldCodec _repeated_int32Field_codec = pb::FieldCodec.ForStructWrapper(114); private readonly pbc::RepeatedField int32Field_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Int32Field { get { return int32Field_; } } @@ -1056,6 +1131,7 @@ public RepeatedWellKnownTypes Clone() { private static readonly pb::FieldCodec _repeated_uint32Field_codec = pb::FieldCodec.ForStructWrapper(122); private readonly pbc::RepeatedField uint32Field_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Uint32Field { get { return uint32Field_; } } @@ -1065,6 +1141,7 @@ public RepeatedWellKnownTypes Clone() { private static readonly pb::FieldCodec _repeated_boolField_codec = pb::FieldCodec.ForStructWrapper(130); private readonly pbc::RepeatedField boolField_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField BoolField { get { return boolField_; } } @@ -1074,6 +1151,7 @@ public RepeatedWellKnownTypes Clone() { private static readonly pb::FieldCodec _repeated_stringField_codec = pb::FieldCodec.ForClassWrapper(138); private readonly pbc::RepeatedField stringField_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField StringField { get { return stringField_; } } @@ -1083,14 +1161,17 @@ public RepeatedWellKnownTypes Clone() { private static readonly pb::FieldCodec _repeated_bytesField_codec = pb::FieldCodec.ForClassWrapper(146); private readonly pbc::RepeatedField bytesField_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField BytesField { get { return bytesField_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as RepeatedWellKnownTypes); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(RepeatedWellKnownTypes other) { if (ReferenceEquals(other, null)) { return false; @@ -1116,9 +1197,10 @@ public bool Equals(RepeatedWellKnownTypes other) { if(!boolField_.Equals(other.boolField_)) return false; if(!stringField_.Equals(other.stringField_)) return false; if(!bytesField_.Equals(other.bytesField_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= anyField_.GetHashCode(); @@ -1139,13 +1221,18 @@ public override int GetHashCode() { hash ^= boolField_.GetHashCode(); hash ^= stringField_.GetHashCode(); hash ^= bytesField_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { anyField_.WriteTo(output, _repeated_anyField_codec); apiField_.WriteTo(output, _repeated_apiField_codec); @@ -1165,8 +1252,12 @@ public void WriteTo(pb::CodedOutputStream output) { boolField_.WriteTo(output, _repeated_boolField_codec); stringField_.WriteTo(output, _repeated_stringField_codec); bytesField_.WriteTo(output, _repeated_bytesField_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += anyField_.CalculateSize(_repeated_anyField_codec); @@ -1187,9 +1278,13 @@ public int CalculateSize() { size += boolField_.CalculateSize(_repeated_boolField_codec); size += stringField_.CalculateSize(_repeated_stringField_codec); size += bytesField_.CalculateSize(_repeated_bytesField_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(RepeatedWellKnownTypes other) { if (other == null) { return; @@ -1212,14 +1307,16 @@ public void MergeFrom(RepeatedWellKnownTypes other) { boolField_.Add(other.boolField_); stringField_.Add(other.stringField_); bytesField_.Add(other.bytesField_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { anyField_.AddEntriesFrom(input, _repeated_anyField_codec); @@ -1299,25 +1396,30 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class OneofWellKnownTypes : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneofWellKnownTypes()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestWellKnownTypesReflection.Descriptor.MessageTypes[2]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public OneofWellKnownTypes() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public OneofWellKnownTypes(OneofWellKnownTypes other) : this() { switch (other.OneofFieldCase) { case OneofFieldOneofCase.AnyField: @@ -1376,14 +1478,17 @@ public OneofWellKnownTypes(OneofWellKnownTypes other) : this() { break; } + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public OneofWellKnownTypes Clone() { return new OneofWellKnownTypes(this); } /// Field number for the "any_field" field. public const int AnyFieldFieldNumber = 1; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Any AnyField { get { return oneofFieldCase_ == OneofFieldOneofCase.AnyField ? (global::Google.Protobuf.WellKnownTypes.Any) oneofField_ : null; } set { @@ -1394,6 +1499,7 @@ public OneofWellKnownTypes Clone() { /// Field number for the "api_field" field. public const int ApiFieldFieldNumber = 2; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Api ApiField { get { return oneofFieldCase_ == OneofFieldOneofCase.ApiField ? (global::Google.Protobuf.WellKnownTypes.Api) oneofField_ : null; } set { @@ -1404,6 +1510,7 @@ public OneofWellKnownTypes Clone() { /// Field number for the "duration_field" field. public const int DurationFieldFieldNumber = 3; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Duration DurationField { get { return oneofFieldCase_ == OneofFieldOneofCase.DurationField ? (global::Google.Protobuf.WellKnownTypes.Duration) oneofField_ : null; } set { @@ -1414,6 +1521,7 @@ public OneofWellKnownTypes Clone() { /// Field number for the "empty_field" field. public const int EmptyFieldFieldNumber = 4; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Empty EmptyField { get { return oneofFieldCase_ == OneofFieldOneofCase.EmptyField ? (global::Google.Protobuf.WellKnownTypes.Empty) oneofField_ : null; } set { @@ -1424,6 +1532,7 @@ public OneofWellKnownTypes Clone() { /// Field number for the "field_mask_field" field. public const int FieldMaskFieldFieldNumber = 5; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.FieldMask FieldMaskField { get { return oneofFieldCase_ == OneofFieldOneofCase.FieldMaskField ? (global::Google.Protobuf.WellKnownTypes.FieldMask) oneofField_ : null; } set { @@ -1434,6 +1543,7 @@ public OneofWellKnownTypes Clone() { /// Field number for the "source_context_field" field. public const int SourceContextFieldFieldNumber = 6; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.SourceContext SourceContextField { get { return oneofFieldCase_ == OneofFieldOneofCase.SourceContextField ? (global::Google.Protobuf.WellKnownTypes.SourceContext) oneofField_ : null; } set { @@ -1444,6 +1554,7 @@ public OneofWellKnownTypes Clone() { /// Field number for the "struct_field" field. public const int StructFieldFieldNumber = 7; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Struct StructField { get { return oneofFieldCase_ == OneofFieldOneofCase.StructField ? (global::Google.Protobuf.WellKnownTypes.Struct) oneofField_ : null; } set { @@ -1454,6 +1565,7 @@ public OneofWellKnownTypes Clone() { /// Field number for the "timestamp_field" field. public const int TimestampFieldFieldNumber = 8; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Timestamp TimestampField { get { return oneofFieldCase_ == OneofFieldOneofCase.TimestampField ? (global::Google.Protobuf.WellKnownTypes.Timestamp) oneofField_ : null; } set { @@ -1464,6 +1576,7 @@ public OneofWellKnownTypes Clone() { /// Field number for the "type_field" field. public const int TypeFieldFieldNumber = 9; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Type TypeField { get { return oneofFieldCase_ == OneofFieldOneofCase.TypeField ? (global::Google.Protobuf.WellKnownTypes.Type) oneofField_ : null; } set { @@ -1475,6 +1588,7 @@ public OneofWellKnownTypes Clone() { /// Field number for the "double_field" field. public const int DoubleFieldFieldNumber = 10; private static readonly pb::FieldCodec _oneof_doubleField_codec = pb::FieldCodec.ForStructWrapper(82); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public double? DoubleField { get { return oneofFieldCase_ == OneofFieldOneofCase.DoubleField ? (double?) oneofField_ : (double?) null; } set { @@ -1486,6 +1600,7 @@ public double? DoubleField { /// Field number for the "float_field" field. public const int FloatFieldFieldNumber = 11; private static readonly pb::FieldCodec _oneof_floatField_codec = pb::FieldCodec.ForStructWrapper(90); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public float? FloatField { get { return oneofFieldCase_ == OneofFieldOneofCase.FloatField ? (float?) oneofField_ : (float?) null; } set { @@ -1497,6 +1612,7 @@ public float? FloatField { /// Field number for the "int64_field" field. public const int Int64FieldFieldNumber = 12; private static readonly pb::FieldCodec _oneof_int64Field_codec = pb::FieldCodec.ForStructWrapper(98); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public long? Int64Field { get { return oneofFieldCase_ == OneofFieldOneofCase.Int64Field ? (long?) oneofField_ : (long?) null; } set { @@ -1508,6 +1624,7 @@ public long? Int64Field { /// Field number for the "uint64_field" field. public const int Uint64FieldFieldNumber = 13; private static readonly pb::FieldCodec _oneof_uint64Field_codec = pb::FieldCodec.ForStructWrapper(106); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ulong? Uint64Field { get { return oneofFieldCase_ == OneofFieldOneofCase.Uint64Field ? (ulong?) oneofField_ : (ulong?) null; } set { @@ -1519,6 +1636,7 @@ public ulong? Uint64Field { /// Field number for the "int32_field" field. public const int Int32FieldFieldNumber = 14; private static readonly pb::FieldCodec _oneof_int32Field_codec = pb::FieldCodec.ForStructWrapper(114); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int? Int32Field { get { return oneofFieldCase_ == OneofFieldOneofCase.Int32Field ? (int?) oneofField_ : (int?) null; } set { @@ -1530,6 +1648,7 @@ public int? Int32Field { /// Field number for the "uint32_field" field. public const int Uint32FieldFieldNumber = 15; private static readonly pb::FieldCodec _oneof_uint32Field_codec = pb::FieldCodec.ForStructWrapper(122); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public uint? Uint32Field { get { return oneofFieldCase_ == OneofFieldOneofCase.Uint32Field ? (uint?) oneofField_ : (uint?) null; } set { @@ -1541,6 +1660,7 @@ public uint? Uint32Field { /// Field number for the "bool_field" field. public const int BoolFieldFieldNumber = 16; private static readonly pb::FieldCodec _oneof_boolField_codec = pb::FieldCodec.ForStructWrapper(130); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool? BoolField { get { return oneofFieldCase_ == OneofFieldOneofCase.BoolField ? (bool?) oneofField_ : (bool?) null; } set { @@ -1552,6 +1672,7 @@ public bool? BoolField { /// Field number for the "string_field" field. public const int StringFieldFieldNumber = 17; private static readonly pb::FieldCodec _oneof_stringField_codec = pb::FieldCodec.ForClassWrapper(138); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string StringField { get { return oneofFieldCase_ == OneofFieldOneofCase.StringField ? (string) oneofField_ : (string) null; } set { @@ -1563,6 +1684,7 @@ public string StringField { /// Field number for the "bytes_field" field. public const int BytesFieldFieldNumber = 18; private static readonly pb::FieldCodec _oneof_bytesField_codec = pb::FieldCodec.ForClassWrapper(146); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pb::ByteString BytesField { get { return oneofFieldCase_ == OneofFieldOneofCase.BytesField ? (pb::ByteString) oneofField_ : (pb::ByteString) null; } set { @@ -1595,19 +1717,23 @@ public enum OneofFieldOneofCase { BytesField = 18, } private OneofFieldOneofCase oneofFieldCase_ = OneofFieldOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public OneofFieldOneofCase OneofFieldCase { get { return oneofFieldCase_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void ClearOneofField() { oneofFieldCase_ = OneofFieldOneofCase.None; oneofField_ = null; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as OneofWellKnownTypes); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(OneofWellKnownTypes other) { if (ReferenceEquals(other, null)) { return false; @@ -1624,8 +1750,8 @@ public bool Equals(OneofWellKnownTypes other) { if (!object.Equals(StructField, other.StructField)) return false; if (!object.Equals(TimestampField, other.TimestampField)) return false; if (!object.Equals(TypeField, other.TypeField)) return false; - if (DoubleField != other.DoubleField) return false; - if (FloatField != other.FloatField) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseNullableDoubleEqualityComparer.Equals(DoubleField, other.DoubleField)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseNullableSingleEqualityComparer.Equals(FloatField, other.FloatField)) return false; if (Int64Field != other.Int64Field) return false; if (Uint64Field != other.Uint64Field) return false; if (Int32Field != other.Int32Field) return false; @@ -1634,9 +1760,10 @@ public bool Equals(OneofWellKnownTypes other) { if (StringField != other.StringField) return false; if (BytesField != other.BytesField) return false; if (OneofFieldCase != other.OneofFieldCase) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (oneofFieldCase_ == OneofFieldOneofCase.AnyField) hash ^= AnyField.GetHashCode(); @@ -1648,8 +1775,8 @@ public override int GetHashCode() { if (oneofFieldCase_ == OneofFieldOneofCase.StructField) hash ^= StructField.GetHashCode(); if (oneofFieldCase_ == OneofFieldOneofCase.TimestampField) hash ^= TimestampField.GetHashCode(); if (oneofFieldCase_ == OneofFieldOneofCase.TypeField) hash ^= TypeField.GetHashCode(); - if (oneofFieldCase_ == OneofFieldOneofCase.DoubleField) hash ^= DoubleField.GetHashCode(); - if (oneofFieldCase_ == OneofFieldOneofCase.FloatField) hash ^= FloatField.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.DoubleField) hash ^= pbc::ProtobufEqualityComparers.BitwiseNullableDoubleEqualityComparer.GetHashCode(DoubleField); + if (oneofFieldCase_ == OneofFieldOneofCase.FloatField) hash ^= pbc::ProtobufEqualityComparers.BitwiseNullableSingleEqualityComparer.GetHashCode(FloatField); if (oneofFieldCase_ == OneofFieldOneofCase.Int64Field) hash ^= Int64Field.GetHashCode(); if (oneofFieldCase_ == OneofFieldOneofCase.Uint64Field) hash ^= Uint64Field.GetHashCode(); if (oneofFieldCase_ == OneofFieldOneofCase.Int32Field) hash ^= Int32Field.GetHashCode(); @@ -1658,13 +1785,18 @@ public override int GetHashCode() { if (oneofFieldCase_ == OneofFieldOneofCase.StringField) hash ^= StringField.GetHashCode(); if (oneofFieldCase_ == OneofFieldOneofCase.BytesField) hash ^= BytesField.GetHashCode(); hash ^= (int) oneofFieldCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (oneofFieldCase_ == OneofFieldOneofCase.AnyField) { output.WriteRawTag(10); @@ -1729,8 +1861,12 @@ public void WriteTo(pb::CodedOutputStream output) { if (oneofFieldCase_ == OneofFieldOneofCase.BytesField) { _oneof_bytesField_codec.WriteTagAndValue(output, (pb::ByteString) oneofField_); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (oneofFieldCase_ == OneofFieldOneofCase.AnyField) { @@ -1787,40 +1923,71 @@ public int CalculateSize() { if (oneofFieldCase_ == OneofFieldOneofCase.BytesField) { size += _oneof_bytesField_codec.CalculateSizeWithTag(BytesField); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(OneofWellKnownTypes other) { if (other == null) { return; } switch (other.OneofFieldCase) { case OneofFieldOneofCase.AnyField: - AnyField = other.AnyField; + if (AnyField == null) { + AnyField = new global::Google.Protobuf.WellKnownTypes.Any(); + } + AnyField.MergeFrom(other.AnyField); break; case OneofFieldOneofCase.ApiField: - ApiField = other.ApiField; + if (ApiField == null) { + ApiField = new global::Google.Protobuf.WellKnownTypes.Api(); + } + ApiField.MergeFrom(other.ApiField); break; case OneofFieldOneofCase.DurationField: - DurationField = other.DurationField; + if (DurationField == null) { + DurationField = new global::Google.Protobuf.WellKnownTypes.Duration(); + } + DurationField.MergeFrom(other.DurationField); break; case OneofFieldOneofCase.EmptyField: - EmptyField = other.EmptyField; + if (EmptyField == null) { + EmptyField = new global::Google.Protobuf.WellKnownTypes.Empty(); + } + EmptyField.MergeFrom(other.EmptyField); break; case OneofFieldOneofCase.FieldMaskField: - FieldMaskField = other.FieldMaskField; + if (FieldMaskField == null) { + FieldMaskField = new global::Google.Protobuf.WellKnownTypes.FieldMask(); + } + FieldMaskField.MergeFrom(other.FieldMaskField); break; case OneofFieldOneofCase.SourceContextField: - SourceContextField = other.SourceContextField; + if (SourceContextField == null) { + SourceContextField = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + } + SourceContextField.MergeFrom(other.SourceContextField); break; case OneofFieldOneofCase.StructField: - StructField = other.StructField; + if (StructField == null) { + StructField = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + StructField.MergeFrom(other.StructField); break; case OneofFieldOneofCase.TimestampField: - TimestampField = other.TimestampField; + if (TimestampField == null) { + TimestampField = new global::Google.Protobuf.WellKnownTypes.Timestamp(); + } + TimestampField.MergeFrom(other.TimestampField); break; case OneofFieldOneofCase.TypeField: - TypeField = other.TypeField; + if (TypeField == null) { + TypeField = new global::Google.Protobuf.WellKnownTypes.Type(); + } + TypeField.MergeFrom(other.TypeField); break; case OneofFieldOneofCase.DoubleField: DoubleField = other.DoubleField; @@ -1851,14 +2018,16 @@ public void MergeFrom(OneofWellKnownTypes other) { break; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { global::Google.Protobuf.WellKnownTypes.Any subBuilder = new global::Google.Protobuf.WellKnownTypes.Any(); @@ -1984,29 +2153,34 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// A map field for each well-known type. We only - /// need to worry about the value part of the map being the - /// well-known types, as messages can't be map keys. + /// A map field for each well-known type. We only + /// need to worry about the value part of the map being the + /// well-known types, as messages can't be map keys. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class MapWellKnownTypes : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MapWellKnownTypes()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestWellKnownTypesReflection.Descriptor.MessageTypes[3]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MapWellKnownTypes() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MapWellKnownTypes(MapWellKnownTypes other) : this() { anyField_ = other.anyField_.Clone(); apiField_ = other.apiField_.Clone(); @@ -2026,8 +2200,10 @@ public MapWellKnownTypes(MapWellKnownTypes other) : this() { boolField_ = other.boolField_.Clone(); stringField_ = other.stringField_.Clone(); bytesField_ = other.bytesField_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MapWellKnownTypes Clone() { return new MapWellKnownTypes(this); } @@ -2035,8 +2211,9 @@ public MapWellKnownTypes Clone() { /// Field number for the "any_field" field. public const int AnyFieldFieldNumber = 1; private static readonly pbc::MapField.Codec _map_anyField_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Any.Parser), 10); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Any.Parser), 10); private readonly pbc::MapField anyField_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField AnyField { get { return anyField_; } } @@ -2044,8 +2221,9 @@ public MapWellKnownTypes Clone() { /// Field number for the "api_field" field. public const int ApiFieldFieldNumber = 2; private static readonly pbc::MapField.Codec _map_apiField_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Api.Parser), 18); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Api.Parser), 18); private readonly pbc::MapField apiField_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField ApiField { get { return apiField_; } } @@ -2053,8 +2231,9 @@ public MapWellKnownTypes Clone() { /// Field number for the "duration_field" field. public const int DurationFieldFieldNumber = 3; private static readonly pbc::MapField.Codec _map_durationField_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Duration.Parser), 26); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Duration.Parser), 26); private readonly pbc::MapField durationField_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField DurationField { get { return durationField_; } } @@ -2062,8 +2241,9 @@ public MapWellKnownTypes Clone() { /// Field number for the "empty_field" field. public const int EmptyFieldFieldNumber = 4; private static readonly pbc::MapField.Codec _map_emptyField_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Empty.Parser), 34); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Empty.Parser), 34); private readonly pbc::MapField emptyField_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField EmptyField { get { return emptyField_; } } @@ -2071,8 +2251,9 @@ public MapWellKnownTypes Clone() { /// Field number for the "field_mask_field" field. public const int FieldMaskFieldFieldNumber = 5; private static readonly pbc::MapField.Codec _map_fieldMaskField_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.FieldMask.Parser), 42); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.FieldMask.Parser), 42); private readonly pbc::MapField fieldMaskField_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField FieldMaskField { get { return fieldMaskField_; } } @@ -2080,8 +2261,9 @@ public MapWellKnownTypes Clone() { /// Field number for the "source_context_field" field. public const int SourceContextFieldFieldNumber = 6; private static readonly pbc::MapField.Codec _map_sourceContextField_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.SourceContext.Parser), 50); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.SourceContext.Parser), 50); private readonly pbc::MapField sourceContextField_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField SourceContextField { get { return sourceContextField_; } } @@ -2089,8 +2271,9 @@ public MapWellKnownTypes Clone() { /// Field number for the "struct_field" field. public const int StructFieldFieldNumber = 7; private static readonly pbc::MapField.Codec _map_structField_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Struct.Parser), 58); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Struct.Parser), 58); private readonly pbc::MapField structField_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField StructField { get { return structField_; } } @@ -2098,8 +2281,9 @@ public MapWellKnownTypes Clone() { /// Field number for the "timestamp_field" field. public const int TimestampFieldFieldNumber = 8; private static readonly pbc::MapField.Codec _map_timestampField_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Timestamp.Parser), 66); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Timestamp.Parser), 66); private readonly pbc::MapField timestampField_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField TimestampField { get { return timestampField_; } } @@ -2107,8 +2291,9 @@ public MapWellKnownTypes Clone() { /// Field number for the "type_field" field. public const int TypeFieldFieldNumber = 9; private static readonly pbc::MapField.Codec _map_typeField_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Type.Parser), 74); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Type.Parser), 74); private readonly pbc::MapField typeField_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField TypeField { get { return typeField_; } } @@ -2116,8 +2301,9 @@ public MapWellKnownTypes Clone() { /// Field number for the "double_field" field. public const int DoubleFieldFieldNumber = 10; private static readonly pbc::MapField.Codec _map_doubleField_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForStructWrapper(18), 82); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForStructWrapper(18), 82); private readonly pbc::MapField doubleField_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField DoubleField { get { return doubleField_; } } @@ -2125,8 +2311,9 @@ public MapWellKnownTypes Clone() { /// Field number for the "float_field" field. public const int FloatFieldFieldNumber = 11; private static readonly pbc::MapField.Codec _map_floatField_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForStructWrapper(18), 90); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForStructWrapper(18), 90); private readonly pbc::MapField floatField_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField FloatField { get { return floatField_; } } @@ -2134,8 +2321,9 @@ public MapWellKnownTypes Clone() { /// Field number for the "int64_field" field. public const int Int64FieldFieldNumber = 12; private static readonly pbc::MapField.Codec _map_int64Field_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForStructWrapper(18), 98); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForStructWrapper(18), 98); private readonly pbc::MapField int64Field_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField Int64Field { get { return int64Field_; } } @@ -2143,8 +2331,9 @@ public MapWellKnownTypes Clone() { /// Field number for the "uint64_field" field. public const int Uint64FieldFieldNumber = 13; private static readonly pbc::MapField.Codec _map_uint64Field_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForStructWrapper(18), 106); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForStructWrapper(18), 106); private readonly pbc::MapField uint64Field_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField Uint64Field { get { return uint64Field_; } } @@ -2152,8 +2341,9 @@ public MapWellKnownTypes Clone() { /// Field number for the "int32_field" field. public const int Int32FieldFieldNumber = 14; private static readonly pbc::MapField.Codec _map_int32Field_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForStructWrapper(18), 114); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForStructWrapper(18), 114); private readonly pbc::MapField int32Field_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField Int32Field { get { return int32Field_; } } @@ -2161,8 +2351,9 @@ public MapWellKnownTypes Clone() { /// Field number for the "uint32_field" field. public const int Uint32FieldFieldNumber = 15; private static readonly pbc::MapField.Codec _map_uint32Field_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForStructWrapper(18), 122); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForStructWrapper(18), 122); private readonly pbc::MapField uint32Field_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField Uint32Field { get { return uint32Field_; } } @@ -2170,8 +2361,9 @@ public MapWellKnownTypes Clone() { /// Field number for the "bool_field" field. public const int BoolFieldFieldNumber = 16; private static readonly pbc::MapField.Codec _map_boolField_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForStructWrapper(18), 130); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForStructWrapper(18), 130); private readonly pbc::MapField boolField_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField BoolField { get { return boolField_; } } @@ -2179,8 +2371,9 @@ public MapWellKnownTypes Clone() { /// Field number for the "string_field" field. public const int StringFieldFieldNumber = 17; private static readonly pbc::MapField.Codec _map_stringField_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForClassWrapper(18), 138); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForClassWrapper(18), 138); private readonly pbc::MapField stringField_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField StringField { get { return stringField_; } } @@ -2188,16 +2381,19 @@ public MapWellKnownTypes Clone() { /// Field number for the "bytes_field" field. public const int BytesFieldFieldNumber = 18; private static readonly pbc::MapField.Codec _map_bytesField_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForClassWrapper(18), 146); + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8, 0), pb::FieldCodec.ForClassWrapper(18), 146); private readonly pbc::MapField bytesField_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField BytesField { get { return bytesField_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as MapWellKnownTypes); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(MapWellKnownTypes other) { if (ReferenceEquals(other, null)) { return false; @@ -2223,9 +2419,10 @@ public bool Equals(MapWellKnownTypes other) { if (!BoolField.Equals(other.BoolField)) return false; if (!StringField.Equals(other.StringField)) return false; if (!BytesField.Equals(other.BytesField)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= AnyField.GetHashCode(); @@ -2246,13 +2443,18 @@ public override int GetHashCode() { hash ^= BoolField.GetHashCode(); hash ^= StringField.GetHashCode(); hash ^= BytesField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { anyField_.WriteTo(output, _map_anyField_codec); apiField_.WriteTo(output, _map_apiField_codec); @@ -2272,8 +2474,12 @@ public void WriteTo(pb::CodedOutputStream output) { boolField_.WriteTo(output, _map_boolField_codec); stringField_.WriteTo(output, _map_stringField_codec); bytesField_.WriteTo(output, _map_bytesField_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += anyField_.CalculateSize(_map_anyField_codec); @@ -2294,9 +2500,13 @@ public int CalculateSize() { size += boolField_.CalculateSize(_map_boolField_codec); size += stringField_.CalculateSize(_map_stringField_codec); size += bytesField_.CalculateSize(_map_bytesField_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(MapWellKnownTypes other) { if (other == null) { return; @@ -2319,14 +2529,16 @@ public void MergeFrom(MapWellKnownTypes other) { boolField_.Add(other.boolField_); stringField_.Add(other.stringField_); bytesField_.Add(other.bytesField_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { anyField_.AddEntriesFrom(input, _map_anyField_codec); diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/UnknownFieldSetTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/UnknownFieldSetTest.cs new file mode 100644 index 000000000000..438b2ece36ed --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/UnknownFieldSetTest.cs @@ -0,0 +1,194 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.IO; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class UnknownFieldSetTest + { + [Test] + public void EmptyUnknownFieldSet() + { + UnknownFieldSet unknownFields = new UnknownFieldSet(); + Assert.AreEqual(0, unknownFields.CalculateSize()); + } + + [Test] + public void MergeUnknownFieldSet() + { + UnknownFieldSet unknownFields = new UnknownFieldSet(); + UnknownField field = new UnknownField(); + field.AddFixed32(123); + unknownFields.AddOrReplaceField(1, field); + UnknownFieldSet otherUnknownFields = new UnknownFieldSet(); + Assert.IsFalse(otherUnknownFields.HasField(1)); + UnknownFieldSet.MergeFrom(otherUnknownFields, unknownFields); + Assert.IsTrue(otherUnknownFields.HasField(1)); + } + + [Test] + public void TestMergeCodedInput() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var emptyMessage = new TestEmptyMessage(); + emptyMessage.MergeFrom(message.ToByteArray()); + Assert.AreEqual(message.CalculateSize(), emptyMessage.CalculateSize()); + Assert.AreEqual(message.ToByteArray(), emptyMessage.ToByteArray()); + + var newMessage = new TestAllTypes(); + newMessage.MergeFrom(emptyMessage.ToByteArray()); + Assert.AreEqual(message, newMessage); + Assert.AreEqual(message.CalculateSize(), newMessage.CalculateSize()); + } + + [Test] + public void TestMergeMessage() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var emptyMessage = new TestEmptyMessage(); + var otherEmptyMessage = new TestEmptyMessage(); + emptyMessage.MergeFrom(message.ToByteArray()); + otherEmptyMessage.MergeFrom(emptyMessage); + + Assert.AreEqual(message.CalculateSize(), otherEmptyMessage.CalculateSize()); + Assert.AreEqual(message.ToByteArray(), otherEmptyMessage.ToByteArray()); + } + + [Test] + public void TestEquals() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var emptyMessage = new TestEmptyMessage(); + var otherEmptyMessage = new TestEmptyMessage(); + Assert.AreEqual(emptyMessage, otherEmptyMessage); + emptyMessage.MergeFrom(message.ToByteArray()); + Assert.AreNotEqual(emptyMessage.CalculateSize(), + otherEmptyMessage.CalculateSize()); + Assert.AreNotEqual(emptyMessage, otherEmptyMessage); + } + + [Test] + public void TestHashCode() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var emptyMessage = new TestEmptyMessage(); + int hashCode = emptyMessage.GetHashCode(); + emptyMessage.MergeFrom(message.ToByteArray()); + Assert.AreNotEqual(hashCode, emptyMessage.GetHashCode()); + } + + [Test] + public void TestClone() + { + var emptyMessage = new TestEmptyMessage(); + var otherEmptyMessage = new TestEmptyMessage(); + otherEmptyMessage = emptyMessage.Clone(); + Assert.AreEqual(emptyMessage.CalculateSize(), otherEmptyMessage.CalculateSize()); + Assert.AreEqual(emptyMessage.ToByteArray(), otherEmptyMessage.ToByteArray()); + + var message = SampleMessages.CreateFullTestAllTypes(); + emptyMessage.MergeFrom(message.ToByteArray()); + otherEmptyMessage = emptyMessage.Clone(); + Assert.AreEqual(message.CalculateSize(), otherEmptyMessage.CalculateSize()); + Assert.AreEqual(message.ToByteArray(), otherEmptyMessage.ToByteArray()); + } + + [Test] + public void TestDiscardUnknownFields() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var goldenEmptyMessage = new TestEmptyMessage(); + byte[] data = message.ToByteArray(); + int fullSize = message.CalculateSize(); + + Action assertEmpty = msg => + { + Assert.AreEqual(0, msg.CalculateSize()); + Assert.AreEqual(goldenEmptyMessage, msg); + }; + + Action assertFull = msg => Assert.AreEqual(fullSize, msg.CalculateSize()); + + // Test the behavior of the parsers with and without discarding, both generic and non-generic. + MessageParser retainingParser1 = TestEmptyMessage.Parser; + MessageParser retainingParser2 = retainingParser1; + MessageParser discardingParser1 = retainingParser1.WithDiscardUnknownFields(true); + MessageParser discardingParser2 = retainingParser2.WithDiscardUnknownFields(true); + + // Test parse from byte[] + assertFull(retainingParser1.ParseFrom(data)); + assertFull(retainingParser2.ParseFrom(data)); + assertEmpty(discardingParser1.ParseFrom(data)); + assertEmpty(discardingParser2.ParseFrom(data)); + + // Test parse from byte[] with offset + assertFull(retainingParser1.ParseFrom(data, 0, data.Length)); + assertFull(retainingParser2.ParseFrom(data, 0, data.Length)); + assertEmpty(discardingParser1.ParseFrom(data, 0, data.Length)); + assertEmpty(discardingParser2.ParseFrom(data, 0, data.Length)); + + // Test parse from CodedInputStream + assertFull(retainingParser1.ParseFrom(new CodedInputStream(data))); + assertFull(retainingParser2.ParseFrom(new CodedInputStream(data))); + assertEmpty(discardingParser1.ParseFrom(new CodedInputStream(data))); + assertEmpty(discardingParser2.ParseFrom(new CodedInputStream(data))); + + // Test parse from Stream + assertFull(retainingParser1.ParseFrom(new MemoryStream(data))); + assertFull(retainingParser2.ParseFrom(new MemoryStream(data))); + assertEmpty(discardingParser1.ParseFrom(new MemoryStream(data))); + assertEmpty(discardingParser2.ParseFrom(new MemoryStream(data))); + } + + [Test] + public void TestReadInvalidWireTypeThrowsInvalidProtocolBufferException() + { + MemoryStream ms = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(ms); + + uint tag = WireFormat.MakeTag(1, (WireFormat.WireType)6); + output.WriteRawVarint32(tag); + output.WriteLength(-1); + output.Flush(); + ms.Position = 0; + + CodedInputStream input = new CodedInputStream(ms); + Assert.AreEqual(tag, input.ReadTag()); + + Assert.Throws(() => UnknownFieldSet.MergeFieldFrom(null, input)); + } + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs index f21be7d9b9e4..4b9a56939540 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs @@ -42,7 +42,7 @@ public void Pack() { var message = SampleMessages.CreateFullTestAllTypes(); var any = Any.Pack(message); - Assert.AreEqual("type.googleapis.com/protobuf_unittest.TestAllTypes", any.TypeUrl); + Assert.AreEqual("type.googleapis.com/protobuf_unittest3.TestAllTypes", any.TypeUrl); Assert.AreEqual(message.CalculateSize(), any.Value.Length); } @@ -51,7 +51,7 @@ public void Pack_WithCustomPrefix() { var message = SampleMessages.CreateFullTestAllTypes(); var any = Any.Pack(message, "foo.bar/baz"); - Assert.AreEqual("foo.bar/baz/protobuf_unittest.TestAllTypes", any.TypeUrl); + Assert.AreEqual("foo.bar/baz/protobuf_unittest3.TestAllTypes", any.TypeUrl); Assert.AreEqual(message.CalculateSize(), any.Value.Length); } @@ -60,7 +60,7 @@ public void Pack_WithCustomPrefixTrailingSlash() { var message = SampleMessages.CreateFullTestAllTypes(); var any = Any.Pack(message, "foo.bar/baz/"); - Assert.AreEqual("foo.bar/baz/protobuf_unittest.TestAllTypes", any.TypeUrl); + Assert.AreEqual("foo.bar/baz/protobuf_unittest3.TestAllTypes", any.TypeUrl); Assert.AreEqual(message.CalculateSize(), any.Value.Length); } @@ -90,13 +90,41 @@ public void Unpack_CustomPrefix_Success() Assert.AreEqual(message, unpacked); } + [Test] + public void TryUnpack_WrongType() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var any = Any.Pack(message); + Assert.False(any.TryUnpack(out TestOneof unpacked)); + Assert.Null(unpacked); + } + + [Test] + public void TryUnpack_RightType() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var any = Any.Pack(message); + Assert.IsTrue(any.TryUnpack(out TestAllTypes unpacked)); + Assert.AreEqual(message, unpacked); + } + [Test] public void ToString_WithValues() { var message = SampleMessages.CreateFullTestAllTypes(); var any = Any.Pack(message); var text = any.ToString(); - Assert.That(text, Is.StringContaining("\"@value\": \"" + message.ToByteString().ToBase64() + "\"")); + Assert.That(text, Does.Contain("\"@value\": \"" + message.ToByteString().ToBase64() + "\"")); + } + + [Test] + [TestCase("proto://foo.bar", "foo.bar")] + [TestCase("/foo/bar/baz", "baz")] + [TestCase("foobar", "")] + public void GetTypeName(string typeUrl, string expectedTypeName) + { + var any = new Any { TypeUrl = typeUrl }; + Assert.AreEqual(expectedTypeName, Any.GetTypeName(typeUrl)); } [Test] @@ -112,5 +140,18 @@ public void ToString_MessageContainingAny() var message = new TestWellKnownTypes { AnyField = new Any() }; Assert.AreEqual("{ \"anyField\": { \"@type\": \"\", \"@value\": \"\" } }", message.ToString()); } + + [Test] + public void IsWrongType() + { + var any = Any.Pack(SampleMessages.CreateFullTestAllTypes()); + Assert.False(any.Is(TestOneof.Descriptor)); + } + + public void IsRightType() + { + var any = Any.Pack(SampleMessages.CreateFullTestAllTypes()); + Assert.True(any.Is(TestAllTypes.Descriptor)); + } } } diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs index 89bc82759c59..5dc5035703eb 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs @@ -30,7 +30,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion - +using System; +using Google.Protobuf.TestProtos; using NUnit.Framework; namespace Google.Protobuf.WellKnownTypes @@ -46,8 +47,8 @@ public void ToString_Invalid(string input) var mask = new FieldMask { Paths = { input } }; var text = mask.ToString(); // More specific test below - Assert.That(text, Is.StringContaining("@warning")); - Assert.That(text, Is.StringContaining(input)); + Assert.That(text, Does.Contain("@warning")); + Assert.That(text, Does.Contain(input)); } [Test] @@ -58,5 +59,187 @@ public void ToString_Invalid_Precise() "{ \"@warning\": \"Invalid FieldMask\", \"paths\": [ \"x\", \"foo__bar\", \"x\\\\y\" ] }", mask.ToString()); } + + [Test] + public void IsValid() + { + Assert.IsTrue(FieldMask.IsValid("payload")); + Assert.IsFalse(FieldMask.IsValid("nonexist")); + Assert.IsTrue(FieldMask.IsValid("payload.single_int32")); + Assert.IsTrue(FieldMask.IsValid("payload.repeated_int32")); + Assert.IsTrue(FieldMask.IsValid("payload.single_nested_message")); + Assert.IsTrue(FieldMask.IsValid("payload.repeated_nested_message")); + Assert.IsFalse(FieldMask.IsValid("payload.nonexist")); + + Assert.IsTrue(FieldMask.IsValid(FieldMask.FromString("payload"))); + Assert.IsFalse(FieldMask.IsValid(FieldMask.FromString("nonexist"))); + Assert.IsFalse(FieldMask.IsValid(FieldMask.FromString("payload,nonexist"))); + + Assert.IsTrue(FieldMask.IsValid(NestedTestAllTypes.Descriptor, "payload")); + Assert.IsFalse(FieldMask.IsValid(NestedTestAllTypes.Descriptor, "nonexist")); + + Assert.IsTrue(FieldMask.IsValid(NestedTestAllTypes.Descriptor, FieldMask.FromString("payload"))); + Assert.IsFalse(FieldMask.IsValid(NestedTestAllTypes.Descriptor, FieldMask.FromString("nonexist"))); + + Assert.IsTrue(FieldMask.IsValid("payload.single_nested_message.bb")); + + // Repeated fields cannot have sub-paths. + Assert.IsFalse(FieldMask.IsValid("payload.repeated_nested_message.bb")); + + // Non-message fields cannot have sub-paths. + Assert.IsFalse(FieldMask.IsValid("payload.single_int32.bb")); + } + + [Test] + [TestCase(new string[] { }, "\"\"")] + [TestCase(new string[] { "foo" }, "\"foo\"")] + [TestCase(new string[] { "foo", "bar" }, "\"foo,bar\"")] + [TestCase(new string[] { "", "foo", "", "bar", "" }, "\",foo,,bar,\"")] + public void ToString(string[] input, string expectedOutput) + { + FieldMask mask = new FieldMask(); + mask.Paths.AddRange(input); + Assert.AreEqual(expectedOutput, mask.ToString()); + } + + [Test] + [TestCase("", new string[] { })] + [TestCase("foo", new string[] { "foo" })] + [TestCase("foo,bar.baz", new string[] { "foo", "bar.baz" })] + [TestCase(",foo,,bar,", new string[] { "foo", "bar" })] + public void FromString(string input, string[] expectedOutput) + { + FieldMask mask = FieldMask.FromString(input); + Assert.AreEqual(expectedOutput.Length, mask.Paths.Count); + for (int i = 0; i < expectedOutput.Length; i++) + { + Assert.AreEqual(expectedOutput[i], mask.Paths[i]); + } + } + + [Test] + public void FromString_Validated() + { + // Check whether the field paths are valid if a class parameter is provided. + Assert.DoesNotThrow(() => FieldMask.FromString(",payload")); + Assert.Throws(() => FieldMask.FromString("payload,nonexist")); + } + + [Test] + [TestCase(new int[] { }, new string[] { })] + [TestCase(new int[] { TestAllTypes.SingleInt32FieldNumber }, new string[] { "single_int32" })] + [TestCase(new int[] { TestAllTypes.SingleInt32FieldNumber, TestAllTypes.SingleInt64FieldNumber }, new string[] { "single_int32", "single_int64" })] + public void FromFieldNumbers(int[] input, string[] expectedOutput) + { + FieldMask mask = FieldMask.FromFieldNumbers(input); + Assert.AreEqual(expectedOutput.Length, mask.Paths.Count); + for (int i = 0; i < expectedOutput.Length; i++) + { + Assert.AreEqual(expectedOutput[i], mask.Paths[i]); + } + } + + [Test] + public void FromFieldNumbers_Invalid() + { + Assert.Throws(() => + { + int invalidFieldNumber = 1000; + FieldMask.FromFieldNumbers(invalidFieldNumber); + }); + } + + [Test] + [TestCase(new string[] { }, "\"\"")] + [TestCase(new string[] { "foo" }, "\"foo\"")] + [TestCase(new string[] { "foo", "bar" }, "\"foo,bar\"")] + [TestCase(new string[] { "", "foo", "", "bar", "" }, "\",foo,bar\"")] + public void Normalize(string[] input, string expectedOutput) + { + FieldMask mask = new FieldMask(); + mask.Paths.AddRange(input); + FieldMask result = mask.Normalize(); + Assert.AreEqual(expectedOutput, result.ToString()); + } + + [Test] + public void Union() + { + // Only test a simple case here and expect + // {@link FieldMaskTreeTest#AddFieldPath} to cover all scenarios. + FieldMask mask1 = FieldMask.FromString("foo,bar.baz,bar.quz"); + FieldMask mask2 = FieldMask.FromString("foo.bar,bar"); + FieldMask result = mask1.Union(mask2); + Assert.AreEqual(2, result.Paths.Count); + Assert.Contains("bar", result.Paths); + Assert.Contains("foo", result.Paths); + Assert.That(result.Paths, Has.No.Member("bar.baz")); + Assert.That(result.Paths, Has.No.Member("bar.quz")); + Assert.That(result.Paths, Has.No.Member("foo.bar")); + } + + [Test] + public void Union_UsingVarArgs() + { + FieldMask mask1 = FieldMask.FromString("foo"); + FieldMask mask2 = FieldMask.FromString("foo.bar,bar.quz"); + FieldMask mask3 = FieldMask.FromString("bar.quz"); + FieldMask mask4 = FieldMask.FromString("bar"); + FieldMask result = mask1.Union(mask2, mask3, mask4); + Assert.AreEqual(2, result.Paths.Count); + Assert.Contains("bar", result.Paths); + Assert.Contains("foo", result.Paths); + Assert.That(result.Paths, Has.No.Member("foo.bar")); + Assert.That(result.Paths, Has.No.Member("bar.quz")); + } + + [Test] + public void Intersection() + { + // Only test a simple case here and expect + // {@link FieldMaskTreeTest#IntersectFieldPath} to cover all scenarios. + FieldMask mask1 = FieldMask.FromString("foo,bar.baz,bar.quz"); + FieldMask mask2 = FieldMask.FromString("foo.bar,bar"); + FieldMask result = mask1.Intersection(mask2); + Assert.AreEqual(3, result.Paths.Count); + Assert.Contains("foo.bar", result.Paths); + Assert.Contains("bar.baz", result.Paths); + Assert.Contains("bar.quz", result.Paths); + Assert.That(result.Paths, Has.No.Member("foo")); + Assert.That(result.Paths, Has.No.Member("bar")); + } + + [Test] + public void Merge() + { + // Only test a simple case here and expect + // {@link FieldMaskTreeTest#Merge} to cover all scenarios. + FieldMask fieldMask = FieldMask.FromString("payload"); + NestedTestAllTypes source = new NestedTestAllTypes + { + Payload = new TestAllTypes + { + SingleInt32 = 1234, + SingleFixed64 = 4321 + } + }; + NestedTestAllTypes destination = new NestedTestAllTypes(); + fieldMask.Merge(source, destination); + Assert.AreEqual(1234, destination.Payload.SingleInt32); + Assert.AreEqual(4321, destination.Payload.SingleFixed64); + + destination = new NestedTestAllTypes + { + Payload = new TestAllTypes + { + SingleInt32 = 4321, + SingleInt64 = 5678 + } + }; + fieldMask.Merge(source, destination); + Assert.AreEqual(1234, destination.Payload.SingleInt32); + Assert.AreEqual(5678, destination.Payload.SingleInt64); + Assert.AreEqual(4321, destination.Payload.SingleFixed64); + } } } diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs index 9ecd24c62a5b..ffc60419242d 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs @@ -99,7 +99,7 @@ public void Arithmetic() Duration difference = new Duration { Seconds = 1999, Nanos = Duration.NanosecondsPerSecond - 5000 }; Assert.AreEqual(difference, t1 - t2); Assert.AreEqual(-difference, t2 - t1); - + Assert.AreEqual(t1, t2 + difference); Assert.AreEqual(t2, t1 - difference); } @@ -111,5 +111,106 @@ public void ToString_NonNormalized() var duration = new Timestamp { Seconds = 1, Nanos = -1 }; Assert.AreEqual("{ \"@warning\": \"Invalid Timestamp\", \"seconds\": \"1\", \"nanos\": -1 }", duration.ToString()); } + + [Test] + public void Comparability() + { + Timestamp + a = null, + b = new Timestamp { Seconds = 1, Nanos = 1 }, + c = new Timestamp { Seconds = 1, Nanos = 10 }, + d = new Timestamp { Seconds = 10, Nanos = 1 }, + e = new Timestamp { Seconds = 10, Nanos = 10 }; + + Assert.IsTrue(b.CompareTo(a) > 0); // null is always first (according to default behavior of Array.Sort) + Assert.IsTrue(b.CompareTo(b) == 0); + Assert.IsTrue(b.CompareTo(b.Clone()) == 0); + Assert.IsTrue(b.CompareTo(c) < 0); + Assert.IsTrue(b.CompareTo(d) < 0); + Assert.IsTrue(b.CompareTo(e) < 0); + + Assert.IsTrue(c.CompareTo(a) > 0); + Assert.IsTrue(c.CompareTo(b) > 0); + Assert.IsTrue(c.CompareTo(c) == 0); + Assert.IsTrue(c.CompareTo(c.Clone()) == 0); + Assert.IsTrue(c.CompareTo(d) < 0); + Assert.IsTrue(c.CompareTo(e) < 0); + + Assert.IsTrue(d.CompareTo(a) > 0); + Assert.IsTrue(d.CompareTo(b) > 0); + Assert.IsTrue(d.CompareTo(c) > 0); + Assert.IsTrue(d.CompareTo(d) == 0); + Assert.IsTrue(d.CompareTo(d.Clone()) == 0); + Assert.IsTrue(d.CompareTo(e) < 0); + + Assert.IsTrue(e.CompareTo(a) > 0); + Assert.IsTrue(e.CompareTo(b) > 0); + Assert.IsTrue(e.CompareTo(c) > 0); + Assert.IsTrue(e.CompareTo(d) > 0); + Assert.IsTrue(e.CompareTo(e) == 0); + Assert.IsTrue(e.CompareTo(e.Clone()) == 0); + } + + + [Test] + public void ComparabilityOperators() + { + Timestamp + a = null, + b = new Timestamp { Seconds = 1, Nanos = 1 }, + c = new Timestamp { Seconds = 1, Nanos = 10 }, + d = new Timestamp { Seconds = 10, Nanos = 1 }, + e = new Timestamp { Seconds = 10, Nanos = 10 }; + +#pragma warning disable CS1718 // Comparison made to same variable + Assert.IsTrue(b > a); + Assert.IsTrue(b == b); + Assert.IsTrue(b == b.Clone()); + Assert.IsTrue(b < c); + Assert.IsTrue(b < d); + Assert.IsTrue(b < e); + + Assert.IsTrue(c > a); + Assert.IsTrue(c > b); + Assert.IsTrue(c == c); + Assert.IsTrue(c == c.Clone()); + Assert.IsTrue(c < d); + Assert.IsTrue(c < e); + + Assert.IsTrue(d > a); + Assert.IsTrue(d > b); + Assert.IsTrue(d > c); + Assert.IsTrue(d == d); + Assert.IsTrue(d == d.Clone()); + Assert.IsTrue(d < e); + + Assert.IsTrue(e > a); + Assert.IsTrue(e > b); + Assert.IsTrue(e > c); + Assert.IsTrue(e > d); + Assert.IsTrue(e == e); + Assert.IsTrue(e == e.Clone()); + + Assert.IsTrue(b >= a); + Assert.IsTrue(b <= c); + Assert.IsTrue(b <= d); + Assert.IsTrue(b <= e); + + Assert.IsTrue(c >= a); + Assert.IsTrue(c >= b); + Assert.IsTrue(c <= d); + Assert.IsTrue(c <= e); + + Assert.IsTrue(d >= a); + Assert.IsTrue(d >= b); + Assert.IsTrue(d >= c); + Assert.IsTrue(d <= e); + + Assert.IsTrue(e >= a); + Assert.IsTrue(e >= b); + Assert.IsTrue(e >= c); + Assert.IsTrue(e >= d); +#pragma warning restore CS1718 // Comparison made to same variable + } } } diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs index 5b7185dcd2db..8a9c3d0c685f 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs @@ -135,7 +135,7 @@ public void RepeatedWrappersSerializeDeserialize() DoubleField = { 12.5, -1.5, 0d }, FloatField = { 123.25f, -20f, 0f }, Int32Field = { int.MaxValue, int.MinValue, 0 }, - Int64Field = { long.MaxValue, long.MinValue, 0L }, + Int64Field = { long.MaxValue, long.MinValue, 0L }, StringField = { "First", "Second", "" }, Uint32Field = { uint.MaxValue, uint.MinValue, 0U }, Uint64Field = { ulong.MaxValue, ulong.MinValue, 0UL }, @@ -403,7 +403,7 @@ public void UnknownFieldInWrapper() output.Flush(); stream.Position = 0; - + var message = TestWellKnownTypes.Parser.ParseFrom(stream); Assert.AreEqual(6, message.Int32Field); } @@ -417,5 +417,16 @@ public void ClearWithReflection() TestWellKnownTypes.Descriptor.Fields[TestWellKnownTypes.StringFieldFieldNumber].Accessor.Clear(message); Assert.IsNull(message.StringField); } + + [Test] + public void NaNComparisons() + { + var message1 = new TestWellKnownTypes { DoubleField = SampleNaNs.Regular }; + var message2 = new TestWellKnownTypes { DoubleField = SampleNaNs.PayloadFlipped }; + var message3 = new TestWellKnownTypes { DoubleField = SampleNaNs.Regular }; + + EqualityTester.AssertInequality(message1, message2); + EqualityTester.AssertEquality(message1, message3); + } } } diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/packages.config b/third_party/protobuf/csharp/src/Google.Protobuf.Test/packages.config deleted file mode 100644 index c76539928c3a..000000000000 --- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/testprotos.pb b/third_party/protobuf/csharp/src/Google.Protobuf.Test/testprotos.pb new file mode 100644 index 0000000000000000000000000000000000000000..bc3979e965ef354b8491b637c3ca441bb1050365 GIT binary patch literal 205207 zcmeFa33Qytb?4jP*NyGNLg3>Df+G2;xsxDBf)qtj5@jq+5)?Ky08!KiHGl@#B!Gs{ zfGEgzyu^0o*iN3Eu^lI|b7Cj4$95)`*Vs;!%*6ZdN#-5D%&`;OaXjywtS`@bnQ;=o z->vOy08NQbCVB77ka8-w{G1EUcVvOy*yu7TFRG}#tU-`#l@xZh2@Fa z!sPhEVsWW>qC@=&Th*V5<>~P?snffIjl(KKpUORuFO_mL`LH4I@~vLv9jMBB`R*O> z_1n%Di!-zNj$wfXsACkCiYQ(Dr^cWYJbJ zh@!69*+|8eqQ!hEzxYIcsw0T5EG;dR&Kx~Dm46~XTU>xq$BZuRWO44Osyc-@LaC(? zM}r{B=BEm!rNzR;@=~EVALZt!qUBPa;zXt5^5SG(g-jIYbBimgT&4EtdSU5GR9sYl zi_4UAt~gbgE==YGp*_ki<|8=INn1=s@O+{$#gC;cxh4LQ+Re@uuNUTLqRHa?R6#P8 zBojFKr85*s{yVg$V5O)yZA&y+oXSUY%cUi1zLcY+f|{EsK9L8}NGyovi%W&cd^?ea zQZ!2)1)-cHHCdsDsNj?slhxANKOHs&&}mUFuF79zBLcF zjZ<AiEgm1rU_Jp~~aqx}37p#UvPA?Aup^Z+H3C3-idqjN^nLBfuzD#5$>KPioob5Y*VKllh)Zd%QjznF9y@U>qX8XFwMu)N^L6q(qA!}O2 zbPZmPG7k)AGb1C>P&Vot81C-_4ft%=;AmfFq&?~z?CBrt?HfGb9)S=I4vhv;f8Rjg zDCtIr+7;XN`J$n7(Lg5Ka{-vH?!NxM(aVbAxxUdsVRmjP8$?~va94J;uV<{kD;o`u zWrv4GGLh7*w{N7UzpHN`)7t@mct)A~GlQei$c3){{?!!?qM=KJnXHt)yqZyWhEjHQ z_h*C^tS(6=pGyCQ-bRo9L;32W5c6;LxTrtu4O)!#WRd$%U27f!i(a8JvuPV_dFZ*7nTnOL2cmqVKSY#Resfm$vuhN zgSx=4-K&2FfuBl*seLj>1wk^E@WSN2+U-GokV+-|M3~&~H3p4Al@O^gwcp#fBWTcM zl|)usihTQPYAuz7s&AO6=DTOI4c@ddxMj@*dz15U+s#bl=^a7ix@mgKPSaC|E(d{* z&de{*h1-Lze5ADLcxG^HV0>&)b@y|8?9GX=iKII6+|W>SO&Q(Ym2IwFML*bF_k1gW zpKXy9z@Ee@FZksqwF21l!V2Jp6~I4tCGx@wV6O1O3gCqmzzZvY&aZiH32=?AKyiN6 z3gBK96y2X&oXQi=$g(Do1T~E;Wz@3f zNaAR`tT|GBjM8w9;dEt)$0osvZeqB{L;mSQQ^dCLxykf;-Wi;40S)nF+Sp4iZA5<;AG34Ict z^ld_4;#@+?cbiL?B;jo?VUmQmZD<}&xJB99f8Pr>S8SayRBctR7CF)OoC~=0`?drP z(k3V(MpqW{rSR6Ep+vLJ=Eu=xoai)*v3ecWCqb)|oI2U+qgF{~<0Pj}hP#7CgR-n) zlB8+O8t5?h>|Pc+CUo5*0WcIg}VaN6yp=c;%sXpNouo!E^Id;WhkODnxAQH zB1xS^8Bt+nrI}dai*MaPng&~%ZV3t}g3U$*^Yozn)cBlMwzY<&t?%s6L&mD!sI+Xh zuXPNnY(_X?X@Z$7G{olCH$$oK9+iH)({`q2WWW^m^2Dz?&5C z{`J5{A=$BN%VLYYDlohpgsVl9X9v@|8RVwU!|RbxRFaEqda}*sLQ&hGp}+`g+)6}Y zZ&BF0Dq)+7E4-FfvQU6oS5_kkg|}7V?OBhvS_%r(6jF;oVa^A)nED&-t%0^Zq)o~A z$c@n}=y0>!G-QP+`DhpO3we}iQ)b-S6(!O2HrmiWHFB*<#-|vOEV(L~{xyJYv~@`V-AB^uHAz7|9JDx8H?Hj`?S`yl=SH^mi2*)9;^wu9K`s})9^Vd< z(vL;2N4WC(n=$SX>Abl9W|U)waV1sb++mW{W*cmv8tKZ>%vje>vbq?}jCSRv)8pL{ z(lx}T(<9z=u+`#^uNm`>k^aXY^EO+!)uZ0SL92~$U%CBsjw?ntGwyA%7;8qp@v>U1 z`7S#Z_)U*}uK4=XHv?|?NU+JWwqjCa$_dba%<(U@Kw3a*a2W|4Und=fe^TK;?-;nz zVwMez;r(T0HbPODw<*k<8wXuswK!B^7lWOaoju7~BlA;A=0E0GxZQ$Q8Vz>`4aNC< zk;5@P)D#(Q8!sfX^(xeiT@%43ooG!*UQk2xk2!e*9xAle{n!=6e0-0CUFQnoRvNlo zOQb6MZHZ~e4( zqGNrwtj-jk32GK{E3EIP)JnR(GpdxooMF~x2nWjMJza#P>PRR4vPJENGfGi^6%el2jai{6VG zt;)Mx5wSbGnewgy?2_^_kro%^FgQ1B`iblgS%}$C-9tuo50DX(-9Yhr*K8qI3eN^r zPvmBo^+A2pjRhsyE^+ACyS#9}q|fSX=^rM8tFcuPLE+s&ofJUF%f7a$^LeM7I7fIcXfT~ZBgm$=zVl}0 z^Huq1p)Fan0%&q7JYQb$A^_b(fjh_?ilKRe*H~P9&YrA5Z`M?Ok zZX)#vWCGicR+#mQMWb%p@l(8j9nB|T~_^0M?o;aSiCNUbSj-!k7*rECkmIx)bLByL`x z801*=dSsd+rLR(&7P4DtTYs~G&Xdkl>5S;z7TV;~io$7<)v9EHu7KJ?_XakR8a`%7 z^!&qqIf{%$>GxFW1>D%YhSpt<23R%$YdT#b+h}8Sw_B66tmCatsvE%OwHqMY`4U;j z&~!gqYgOX14!9=q8ss&duq?6ZhULg>I^vqdAhW=B#aP=J6IoY8+a1>>FYAzNlY@RV zXmRN4I%Oj3Si5eyK0{f@T$ce3<;}CYbCxxa?w;jxS<^wwk1_S1?g zEnqI1PlrJ>WY25?9FyIIjfgGmq74J2o2_6BqNo@|ij$dJSX!|eUg-r*rhK+oEEksY zPwIspYZCe0c6+c%FS*vFXbvWQWG@@9H1RG$$}$ zqO$7HLPc*4He$z@={rBT#&(GVNE;!ViBwn?AR3CQ)d3GSS06IlHo-052!#iNJ)>wo zwBF-V-{^($-mzg_pfyZugA~k;qX*#^T#lD3LUd%Oi|lOn+gJ%4dOKnjS;wnH_Di=Y zjw9GXj$|q+TpEH}6WP`LVuWO=?&e?rev+zLx~KVr&%C@k-0T8+oBzgXV#0DS9vlUCy{lcAEXBYf|zQTp& zowfY$tlfkG8kYYQAa%k&ofLC4p~N^X*cyD-3#x^bivhQ%TH5}=qa;XC@luzE(i7=u zI#=NS5f*-v#kmEs3#1gPtjD<}G?`Nu%9i8?(KPq*xDzDzegXtBTV#tAJ(1)75;jTd zGSXBefaEXEt6IrLq?!DDeo+pU$tU>~HXKH&)W3G4SPR=V$a-#1_8BQb@Yr(rx zH7>bF^1HAWw8vt`M}a`0?fauP|g%c_mm-}K)MI{Y_-=*di-r|TsSh_GoS+Ys!5NN zou5GNJ*#XodsIhNNhy2J)>g5U6uE@SUaT!OibwnP`aR0{QsO}AbtodiUWej=((6zt zWX9iaP<&7_ey>IGLCN^`qKh!h)M5LmitU4vp+34S5a%395|nd(X1ht51m&DV5qY0; zC`rlaP>}U`hmr#2ynoK3q(C|EP(;?}9ZCw6^A3fC7aU3zC>Q+m7Ntr>+8R}Xa>1cg zfpWp2RENnvpSw1yvelsU`4=ooH7I?)wUn&}r7vhTwXFuFZ~HAqE;V8DqC=?x<)Ytb zFBR2*a?zpGfO65H)PQo)p)dyD>&y2couC$!d;Nd*?Ad2fHigN{{#k>v36#tJ1Ges)K)Fmob-qoYT;6xuQlMPE^X}kwRin*e z>S6zp18oPnBrsi=XKrTBcDCilP)VC`Y9)ys={LjiVgIs~(`Gn6>~|O*o8kCKHOFkK z+?(O}$lm>C?${D0AM+10cUb+Z{oJ=OVm{_R+bwjn$C@@8h%Epc0lqDZ0;J$Tb^%gwAiDr5IFKkzUUeW5AXgno1jtp_*&;x$y3Q5> za@B#{8YZtfkXr${=0I)*;Yun z$z%^8^A2Qhm|XA&O&8h=$btje%h<9|Z)dT+fGiw4Z&L!YaPNQ_6ZeJ5#~sK%KpuA> z`v7^o-Yy3B0rL2<3kGB#Adfqc{b6#^A2w0@0a2cKvz~kmX|; z19=dTWe0L7Og`bNa|n%n5^IOcOWV{%E>a!|lRuHN z%YY*k?k7^}T9-tT?I$oA(?vZ(wx2j?7ZV*}@@0-&2i#ufxOI^2WsX}1*X1z{^q-d}4Scz*aB7e$bi=wgEx>ZBI#?vc&&-cJ0KwsK}RLM7NG0<$^h-IIm zvHURgwC5i;k+Ok<)GH3p_d$BvtJm8YNRXcPcDCEZAU*9JJqD7`X0`ftUg8ZN$30YD zQohcsl?7}nlW-svzT6S_nGWBM!N~uQF70J|FJiRl}cO->WeO5@C z?=4=djInZ^lALcvy&*h=(xmc9AtY(v>NU&PCTXF5K29rHA#GY6>(Wx#x5a5i4v;o2 z8V^X7)@RdQ{YzfrmrXa|GfMrEd;`)aQgvbK?NSpFU#brAz1^#CQ1XBxWjP6^B6V67 z+0<;(O1<9h#iU9LsnaS7t1pprs!rGpG%ulZ{@Ei!Z}X~?@g<^oaslX4N~v&YE`49 zs-z$Ns^=e5{Rj#PLcYt>Iu!!=1_{vJACkg~{bJV=`6SG|s-!3D}$9ag``OZ*1q zJX2Oq6sj0iM`$!>=;yhahy!fws_`#WoZr6`O%Q(#UFQl8hSb$!X)AORsrPubQSegQ zs#=QpKDv5aQK>K$l3Xb+;$J|tk1?oRXzqNp^E6Jnj<<^@)%bS0Uf>%;fsD%~(Iw*) zY3a&hK95T%bedZGImZ@A?B7vw%J+zB7IDe91$$%y|Mz%l)rOq<+(maWx{N4|wQmq{vXPf&5J~#t}d>5}-$6NHTxGLyIQe6cRQckTFiWVvQ8} z89THiI7O}vt3To;K1P?=UDhS$lrg)S!mya< zs{8fg;x)OWE^UtvDD@FruUe_sM?LOnOTC~d3*<*ky$GOQ1n7D}lKG<^ADGk&lCpf% z;}*AwuP&_qxR>~CBR-TwsgGMWb;9NoR(w#ff&92(LjY_D&}<;d{0S>QNZ5SBicfv> zpS1HM6j+d-FybQs@e!cK2MN|EWmuOYLxS~5JwN)45Y^9miQh9tmOU<3KAnbHZM$OLFyNHYJfw^e_~kg)k(Z&wuD%LKq`SX;#PMJJD7pIl1 zkT$K3b!p-Gd9&akr%Wx7RR&ke@Ok;LH7<*jFT}Vqxj{{!LUl}t{ftnlTmMGu?p=x2&z-OegcH-M3~)a|QYmF)W%$wk&* z^Lz}V5fT)UkZP49Buu~N-6|RtNlWC{Jsc3|v?5SQHS9NS8bBKyytuO=}f zB`c&&t798QIVrdZ^bbt06Nc zDRHT$%$m+ccSpzWv>aqc0@IN&{D#-q6kK6osSm5a=_S5T3qGh@(5%GOX<6iMrj(t% z$vK!h0ehlQoXxSxS?l8?h)PSW06FvG#|l0x_1K6uIrUAiR+NmXRK2wKx9mUz#RvfT zP48A|REb7r1n7YVlFZ+-0}UiC^)0&)ua`#sV~_I~8E2uug8Y_Q1`q%i0ksBN`pX}C zb$Y)*ELeXmVkTn*~Tn+iho*tF!)v}%dwSa?{u>KRTX{&*j9`q+(n;ce1 z9ihJM`Dug2*-SO$pO{gOXxf?py*7gc>)T$7o~a;J?npEtf<=G(uIKCh1C%CJlS(8t z{H`p(wD6=ie%C{{Y)Fv4>m3rMqacy?Pd)#TiIh_sNQ=ZN4P?Fgwj?b`f9he%t&upV zfjn@~AW{DBc}Ck^@5@OIq(!P$v26NvR_TP_^R^zaBuL-$4!0YmnlSZeo`2Fr%4rRx zMXCYm&pfmt8c7xpf9ADySQ4Z^^NybgUgy!D8^Y>8_Y(h|{`}JDQeL~@ROiO{l*H#F z+j2D+;h|F;NSghNIzivh(urLu9zxAIvs&t@lWe?ta)@nCx~K9_O6I9NyP`RC&=G!6 z@q}4;O1sHa@TSXi^pW~=JLxq@m;Vb{GfUTkqB}tTx#dREuug);f$mKcNL5Zae%Z$QQ zG&Xwf$Y~Q((o+z}f2o)IwQ3umYLX(pg3hlb0YwoZU#`~*5{+aD(BC5@nP1`8>5(6j zBEG^mTlWoN^{f2EYkaN2;e0UlD!*2LUK@nXt9^4S4#n68smC@*n7rCI<1HjvU+sr_ z(1e7^tHpFd#N8ZLKkX-e+A!hxF!i+0XDF@OEKFYOvm}yMg`zHyPiuXK1i*#>{S8Bs z`L%wn)*wK_=C!`+A%3a_4U?bv8N;T9l&`lUYY{eYuxy}U1NnL*G6G;jfMx?p<~LY2 zkg$1!uoUIBn5qwmB&UjOn&06Mjo7T zrrzx1;!DK7QP{l2b|EO(K)#tBvwSWDz=i<3$`{;uz`G=sSN?JAwbs#lFYwgYXb?JU$C{=99F;GPyDiB!^vmr?Y1_X zh0Qx`ZJ=NS`F2wq0$@Xct_>ua-(hP537dD=+H47{f5lI{%dp`*H1#V!>TeO+7Gd*F zpHE-j!`q%x$`{_hYx)UkQ zyWNd*f|~ku>ANyDZAD36{chiXpRcDTXrkZk*Ve02ZIx2J$4}`m4~jxSYMmn_Y2V{B zX-T_6Qi%8Xn{+SODwEH@_fuNq3`JH*{e?rSSWZxMRvC@|y|2}dATjs8*H7tHFBGF9 zq#hL^$@*U3jEazCeXq}`c$BKQq9pMXzw3LQx2{^a>mg8IThnV6Gx%{7oce%Ys}~Th zQr%~K|BNaX6r&QPE;A%mc*f@>Ov(&N)@S@p+JFU;ay;X6_+etvDnH{Nx$K{`gVsQ+-x zNEY=Uju|Ck^x>FMQW$+WW(4v_Vn(v&hqR1j&Hs^@k*xVY5;H=b59!(nWfr8X5$YwO zT^j-Q(U_5J2_P*a*%Ev-W+YpJkH(B-OYqT{Q5B3n8Z)XAMjwqC(Z4?yGm;$xq-BI{ z7bHjQx>01u@G+kQSVO|-V=<#@7=0{eR4t4?7BgZ)@mnz?*-$`QMwov=I!3ag_^p@` z24Ij*bTu>(Z}bF#4^S5wRbS8Ht4$q-BJK7$isax(cEm{J77#v>{>i@t6_zzL2hs zYK76qV@4bSd?IEfMr4qd5k_Q?j*%z`KM^y+j11D%s18P-h#A!hqff+)Q0;#*W+ZlI zkd_g4W{_@V5VhVX;|~@~Gst~*WC&pN$(T_fj6NANst;4Y9WxSBG)T(`Q#45T9f|hf zx8q)iF&d;}R1c%yjv3Vpqu-7hHH4|(i5ZEt8l+`}wHhS$2f9&Y&-Oe1CVe2->NmjX zcVb2jF#4UCQG+o0otRN0O3s*(7_>oJMvZj-XMM9FZuMoo{H(v#c5h7DAYF|bVf1Xw zs8JX_D~#UYG5Bvo>FFo_GxOfdaE-c3W#bf^X4i`XR5WwL@zweEh-WvHen)o1GE>Om zMKp%%R?ZfT!&EbY+;!wE`a46Y(}lHG%%b+jKq&S5zB!fICR59&eE)7GP$;ATsigpk zxIbk(5F}YYWxqX0r0^;Kpgy93L<*ns+wW3Si;zg+Q~r@V)zq?02JuhFjAUwow2WkG z`E<-krj}2~jAUy0bj(PmmQTlw)YS6nm=SD06El*j1=2E-spT`ar*2b|_Gj$32MMFk z#EfKW`Ap16O)Z~^8Ikz2F(a8;AT1-AT0R>ylBwmhF(a8;J{vQVspYdVBQ>>rHf99! z=VC@OwLn@%GPQgzW+YR~=VC@OwR|pSBvZ@hVn%9e`CQBhsL#iYWNLx5jAUy0e9TCu zme0qGWNP_*%t)q|&&Q0^)bjb55ntCAVn#BxKw3sJwS2*j_}hG$TE5_8z9rv0B#gcg zGm@$03o#=#wR|CF#MJV|n2}5^kd~25Enkco$<*@2n2}5^UyK>a)bhock(ye*7&9XF zOEDvvS|BYWnOeSNNBnKROf6sXF$2>zs)f;)Vn#Bxd?{w6rj{?ojF?)!95a%s1=2E- zspZQtBbi#h95a%s<;yW6nOeRaGg4E_mt#guEnkTl$W+YP! zq-7*i%h&DHvQ14bU-!4#?k!Wx*JDO9wR}Bhq^6dyYesBh!sT;r`$msr`77A9=WK~q0bELROK$t zOkgLX(#ho;IVO@BXeQ4|k~$g}Gb+wH)SFWZ`%bm_x537xfZgYaHLy%}&Q4{jFeT^o zXoqHI%-chgSMrnB(9gs*PY`rq(3>h&5Va{PwB??7;m5(bff zB*Hiz^$4a?J>^h7p^Abfhw$yuRe3K;R8l;fB1TR*Q8+v1GGT#WnahOrN4`g76lUKexDEWD~6GDAN^b9SNIn z#&wiQ^qX-VWxD#NzweNmVcUfI7HkZX%tw$GN#>((#RZo6=v#4tWj^|rAVsRcWc{}9 zA889Iurgm*S5BFPNMg}t68d(GE|bu=V|1B>zU}YR=Lc;v1%C&0Q%;#>AT5&2GT*T} zHqwIh9e<-OH@@{Ffc>kuwN!5y0U#)(GbG0Xt_BqlOeO^*cB{ zAfr;1VY>{0Iz}RPqQ3XJ`6uf*?2#d`9+QY&DDM4)wm-tg7=nm>fnSXtn1GPJ>epNE@b4iZ<%4#;tRZJNkZQFP5agjEP6QmrY z(UeUS9S?3MRj1Z>?xqZ{N@99(jJ~;B&Rt%U^k17ywnb6D;jJBjxb1;0it1P70N^#r zU}tcOBNRyK-cKh}+uQct2tc2JIT$&VQ2FT3WPD9BLZfGb=+Ok}JB}(1%$`oN_i-s` zji-}nwvR~hxx`rg`lSD}6o1EB?#h_MF_j^WB8c84Z_F7h);4#H$a-z_L_;+UT=%+c|9o;ovwNW7M-KJm5igBV-|Esa3 z>gA#3=oDL+Q0~-Cqn|n{Xtv}Q-G*9pmSdD-T>s(S36b{mm3>6z(f`I}FApt8r|g1G z*{g3F{nSZ8D=)jI^}jsIuuusW$s6-I39ftH=6^x*IQR+_OGssh{lH4zpFV(i`e>T zhom=j=(&m$tzxpR4?gGnnriuuy(0-IcTP0W^6D% z)x;H9edp2VX>bLseXVKaCVwi~^SeEYca*34qrbMhxzt@OZg@q%5NXCd*W|7ur1zW*w zyMD}LpltNbkY1xU0HVYzLE)mFCkkqqVOO*2eUlc2fBW+YT7jL@S&hxN=Cs9fS{>Q; zq9CMbDw`)fG^x%Tdk+t(3(Mj`r_5oDCIlHrxm& z9s<|lG*`fBF2`}bt$YA1mu^)B1iu`iE7)jzeA!6%d=Oqa#Mz)32s?zWt3+*uBGi`W z*B!ompjwAfR{^809HUGS@i6s#wP+|uU`b{L;YOqi0LRO}{HD(Bl|~?N1fm>$F4%6- zR}VSss%l#7bUB}!^MD?YA?bUyLs?jkEKe9M7(UT!W!pSHms?O{S$*Zwo3&=PMiPUN z{;$Tbp&3C53McjYRgDeK>9SsN-*`;cm+r_e%UCtMt{RhNwki*8n^FT|dC-l7b!xS+ zp8tu6GEu$O50tm(5zO<&@vc;_D@ak8<48#+#~aRKWm%+3$5rvNDyxC$G~0!nh3JeS zI`O|*=TIy3#2e2+I-|z=aWbZV14l{H{9X8R&50l$y3xMM?AIzhUuLqpHdgJYtK}AE zDy$5gb!9;<^!4WIX2Hv+Si5txJFMJ|cUZSo`ew_kEoEOf|7N9smWPIAEU3V;u7TcW z-873;)3ak?LoJIE*lYJ%H^pMz?5$XohnBOD<-M+j-f-PCi&c}mV_`$XndjPd-Eh3H zolsh%!t9@Q+ak9rSjC9Sm_3Ktdfhyu)eD4}kqZy!o_qgw$IbLGyLzyH^*2&+6Sj(- zw34lv-h}-a?A9zcvN5|jrtHI9vlF}753_tVVn0k17Cw5z?br?XlI1<2Prih*l}dK) zo@}i0p6vL|G|8$pOm@}A?16P#9K9>Mq0(Soq1~z?yLz8<{kirzdV6-)%@kfqro!SP z`@&|2HwV{mx?b4qte43Po1F?B<$vmC=YOef#@~CvF0+R3Db6qD3iF&*$T-)7&Afg( zCFGu=oKBmy^xc(4vgd*5kY%}97z=1 zM=uX&#>ESLBK=IIs%NoqPb#e2`>jcS5QFdg@D8cV-EG9^{l4Fr0oW^lQp~$*vRqn<033D@aKXT zS}Zhd0-GDhwd%YY2em~U+A6z`lDXn)4=K4^s_vGGcM;xq=R|qAu%z6yPGdzO`(OHV z5K)NPyqxW+J9nIVUy&E#1(gg73&ln38pR|13FWO-dy;i5Qw#2A%)0VeJjr5ZqkdFlwd8V>iH?Ea%E|0p>*cx z(J6fJ&K4JNMA3m^32ZtzA3drHG+CTI!XA*vKT1af@me=kD4~YN;!}JT$SoSIZKU|6 z;_@OMCe*!}!h8;wzEZAIyT15~u;mIj2BHDoW2!JM{v|-*A`TLPGcVJL-yV3r;K2R` z2lg*Guz$gU{b(k7!GZlh(}BHl{JzE;yz$U}AhFAMXg`FV);3Izu=+TXxW{X2R90Y2 z;JF1c_p|QRkJR!a4+bq_7L)8Sx9TCVitF%?SeJ3!z$MbU7{o{<+0iB!`^DEChAGL8 z&JzZOsG|-=j24gj9Vbmn9HtRzQLw;D9(5>KTqTb>6hBNJb0}hyc+5X)QMmU;q(#B3 zD|xKV`bfnFF?r0PKpb}{Vvl&-KW0(zr$D4d!BQr9+@WBNm^|)KaP!ycP{i)A(?4!e za0NxAMZxSa+38TQI!tyt6kO?@a42GPc*5_rC{>`Ga447@CQmpNOns6k9100fIutQm zKk1*aDELqy(v}6Q_2kJm>i|%^U7vI)c)PyMp@>a7ltsaR0+AL4ll0_m4n@3O-{w&8 zc74jBh{5?O|2B(K3(6^ng1ve26i(UEl5BWl_Z2_1z9dyj|bjX8lczx9htd3f`{I`uCWY z7H`*Q{kttnGbm^A+Nk9z-mcF^cUTIPvv-|UrkGf#btQT{HG0YT(ZxL?=>g(?DcNl< zA47oN?RRNE@Q|Q)8xQVKyr4)< zP~^LJlP)q8#k$wHtxrl#`yGl5**KinZtIByrQe~5$on0N4B7plU?Yob#nez@M2Suu zD<+4k8l;T)KctMq8bAo5hVkV{p@d?XAI6|kCnV}Vmryv}=MrL_o4n5@gvh#tQu?e* z$Q9{imV{!qOGU;KdEJ^aGLLcJU&NM@BHeFBE(p@y?~iGJvyfEye$$_!$alZ_Dxj$F z{buA6*PF>p4n@Rv$-iHZT*QHL$)QMPE;$qt+a-rWfgf-vGSlHP-J-}$_kcqYh7XwU zoGuB<0}ch^vO|%X4v*;;MP|Co4n;c9Wrrd&-DQWuO!uHe5&1pnU$!VR(>>@=M4k^i z6q)HBbSTVp4>=T>=^pYQv?wyuJ>*birhCYt$V~T;Lm}bA4n=0Vhy8~vip+EmI~1Ae z9yW7SO0H)mA9g6rbdNX`ndu(!AGRnm(>>x)WTtz>p~y`4h(lqfd(@%GO!uh&h((c^ z?oo##Gu@+Rj!OA5(>>}?nCZsND4J3;-MIg#MUk0q+@Z)!H||hmrW-e-Xv*hZhsPX> z%yf_W<9ZY&4wT0nip+G6xn3tT-D3`gnJ(v0WTwmck69F%>2eN5X1bi2=~8N@%Q+Ng zx(SCOGu?!rvnVptO*j;p=_brfmy*j&$q9$TOgHIJWTu<+CoGE0bdwH6X1Yl;yQF-X z=_VZtGu@P#T~fZxbW{GMMUk0q%FHfAf-+@h7bsAsm|dnAF)&0gB<8)g2hh>v@mRK8 znq6skiXR>aGCET2GmwXY(2_=?U5t2PNiKEZZB5-zLM5cF%8S#eL{J_n18_5hORq1~ z%B-JCv3dwoSN&Q2A`cXCSC#vUYKfDP>Kgu!dXaL*JRu+M-rjbNkGwQEo zkydk8+Ei3N%*Uyyln!s9VRBLX=+mA?Q;YuNdJ91u4YX)x87T5CZqoA@6s23dWrwps z|JczWHYqQZN_c71O2d$+ghkPWjf@UX?+yhWn#dFe$tjWM* zoA!BYgOJ382R~H5R`#YRkz>jW!J=nh&gLnNLzEzG*X<)o4!u|^dIAhU94p;mWuO={g7OwL{T2{a?rvohd|m8m>UNQ zOa-aK>2OC-S3GX5nuS;0g+#Wtc-)vLZx8rwGK*lVh^;9e*Lm?wsKG_SJU^pqQJ2*W z%kp=c{M9PINB+*3H`f((X6Z+D7d&`(>b%{lz%L$G|8}PD(^gPYK@pvZSDt}0EY)w^ zR@Ym(p{Q1ZB%8`VS(r-y94^v^#83Y~esM-*#i>&KdNTD?RCqS1 z*4L;MV14JFb-kh-guz4H*^}GkYU6^E4&$`Sd(yPD_oPtrnMr$iE8R6_P&zagG?b4& zI06d?Gv~WT`|dYy70Zjw%?ZNm&hce;a}033`G>2X9UdsmFPA7(vkm=`cLOi$Nnrgz++)&$8S89jBZG{(p)y{bcvx1|pGJuHVRrHen>Eid^d60gJc z8&4LpW=JGLqr%%!7&L zZW+~?hE9kt$B9Kbr%>OFI)`|C8BcG_!&5=$FM1pt$wgR|gRPeRf=c>oEG{0YTC`Na z<*zyFkz*o#)`QntHN9{HSvG0B53bLRRuq?O`GuuOod$6%#&u_26J!iln>&?DJ13I~ z6v-3L^)tS{X$q>mv_8qyiIAAqYZI-(6HLgg4;m6JUfWeInuxjV3`ba;Kbd=@bVodl zFHg*_9MPRm*I5{?Py!Bj^2~Ug!I{gatWnI3XgR})y43k>siWKc?J<+LOu`MuW1M<= zvC(fXe|oWzYnI}skvMsnu_?8oN-a|qP2Q%4t-<^GEM;eSIC0eL{CO`LlGh()LXM7~ zIHL}zIG>sJ+VRMw?2H$Vi0qH5d?ik^ScA>pQ<%CNC!Y9&zit3e9J@m! z%8}O$r%}rjtIoOXF_-Nl7LR;E=V7xy0+MEs{8zU1Xc&f-pVM&n)h$US~%5WTcK zad+j!-Q#76>8zz3=XhN=NSqs=(5XTGBacT1=L+&9rk0X&jLZi}51G^*KZq{op2%?t z6p#0EQ=TrlR4n2Fz9@Zpg2T@hdaSuej-z?y^qm&Z$;lvtr+Unu{yKtBczZzjV@c~Y z>seE!LFMyQ%^{TqF@EfLEQwof%iqCyr+t-CFQlJPix&3mTv?QEcetv>s03Iuw(|g` z(H0QZj?cANchIh10YsBP)RC0ZbqJv-dGbNM&cMfXq}eJNAUaY?_d`O-*1>XGCluX5 z$A%WAJ3!BLJaJpBXF6W1-?Bqrgi@Cx$<>1Nw|-Uzihb#cy`npAjPC5=!mXl^{Mm9K{RNjB33S4wfo@~FvaPWo0$s?zO zw~AXKlx1fUcY2*a?U|9O^Z38`o9;Xw@SMnGQJzw@+A;MJJT&E&vv)5oF6SSSQ}>5P zR+vENI))}n#aTS;KBBsiQp}t|MJ8$~+VSqhi?muwy2ahN5EpF|?SWD;rSxG!5Ovn{ zA1JDMc8k)n5l7TLrjI}a}HXZ{_Y26_N zJ*Fqs&2mVqQP znN6N=)Xy|R!QuQ4y?2C?eC>K?3k8Ss9bJY)QYvx&=!*;oF#A&atRboNgMF#Lco?cJGC+yl3EVoK~&@cMZO{2!y1ah4xy5e zZvuTvHgQ>h6H?zSu297TL6xi+M*Xp5TUwsL63Y^%1ogI)tk(iQTc~QO^~idzRDMT-@@gI#EjZQV09WC1s8T>#kW$r{=LflJ~;eMQpkZ z%D0Xwh*=ih&?s%X0(5jehoxIVUZ|3TbJ1))RI8s_Lqo-Tj(BR9u@Qo9G~+*{kFp@? zMl+@xL6L7pxwchF=|(fmGolEr#^Y?NVD)uSq%80{j&xLcS|@omWffx5Gq0Lg*@%+3 z`c3L9QP1ckubMZbt7Q#vEv27_gCN^AGu1$m?V33RgQ6tY=+K%Q#JqVTx7wG(gn3sk zA2&Wk)*5y)63^Fdwv=Qv&T6a0$Jl~j(jO%hDHmLQ7#AOR1!I_i(sN+78hIag1(T8Y zaaS-BE;=#bs0T_957lZoU36lQ;dBu($RLCVw(E(P=s`%7{MR`Kx`R^n8wLt@DgtJOjr5D#$^v`wg}qs4p@k3#lNmsdyo`v#fS+CwktUD zkdX|E!mXGwh*yNdZ0N_({=T>`Eqm%BH~sHL1PF=pizKQWF( z7W)0AS9tUW@%UUTPH|o-F9m9EEYNh|S9$>&G-hE)x=ZROJy!SP%0|)nZz157o;Za! zLCkmrY5)2v4In=$j^14g)`>sq;gQ;+lHgV4sC0p90)EmHm)9DVZXju5RC)pdWvFxp z0u(A$5$DxE<@rBttD>A&|CFaDL87H1PkSl-qzM%0kh&v7g3VKe+ND1v$WP0=ZZb&K z(j`)_^^D(ZDCRy$n^lVSTKgObv1EO%w`sG}-2b2d-4DdM88)bHkI#nQDqpM?-&m>I zoqBp8XgSADx7Q^c$uEVcgVZ#E=*Z-b=N_v-u$ekm=NJ}MR959k|7j}NSRuBeny@vf z5qG9+;EjsVl3MY)ke{DIxw3+;FnOR(6t6ZUJRG#>r=`c^z*f2MRh4bl5$M=V_Hci& z;X04Ql_wS78CBUP2`)?66Ev8H0{P zZPFPnjdHcRw8FvQldTP+mChO}{qbr!gRy;EHABTNc4ttfmU?tB>B%=K1D$8J5cRFk zn*=BmVpmYF7vH)^NMEk+eEvQa=uGRols=pJal6z5!3NhK#uvr*-FPKBx~@gmh_xeQ z`%zZ1Wt$w1qQl-GP}2vW*W|3ZO}bu6Lo&mxLC)5xjA$fgIn}ehhu&Jbr_tt;+o-Y5lvcAu8E)l2J1R?l)fv4i<%jeIa z$R1Cf7gceTqbLU1s@dE`epVf$HFX|dC%Z}uYD*@6k!nUAReI`?RJGD7Fq+=QDvvH-GRUMv=WdhaFshk$-ud2Wt z_@o*=IeJtA zxkc7JG}PZ*>o7+~vwef-o9i6r`RvfxaC6`g1~MZfUFS2+^)5yC<y=EJv61SWm23*>xzabxr(T zKiF7d`B9O{J=Q=&&z=X@u@E5DVb>1r+J{K_3PO)^>sJs0v9^%mBkRU=J?)*USb{ao zxfY0j8FRdUb7Q-#)7FmdcLpu%fNpkpPqQm&y^(M#iaH+Yq&ee}?#}pA))Kt6q6kzY ztQBMW-CnSz@=CE{88~3q4q(k{Y5kNmkVlU+wMO1qldF6Z*JZ7++|%pUbtT2o%;t*V z6$`o}2nzFP+w_u31Xh==Qz0@ytHD!g z7u3rZ$}kT(Pq@ml@la7@-6$l|+l8mhE-fP~wIps>jBJ zw*?zj4y)(GAIL1`FEW$3lC?;R0rO<9l&HjNZ->fey(*7$8IyXCb9Zr^tD9F^Hwl0; z>DeX;&*$frf;OX)bqY@ni`ur*AGo)66_F3N`?Wp8E2|ShBKMoY`sM}S6syQCYUKY0oN-5 z*Uc2IcoEj*Hd@B_&?&Uw{bM> z^SM&%uJXi9lam=0+odA0XKN`=T%FWilIzKNw9T!1$WfQwAQ7rV4y)ksAmGX*L9MBj z6-w(~om7X*+C~M-CsDdym|n7o`&F`f6=u*51kEA}^)1+B2UM~q!pr%xAd{5x!Dyxj zRk8*GV~!_-Es}`wF(6vYqMVD%6DzJ~9ns~KFx$8O)fU}p4iL*b zepnaiuFr~ug;vi{Z)SX?@4*a<5!Pn?eWRK2?AYLF-$150S+-!mn5x~^yg&VQKWJLL z0}Jm8wjwdHzu=Qt8kZ+&qLZdo@~n+2D#EJ9Yz*bCEv#qoe_G;6c91Z0H% zH`)Fm&D!QV{;k7p^mkC-tBr~@6B-oR)=bJCLdmbGbN9MgsXTQ@kIZFfs`ctPt8lzwN?u%EF%oM|gtbAcXDHjt2f-Jh18EO`1K4`jjMgY@j=nZT44xIH~5UbjjE@+BW`I``*h~r+*Lib=ksN zRz&J3a~vZ*hHP0e)n)?~)FmM|+jRdHh3Dg_YOYSdgTn#0g0{k2{h7-`sN!e-Z&A$j zFX8#oO!bwEckBPB#rqRKXk4|3UDL)lEZyTl3kS<{3q{n&lPlx1;^3k+tp<(t%EDC~ zI{M;#{gUm>#=hRn!0^y$X0Ye-_}JjRgF}}Fv(07jD%ro{XFnV?uPs!#HKUM#ccbmkruSszjVq*H{mt1OV9$1!I zwlK+TvyE}7S-&Xb*StZMxx>rW>o5%{OEJBS*QJzMwIN%t!*mi3U~)4vi*f_R0*P9x zF5BdSRl>H5L9La8Ox5$qgr$>GrurnWl>iZvtp5t7aiwBYCmep{GoaNMN=~tvem4u2 z)rSjgUTSBH+IfmO**dVUZB}RL=r`%JE@#_UFtoP8Ot-0p+|m^VSH)!$FRN$?XDunF z?;JGgaG_<5Yu+5;Y(zapQ!=LT8%%hQ36?XiCG)~XoK~8(F57G)T;emqHj8WDGKn+E z(M4T$t4Yvn-a4^)(_i<37PTLsd8XXS%RmsQ>qyGij1kxRuDmW^N0(gHQkj@w-0!xz zAc$jbC^qIPeE_7kqiUXF=dOcfLnr!|i9CneMjxyRW^bil7vbO`81;Jh&vNAm0k3V| z?&f&ys1A)v7rY10mYL|z6lXc*h|f9H1*DSz54f__f9`~ez?1W z|EFwzdKMc87IzoF@T@PE`uh`qTkQq!)gGYsC&Cw87EOtj^%X7!h-JZaQ7o?5@QZQL z6oVSeVzKoSyXd7ecu|u74n?bdDJdf?-AT0V_MDh!afHEj8-<#iz?BqH#>rD4#$xQ? z#h3v@hgsY*i2+JEN1QXQE)Kq%*h+F`L2Sb+7XoGzvHK>>oKzv`K~u}v;0c^6M-Ug} zUsMiUZ|U0ct`$b?#sQajkvb{{HSk;H3L#3L0t%YgJCri`B{GQ0-BGzp4Qc~8Ra_Zv zMKJoNNTl3h&5IEaRgpL)cg#ejM(m)(vsH0XT%d@RyuPZ*4GcazOkiWmCZ!_9?lNk&%E6mbzdej6ZH%YU(WWOzc3nI80zoMWJjVd`~>w34RW^7 zJvKU&9SNdz*9ckDDyD1ja+G<1TR9^m(NH$(8yN2I0}c3W7n|hFNPE;b*wa7O%gIE0 z1VS`8G#W(xeFJQydoj{$S8Uhki-yic1DR~k1z@_m``CA1Rt(SejSdR4b3<7S?V{nX z>}X%lSbtYG8Xn6I4~=9ZsabE|NKbzkd-UE8_`@^G+@Bd7jYckX_4lu?Xb`d3%4DVV z<<*S3GnBH6QypOi>&t+0`Dj!s6#wc$coeW7Yee*AJ$?K_9xUc4(dBjnI>LDdsfdhv zy9PLc8Ho-&pHyg=p0R9ZKuV1$M#j2FM*Bv`UT|5Yx-LSdJ)^#JQCIK%eIxWFWF-BU z9x&2px{DH9&jlm%j-d0u`cc<1n)$^u(KQBw;{1!uSrAiTbl_eU6y1-SC3ld)s~bBn zyaLK2j|HYuuHg);S*|!6b!&HZa%ZbB!*GUYz-S~lf0Zx#{FVG%?s{&iJ-UeD9`^`x z;(?BFQjIhv^${{I7+sIDbXDK8=#>SJTa*k6GIVgzi7!k&v`-h8fnXrh=1CZ%qGc9K zQ@PsoqD6mt~OKrwPe z2l5>=9WD(jdu2<@kQN!=iU+BezA<)?8)N*!GVgF=EWjUBEw}vTrw(jSw5vd@`sAk$ zJd!xB0?8ylbzld#@+A9S?!)j?2Odq_ssi`mriq_A@EG2vB;_u=E@{V80G&+S61BJeY?NKqzmLZ*m5?zQcw?IQI zs^-#XF6-I`O`w`Gn4bk*I)yHKpgVwgn`GTzlCGdEg2lx1v~fnGuI=C9TQ4}6hT=I$ z8>$k;Er2`fcPcwdD6-wLYqzDavAkp7{@^Hu$CmEy#DiYjZaT8=n(}a>lwGd6ly^H* z0x=K0n`=sUV5q0BxA@!B?W(wHE^J4nbV_D3>5PlWOJ+{9DB&;bydZhy0;~5DdE0%fAEwl3fa#4``YH#7De=wH&+nG zEEL;jsdPk{#mLAySD4|pl?*lF5w#=gEvkzOe1fjbTsncdZ8|a6KJUsbmqyOF*!yW> zu6=&@US5e5@saQ%Z+IS54oa7b3rCcuX4UAb7Km$`OI@3B{M5CX`ZgmKb!}$5c9{hS z_+8|-nwU0wat-NTLf`8^#AD38=Bp!)Lf^Yff1gl*+}A_lLL_j zk&8Y94utV@$k#)IC;nofEQq*^8RCIVT@rB@GqhC?DWn8s=+<=be|t(Om}ZapN8A2P zt~@J2qeHht8_Q#**H`yk<2i>OyR0`mZvHLXyU>p=7nju>K>l(d*JFZ(;& zhSiLr?K*Ao)cj$_6&m6H$YcH?ReT7F|Cj@ji>i;Ao=hAdk41ZJNNocSCSG0Ef7B1i~8CLM@e51ceZ1aW{& zZr^890y25RuW+;WDnXaaex@c*rt7UM~ zR973*aXfHWcOQyr;I8r|={AS=tZQ=_(Pv$A$%sB{K1c4H05facR6zkU>)M=z^S<^Q z$t_br<{gNP=<}}Q$cR24*?uY``n)R%Bl?1GyMv7A3l2m^^aWQE8PONo^!VrY;$(G}NnGL5d(TNjKnjjn9ds{$?=1G2)ZfZIDV`Y?~a#NXSt95;-fos@#e zUMCWj(CYTF%~PoZ?Pc6K9HLTksXX-x&p*@FrS~?n6=4U(7E4yC z`mkR1DE5vfyU^myJO)O}H%W)`|6muU`cAi8U;|O#4oxiG{}tY@6PDy^ z&nvuBcLWbg!PNC6e;ap_dz9r_N$srECK{b4N=Ekhu1xcBXII)ewOV&wT>Mhla>-ze zLx_-@O^y0?rE(7;Bu24}y^u_euktpx1}Bh~ye#e|{&%jL?Oiod#%mFp(p?tgW06Z> zvd?`t%pOl5ynVJk^AepJJr?`9g`ceuC-+Yn_pZ+ zkI4E+-KLf3>-oZ>-rTbGqH%BrBiCBxp02D_IJrtdjyHICzPxU7K>u&#Xq&;8&QkPXVdlZy44O{4?=r=k0oHMl+(O2B zoqM@Fq7WTF#=43dwj>y153UW5mA!OSz>}RleJfw^%oeV(1}v+Lloif#(U?~VplG%- zbe=cL{WDt`8Cwa6tDhvt8>RZTGW5-V_dl&N_;b1G%1HNsb6go&jQzXv%Fy}W?4>rl z$}pWtfWEyaEmK8~H+vhkw;T!J%X&+B4(2Wih;vkv<1OVmxWf8YMpDOviAn+*;{bBJ z)#G-i6>%-kwwH^T0a5~D5#!2(07U#9&vcl&F!grn*<)RI%WcWjWSmb)^3nin<5#>b}C!Y4YS3&rakwsXaOSadM>?OFRIhjC5BgB@J^ zW)M}6c%Y?FDi*a9m{E+yf=fL;!C?%VJrweMOiPiDG}9@LL6+yQ%@?oFn-RRMZ!*+M zCFAC-Lkw^CS~dnpj1+<}^$spLqQ&UX&(ADfsVoO4c=i&KK5n}Jz;}2XHwU{7V11bS z6%p%3?W|~C{5{E;K-5`QF4q2%DlS(&Fux+@vJKi0rrufJX>h110da#ikmH>m$B#Bg zW0-nZ`H+G0ObLiPO(Qwp<>48}=4c92zv^)<+kTfg%9H?{37T=Li5$P`ZITtF9+ozQ zsb4G4f%|6(h;wWp$FE6_{U%3qnEG|) z-hES0EkKbnhH3%o-C9{@87al+JZ#6pAC0dWr8%8;Tg2lRg^&mj;5#5rV${ST5u=1lS3 zk$T2s>nD?>cHRN0XLjYhgIHD{CKjw`Ja&JEWN?1QV+E#>i2R`E-(n(RDWpY`d&wX4 zPzC9%QjZUMEn6)K(g)eJ8YD{ip}0)!Erhg4GA4c~Mw0q{$isD#24)`!NtrNclIlTz z%wxUr20Ra;I>2O58N14egqf!~GZkHdUC|NBj7HiC6zp10A?E@vC%R?El{l}{PvZoR zWxkpQ0W^(z*T;`F5yQ0-)AHHT?T5*^_@f=CjK4$Mz>wUz>yk>p*8dBATYy2PM zUK3R#@3WpCwY|qz$~wEpm(u2$sa27Ac1JCmsIDj@)e6+8P^3n>rZxt*Z*tj>r3jjH zRzLeY_P5Kzkj&G|v-pg2Zt=)BM6Si_1-WG3bNKKPncAZghthnRylS+}!G{tQx5bLmeW#7v*2dz zN3YW^$3QaW$a_$%u2EaF4iV)qMx=Q;{LoTo^(T^ZBwh2_xRc8?{;Y?^j!BHvpY?X` z3VuQfowWbS^LMo^D4Dyx*z?Glc}jFzD!E=$^@&*J`6t{_$(gaKh~C6uX~GI!-iosQ z)saNnFn zOrBf_0|^fUND`6>nFPcH#at#Z7?S)Z6OgtFlVp+%OfqpM0fOz%-~~`B6{RXws0I|P z_$^i2e(mMkT51&qFQtOo)~ba{(Mq+o^+y$c@6TF$pL6Ddq*ng=GA||1K4+h`*Is+= zwbx#It+h?>oB(KjR^QQTm?hb2HeN$qk2$@uB~a`7#JvC82;b~nNhC7rEjtbvk%=jIJ}hXV$e+}(vxq-o+v3&`P&I5M$J=7(1c=yq@H{` zX*(spwaTY1jzu7SJHgE8IH8+7nsC(OkhBO>jF6<8JeqLW65ayo(S*~MPz2JW3CAtJ zD{)*^7MbrQ>61yRG^{x&4ftL(IF&EaXAr@3t#63K~s5hd!RP| zI+-VpOU($+tr+y2u90^d*Zn+dQsNG_dFra(m$5 zeRKr>C%hi)L@2B+Hc#n*_H7(FuI%Q}W@H~LMVOEf40?Vq!Blx7$~HwY$iF0$td-gp z*jomN*VAlIVh>>ce@QSYW;Fo#F9`;XgcF9{aQ*a8*4pP0$AXrhnR#Ynu)TacRj z{bCE67T-^>T4tZn!uQ3PW-BIVR=xc1NqXkgw&G`Hf$=XI6D*SCFXGls>O|wqM0P+v z;{WGoxzEZPWKzm(#m>M|S3x#%J4Y!L+kEMuCv^4SlLco4ZkM|H?@8D4+OW-KKK-$D zk5}iW)f~fyX=zi~S4Rh3zE5dFwKPqcRV~<19aE`zG#4>dcEKO#vO+4}kK?jU8Zj{a zv1HW>WL0y$`je#Tx^$v9g-yDsbHcdY%ja+Dj3A`N0( zOXC~U7M(JO98zye!xob)Q8Z4`8~2n_Z%Tt0_mom^N`n~plu~bE`xYPp_xcnozq&!v zC?HXckR-;hPum*ttyMnx^jM@D*Qb`PRyaYB8&ght9Fhn^F+vhSZcI7r32%XPW6EJq zC<5uml+&IwAxLYz`s-=aZ$XgGaRkA^m)LUG@5U2HtNpL180STtR&mQ)BXKB!2t`MP zB4hm4NF0iM`qoGsiXie<5r-VR0>#@~QgpQ&+3PBx+#T91cHFmJHp@(XR6=v@W2fAI zplP%DK-HFd=f}vo(9gCcers>=3np{8bg0Z?ZtVrR4Px{P%wn&^xwquK66fBM;#MQ_ zQkh=el3E5;b&7#{dzyBJml`OF5fW}A6a({67f5eUiGOxT;@r2V4IR=65~W+y^tA9& zvW#McBw2QA${~?|Dp_`Gdc5-zpW3&irtL9EeEP05eKEIl5su?wEi8EWT-%WbyJ&^W zkL9T$!}GA0B~7U}A|VBwtVn0xm4<9;t>)GBuCzU(AR+ax6coa@DCX}28YDs4} zX2SjA;6XmIqYkz*J~L_!PXn68e8gOXT58?vP{$);dTh`{R9IqwU5&Bfp*?%$#L3mh zObWO|7gDnsw(orB+rVtWCRfKm4nr!}zJdKi2M);-G+bS+%~Ko@W>R)uCO}i4mtio- z4HA(8O9E*Mu(V;Lmxa1fe>lvJjPAHa9HeAZx1A`SIF>kGb`>+Un@1$OblHqJNHpCo z=%ub~pmHLGFzawybUWQ)yu%=R@n#M^+LbvL`Y<%Y$lCd%VG%QZL<}(KJZrC^l6hf{F~^Pk)_r%( zH1DuXQVU%fW<1*>CMbmaLH1KPq%LD8GVEpzT{p33m>U#^mt`ZkjDSF0h<>=>tZtpx z%^oIR^U;nZ;%HrmTV^cLW#Gf&1mq0 zxFAXEvLFrJBSF)Bz0Zg!;l?~T4ap~Hsz5N2%h|ze2ILH_$=p#z2=GJp^x`R+^DN#(LI1#ctc z5#M6y?C?)hvO$}tW=&e-eQA11$75UrGRRt@&R)onBV;TEscwBiqFBBV7L^^Y?vW&?D(J`Uu^2eS{+V$bC`!qX>=eOUbq>4T&Q9 z$bBi+mOqoVr6%3*^J#iU$GvH0jg<@*$%PZykMs z$~}Ed&xTqiR%P^sJ#?gGwiE8ISVXd+A(l*JjNa+v5f+xtWy_ctmszSE`HDxQs84tM zxVy2)hL=Syj^e;DN;_>}+_7j9Yc7-Q);}LHO=GPbmZSV2(g1Oe)E|<{!cxLol2gQ} zACFBSAk>F~k^0i&Kc7=yTKwlz(mXr$rNw_f#h3EVl2IQu{-HEo({XDlP#;_mc>-p4 zUo-ACbto_^%Z>47XDs_I0{Qpbe3qb4d+xGl1N+Iv9bk$30 zi*5L+`*51};FfHSr0L5#9*HtwDlY7Ht^C>8FjLtT;yJ1d6=V&%W+#_< zNpq5#CkaJnTS2nQ^+ z#zi6Nd>-iJEQ6k;L6q8y0+g|rA%sLW-x1f!oVfBOgPV-@cKyM^T}j?KjfJZZ|X=6UC*v z(L`cgIr+blzWChQCNYwn?!KL--$_dy=QhsIrb!gwA*fF5r3`7sSh2X-8smAy(_Hqx zoi@*|ZNQ)maILHVn3iXBuF8PJ3?Yol240GI*cGuMvT)?6AiH0OL7{_y@g(f_0P**a z>9pxJ5*JxJRCtWp)=~9Hr_SZ(Lzf5GZ#iHRJo9}LsgX%O(W5({AWQ55$vt)K0Zl!Y z;@%aTqWn)OUNkQ*b_r(0-5d=oaMmV`qWL+%P7{VymTN)Q3JN6mU$O@V8gDh(SGYi_ zUVa=AAI43#1B#Ia@Z+W!PK*4qrN`6xZq1+w3p}2l9%YGa2ao5nM7D#+B}=~TvlviM zrfFx#Lus!3oG%BkqUys8vY_l-mOi)YgHAVs9~-U+uK5&!hU3O!jJNTB7UOTKa0)0BaT)h<47$nIhd49jKrbT4;j1#ZPv(og&gq_vCcB!Vq9~qpa_w(m6gYwL zdRmM9r^}6PcA=`_-(de|vJ+!kk`@|h@SS|7x zdWlLr1DKEK(AZ8!8+}{XH^%&?FP)MP`bCR*OYAKmEoKIel_rRJJ2V@I25J^ACQ|Kn z8;qnoJ6_*>jmZ@upqOFE>KiN}w!gVjE-!FER6PO~S|oDMNBQ;-4veCGv1UkKkLi<% z$#1ae;###ZS45IH5wffVP}Fyn&rVX- zAPhc4(nCl@Qs%&ckB@SOqUPx8MiZ896Y=dd{R-Dm7TF-)w^7hSwL=0lyA&2Tbi|A$ z<;MV9MV6Ew!_)bqqC=RcbL~Wa3{U6UNi!1V>0F{T8;2rMTypX9nKX?nj*k5)#&&e< z|4iPF&NiM&+ue*zky55@$tmDSDbu!EY3E2O)3#b^=SV5*500tVmC}fWE`FyN+o{pcb$L75 zSzcFakCK=WH;SkG;dd>q(av?HB~hr8^M&GBt84$J6Ng%g!|DyCw7cU`P8?XU+$?7i z@|@}JL~QLkPnYz`oT9}B4q#+)A0I`7)rQmVVv?+7pQN>W5b3M>;bUeu^WDr(YzejW zO0zm_`eGD@E(LkTmtijp^ZAm^tRnCqZr!yeR@e8q(co4eo&U5&6Kr;)VI{Yg;#?Bm zYD0^z4=RCq>UCCxo;T$5lzZ+CrFM70fEezz6f73xOm(AHV`tb$GxFqA4JJ#vL)mO`W|Y!)z3@qKpOkfI zf_cN7lMs}ELXi!!D(miax(iaVyVL3J+e+aysg}wK`fVj;xHm;~I^BJnW?-+46%Nqv zC=u|zrm-3A+dK@7oRf&WCN^stoeiBUDj6CxKm%A2jTxZvjvNhnR==ZE_Y<&MIs-J` zQ6kp+7FULFtG=zox%%tVg5jpIP5ETwfGdrSO%03N$eAZ97}ERJ(+Tr_GXD)-Mm(@n ztd9>U-(t2Pvjqzj*KN9<=mtU-68I_%ngH9TdHLAkeLIM-RnV<%HoN==C!6NMgr*UR z>W?W~m?WfPIb2@)c{@98ogip0`>f4mtwaLOgr3kOD?-oPa(c?|{I*hNCYlL7Z!4XA ziurfeQhd&D*RUSQRZDW=9xHdM>Ldn0a!umO4THM}NJT9wXoskn80WHfa0h{`2=2G% zxXaP~_M8{EsemH9@PB-c;pKj`MEKh8Cbpd@&|CD|xmWRmCQ|GmnBg~<{%GELx#k}& z1!v1zI*ZO9EfM|pIq!TOKmAhL)$zywgU++RvYf|JK%(SL8mZ@`g5p+84!a3I5W@T( zeM9=(gs4LZIui*|hY)w?gs4M^yG!-BTdG5dyGv&*tNn!&Vm2`Zk_aDvE<(idVsTLp z=gFLV%uHZfxx3Tn`<7#518X{gL0Rc$( zNoAPN0dtyuiNNxILsbya6s}%;ZO@^2UN?7XduSgKvMnE#m zmj}0$n+CKZS};_r81kj@%C@zcVXLs}*lN8ao;WO%&WNVDW607>*pjE=4)&1<-Lz1S zY}n;oiX}b7qKW;pg-Z?R`I$U`6aVsFxh11UvMORv!{W}4eW|%Y?;d2|*w{^Q+96of z&DG$!PfM+7vYZd0NyA~r&_U(%lW(@sVU4A;1C~9?bVR%9)hrUR`o@uwaPxYY1o1R{ zV!Cs#Vb`{c3+(lmld!Q$1F&!48hi6=wQ=sES*k3l@gj#E$%_mTJu^d&ttk*xJ3=`} zSk=58^>ZznK>kG9ukA{uU1a^1`O5bEp@+b>WI~LZJT!y_rq$p|suNt!0{Dl~kxnU! zMhZx^Z>$TaRkmnCes&`+EPQQq=MmjK$rxdrwW&`n+l1?&m|>U0x%Tto8)MFK{_idk z;A{j0teq8^^bbTGo43q^2TJYkwMG#E@jwZ$HE9PF(Xk&W1=}b^bnFL8*harA$=@ae z-Iq)0#*V*B8XJbjbolE#h@g_l@&GA?9yTS*RNv^#-53@v#uX-{ppUMY(9!ZC?&ge0 z^ULCb+@c&Ip*Y$?XU8WHPOM8Lh-rrV6eyf!4GM}-n73@f$OgQIGZon|Fi3{Ugw=vn zY0fSNm@}~)Nuo&tEp!}3Z?htF{Bll5*+suxYF{2JL&qIA6Fz}A@I5C>nz=RmkBD>+?fP`M_&w)@SLpbb%UfSpm0vW-p zzf6XWM`%LtYK>l5Lb80SOij73`8lt|G!i|M+vI}2H}qesH6Zrdj*d-%#Z=-qW~-yo zrV{Kq(RwSOdv%m8mZp!Ar7`aj3bhDcILBJMwb!f{7A26Kceu?5F{M4Bd7J>$a`?$H z71Oz3`!I@ya&p9R%D96>rah};rm|pLjDv-dv|tV=lfha)MvqzseI!iOZtRqEgKb64 zq7VTDk!1!JEj183oTaNJH#YlHU@JLhB=$kBk!F)m=bcQEIQf(z=zV7STXZu6YYGKZ?pVMP$#9q+BcUNE>ARv2^R_A@N9?)a4&Xb(s=)P;_;fB1HMI z)MaVC)9Tg#Dm6V^cCA+ywf`z{t@NET=1h~;d!)=B_SV!WX4j`gUK9WMk(PKLtDUc! zVfrEinIU3aJQJhqsp3m9&P)p2^oheczCb&uX5k4VL6^Z~j z@inX1A!)?%VB};Ub%+ELK&7k*6C5dr$a3C7(j(;%4^9y#I8w$(Udt0jR;wfB6Wo1( zBCFMrGWVS;qsufME?-wpZ!DL*wjB>&S0=dsB#v!)t?_w7xjeIDW@Z-Hhvvdm))}c) zpmk~#9x(WCC{LeZ9to;Jg*TPMd99WGK}!Zg5&dr}GhLMfKs6}eP!3r`tjrfY@N-yu zU^O_0{kn4z?{6-rCv<$?xk!6!1|$rZc9e)JY{^Inw?|}a2{Bn1;1#oF9AXAbuP9d| z+mK{?mr1PUrI zmO0U^MKBK1dYU;wLEOlEa)P?K91d-GYou@Y_&A|bOG zW}=4{*pn9euq++QPe6Mp%dn_IBwenB^9!f>b4C%6rS{2QsOuN%G!u z^K?tjGOcVWQ|@48@31^CwrWHosUMki^?WJRbY~a)k{NYJ8E2QpCM(I0LMj}AI^GQ6 zg`shti=H$3R%lQ+2PVP${vt5ScTEY*hq(w$4O2Gk7 zniv&gahLLxo6oJcW=?#}cCdS4csZuo9nOYi!HXM2 zcj{mps&m-jaw?B?w_8F^bE**}^G9qnHXZ_hj(jj=iq$ZM?pmfaz*!n!@m_3<{)*Kc zA4INgp0ZI`Bd&x!f&*M^OweovIe$=@%&4U`a|pYdmNNKpTxbJg9tIl1 zP^m77O?$_BecsBU5oh1vMB(1&Vb;ndqTI>~MsQm>tcG&$`{eOcQBIw9*N9C4>uAKx zcIVJsV=<^}D+e&WL^poibUopZG0S+EwsUYpt}QxQuoHUx$S4QLqAJUj_~cW@^O*{7;D zUN%K}27YF=VTwhu&S=WY&0xDs&(?F96lVeYv74v%-DlkXnk>$(AQlOZj?U zVm-gFeEgDFWIeyHOhSyuWgeX-P2v7B=FzX^=22hAo;TxYG)uevp7kQ0E2mxE!HB1F8ujA8UV zqalzUD3kDhg_$q?PNHK>wC`gi|5_kK)D)ZhK#rPXb05gZSN^pRl#g>O(zI0mwGWg# z{8WJ=s69|VZHc9eou=UTFO`3BRvQ3+Dwzx=Am*pVe(O1jZe`GJ4F7v|Ie}R+-Ae0B9Q=TG} z|9Yf6MOy!Qq&!6^|Mf_D`9l5u^F;aSqWs@S%2NUlicWco(ChC-dC_Y|z52~^)4v6J z$rtLIWy0Vthh8&8uSd&d!0Yof;=%@rwZQZ;{$&}(OBPeERHocE<{7s+yfQ0C)LLr3 zuM7f!79b!^H~}d_l}F<&qX;^WmfJmX21N+?Xqi-Tk4a9>(4OE4$;pRvIcZzA=S@ti z7asD&O7T2ONjpl-XrzNU`Wa~?lgJY}jkL{rA__@p0*#)CLXskq=!qyKDI$rUkdTxy zdIpp3dzy65W{jSpdH20I??xn+Ls zKgGT?HM^b?`#wH_eSMeoyfd-S#OM1g)Fz~x)B;1(aR!#2`@m9Uw4RC#O%XCZ6&adh zNyV`0Q-qsz8jWDh19@BMPY4JSz2d`2ai<3(n<+DC^`>Pga?mQf`D(YSKm-+`pv+Da&UY@1vj9tl^|HVc<|;5 z4(5fE_!v&{yfR>D=NLOW;6pFl2h**bKdLlzgd z6bN}&95LG1Mq2SHM8N2Tc=sqvn+{Cb;E?QM;K0c6$R6eN*H?Q-Fnokv7yGT)6pJMZ z2*w6UNQ$D3sYigwcwu2J1H;HOufD>Xj9d{eQ6UJg<|?+jzd` zSTGs=-#5h=SNN8Jb-twtGaijoj3QicG)^&!@a@q!#V9hxj>aiQktudmQ|w=*9L&;D z>D`s|Bb8E7GzX?pINCA~8eV3W*+s}4Gu2@Zx}d**t85i`i;$Dq2Y(m-<;Xsc{VY|| zez&Kb=XLEyM+@wmU;!$a+s^Ol*D>)9lWuAWn~%lBBgb^kwUrxfv-e;Znv0b(llFu& z8m=kr5Aup0L$13k&BxifEJe+l4^_%1+QF@rslWrziEj^>fgh@n)%;XWC-i^{zf&pC z@0?@CEX&iG;o?WeR?DmT1s?VQIKNYwcU1+W5UuM)MX_@2vzG zO%YV@jWSwc1|NT(Wb`b_=#NJkO$j_Gx{Rg>89puO<{mjIA;jIkR)?olgvrCV7I|}U1k*T6y3UA$qmqni za#32ndaDDrs49%Yd9sPEr1_QxqNL?^NQ(MkXE>G>O9L! z1-Cno?jrxUdGfkF+wsf6u3jBLEL!a1f|C|c_Dna5)z))EdjH6x#f#lq=vf(Ta%?9C zg>wgvn(6%(_ifQxgowJ22``6q1zG%Qg;d0!ms3Su$$Iarq<@9L`y+R&u<(W;Fvg`R z%MXq$6P=$tLbTwCBX_m2!95|MTc-fKMh-5EsZF?t0L2ZZZD{PW%mZ2mc{69=*i-nr z2$JK3y!s-t5+YCiQbh?{M5}^z$MJx?d+b5c1x{hjJ)9ITeQo2H!>z35An~fDly?k_ zay{#{T+b?G?9pouU88$r75MwA#;+AR$^GNH&2>@uW^tEl23ZO*A?|&ZnqMbEQL^+e zE9FiTR90p-^S~49+5;x(Usk5OP_zet_{++i1^Fk;>A$Ry?NNR+szHTMSIVbk6(r1f zki(Rv;?tUp5|8$UeL`qh_5hflu8>1Whq!fN`I$=U=_M%vkD^N)ib$N#RN7{n5s)IV zK2w?FCUuHH`b>orbGw(KF62I6Nl(|k6wHp`&G0k0i9mljKrmfd$J`@?Aw}0FgFR|J zZiOrbo{EyQL(VtG;%&z|7hqy`kyXwE1eABnTVnDC4@M40INOZlV{#w#V%IFyPbD}5 zfV&|dA`&Umwa-^h)2(?T5+dz^O6mc`lpqqt2uZHR59E+Uh6gHj4?d zU&wKiRsRc>5FbcoAblZc0qTCSl6o*^J(UrjVuU0k{1Wme=D8R5Su26dcZ zmoHU92HLvY$a6@_xA3JLC$o`P>Yjm?%0T*3g$%S`Pgpi)V^Xd(eXW{wTtVD0cP5O5 zG?K*|QT@D2ER)^r5bkMJ#IPTodbmD$l{WGym!!6dBVkk_jTp-G<-f?po$Ol+x5mQi zyGL9KE7I$$vIo3=7R)tUGw_X7Qr!MqI}7Bd5dvcr)R3{hWb1(;jxNRE<00~+jx~#?WapuD!F!IUHrMo75a#s9ACqj)yPVrEGaOv(z^;g9Dra>%XnGBWpEZsY)^2)5T zCr4bgg39iMATlju8bq=MAAl?sGh}l0&WDwA=E33J;p!bbMz-uJ>Q;g2{aOH8v2xGNtPkUM7y$`10i?l(4aT_{4zD1+Gm^v1Z4+;<@IFv@_-InJGUJkh9esWHNZ z?rUOhq>O9iwnC4K-5eVsdd@s+Ce{>=*~U)peXyoHgXA0pTy2_Ie2BA~G>ICWcE@2S zbrd*^e+a!*=E(uq8)XpD5@KFvIqwx2&Uh)LLd*~|K>32H85kyv2|o8H7Et|yONNx* z8cWN5*1X_Mm|ZBrj9IVM(V52YECE=yEz28?8Y;WI9k{F;f6{sU&KMT?;j&e-94|EK z*(;q&F}&OJRw&#NQxKC?iqSA@ZA?IPb)O}|<#nVw3S+Hb0|5qd*2yB5mQ zaBi=bmv;QH+USiMy`;nt`LQIYgX;dQI+_nUgCM6qT`?9pP|JpGNQ1z3K5{nj699Qg z!e=hjOqv`vk50J7q@>bVD9VsC2(DI}5`(}HCXpoCL~QEkVmVIZOy&zo18>TPt>PX}*XqAg(!zc^CtXJ0mb0OSp_Y< z_|oNnR3Im7Tr zuPhIVJ06aabBZ|ak^R!EwC}e`$P{N5x~ae(uphg<8g34<2Ta`CtFztMYY&*{w^uRt zW-zdS-d;WNj9PoG#ewP`-P@}Rmel?_4U-)pcWJVJ3VWZ29%@jS8y3kg4_58hn1tj7 zk9yW>1#cqh(7yec!<4>TFLK2d3p+E=ZfZpSjj;nE{XAnLVVDEL5U)=i z4(nLI<#y9?V~8F?GAp_w#N4>l&{1NH2ikdtzQE z*A`5E(NnRw%$f>=4l1JHc&hE_KJ5@$;LT>MB{pd++vVUpf%a@b(TiYRRDj8wZ z|9uG!3Vfu)(nv$83fv*Wv=vWD8H4EX&CuAD`K5^&xXBVz0@G%jF@~$A(AYytEJg$I zuzB!m8(`zy5Vo1AOKefd->+fq$+GTi;msBnWC^|u?0d~5VXOE0(ETFg%6_cxSemDL zEz9y0V0jE!qUFcE3uX|k*SuV5q4duR_S)F$T386t=~JYL8DP}CXGINLcYqNpJu9SG zGo#I}5uz{#8$1V5)Pn$ELzoyDpGfwirS4&EjY^9cK1?Jn8svf}mkkmmvPb}hh!FJn zJ#)tQD(b3>q8*&gUg=C9XM^Cd^>7W)`mG&BMucZaFP~a=iFuI?!kAbu=N^=y!V8Gs{R*v7{XvN3Uf z^_L(@I?q7LkX#ax?qVw<9V5e}7svq4I*~6&GJ$`k8cs5-2FuY`s&h`wRxp{tzf#2v zu9FPap!{&Pyd5eI8)j&nwOlLR;b(*_gu`aX7~4B^0De1o zwc-`VhZUKu(x!icd0K*$4D~Eo=f`Z{+4>sop4t$Pjg9Qog_7aS%Od6^r?Xa&p|(03 zy!@~{n3G(?#9$?iNfa3)=;KEP)3F9u2ZT!H^^I!F@wIE%+0D_u?ORoH?_Hr-m9<&k zQdq*4Ae1d__08%bl@v>Y){G22>aiWBX(VmX^h|dZNkS#f!2%wjA$N0HX5?r(E3zN` zR<&(zd<&Z2s?PIk#Hh@eeXGhfV%m?+(SG#X)%1s9KT4U}->%l?)P5s@_b97hk4Z&+ zU2!`q9VFXE`qD6A+{R(*BFdCTi^4#75rb;WGJv8sI$nF~+7zt8U1l|N{mu}gyI|yu zY7b!4$D)2`59q{WQNObXbo#NV-`NB7yT_t_=MPZl9+Q5zCG;B@k5|j5cAPh{-{MD4 zF^z0fe4ZN(r|v(4B)wEkNG}Cqj<@vE$KwRE8rJ5Vlk!i%`|&ClQ(hgA0?F@H%L_V) z3d?N+8Vu9q#ULZQcgunXYx&jJ!GtlM&$P8dNw;a~3@;ejDGFMKC1x!kFDXXLIr5TX z-zySbM|t0?hO1Q78%eG2RXOqe+sH~h_(8RNLdWNDGaHXSdyivA-f*{E5={5ZW?Mww zNMK$Ewy6mu$xk{Z7Y?8li3~FIvkg^dimQ~gN>sy!?_=tz1sY)sX><0a267ovOjj@! zC?uIo?{W%BCjX#FA<5()RKr!UqL2(Vk8RLyWVa_!nx9g+azRsH%^sSe zp>tcUx^{mL_9U+GtgqeNvw8bPmu=s?ZEMf^-i^II8`_)dGiz<(`NeBDt-#@TUhzS9 zd)iUC_xh(QukC30^ncvH;JZJ0=9$&)EluD2=f7C+*=NFEvhMg=^VPKJ|fClwLu-H(&|(5|&(KIX!r^DXd2vDX(3?eAr4Lag+~%9k~^ z`id`o<6{e&9{;P4EjYs8j|Dur_fNc}Cr6Sa@1Vkue{}DHrXzoO?*dhr`Qvx_4;7wC zZvWBmE`WuaZu!3dtKT1etNlK5+ruBScRV`MdCNp(2Cf;8%xi>9B4h-(S$OD&{$3|E z^kb$_(GUAegwxafG@SIq{tPGm5>Ec;nP-F(zh5Vu!n4d=$XYD`#-O&aAb?L9K``n-Z+j$@6_lyg;kY{9Rqw|uH(cxX4AN$(T1#R}I z$sXKDxiDs{YA0^<2=l%{TxvFAZ{0e=jc#OQffi${=ct*crk7hYqGZ#{cfP!Himx^k z+CJ&4PYJp3)t`6nsMXn3abk5%&Jio>?X?oyE)xTlKK-oMYi0iF_Q~F7zr(YY^Ggx{ z_H1Q%wrYO4Q3}sib$+xoMI+ty7uQPc(yWoT?$caI6-8RtWW@UPg|K7m6;RR7`X;dB ze8wptgLV0BLhzluHprM|URrJ4PMhpiX?6L|pLb-ri{WLJvnY#1X?@UwHc zHuvIzQ5`Ri8>z9?+m3$wHy5NWOYEP$3u!yjtg7Nv(Y|!asT%O7wPIP@C@0V!O+0(=f16DXgtp zh%4)+X&HW^WRte3ugz;19;>Tb5&yZlb7QUMkZjRqaUH+fE~w4g%u3U zNk>&n?Dv|(8cPF9`f9a{%w-x*SW##Bxu~cAf-M_Zp;k;-!12K=ybFu?q=zizOI}@@ zo)LIz^iHc)B1#>f`^lTv%&pH>MO%Mz8g|Tm`)}U3roBEx@AAjpHwVQ=Yw^&|!O4ov z&RU7}zrJ`1UMMbn)CoF5$C6{I8kC00H=p|Tg=t6Y+dg*F!iWC$$me^zZ)2>p9tW)I zSJtXd+4?C{0MDuiPUtw6N}b1j?z8V)Q?Iu>;G85K^FQ}rH?NsppA{O<->g1YoIN}! z(Xyg`;v~_cqpm1dZod7ik}KuD7JVUxSlv^bw$If^2k@M->AfE{7?r-Z@STABIe&V4qThEa@g zj{d>7giyV&EqrG<4b&hphu^y#%EC$bWb<0r3(ddhiw0yy_kt<7F{`?wujW9liI>(| z$U8Hv2A+FWdg3Dw3(Ju|c@^s6m+C*XmytKpZO)|8TQ`C_9J@3nf)MRxJMfMguXcuhqW_ zSg3HUSUmH315tMnj>Y;~nEc#)3y%ooSP}X5PYp;l0C7wZ zDxOpBSW)@P4-CpoCO`p~49u}2^N(*aFzpeHV*{63^0;GTk*ELoZ$y<88L5nOVQk!d ze{2vQ{D?tF`da;~IK1Yud2Ap)?I2niUi(TQ=!Thojt#;)9m2G}7W+s54%bZH9ozS} z`1doqS5F~LiW|`JJL0b5cDS!O$k)|JSU=-3!@006R?jVPe)oqDX(-ydyPpGxDK^1< zGeUb(%hdbfaZ31#=WhM3zx!)%{TO#L1&w>fgx0#ByS1919-*y%Wv#kzY>(hRrxx<=Cyohp zfVcXWYG^!YAc8$vw=l&U9T`UTHU9a9?_gBxm8DHzOq1GwwAYep_0rO&diSTM`8D4-zr?tAJRY-P{aphG z2QbldDj)7-@&l0?=iCPlj}GnGd$7@c=9%Y&4@hOZlQaLdcv9HAF|5@hoZTC`_u#<; zW2={A^u3DQ%%oTwi|QX6d$$RL#4^k)@}gVL$z|Ul4m7M5_(&*rLOudYWy(Q8I3UxL z9bDy3?l<8Ty*@ZFmiGsz`vljHa6+bQNq~S`CFjO@!rAE4;Aaf7uxD4K>M+bN(j0TQ z21b0f9j5ANcRXU|RmIc*4(C|TaigEk)2)BS*ra=w_hv}mX_r(_J z*LZXw1m0sq`{X~QNL$VzDyE_6$ zXO`qWcOP-L9Qwv3TZOUBI<+|@s8jFFoe#n|GdgdP0o=NxcSd(k9n~Z5I1roY{7 zZZQCycyVCEQ*%y(7W?G) z=s&Wbla)sQ1-;uE+qP`%zhrG+PlMlE`?g$6Xw8Pkx=VT4(^$V{>!p3Y=U>p@xM0hs z4LyC^8f!Oi;OXZ6zTS1)`?vIMBMfovHa_jNH)}Uv+UR-Z*1n!?+ZtQ?8od{7-Nczh z1Mq!oH~07UY+Kss-MoI&_6@z8&tKXALSyrmexhZ1FY3jD(&*o^)S8|AU1Q6}#zj4S z>n{Mz+I78~diyW61~>NhV}04y*tn%nURPV!_VxF!-@a*W9}($&M3?t8)Uyq}+tzPd z+j~*Z2GUkyFuVPEWKV_gqeu3fjOM@`Z6r2y^g zS>LY?<-gWLJP_Q3my?~y@C$nMK!&w_mo5!JxApu#+o{#Nc2i@++Kbkn-?Oc;=((uE zz^vci*K?7uh7{YjuiMt&+rPcPr*Zz4EgOv3+j{yg?p@!rZB1j-7Lk8rWBaxq5ZSP{ zf2}nQ49LZMI|CvwACD>DkhEslbX3 zHUdi>o5jelbpwjEL8NC#(OX0M zm23^-Xb_(j4mqj5ZD9WugnOJ%$n(I}0|%EjF2t7;$Bh9=bVQ{I8#z0`xXf)Py|g)x z0@9f`i>C>V&YgB%8Dq;k<4snQz7y@&weByc(HQ_(NCtNU1?hO6IpO%zHF{Pj{5M8- zE_Z<0S*QDP0LB+2x-Y*d!*(TeNe+PK*6-ORJomBUTP%Yg3-HLZ1I=>AHrAhFP74yA z=2n7tl-*KI@9hwsz>vdsM+xCEkP#P0CBqrne>yi+A3AV=B)()a6#=`$T_VDacn~}* zsdhE%E@NWL>HdR2;(PCaw-!Jkj|;&k>Lq%T6j27KrG~$1X?atlc2=#@BIBKvI!39|uXI|y!7aj`YBxr^N zYl!Zy)k@7IW+<(0?v$fXv;1q;q^nQ$7Zp`%@!tu*TkHNCny;CAA}9%umo>dS5q4Zk zT{Ad3>29WETHaJMYtPdcG zwJxn|KE*)FLt}lq?lk)p?+hxn`fot4$D>Ce@yRHy&p>W$y1+s5^!(8A5+FAQkaB4_ zKi%jcac7{CV~Hn2>HHS&I8F?u^Rtd$*tE$(5>Nk%fMpqw7Y16&%j^~Dg-%O6%%}un zV1{#9=@o5`B_Y?PS7cajZrbV~slA2BYt^m*a&zV_7_&ku_XMuw58=Z ze-6kk9VZ7`_BHi8$ZEZ`Ep1qhDj@s9@F-#FwzSWOhfr)P`G^yTUE0<<*FON{w)q;{ zR7pNAZu+G}&z0h%ba91)m|B_q9`Mv9kak+Fq5`ijNtM{rO0;+h{xM#WSFcRxg;#i} zQ<@b^RD9)}xuGJ3OS6i2-B5}Z#SfQK(V6g9nqKX_Y_6AHMew@_*G!FHX+G5mr~A}j zmHx_$`~{?VRXWXo1N2oSZ?g~R<*QEUti4Sxespt3)1gFnIIs1I6^tjYfKHfY2uH=t zg~-ifWaJ{PFC1_qewnHAysS8UjZk?{y4SC*rUX&;q=O4Z zdc9=u_b~XO1kgRLGh+!bd+MI=ftt9K?U}RpY~1du`jC6#OMB*?MD$0i6?K?VFYR4; z7GKkB3(a1U?khR07WLzbmH@d$(&x(ZLjRVM&N2Ln^-Y65TH;6_HNHJ0?QHaC{| zYm)|bRafKNoODa#QI}&D!rzBf)i0i8hTB6US0<0 z*VsKfbf5RU9xczwUW=ng%QN#b)klqZUY+7txhs3E&&LYY#o1$2w;=?&1lbs_sIzJ{ zYb`Bt#=@hyOKZ1^Q*pJrw&}G=#|;^$k{1tWW;-YRdAU_Cr1)_D{M;%cT-&k`rc4ov z_`HG>s6UliAmEN!z=ai4dGQ4KhEou zreF70RmP@#yaQ)~jz$(whf4j1cPB~rMU5@4uxRyF z1UVNmcuaQ;&zHfMfF|yFBUS=8*r;LdGchuF&E5eNOQDyn~t)xZE8cIa< z_N3`|c>}XFBU|oBYA;f+n=OhgVWpa`0zAQ++Y?_4TktugIKwLf?v7;k30`1S?noAD zEl-1M*jwHMT97PA$3b@}+>JF|IaK9bF)#~NH?0V68sK>I{s2z7#wj{DUCeegf|~}oqY>Qndil->Zh8^ibincEXaJ`K z+7um}@_gSJ!A%F;oe|s&!pb7J8AWh20LPm<130A&rs&|52K%lEZU*4)ir{9}%O6OZ zopv*e;AR4jH+Kba%Kl2x!71_Y2NKd)i@jz7?gJ5Ad%gU@2(G;dj%(_xy!k)?r!&8UHX1^1jmi< zABy1WMQ~i7Uggc*0i3Q+r|966*Xu(OTpe&9ir~06{dXc8&n|-FGV&^KJ`}*|GIELz zP6=v$C$h0FBLAHTj%&z297lFe5ga#!S9$Y00o)wGQFL$$D)?|5S=|o);RtSSz5I~~ zZf+6WT)^?>!vWk}z)^H?a{>2}2yQOmJ`%yrBUfMS?7Skld4S{1M*_HcfTQT(<^k@W z*x7l2yC;G>j^utx`cmVd2z@O0r$TIP75c(^!JjcKMi6Q)v)|~ zVRbAwvs?RE!X7|w`pwPqT?h{VX>UIs)=moYOsJRbL45m(B<%{{%I$!Q(e)s{{rx2M z{E*Gfaw({n?LmC|2l-oh3vf5O9>lkQn71oOfO^>;#JB%DZ&zph^|C#PZ$Fts*6BT0 zs}~{vQT|rP^7XPkh~NHk-mZ?@>t%Zo-~LJ7u1?YGWqTkZx74eDmNb1n5E=Ei{AZEK zEfD$76SjjQa!VkxJrG#E{Zx|ry4(_oY!BkwzerM#I%;WlBHM%b_P+dEC$c?=Z~rp? z)`@Hn;@eN>-#U@)L45mH`L|AFdl27#CjZunY!Bkw&*tAck?lczdw>3|6WJcbx1YQ_RC3nM)+3#2wbJD2l4G+C+X?ot$YpY zWqT0cK9r=(!&`Y0)XVljJ+0NN4<}7u3q6&#@Ni@&j@-(RB&mnm*8;-!Kw$OutC7QN z0bzR}ux<6~-zH7p2wKyDBx$_9RTe3V9_q%mML_yal3o3(&C++0SswZ3ml}O1vE8rT zyYfWR^y4t@(#M{NgyiOvdilGWIqEzm5T^JRdl5Yir-DJ z6#X!G$9<>|ONJDwJJ z^K{tj9ZxqXx;A}0(4R?8U+G@~`jZ8)a+4cK z-jp`IEloPkFJuqF0H7w=JPI%Av_9(u8bBbYFd0u8V%Rvje*pvAB zEh)p~;PqOQ-X6vGH>K$-!siO<;I%!8uYWy-mGjT_-X6vGZ%xxP3-5)!J&Nydp75UU z?NNOH8)@1dnwP^DukFbfWJu$Bj(4R^w=+OzVe{QPIE7t_qeU zKgD+gTvCV!z~VtmECTB`9nplhz`8Bvp74_l798|mW>3c~i0)AzAtqPx#DXUINR8WQ z&jCn2^1zpO-UI%<>9p)E;NP1f<9FNn)cez>O&z~1mm;pl$|4YCcIR}|23Cn$V!m+Y z5}VqRpSi1qV_I?~kj6yWcqGYA#0rxxxzHraiS+3GX*dNs5rNDb-vyos;uKtToe0|R zPsw`$Z#JI@((g~#_J;F}qabZ?7hsNwa2EjgXd2FK766ww4tD`?DLC8(z&)ChoJ(*Q z0QYDP_s$4+A$FMvcOh`^Ov6FgLg4bo;VuL&1&6y3xOb+j&Na9TfqQ2T_pS){Bn&hW z?n%JCE7IX4;PS@do&;P94)-MB-WBO^5^(Rz;eH^(ZD6U1a2vq=KpKw38o=d^!)*YU zg2Qb9_XFuF7x@j~ejtbY!3g){dijG9?#aOYV5INKz~zm@JsG$Z9PY`${a}Q9GH^eb z!@WDg?ZkEy;dTP|?lhc4bpn?+4!0Ay6dZ0RaPLl6`EI`xxOWRKYbLwR52sD{rYXxv zr9~d3@j(ZUIxHT3!EVOeZhRIe=c|d`5T50RTT?!kHvK*evqYr~ zQ6EdWAIl0XDj(OXAT4TEv;0iM0|^7}%fJ$lVi3`6rNnHd_;KoMw(b}e z9W*J(FEc!l@jn60>L=6mk5f1PQ|9AOrd3ny^_o%oWIAJ^5K$3mpG+6OBo-OAKT63V zBI7@A%W}&MkH8D_eD(jNO@HBdRfO07LH8H=D#Gi}q(^`k1-ZP22avA}>9li%vfh^D3#&)dUtC+o zh;s$Qr&D=zcD$(3FAtXqXPR=n2=Z8axv;3zY4g(}xzu(N$=9oYm8SPQQB~&kU!}F< zgoBDS_?eV50xjt(+KHq;in;6Q|7X+k3aWT!dNB|WK7*-C498c-LOgQC-X74*XVcoe zyat{9EH`}R4`8IvrYD?Pn_a_}E*LF#EXl(Ympk%0MfqHsejy@nrzoFGn`hZ(pzfzA zpC{Xk167%3dEomAs{qMAueHXytCPj@11U#~*4=ot=#Q+szyQR9Y5A-SrUsD*bMptl zd@yA%XT8@KKz%UnSVihgP8sZhP5^m!!pa?0cc7_#YiaHH2_8es$+PB*Rek0J@1)MN zYo)dO57&>cwPk^{KU$Gxwp?(<tS zVJ&hU54SfiXEnXtViE`dvCZkg=#C+h9HQ&v*Mn~_*Wm1OUsQ$Nc*IL)c_%mu%YniV z8UwY)_P$NNP`Iri=Bd*{Ec24tm2#ND$qi-Cqj~^Me8~=Ln$=$G4j~Ti>Z?7p++&v? z+OL1e1SdO|vgt&RR>jmtZr;odpbr4O%G(9$Cq~f8E2@v{>XN~;;7`CU0q$4bg^L|Q9we8UtNNx z1T=O(MR-nq2QkDw5~{S_I>{wlF9IMJZN1iClYu+d{Ivp(-OqvJg#%X&90QUd4h2XH zxAV%MiQLfGBD&gTmzWiC^S%pxCsd(U=%uad~Vn= zWDMoiFKxW&z>Y5Pel3`ALrlbzywIbg4PLvJ+I10jy}bj&3_!8*4Eu?|A|!e>9?tgt zWV(%z=rEUv!9i=R*2yo$%X2tqrktC&yM|B?rhv_@I4!~)w0rFMeQ=~WK|LGjVXT6? zmE2R-ty<%Bn?A1p4;&a8GrgR$AS8PH=$gV^23)FUyYok1J zCw`)yBj+-y2xIKqF}O>ol|ep+?9c;*Y80fH#nUz}f4R`TJltcT$TE}SMf%zWWy*dO zBLX$X1A7P<@XZh-t0;yrMWf^KR-zh-8OQ`rNGfZIiZ3(b#A}bl(c!HIAigA1u<^Rh zd46S(It}H{)s0S}9(H#bvy4Zo%hBj0p2`0@4S~%J4gk*eW?z=S6#^4p=2%!Zaq??U zAg{9$u`XA$8C-Uyc7w)}${0To?G!%#<3~^D&FqQBKXgvQ+M6|_F_UrK^Y+&om)o)x zhm32KbVU|S5G*3bS&9Y;3s%g78AduLz|O=d;$k#%O5>Mv^4V+R^m4w{Qfh#S*HB1c|Ds_c6p+lsuX>=~{Y!E6e z2Y9UOCIL-|#Cs$|lVD3+k!2+f(XwF{d#1~YvdN}L_|!zuB3NmN>3g|AgjlOAr9w7F zmvbppKa60X=UFu^G6=uj5j^zKUR=$wH0F73^3JYK1$`+~^}x=Zg9pfWwOA{DFQK36 zoX77D4(!uyQ^-&#Ob?KMx|dWj0G^jKMC9sBLU@bzzUe2fZSWfIwIl&5Mt~6swy1WA zupARg`XTwc8W)UQEiYsjxe$(dwO4nn1VN6k_fEVt1{;?v!us;1{_hw+WC0{_!QN6* zF8J)E#4uL=)k6oENWu*`3e{G8Ehz5eaz3BO)*={2IhNm$!fe)YmyTw*;j2bWG6ErM zv6wYJLrM?B-3};dOX#3qovdq-5ssR*wCBOgzIY5wo`U^g%kJQY^AlMo7 zcyZLe!mul^Ja7ggGWvbh$dEi{6vh}p8%u^uW@An94NKk*SF;t92J!8P%cg}Q=mh`@ zc^JOEHHPYHEZPq1Fm8%PE-vF%XWzhn7AAeWgG;%tl-LXqQ2EG?PdM~ysLrTF-5zxS zO+T=H9$JXP%cXxx_ztl(OysH^B9HZO5E)Wrl$w^vP7lh2tpgDF)T14Rum}iMvn#E% z&tcBC|h)rRGTqO~69vmr%*&y2nb`b9wL(aosf|ibEFeK}oHc8)^%rkp6 z4|Gl&{Wd6C%PkRU*`04o+Gk}p=C9Ukr}}D^TXcQB;1UZHInQQpURs;JEnFC4^>D3k zm4;)QNw7Ry0yb$1>wYtt+R9uX2V-lnH?Iu~tlOHqxF}#b+exF(v!S_WJl4l*i~dr3 zjRU)dP0L>}MekD*12aLqV2b{E6LDmFq8Cij?BI%71YSshp-dkyn4(`WMb}G3Q*>r^ zJ|(j{pW3uCTAlSXnxZqS^J$sY`9-%#RJ?2U#9be6JZIU3LdeIMeQUP#p- zB`WMx&uE!jyE6$p)lye_obojE^SSnH%W}h0adYPyh&N#Skg&^?F2tAll#-#F7G@RWvBCUFxK%udK{&sJCnGyiB!vZ*Q$* zVr!<;8WAU*-*-IwS%1edsc4;VO>5FU$K07lhdS) z_6t z+UMg_blXt>3T_(&$k=feSL(P*xV55JH#n;uSsO_t-@?0=zECQTRjUp9WRguB zE0p*vut>TRUo$*f^gv2HH#bZVcIeA&k3GN5DohIxFV;a(Cq6u7QIf>#({$wn>9=38 znY2%ScZNOLuw^^Bp73RzQLEX5jhnWt?I%JrmdTrR_9|j8@h^7}{-9i}u(F%5&Dh4q z-dFZ);FIe3C)8=KPp`Eakab(OY-(@GU@DQ)=JVTIGnnW1ZP~uHy_P|^h}2i)k7{qr zYOK4IOD)=`WgxbL7EMggn&{!akoFmMHi6dSHbaXVGbcO()AkGs`IrQS6z!q6dO(eO z=fPTAfw$_%)n>0>+edb!o2ElPftu^bylvKzkb_&FNVi$ztG4`?Zf?CzPJ!L~niXK~S-E$_98e?Ga z<644*cL6A7+jc3L(q4HPS;_jhbTjoPJX+bFtoya8cjT>FLgGd|T2X)IM%>QU*4TfE zP&(F~_m5V)7uX*qFKoSE*m{qeaqflOlcQt^!7v)GD#uv*Lhi{Ia!dZInw9Gf`MNKE!=J_N!cb$~&sIy)A>DexQQPYyR zOV>}|doRv?!}QZ1F3ET4`sokPXxbQe>H4|M{Kd*$O>2^llR3GyJ!0W3ARe^Y1~T7H zcM-&VX53Am$pOPDwwa!IR2sk5u5jGe_RO?vM%=!#wLNp(*7nTSkX}ot8KpCcSm+Fg z8Kv&@#E!YvRLoRtjuK-4_suZp5>(1cq-X0U&^f$g7`kW0Ej33HrEV^s-(s*Cw^iwa zj&7iW{AAlN+s!sP>9SxBX5kL2p~p8lv!|9n1CWksoRMnJYSyfDS;YEUpZ|v-mzhe3`8BiczJVM?NqW~ zQNpjGw5~iCQrTYJPoWR(H$M`(qr_@fi?7y|+w(H~v~KpC+9?4FuQ!xMlL8dKzM=p` z$ZiPP+XPg?WCLCA3_vJuEYI$kT?AscXcSjfWE>{SKDoItHcDB!nX!pbNOQP#N+{!SQD(%g1t>}hxfLiUhrz*B zx3669s22xE7x@&rquhpl<>}ejkdmy_hjfc{ZLOF3C(_lOTna!)UP3L;2q-2Y5m~7p zx^4`3;2nH1KwezLW6$Wwp#xp+g&VW!a(+LI`=Gq@$RUfj2z$B7wI=ML+zj1TR?;k1vA$0|{aGJY%9rKEmkN52qzz}3lJq3oj=pf%%>GC=AGBE9==A0VL zIIhOXLcJUerj^nTz(lIds+V?6q>8RU8pqVcW>PDs3faXbGPX%NgCWP@( zD+f{s$ZmkFH<^ncz!m9Oi8%O6_Hx}8t`oskP97P)o(&8y@O>9Q6p%nyxHi=Sm?Q3X?hJLbuJX0%HLjQ>%9+C#%>lHC zdo3y6ydiR*l&)nlahg#0Rn*ubO$tgY6b10Frq|96A1kf%uLh09$^ENAX{97si1l}3 z&xD$+maoGvl7tR9*3wYidn?}Tz|6>;<2Vh=bQyk143WfFx~4lPjpaVS94wi(#`nc^?n^rMNTSZmVO;RMIZ1U;py}G zB%R;!PVbVP4oCx2A98k*T6}pw9qsb-9DD$ep<_;?Q6y9Tst@_&%Xgw zZZ%~Uf?HSc1JkC!W|P<$C9?vauX7J2%8s`Ok5fc4y*_F2cw35iD7`+JcN`0;Mh)kj zH_CD9oJ?%t0w*WOfnj_}_cI#!M)~0fk_X?t@qWS}AwMbL;3oy3*C(F$hzDT7gKC&- zN?!WLgnYt2HL76oM*O5|OAQM`p06jl&vWhu{9|RNrh1&l&Gg~=g#AExOH0=$YzRV; zmabRopHrU}<-c+hxPogA;qRgp0aA!3BrHvaCPA0=!+PE>9 zdtB|6)&}`g-$J6Wjti}g;J#}{`p7-uKqq)o8cQ+2##2+NFBz4UfECa;W>jtkFCIj^ zl=1B?No(W;rD1(ba=Zk;G7493PMU6GS8-fJ)_3Qte1AtH%3Of(DBrAnTgo(&%H8>G z;*VK{ZwjQM0w_`A=EM`3@Box};3!c9-rEv{hDb#bl-{O+Ki$Cd^6li7>p0%QJCSmn zv|aJH1hU@joKn>gy8U7#a$iwtxFuSbKy}~`|?&K zR;e0W(d@W2a#pJCEXBZC6lvvFan>o;3MJeXpLMe-#^MvGMXg%{WAT6{c;JaxDAL3` z6E>XQFJ+s0r#hm2oszng-%XCIXW4Rk3y8ZamEM_fm}pJ1q19J$Jdk)4*>;AvwD4|a z_j(a5LUQT%CQWz3BJ-ynkH90s^1TW9D70La#3OfzN9x6o3QR%`kfO?a6PH3ffJu1Z zNKpjf9g#^Wg47*i5_P*IvcE53J)AQRz8(CAnL!;|pwbH1cu?-q<|v(o>#@8jz=vp&!h%V-&B2(%NF#i=QoQ~|%UD^% zbB~7SUwj$!mIwr}5i;G)%rEjf*>PxS_~0@Y8Lu>kr*Fv0ZF3S#hFF{P3`*`fvREM` z$S?k9%llsLG$}w2&LOy?cjDlF*&x?O9oG76O^;8Yu~d%vdCY($oK~VV)7sB~@4$As7S3QDIbPxWdKN1g{2RxD{n|h+`<0Q$|i5+c`3dzxx4Qd8W|Q zQJLRxtClv96FWpVam4sxNd8`)@7!r~A*X9-vm=ipx#G;X~>Y1l_3xR)6 zneBS*VvOqVCrzACcC7KW(i}{rQTaR&)yDg52frxsTA-54B;Bh)`rJyJWRhL1p@g_| zkV$@KOVElSbqCKQzimTROc1Jw4ERF{LjN9UB*mTd{mT4%NffHY@0no~>$5ZWq`%%U zMRpPR)9{$=opektNF6`J;i>aeDG5pr3{82?&B1vHhYapXlRZ@~vP+`-V!fZopJ0Bi zImATZyJRjlq44;2_H+d+t{aa@>*1D z*FKj$#$}oVmIFo}3ax!J!t;I}D-{e^9>kg`fP^eDt;|cQr7wcm7N6IbsIuQ0pTl(u z&WtZ2;AORXd~{h3S&kPieHoM-birf7Nj7=lx0r~}-N|x4uwx|J@><2nJ|*Wt#?g_H zgXZFeFP464U3wx5C#48hl_LP2mSPiOPbb2=Lh}#NSXa7+rYD$29l0D$^_&N zNr4_9xPZ%~mt8$*&SCks&J38^(QNG{_8L3j?g6`6F)#43#qn|-lYd682W=-hC+h18 zZzgPejKFT)AWg({IDa2w8#H!^h-$vtLBbk#9G#(ZXXDDj!&i@tYPSiJh42Kw(385{ zgGu{Yu1?Yk;L&CHZVL^@t#oFu1QJc}aJ;gLhTq8qDHgP>n8(*`vF&VkpU3Bt3X7n_%+|cnJoC{kBJ&==%~-bIjOF zIt|%y?%z3l$o94|Q-^9YQWm>Tt6|i$PcTUsiM+QUB2$e=h`b~{D|3~>e*Y47@3PqQ zlKJ(Lac(p(VehUJIot~BrE{_Roo!ghv5L0VtW_aO&Xy3F3|jD=r6~3W*xdppdYE(%?KA=R#n!3LG4;OWlhG9Sv)S1-d|>wdpg%SkM{om_TD?VujIP-#J%`2{lGML5(uUr!32;*2J z?~mQB+P9x`x=-Kx`vG7Wy8QMJvS!F%_wD}n>2&&Z_c^EEU9JTZx)eWO^{>k~T=Kgv z^JgO05$=G-dPmO*LY4P8(|@zBm)VaCs{Y#pw$C5DYs6O!omKh@=w zBzj9B4q;@NDScR2jqBqX`jV}c=3S2n0~ALSX&EWFe_Pf&n9%|5`~)eD-gA$53eZ>3 zXSj@^2JT|^uJ~~P8b0W(e7Omhvl1PIzJhYXq7EVkmA-oQi;^l`U=#cRMJ?vBTnML6o@)CB6q#145dqxR2m_&P9u!OW~cPt|VW5 z;RKAy2rIaf9QzlR0+aKeG^Xiotvwe=-phtE<-nv3gBMPOW2Prp+?|dnSD`s?!gM+N zw706YU)86?Y+(w&sMeCj)u+Anxlmxn@$SJSW@wfU34iw@jTCs4J7rR5DDt|n4Cp&A z6^;9&Hq@CAeoH#aojnha*57Gj;GdQ|OqnR5c7;Z*UXzYnm^dyQ?r~4gxhaQqemc|_ zuIe3MaYm&>-;nmlc`_57%M#8GWwklp>sZCkgvG?sMv$Maq13XXoooNv>M*3UGgXT^@Fk zm1wCV*t#UTSp7k_kK4}jevTH8Ack>jI9&EtRMk{)2X1K_%A|G6loaX3uP|7(o6A*0 zWSF!4dRj;|9B!~MZ&B`&Sv(!hObdtSX?7Y9H{xN_NZ=?uJYUO4Xuc6{_eCZ325Tv% zeH6r}TP$bQEH2_IMpsc;zU1L=lScfhu(S>tXq{W}4ZC&cHUUQ$bs=sCH4dTt_A;k}3OJRz zjedxXFBBM(@~L<;i^t9u_lPW-f`03y zt<~G`mNqkU5<~83eA@=kcnuAOGqkdd*f|WDr^oM0kF}kIfe+q7P~r~O{h6K`l9X*j z<2CM|Zgu*rv5nR&UX=-?z`KbcMkzKpq zIm8D*sy*oioONp9=2@|%o^nNrG+%$mJTO{ad)$Y#mXApMVTO7=!PsrwH+}XWUVw=OTc9 zIi%q*g>w+j8kAkb)WpZKzRIQhD&cc}aTiaDT!)LNR4&nkVIy<8ECy5>;1+g9S2r^BM(U}#Ld%kSa^zfxD1~~ zhvjnXl&}wDj$vO#CmM5gzU`b*CHtqQepwUx@90&# zN;~B57dF`MwI)4?8(47ezz<8b6!3?FcRN!-q(o(6wu*$c^lWeM1!b>v35%>_*Qx5L zpZ5PwbH;O#LP08g2sf7FGdhoCfeI4`^-(RTl|DEb7E%0K=_2)9U>n%6*y7(0qzTtDY=Qt4-uvU zC#oV}G?gExlK4eY`H{V_s&MgsZBlh!#;)wPy_ZA3Xv;25Ws8RmMi?KXQHFso^o}%9 zmI3{XURj3HAdLtkO_WN$l9DFMGGBqTpj7ft+w+^;ikqqg4g1w$5zUh7L;2s=tEIf#g7S9F1m0Q2eT{fraDfx=U-+hel>ypy{jP^UU}I!Hh6{uL3;PUl z9ys&VgTd4L`lt8xPw(q{pWfF$y|4eby{~r{=8L>z6MPkH4ZaGtm9^Q`y8Lw6w{vkX z7yF!D$xj!#qfAu*mSZt1KV9U`^bTKsy2zUJ4qtwL$~|tA8)f0E`siAAKDOK<4|6=h z4GEWMa$0Z$=hLDOes5&BZhU0ohHR~-I3AI6AZ`rO=w1Qo+zvLIQ_frb@3*QBeBK+#s(4$t96j8W>26tuJ)*^d3ScKvV1^?~UQD zQT+Jtu4`)C)7aQpxIe15gz>HOCK} zxYMl6%=rmx;CwSjTF|l>n}9XU9BFFw4?Sgi(Mq#7pzKrqY3>}PW3|kh*V5>gl zQ#cQkl5;A3AVZB9MRP-5Vi2}zh{1kzWJ0)&v-+?L1I%qXH5XnhCM>XLJr@?;DN{7? zHw!eO@-0F3ciPpcE!B9913Ag?gQr%QKbI<^12MwEc{n=vx&xUt#y<(9gUIblMRS0a zMij3GxJtH#iQ5Q|UTpePXt8*AuGpAavN%^V+ZZvGa&@QAG7Tk5Vs*<*wd#uDVpC8%7Gj}1-xbv30iQ}e}P!DR7~Kki+c(dBFNeW|`sq zv_8CGfh1DEkFg95IqTr=O4dGi63F@VzD6OUfnm=hAO!f)aC4g9&8>x-(+x}uez)w~ zTi?8wX>)(3K~`6ybcVX6)-KyQ(&0LJG`IrR>ttu|?v%i8EjO1va&di&E5rX#uI++I zHqB|ye~qnOY)q-JgAkPeJj8ciwhxM8%q`Gfg)K$DXn6V+%C zJ@g(Z(6ar09NSr_3=j^KCTG+%OvIy!ksI#FvtQ?hPw2+IaRpJV8pX3oD3E-&G3jE! z>5-LMkUN7eSb|od2+dt|%7vI!kIMj+CuK@VeM{&p9We(F9^B*qccUc}kr^r0eWDF8 z9p8G+>q>|=z_fQ)fS#Uo5l4Yek3!VwrZXpA|1rt0FFo8XyO!mbw9C6BC+;kK zc9qw!c5t=x;Rjb*+GCtr{lEUniUXpARN-_-Zzqng z3#YrD`rUl$ck{ja-E`+hi=0{=wF9cHWk>x9(;}}g@79$1`tt5@Y88x37JYr$POZZ6 zSPjQx|4*z&Cgm+nC^YSRQb;qG|*8C+GBFW_qMfe9a(kx;NX@ zq+9k9!*lM*I60*$%CDOcvQLY#2U?(Qvc1t41-&}}*?52_u$=yQX~t_9AnrI}2>CA6 zG!PlcYg>AiIMwRK%6N8QVko>fYWJ`_f?KS6a$;cGv|ui;TcrBTd@0lZn zUSuxanFO&BArLbY5#Rb1tzT;9+Cme$ty-b~?RUf`-F5^m%U6ZV!cQH^&+{Lky7hgx z2WH+_On%~>?bG65;yh{OR!}ZG<+e~Bsc?Z4-@M3UW2-|(6R!^Xia*edH>K%t`tvaa zu1_C!cD?@^J-sJcEot-DrqxkdQW#zBx0O>McHrFyuQrAVn0 zO(e&3sB+n})#@wBrp#@V_RUuYu z1#1mo`61^nOXv%ZdGGC!5iwkND_^Lg@?)3;s<$k&B#>c8<4U`DOISC;y-lFBlkN{N z$G#^IyQ>wFJa_MCd=FL6XxO(2KTv1GelF4bVufK(agW@S_txbYTEsiAK3lHo={g*uam8ML(kt*8|!oa*REN62+a7 z@p)4RRRtaa$0k*`iiPg>p59`{;47uHyFqWY8pg1BXf~7*pq(cJnx_~xkFo?lVMFV< zt2{rAFf*pkh78#wVwEE|aF`m;sl|@&vBjcEyD_jbMzb^QRL8Lk)W*BvbNgTHcAPH) zw;gwyA-B1$30~&lLok0CDN34={IBN)jN7fALCdIB z7JJdL@GcvX!f4yFV+Z0&**p^==mR^eCO>Z7eF}qVV4C_;ZzD}_$Zkvu&!^|4CAHXL zbr_+Hw}^DoI4;c1te%>ngD>1fZ>^+Be0i`)qa-W}(kIe_!(2`cVDBKwwL@pnpr4(@ z=>{6fZvF=9D13^CJ|S4T0>2gJ)2$1Dx&yG*$u-dE2o zGD2QpAoICWS{>=N1(sNBphxanYd9MZnv*fe9kp9ZbjaLeB1vnPmf*&a>z~j&?oN}s z4#0V3?JVV$+8M?y{b-%fCGj#ST(ZBEO_nUXX%!bk3O(#5m}`mrykV$4F_E^1Td!yh z9BJRszI4ouCD*q`hLXT0O51|*f10NE%k-YY4bJY1TFpxkCM;%Frs8F|cokk~5gs~J zxYl&t7GdTcgEsB*$0&!ZRre>X?*iSNfu>3E@#5r?45JoHD)M^q_8JoJAouqCGgN(@ z51LDQgJB*7g28Yo_@Jr>l8`_at^1xrmc}+H#7ZRNnnu_zQi1rAU{!FeSa<_7YFgsd zuZI^Wiuj#q?D;_~oWO)W$2N5Op(ZGG(f=&if4y4l*;v0URpySN5RL%)aD~h2gNyMwX$w18iJ4+_xoKb}XJP4$)oeG)n39t2v)NjQ|gf-$h--r@t=@J8e829K&-% z!uqKx(*#z=w5NZi_u6Kh08+HC!y}1QWPB3eDRSsuI)rqEPnSfu-W9KjHWU0!Lzr() zMV3`t8E97Sl?Rhmuv}QwS%6W=ly;(x7a?v=%JOTb$s$BZ6}N6hhizg8?%;$gw@Fbe zIgwmR(Mx4DEHvocvO$|lp5DHS&8D0mr0uJ!BRco}T))uPd-AMKKaoypx(gS3r8UB2 zo}p1^M(?{4&D9Otz#2)opwE+nSb+IyG~@ThdgswDYFyH@6mwcGDbRsKila&$PO(dd zQHEB=ylH+hju~O(MbFFYv^ga=x35u4)tQkg5lCH&imvqS+XHNDr64vBq9Q}RROpsW zUgv27R;)vLcCta$so)bM({)26AD2u*F1tsTQ03l!5X#WJ$3qq4a6Z0jZ|NXREdz~Z zJJVSmnQpCOp|fus59qt_Z`<;Bk+~x$1k1Hgd&6yIi+V$(n0`+&Mz=7d@ySVLv*HNOqzPrc zfegPcS4)-Zv&8sgsjzZaYwdij*sq2WAyZoojuly@Y`;CFqm{SPV^(@7SQ2vpmMyoF zF5OdFO!0O?7Mre#5gVQ|GTk^8IQRyhfM<>G${dlTGlg3$r$Wi}$c;I+L_R@%n8q?N zVAsKB)c2UtY#rF6l+w%D14bMJZmz@`~FQK_IDn7MX7koWSBsBV3IJj(w zyt56rA(WLfdq5&a?Y@oZdF@eKEd1#sjARTxDdW{_T73p>Gk03#_Vg5qE@4OKrM7b& zr~2Bu&s;p;-r3uqE_XtbGAYJ;dYLZw-*Xdq;h!2992dg_vBed0*ngJS9ONw)Q6$a% zi@aXqUS<>~PYpADtF(~Sc|j7zOp=En=B)o>?;)sWCP5xn_lYrQ{gabj#0VPw~s(FU$kKB-?TSHaKrQM%DNZU!svvmY-k+>r*jWL031= zf5p9%B%1zgS@#M_?=tgPq;s<7v&Y!uMkJ|lu_2M0x;|04I3brrF4iU5oX^Y4d_IZz z6JIVxNt{dYQhp`rX>FfGyofLKZoF$p4^MKJn_9|olFz$T^Ukm3Ig)64DO%EN;Kb5= zPK1wY9HNF43GUtR=pl!y8&ote*62RfuJ!p9p%IhS`F!WabLaY)5*ORomYw+eMU)gO zTy0o~W+yL1SDPNL0P5Q4u={6f@G&$Kete@dV1E6nV!~6!gr|xLPZblMDkeNtOgR1T zsF)D+1+oUrXHBzUTiMy5m=IJLvIfj9QVp2Rs`*h2n18lh6%%sJWqYHlA1yE7a7m<$ z5>)}Wp5jTBmwCkzmoEK&H|&n?P4MKfz{%7|u5$D-d|&p}7#qvI8e;XZzYWmi6jeOH zRqTy9)J-|rvBJgf3UB8k^v}%U+*>y7?vCHTa>#k999?;*;H4MZ$lEhRIN{Sfg#hnt zn_upcvjwfAyMQX%U#50-?ykqV-S!tbYzK?W)l-G^*l~8!U7OJY;y6q825x8V>!4R# z5^E$Ond@$BQDsu=3pNHBJyNon3TgB5)jaX)ZOU5XLe-waMb4QxPNKo22k4eXdmwBC z*cY_M&E{@a-d1gm&HhI`jkZ3&-dp^L!B*?0&H3LD1!DFhN6OAeRX-mW`c+aa88nL& z?8k>U_8y_BM$mQ;p;}IaoaC%WjJn^IUm^u_6e>Ttp`Du+%QovnKN8t2aqlfMt5n%Z zrlN672XMg15sSsDX6`*M1Z7AuK6TTCaTed*N$VZ%n>p|l&&Oz=_(NLRqWKT(_k!bQ ze`fj6e)O$l-KgaGUKER}Bla5nayE3w;&bvEd@tj~j{GdWI{#cQJ#vgkALUg>Ji#XA zZM?o)Rp_=UAzN8#P1gz(<9vonx3=+Av=0H&w%UBHO1HM*YqeG(`E-((j5icRx~Jhw zK*c)jWX_6^x}2^N0SJ?IdDvn^=0o|pP z5;&8qtlC&isUI#SsO6A)CTDJK#r^A<72)Yz0pgw2Iz`2~Y6qkiicvExu$WwNlH3u< z6<@C%f!rLx9gypQq2LwzssuRP{rE`~dQAMfz7l#&JR-jmdQ3bbze11wM5Ir%<$B64 zMOB}O3jJY|r8?+#j5^DicIF8}caLO>AHtH-0b^W>GmA^I!NWzIoQBLzaH=8${lOfo zxOin+{etcF-sS1H@}4ED^Hu)kxAKeeGgYe!k}ca`?#(wou9U&#o_s66xMpqsUFwT- z+1$0V*Q2UCh5oQ1_0_ev`387ip7XtV*TcpJ)G>t2u|;`rF|sBbn4TW6R~KYhUgIF< z5JN_sqN)4qIvFxq%^iwcgbNA*G8M_2af3~WPB%B$geb+_U=yO#af2O>Wd5}wzq#~C zMr_`>UAsNC*r^P=c(GB}G>`3L>;ntiX|4{4wpHK#@U42F^f5N+|971;ANU`hnh!jE z7VQ4hUHa2q`qN$d(_Q+1_g#8;!D|~YcsYy9Mcj-9LxUZ`(BM&a>Ho4`cj-$$P{ztv z_4n)9*@PuG-IR*tKZV+&bJorxFMAaPk|Mufvg{V#;tEbKm_&^N1wiu!#?#bU$1{)P zfQ%hn@IVGdsRJ?*vK)|J=XxK(q8WlnIyEW2>SqfVdrz|EAD+-%Keu;1 zW@$ROzfo0=L{4QtH;(c%W)Ww&fyMtlC`P^CSfY`w9&kvWUntceZw1{Qm_|(iBGiou zjUke48#1W(`=dL1=MzO7u+mNwH|h)LM%Yn%ry!c5dIl98w%XO0Q0Vp%)fG|XoDx^o zs0y&dl*>ESv>s9SI&!bBuICZHoqzs4+-u4nXaE(s);iqa&?~%zG$0lLg6ylbH21W5MpGRJyu>us>3_YAjfeEVt5S8`fE=uAYR02X zZ*$9`y$AWPUgGr6Ro)UpTZfKhhlWi91d>H>ZxtOkJgE9k%y1;+VhPHQUbQE1h^GDP z{Y+o$K7BG@XlZFVnAYX)-MjT;BeSFOR#LhJ0at8L~quhvPzOl41ZoNMpx zINx3vo%PjREYFV7S)=q~M`!Q8R_Zx~ZpM*9O-+r9sU4lIAHI7Q#&HU5AStP~@X||# zmgd^R`ze5L=O*vkCu=u+ytfsgcX;wHTmVR!p|~>2@G$JvErH`wP5b6gBd3A^nq+U< z*V@{;zhxgVeh6`Xsj7GvCwQd7qrl8cCnI{5?`3?}Xp7X+6s}Pkg1fX@o(#y4^N@?%Ty6pKI-{xcHn&1zQizHwFWz8~ z!W{$asxN6zL5so`#uY|bO5+5V60MMPjMwfNg7g(7DG{JUy9~p#u!s29a;Bz;0E)wL3xT$my2*ge1I`Cp&t&dh|rQrZyFIg4kAnd-5%q-hj$HBNKHOdm4BgYNp}x$Y4WC zN<+6iIx80s4QIwD2M5Ocx|D{Q1|g^+QwSW*oS;w{=igH9NQ|UH|1deE(d+F;zuErz z+ZQjciFUV&cO_M%QvGm^QNifX)Cj8Ur|$Dw)r8iixnX>4a2j!4h0*$(v$w~$YO$7= z5ymx-Q$d#x){de@Uf8+)O5OI`b=!w~x1T+<{rsWrJ@wm1ukJ+L9(!Zt?wHt>!Lp=* z(q3XbJG7T4hn-VkEFrG-)Be&(y%fO^5@sb8mmsUp^%@Kj-8-EkecmFcQZGO1gerM{ zS35*xQi*l4wd?bS`Pf=dD`0!`DgMhBYNa732h|)GjasEb9}62$JwCZ-@~`3ORHIlG z+tj*EwH{p-MyUL8t|LFdIrAsYb!6_{2;Y(45@l~EJf{+HnQ_|0Y$`A?NJWplZlvbP z9>wk@7uhT17uqabrCWH-L)}c~^Q-k`Mb5I9K;H+RH7!DP3<)o@AXkR(M!0`WbqwE) z@c;Ptu5x_+kUZz{M-e6y6LrD6qA}%1a|4Nen0L!)EZp5Jcx!?bO!e8hy=L2|X5aFF zNGMaKd!JE;8cUqp#nL~rdz3LL?Oft*u~E989aQRZG22M;un0~Rd02#cz8gK~+d&={ zA;MZo9v1nKJh_zoXM|=gb z&zKugg~!NiMpol0;Pm+9fY%u;N)u<&bWF_dYh3`R+|p3k#l;fkED?o~rlolSAf7Z) z>V#?mS}@TnON0}o6G2U~i0I{(1RTeg7bpx*Nv<#mI&mL8r?&&y}7aRfX~3PID}cR9EIrVx+uD{&f^e}U5dS19#*uX zg9sgY5K)IZuMp9|BHKNJ9RMpL4=#$aj)(#xiZFM)k+a0`9=m_%{5C?R>Q1o!%fHyw zv&QKwfKIKOE*}M%a5m*AE*BfR1}-PIajbHOx6e43&LSV&8kME zB7{_N2#IXVxdJC+95TbjHJ}U`o{kxyo(16caByT;4gUg&7jAJuR3ettw@uvl`X#au zXvy+|t11z)36ewR2@cLhsFH;Qk$G-x<|gNA`nHH}jI&x=Dcy){s%+?tVFX-G4b1pj z7kt?Sx{BCRY+@kWs(}g0qE5P8$x_6U6%=)xDT`Qvu?563jtd318yOfJ8y}lhHzjBe zqGJX@X6cK$cyzd z+>xIyvLStPM}E4<#f}D?~Bw%6!eZQPx6~p&rMVZ*=;3S8!e)!GUygknYQ?tQw1eRW!k(ectT*cc~|g+ zs7xF0GD>Ao&pK1~@}iYN7TwqS@X8?f`&~v_84)G9h;ut*(ZD+6D}!zniguwgT0~K0 zNI+#e;xn!?1gT7iuM8ouI(%gaQJD@ZBO{H?S65m0q9bkY5o?p#4=qw1(Mas_BduJj z^J*Aru8^Yokb?TW8h5#oMv(fv>PH$Oz+UwujS%&D)sHlCT`s%&pw4M=ufaZW;?OyM zQCc@oJ){4y)$g;E zRqIMI(3*GWQ44(H4SGeWddM5ORS$Ymr0StQv#Yk166Fpa`Z)O(-+i8l2U<2)Jxs~A zs;aaQX{p8PXVRwoUj5k>`J|Ua;LEi0E7HupB4Z~_`4u!@pGt0eN>|bRoT+_S(~J1r zy_{sH#qEV=nHuw1Vzu#IAj{MkS*FHZmgD)=_D+q@SFZWi%`3{DsOny2863j?e1$qX z_u0jAc_Cw9b&KAe*Q74vsr=eeAzK}s``pf`dA?z?<`5hI?$w${emay3`R9r|)FU|) z=S}mf(W8!rPP)$TPF!9ebclz7p|uuOxlC*H;(R2vAyO-D?4?}Zlle7rCafp=o{;65 zeSVdCEnWBOki~(t=JPUqeEt=h|M_{v%P8qyAqicsWBHX%Aocn3ns39rd>N6qyTavg z059b$R0j0VQ5dHGWrvpcWpLvEFXeD0NtwF6xChf za%78dY4-V7FJ8PCTeSF==Az<5_B9VE-tuel25`_@?~lrWu3W3x=XZHnn4MjJDBG<~ zp7duHDLb?Jndg8|bzKg8{$!D=r^`)uUemkWOkb76eC}s8_hPpEc}=PrtN+{b{0nC6 z@L<+e4ntUg4?T!=Et2J-tV{Ae0qc_N^XvYotV?pw?{sag$7EfC^l!tu1nCJ_*TPkL zbk-&L-wW%Kd{4r#J7T?^-aWY)DX@sG~B7A@Xbk8n=oJg|M?gBjMfc=4A1fviii z&mYB)$hsCT`_Wm~!c||Gbya_QMgG|?amrM}ep((;a>B_;DmzK0N0FU0lSxk}9$R`M zdx`vX@G;~ka%Ux|)9*!s0;5!h>V6U#3cQ7+sMKA}sIG|*mZAU=Z#Y4YYJU%MlvJ!l zlG^vkk`$RUvQ*pS%TiKaiu8$vho!9RX+0T^26mR$*(!wx=s}ySE7#%2()dyQ@I;SJ&mAIX^H}!mqlD`IYd%X16!Y?yl?SWt82YlIgrcn^y(n z3~pxW!D-^EqV*x`HgSn_o4CuA02e(gWRLEYE5L0F)O z*5V=_c4&~P#pV23#-&NzIz1P_uPer1^e7<%O!F+T7A%1M(B=s++2-lVuP$B;7C_!z zO!Xos5E+`^mtR}D7AyeUTnzi*1Bwj#)%=>01z`d3reg31o?aAV!(_9o!h6A1h)X3- zQmbf{(v@KW@Q1ca_T*z89|6p@Ulx z7NWa!u~-26p>#WpdFYJ8k`-eC@Q1dzLX={kIGC@*7OeeEa&cYdD&Kp6(x%m{wMhPvKo!$KD452yZ*!(&&sl0`jZ>fRb{HARE|@g z)nz+0c3D!srmR+f;%ski**5*TA}N0cupblmL^$z!p=@_l_3@}6)pW)K-acBb0eA}p ze|RXjjgQyq&8pX{!@y8piSieO8Y$**K94+&;e6hY-$xG`qjYnehmJH_VZ1&xj6M=i z-l_c%52AUcbWyj?#PS?NM!D&Q(O3t3s^S`tQVvR0ysqA-lrF7`ov*So9T!!VxN}xLt#Zk@ zW2Z-9M68dSJW39f^>I~=Pbt2?*2m@@Pn2HPZ`fnsKw00==usF<8{&f=WeF%7;`L2F zXKZA>qb&mq%F&%EoxZL7#G|eyp?*C>z&pw-6{BF(h?; z#1P&TH+qz1plpga?(!*@fwC#oNHi)oZP;z!K-pB^;87U;o8uiGWjQFD<4uh|<#JFq z$1hk2l+7=0u@ESmw{7<*Oq@cXWd$gOc=HaQas?=bc%y|tDQq%2SAbHeGg^40b4wU6 zc~G{*1)~M-!bcm)c~G`&wEoM3vSqi8mx`pkI-pd5QXOxx@lpXwbwH^Ar8=NgfKnY$ z;9y%rjaGuPHLf<4m7r`5HChSE)=;CBpll5_T9uS<3$&~PWm~+}YP1TJZGo0mpll1Y ztO8|Qpk+0Wmj+r^gR(u|X0)sZWqY7yH7MHyEvrG<9%xyUl<$c5_?}(^%8q!u(Xs}V z9bvqz0cFPq>%TRi?5N%CdwOkBzBACW7L=Xw4x1}$LD?B-SqsX}K+9TCb_QCW!RRHl z%QK+V#5;|aXF#b5?eYvLHKARe0i}j^Iip-ELAy1stvXb=Fo3fP^kQdJ7IrWFIc;Xq zImZ8}S+&YamSMo=J2QcTU2%=IX#xei0#`|(U{~NO2^8$wQIkKw5`l$Rz36-H!4E;P zTCplY>$@c-%Y*0H!ZqucZ_+kJ?J_BEi0gEM5P(xP;ND-D7$Hb$sMus7vNddW!`^9Y zHtgQxLHN`dKw#N~3`96~V*rt|8v}@N?8X2B$8L)E`_kapgbYL&c2k98u2C!uyJ=gq zr39pD?>r;ViSmKZG#Z3Xx>Ap;S1 z-BRHe5)uN^vVE_m1f=Bv*D(x`D283P#wYwI*fk*o5pLaDVNEIAy0!L*r39q)c$)_y z;oi8#e}Y>RG7w?bdn+7EjABv4+v}MGAwc#vHG2@4^*$C3R~?u&Ap;R!y)RTpc=f*R zZr#9`5RiR--H2j%_5QfQgTSi^8Hljz{S|KUAt5093%e{OAp7g;^Ov+uVATiXgH;_~ zWqo*ZVkb|b49)VKCC+_s54^!_!BdW#Pxywxa2LBT)sf$cF28@Z>*mlx6l zQgD5MLkM~fRyYK#1a42rK!n-1g*Fjp-xk_Ln0*^CQhqw;1|b28I-PT}qSF;WUFoK-(-lAMr5WXIXF@h%o@YWf zVV-9~HesG;LN=J^*_>O&;#k<_*_@MC2$AjVMkj$0BHLLnfoY&4x69EV3xn*)t+No> zI;z|RAR*a0y!aOjgM2yXrW66Py_|D079p~|yveO*gvj=?XGH3i_m$jXk1tH{m7Fz# z`lhYkXWz*7%E3dvB}sTL=QuT0(~y(h2~pa)^*enwVSDFxIcXt|VSDFuZj~TFw)25V zVRYv=xmAyEWINy3hMojE5F6CzvZI=2iFB3q}I@#7fQ))h(W_y2nXtFu+rc_7ec=Y&$*Cu3vR4D=fY;|9N{?^ybKe^@SImeHsLa_hHS!R zUJcoV%e)%0!DYGwk-}HH1Chd4x&x8ISGog{@RgoWnsAbyP?~U(o=}=_lAcf+oTN9D zCcL9JlqS5RH&gljQF;G?`v^#QkhUXC{Okx$Lu!AF97|3^A+?4F~bp!9s>So08 z2umr_rtIT+(a1LFa$NEH@^w14ISj!Dfkj*_CI}#S_QkKettUb1-WNOZh!FYuwz$DZ zh`RT&iVJ5e7k<(oP-KJNANM&9&Noo{1B!60{(vGJt3RN?u?FDojuzRV55)b3A`EOG zcD$!t8Q8!MCzcQbWx$Ii=TBP=-&O^e7}8Vd-==k`4MuJbcQh6y`S)I|fv)%x`3yWBPdpxmf-JdO}3H@rAqF0AopphY(5H{%;ll;RsGH#uQ(?IN7=X06dFobu)Yw+fVt ztTqD|4zvigvGkt0Y;cs@6jb;_mCtLN9 z$f*~!EMS2Wj8h(Ff%0%8lP5GEnMZ(~+&bc`f33@zh~Sk&?!KItk(Ok8ezkjM8Xr-5 zA+B~JOS)HCtX__kCfnCqDfhkQMalNHCOh+MEMK2o|F<+(iY>^h?of!kb)T0IK(YGB z6(=k~#7K;<^X_w2&dBNa{;}ev)?2FY<9?PhFp5|DcRpNTQ>a~N> zofxvKo5Urr=R=J{#k9Z|w7^}DRx5>n*5G}W6#vZ(KJEZ{Ms>JP@n2N@BM-q}pugH2 zN^y~y$YfupNH^&Erp88wMk*^Qa>a>wdE6aHb;Iw1d}gqwBYKF3iz?Uo^ievhPZCd? zJrmyk38P>=i7T3$9=kr>YXg=a8!{Q}Al5U}&8YamOf9xU7+7gC=6-=>Fw;yj$NDV7 znCTYM!AvbWWu_LR2?4AoAZDfah%c!1tWZ5|nT@i^kX(&bHsD zhqKuS}3CrBq zDrHzLtxSuxG96UdRvy(-&%UP~^=pj($JJE^O>ult$y8SFtUntU)Xbe6P>iYXmR$a~}>+OerH}Hbv+bS`-(^$8PCo}BE#jMw)N0U;gbhG!Q z@-d|)3ST^00%dOGR=z3Q&_J0Re90Cw=W{b@nlvlL;!p9Me7`yGLXMTpkYYJ0R=5;$ zIui==g2^mNa-kq6WTXW-b~{I!I27dgWWez}@(yXDfaA9~*NqzO=DQ?$LJ2(7MZ2>r zv*{nCa(({XvhqJg6!l;`@^Bg;4DzzmR86|`;fThs0EYMlhd5s?URk+QM-GQL8n*~0 z3#eiK-UBerOGy@UU#nqW%p8fip&UTJ=s@Qi2V|U#r3YSa$S($)q4i4-f;D2psgfH; z2AgeF9Z-STFE7>tI>t&`RpSgZ+X8L`2GHMMj8r!$9cm!eMJ@#E*O0qzY*c<_F<3V_ zOJH53!Dd@P=WZbOe_gBvbUK%`fW{dngWtAsPIxdv|F=ll>3nk^8R-u3S<6{6_$|6* z@c)5BeDL76yrqNR;@xI1RQwMgfNA6DIm-)X(crgu+t^vvaojH(*M|&#%RO)K+XugC z3$*_6gJ6x=&>Qmxe}F9>{9j$H1+s(R@|F&Mi}xaGAoWicBeiJoTkd&--#*wfZ4LXU zi@_ERe#<>?@Y@G>G8KsZ+F~t`9sHKJXz-uOT$z|Zu*(10*%3a#I4@kMn9*PIay}f8 z_syD1tjhnzA3@kOj3t%BCY0F%P&8Tv4d{FmTrfm0ET&8>eqeFUN_gJ>Hd+2J5blr0sFK(5;xENOG zitbPsjgnl_I|0l0&Tl%P#e2sxq`hM?+B?7O@-Nammelu-1^Zm@{EExFXzy5Z*E@_; zi|FGCv{?`GtBbWnc!@l1i4c__aE{7YpBT73(p35Fa%H;&Pa+{IDPYE~lR;86SAH~` zqEn)fHdp%jB1u{*zr!cd=9VNaNp*ge1L>0_t$mf>SqjrCLaU}}lq7pAzsse_#>xGq zgK1QpeU;x`lt{|j7iuJ-{gvNSTF`z;5J)>v`7xg$jY_L55C<#2w-n+a^;xOu`y@qE zW97#^9RZ}NQPXs^pF7pp*>=9Ysj2e&ER96ExHQd#;51i$q9~2VCEN0=`!em@)Kd9L zOC|lH6tuWhjwZ!wt^EFZsan$p)b?xITlp!UXf#0W%_LIneU(2jFVQ|JPxCmS{e69v z|Kq$=`z2L|rURtXJR|orjSufRSV| zPUT;qJ@h+j{+)-jW&xZvi{Ye) zqVsUpE`YN(ixWm0EhA^B^AMISfMBmKX)m|spS2P1Ddy?D5@p%Fjg#pVNWb&s^N00O!-I<_5zbad^pOlm(IrJT8a<-79-|lF)@#M@0u}0|Axp7@=QB~6SyoR^L^5tE%ylzg0d|z zlV4Zb0uLhNcrh7|b3vQdy&9LR>A7dJEMI=Qt7~nU{5a9pjees3xVko$cIa$Bv-ZE) zpQ!puz9Or-vMRr#?OaD&PoF~wL5GtG3L3DlUVP2{cysQa`!U$|*4nr#UK^D-{Caum z^8Z@C_P>=^Z(=WWP91aL{a{8tJDC0JFklU+^VOqiaE=D(dHkW z93P*&E86_{4Ik!ZoXH8Eshvi#pBFd}@sN!C*;Vq~nZCi|JWP`fqknyHP~Lr)w*x`N zet;KthU^_S%nK%Y${DjceF##v24b3;EfEL)#pLiR&d~S(8|P{Niu8OUC@k~Bnh}Av z?C=~9LQy>c&a4>a&Ji+c!`mpS#N+8N%*nY=S55Ay1> zZxEB$hkoqExKOFi5#He8y;&hwU%;Xy#CD-w(^(`MBJX7#ePHEMBfRTMpAXp*UQU3IANHX9G&IeN1h~d@6r|I z?b5N)u_1DefpK?Q{N?kCuDne*Gs6JEzOnderb0(g;X-%UrH)hWrwS*o@Ugvcvg^W? z?v68Odkbf~&Yf!S?kTi&o+7rhx4YxS#on&&9-ioJ>mh5kerfBxQfPneLU(&lPob;3 z&~g64xem}Sw{>^7b@q0&_v|Tjbe=qS@l;3WnLPy%3Y}fO`NFx5^BujU>+Ra3#m>)H z=sI0E-`;)lEHG^+I?i?UUeN+icl35jVKAgT)-o5`x_diLUOd;23vJ!) zg;O0pC(pI`^jFZQ2Og6jR%3}cv89NLi@=Me$gK7G(%hWl|3G`r~TE7q~c@YRNMKsGwnSE z9yxz-tI#ngFLt+|7piHBo{J}XdOLbA_O=(!bakE5#_nnFzSMEDz2|V@T$eQe>B7aH zb_hAu*4w52^mcT0*3!$DX&I{CM&47}!d;zGTNx|u zUENm%R@y;(U{B%l*>>XT=uX#KZPFk;433k%*<=*RSfQiSdKOsq&UKt=?>yNq^mGZ# z<&K{AS~{!)+Rg~3H1p*)3T2>Bu#8CPqKp15UKOKC-2WD4hHj4B)~9e~g2@BY{zi|7 z#4sghZi!m0B_pUabnw2g)jDSE#L&JiFXo$Cstb8o$+$u-3E<{tC*fIM_77&91o zI>#|Pan|D8!PNK%sjxMWpDwc2d2NvwrR1lJ+*7t8e+tJj7`*Va>Y$@d$b;wjm&2Sz zGrnBh?7z>eVg=aJ2(ML7jgJkD&5qw^+KZzZjJ4`hpEC{K(F|r&jo!Nq<_=BXr3?m4 z&EBO9R!A+RbrkJQU)YkLUyIeb%#x#J|9ccweJOSXYMYvm7+!q8GlFHBybB;KQn&cR zko7h085Xd)@c~{BV;!+0DEET9Se)_d=gj1u!Vrg-ydthnX7EyDou!#ZxW&ypRV;6? z3s0ob31(;IkNQ7Wus6=Y1r-29Al$c?l~qti}M=*vDK5@1$nwe zM-H{O$Ci)c5J&8T%jm+~vG_!}S~n451Rcx2h>^`w`6kwQ$8&4*Yx2un5KEWixnt{i z2-!!_mB(`{(lGgv^U^Q_;P`5J3fbZDxh;p5ug@-)d2PAlYeRam&1=iOkcK70i`8iu zyteIP=?3lMgXmP;;c3qa?WdMK9tx~%?Pvi97vG|VtdwpYCtxoz(>2h7XDlUz(3yEDnLe=qOOBxh9iWRi>Jc26ex5|VRX$2j*cp)SXpt5|D2=PP9v4D!uJIfu|9oY ze9cgn=*Q)5D96%c?+YkPKzUz4fkj-$sMEEJSf5^x-)AUGLAf5U@F-$>e?4zbw8Z-K z`etqlv|X@1eLbLv_37*Jb!RDB7B2(k^?)MQr>_STu|9o0pkRI4hxx9fMXXP;RyLI7 zp!9i94rOY6+E-x?n#B6FufS!3(!yfgA5g^l6l-N?6I>Rr0Hr^mi1lfIKoRTH{>_Gh z_31zubz*&rwX&h)K^X|6POMJ{!l)DL(}4{(cCkJk41FZlr&uf7sH*^FF!Z!opALpT z66@2!jW+7AJ{^jM6Uht^>r(k*ti&&oy2U@T`9SQ9s)~8r28!f9r842wo)~6$(UBvoyB(w|G zr#IquUn8+Ty%CRCyNLDajd+b8bz*&bW9Lx|fpX)-DPJS3Pj3bku|CDlxZS4|>(iU@ zS_^@4bLTM&fpRmTV10TkposP9t@x&)i1q2MSe6TEda*vewbNOq5(4E`K*2rK8v#XJ zJYgYhDB|Mjjd+zuNkDmHr?V3;gDnvXD9?%!u(ivxpkN_vD9?g29#EbIWjvrf3(9yv zc}~oC&2ijwpiIQ$hVmSJG!c6GIZ!56*eG}ol!+~(W3J3uF~=*G{9!S}>= z9{7o+2>(bwwAd1tX-7Qa9dZ{kACtw%2=<+Jf_ z)}!u`sS(Z)hV#Dc7vaLQffc+6&9keYwQm5yz?(0c1TO_X5azK<)*Q^?=+9AnO6S7eF@1!-3W&8vwZ< zKsEq!KY(lidow);`D8Ibn} zkU~=aP5>zY@=gFL0P;=%DFE_L04V_SP5{}Glz$+AYysp00b~mx9|(hO3m_i|gKY~S z9|$1TN%;o@NHriI3?S8jd@%G*H6R}hy;BXy2LVx0Io_J&zAggAEkawFjs#7%+sdn| zUl*-;*1jTFe_iyPNfldhp7M23K-!k%zCK0T1`M^i3&JZIb&?ic|{{K|`tq=|fS)3m&N! zqz^@nwg%OL^q~}KSCad1gp)hhh`T@{Xh^$g@efB8vgwi4au-M+j>KHo1ws07w96R! zE}lgFa8%dEj!Ag`E_grT`s2PCcPF`zL~*mvyPJXtT0y%h=p$)CyUF^I2ptbs&~6I) zNK|cZX?Ii5N22XbzM$Pw&_|*jjrnJFA={JWz9otqtCkeFkjk@{7Si|RlBL9cBr*c_ z&`3ncR$jk@@h#E%T^6LoZ;5af;d?KAK`RCAsfNv6{dl z_|bsX1Qrp7)dbdeq*zU0eMgGboaDYUid%hqHG@U)I|5cSSVY(aYzFH)qxI%BxEZYP zjG9_}d$lCF?@F;+z#{maQLFFu7O;pgtQN4oE5&L7>$_5{)+G1cQM}L7)e08D?+RG0 zU=dN}p;)qP+Q{GNcd4=f^VtnLHrW9eAk2iC{ZvARFWeQ$*KAU9U`gGKOTVXW>4 ziwNt-{a}4>wBA;f{a}4>R4>krq>cxY+{YuFwmPf>U=jS@$b2dv0E-A?S_i=Tc(mU9 zHXi`%>kwE(SbH4;>l0}m4}tZGw2p_9+$W>>xUb`3un2x4)bTJ_L>OB;4Av*3Er)zB z9|r4_(Gl6wNF85Fa^D}t=r}5WdI>CopNx+C)GvWWgq?r91lIRQTb#QnGK2N~(NW{Q zN0Qv9qWFl%Isz8K?~mF%))BCX*kD1hJ{4`*Z$Yp=6&;f8jnH*8$^AeSAN5#A!6Nvn z=!j2!6f7b(S`e%sh_)QCAXq;T9XqgwHNC0W~&+>fNCwoxiUE47WRKa!T(M%EumOFfa~el)^sqgzu>kd@#H3zGFm zqr5HfC&>DvQKf90q|}p1?#H5>P4SatCAi#YJxSIdi&mKAbCRq-7QL{}XFZkVemo`k z6j=!x!KcXj<0-+X$ok_c!R<-zCsKmj$x6@&ZYS$cqy)E<^(Rt-PbaybOiMjYR)SXQ zX|n!gTIy-C{$yI}nI!j9QO<_$89ImHYG2ngWc{gVjWOXfWc{gV!{&TJo9S$l`*ai^ zs7g52FLs=7EB#qUBuT=ciqC>i#Cnf^7W_{~8;tLq1^?4gtGKw5ZsB#2$%U}^t~`(&IMgr{0dk<6CIFa4x#H@ zlKa^d>l|1FeSgNuzohhItSLzrda2b+-K7|o(GHI&jzgXU=d+;JP+1q z(>k69>$7PcJCoecrF3x?zm(u-LmfN8BEsnE1ncKgx;nx7xsq3(Ig|v>G;x8rm^8xDuSVUMIFM#z6X&oZMX6ADoDQ=9WkEXo#cKgick8q-5?P(q;8OY zDZ(+XL+S?Um!cik!`&eLQgrNu9}hiA?w3=f9*_tcQV&SKoFesr^vfwy4@ke9BK0P@ zUx~tLS1(8e4XGETUy1Pe>uBl)=~p7o0eujpUy0hpO`?p^i%ITRQ>2R^5j3QWApL5J zbP=RqO_45w^s6b-r6l)jY3(k7M9`2ff%I!>?Jj}zYiaE+f%I!>?Jg&|Ur%Ye3=%;@ zx(w2DN=5E`#*zDNU~>xzD9YuYp9+kX{4nb1BkmAbl=HdJUw{rASwj+~?EU zT>*)pAzcCK^J(p_fb{vac2_|9d|JD!N$xiy{BSxBbCpp}@bi%ku&ZDZVGGn%uzn+z zsjhXqKRmgIgj!ULwmx&{`(--wJ)UIU8=gc)-7Qx>N zvhj7Wh%mYFI#|CQtuq<)I#|CQ?H2c=Lf7j_?sp;%OdZziU=jT7$Vz@4EFx^Re;usf ziC(b7ir2yVooKr_%@nM@B=@@!-uE3=A6Nu`C$iJnKCp-|QKt{A-;FA5BK3jwyQ%on zpX9zEoX<_GentdA8xj2=eIddPzyAu-7ou&}mi-`oA?14mN$&SV(sOACKq6>J10elg z%Bu!I`n`z5WSk@>5D1SAV^fHdIlqP@`HTyf<5z5e*4RtzL=s1q_rdFmoCkE}U#QxqEj3bv?2H zJ6&IElGhE!Erot1vI^WlC?sN;ug?uA{)1?FVnHbWgXnp=mX$GbGs*p-@E11+Zh}Sd z4?$hB}UeMTB9EgY_pVUE^T= zNlMr4B=@Is?&0cq8!Uo<66m@O77>PZ8>~M~`|&ndf138=M3VbjiZuZi!9NZCH~|(B zhBX1!*HWwru)daJO(wZNOWSJ_EP`JPSd(B8VOW!3{aM;xlVJT>+Fnyh?$6UPF$EUE zKMUG!6NwQVNARU77>Q^CRl%wV!a90U!+*m zN$xLGtZA?a{zbr=28#&8ng;7HQ>Ly5noDwjlaAFn zun7Kjz?uV#2*a8K>u=JrItSL@q+|6?lKa~f>ke21|0aypJ75uESa-ns+Z5{#Sbv*h z-A!_Tm)7wvSOotzVBH0a2*bJy*59RdybIRfrFFcQm>tD@`zYp0qIh%lqm^`nLeM`&OXT`Kw?q`@ za{mPtDH(ba;v>OT7KGaW5}^&{((>`2)3ib_K}*XAf*~!T|1(XC;*SI^ElO4d*FIzJ GrT;%3Cn&%G literal 0 HcmV?d00001 diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/ByteArray.cs b/third_party/protobuf/csharp/src/Google.Protobuf/ByteArray.cs index b19962794b0d..69b6ef8d634a 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/ByteArray.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/ByteArray.cs @@ -1,79 +1,79 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; - -namespace Google.Protobuf -{ - /// - /// Provides a utility routine to copy small arrays much more quickly than Buffer.BlockCopy - /// - internal static class ByteArray - { - /// - /// The threshold above which you should use Buffer.BlockCopy rather than ByteArray.Copy - /// - private const int CopyThreshold = 12; - - /// - /// Determines which copy routine to use based on the number of bytes to be copied. - /// - internal static void Copy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int count) - { - if (count > CopyThreshold) - { - Buffer.BlockCopy(src, srcOffset, dst, dstOffset, count); - } - else - { - int stop = srcOffset + count; - for (int i = srcOffset; i < stop; i++) - { - dst[dstOffset++] = src[i]; - } - } - } - - /// - /// Reverses the order of bytes in the array - /// - internal static void Reverse(byte[] bytes) - { - for (int first = 0, last = bytes.Length - 1; first < last; first++, last--) - { - byte temp = bytes[first]; - bytes[first] = bytes[last]; - bytes[last] = temp; - } - } - } +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; + +namespace Google.Protobuf +{ + /// + /// Provides a utility routine to copy small arrays much more quickly than Buffer.BlockCopy + /// + internal static class ByteArray + { + /// + /// The threshold above which you should use Buffer.BlockCopy rather than ByteArray.Copy + /// + private const int CopyThreshold = 12; + + /// + /// Determines which copy routine to use based on the number of bytes to be copied. + /// + internal static void Copy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int count) + { + if (count > CopyThreshold) + { + Buffer.BlockCopy(src, srcOffset, dst, dstOffset, count); + } + else + { + int stop = srcOffset + count; + for (int i = srcOffset; i < stop; i++) + { + dst[dstOffset++] = src[i]; + } + } + } + + /// + /// Reverses the order of bytes in the array + /// + internal static void Reverse(byte[] bytes) + { + for (int first = 0, last = bytes.Length - 1; first < last; first++, last--) + { + byte temp = bytes[first]; + bytes[first] = bytes[last]; + bytes[last] = temp; + } + } + } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/ByteString.cs b/third_party/protobuf/csharp/src/Google.Protobuf/ByteString.cs index 11ad6216dd36..32078b4df5dc 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/ByteString.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/ByteString.cs @@ -1,345 +1,412 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace Google.Protobuf -{ - /// - /// Immutable array of bytes. - /// - public sealed class ByteString : IEnumerable, IEquatable - { - private static readonly ByteString empty = new ByteString(new byte[0]); - - private readonly byte[] bytes; - - /// - /// Unsafe operations that can cause IO Failure and/or other catestrophic side-effects. - /// - internal static class Unsafe - { - /// - /// Constructs a new ByteString from the given byte array. The array is - /// *not* copied, and must not be modified after this constructor is called. - /// - internal static ByteString FromBytes(byte[] bytes) - { - return new ByteString(bytes); - } - - /// - /// Provides direct, unrestricted access to the bytes contained in this instance. - /// You must not modify or resize the byte array returned by this method. - /// - internal static byte[] GetBuffer(ByteString bytes) - { - return bytes.bytes; - } - } - - /// - /// Internal use only. Ensure that the provided array is not mutated and belongs to this instance. - /// - internal static ByteString AttachBytes(byte[] bytes) - { - return new ByteString(bytes); - } - - /// - /// Constructs a new ByteString from the given byte array. The array is - /// *not* copied, and must not be modified after this constructor is called. - /// - private ByteString(byte[] bytes) - { - this.bytes = bytes; - } - - /// - /// Returns an empty ByteString. - /// - public static ByteString Empty - { - get { return empty; } - } - - /// - /// Returns the length of this ByteString in bytes. - /// - public int Length - { - get { return bytes.Length; } - } - - /// - /// Returns true if this byte string is empty, false otherwise. - /// - public bool IsEmpty - { - get { return Length == 0; } - } - - /// - /// Converts this into a byte array. - /// - /// The data is copied - changes to the returned array will not be reflected in this ByteString. - /// A byte array with the same data as this ByteString. - public byte[] ToByteArray() - { - return (byte[]) bytes.Clone(); - } - - /// - /// Converts this into a standard base64 representation. - /// - /// A base64 representation of this ByteString. - public string ToBase64() - { - return Convert.ToBase64String(bytes); - } - - /// - /// Constructs a from the Base64 Encoded String. - /// - public static ByteString FromBase64(string bytes) - { - // By handling the empty string explicitly, we not only optimize but we fix a - // problem on CF 2.0. See issue 61 for details. - return bytes == "" ? Empty : new ByteString(Convert.FromBase64String(bytes)); - } - - /// - /// Constructs a from the given array. The contents - /// are copied, so further modifications to the array will not - /// be reflected in the returned ByteString. - /// This method can also be invoked in ByteString.CopyFrom(0xaa, 0xbb, ...) form - /// which is primarily useful for testing. - /// - public static ByteString CopyFrom(params byte[] bytes) - { - return new ByteString((byte[]) bytes.Clone()); - } - - /// - /// Constructs a from a portion of a byte array. - /// - public static ByteString CopyFrom(byte[] bytes, int offset, int count) - { - byte[] portion = new byte[count]; - ByteArray.Copy(bytes, offset, portion, 0, count); - return new ByteString(portion); - } - - /// - /// Creates a new by encoding the specified text with - /// the given encoding. - /// - public static ByteString CopyFrom(string text, Encoding encoding) - { - return new ByteString(encoding.GetBytes(text)); - } - - /// - /// Creates a new by encoding the specified text in UTF-8. - /// - public static ByteString CopyFromUtf8(string text) - { - return CopyFrom(text, Encoding.UTF8); - } - - /// - /// Retuns the byte at the given index. - /// - public byte this[int index] - { - get { return bytes[index]; } - } - - /// - /// Converts this into a string by applying the given encoding. - /// - /// - /// This method should only be used to convert binary data which was the result of encoding - /// text with the given encoding. - /// - /// The encoding to use to decode the binary data into text. - /// The result of decoding the binary data with the given decoding. - public string ToString(Encoding encoding) - { - return encoding.GetString(bytes, 0, bytes.Length); - } - - /// - /// Converts this into a string by applying the UTF-8 encoding. - /// - /// - /// This method should only be used to convert binary data which was the result of encoding - /// text with UTF-8. - /// - /// The result of decoding the binary data with the given decoding. - public string ToStringUtf8() - { - return ToString(Encoding.UTF8); - } - - /// - /// Returns an iterator over the bytes in this . - /// - /// An iterator over the bytes in this object. - public IEnumerator GetEnumerator() - { - return ((IEnumerable) bytes).GetEnumerator(); - } - - /// - /// Returns an iterator over the bytes in this . - /// - /// An iterator over the bytes in this object. - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - /// - /// Creates a CodedInputStream from this ByteString's data. - /// - public CodedInputStream CreateCodedInput() - { - // We trust CodedInputStream not to reveal the provided byte array or modify it - return new CodedInputStream(bytes); - } - - /// - /// Compares two byte strings for equality. - /// - /// The first byte string to compare. - /// The second byte string to compare. - /// true if the byte strings are equal; false otherwise. - public static bool operator ==(ByteString lhs, ByteString rhs) - { - if (ReferenceEquals(lhs, rhs)) - { - return true; - } - if (ReferenceEquals(lhs, null) || ReferenceEquals(rhs, null)) - { - return false; - } - if (lhs.bytes.Length != rhs.bytes.Length) - { - return false; - } - for (int i = 0; i < lhs.Length; i++) - { - if (rhs.bytes[i] != lhs.bytes[i]) - { - return false; - } - } - return true; - } - - /// - /// Compares two byte strings for inequality. - /// - /// The first byte string to compare. - /// The second byte string to compare. - /// false if the byte strings are equal; true otherwise. - public static bool operator !=(ByteString lhs, ByteString rhs) - { - return !(lhs == rhs); - } - - /// - /// Compares this byte string with another object. - /// - /// The object to compare this with. - /// true if refers to an equal ; false otherwise. - public override bool Equals(object obj) - { - return this == (obj as ByteString); - } - - /// - /// Returns a hash code for this object. Two equal byte strings - /// will return the same hash code. - /// - /// A hash code for this object. - public override int GetHashCode() - { - int ret = 23; - foreach (byte b in bytes) - { - ret = (ret << 8) | b; - } - return ret; - } - - /// - /// Compares this byte string with another. - /// - /// The to compare this with. - /// true if refers to an equal byte string; false otherwise. - public bool Equals(ByteString other) - { - return this == other; - } - - /// - /// Used internally by CodedOutputStream to avoid creating a copy for the write - /// - internal void WriteRawBytesTo(CodedOutputStream outputStream) - { - outputStream.WriteRawBytes(bytes, 0, bytes.Length); - } - - /// - /// Copies the entire byte array to the destination array provided at the offset specified. - /// - public void CopyTo(byte[] array, int position) - { - ByteArray.Copy(bytes, 0, array, position, bytes.Length); - } - - /// - /// Writes the entire byte array to the provided stream - /// - public void WriteTo(Stream outputStream) - { - outputStream.Write(bytes, 0, bytes.Length); - } - } +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Text; +#if !NET35 +using System.Threading; +using System.Threading.Tasks; +#endif +#if NET35 +using Google.Protobuf.Compatibility; +#endif + +namespace Google.Protobuf +{ + /// + /// Immutable array of bytes. + /// + public sealed class ByteString : IEnumerable, IEquatable + { + private static readonly ByteString empty = new ByteString(new byte[0]); + + private readonly byte[] bytes; + + /// + /// Unsafe operations that can cause IO Failure and/or other catestrophic side-effects. + /// + internal static class Unsafe + { + /// + /// Constructs a new ByteString from the given byte array. The array is + /// *not* copied, and must not be modified after this constructor is called. + /// + internal static ByteString FromBytes(byte[] bytes) + { + return new ByteString(bytes); + } + } + + /// + /// Internal use only. Ensure that the provided array is not mutated and belongs to this instance. + /// + internal static ByteString AttachBytes(byte[] bytes) + { + return new ByteString(bytes); + } + + /// + /// Constructs a new ByteString from the given byte array. The array is + /// *not* copied, and must not be modified after this constructor is called. + /// + private ByteString(byte[] bytes) + { + this.bytes = bytes; + } + + /// + /// Returns an empty ByteString. + /// + public static ByteString Empty + { + get { return empty; } + } + + /// + /// Returns the length of this ByteString in bytes. + /// + public int Length + { + get { return bytes.Length; } + } + + /// + /// Returns true if this byte string is empty, false otherwise. + /// + public bool IsEmpty + { + get { return Length == 0; } + } + +#if NETSTANDARD2_0 + /// + /// Provides read-only access to the data of this . + /// No data is copied so this is the most efficient way of accessing. + /// + public ReadOnlySpan Span => new ReadOnlySpan(bytes); +#endif + + /// + /// Converts this into a byte array. + /// + /// The data is copied - changes to the returned array will not be reflected in this ByteString. + /// A byte array with the same data as this ByteString. + public byte[] ToByteArray() + { + return (byte[]) bytes.Clone(); + } + + /// + /// Converts this into a standard base64 representation. + /// + /// A base64 representation of this ByteString. + public string ToBase64() + { + return Convert.ToBase64String(bytes); + } + + /// + /// Constructs a from the Base64 Encoded String. + /// + public static ByteString FromBase64(string bytes) + { + // By handling the empty string explicitly, we not only optimize but we fix a + // problem on CF 2.0. See issue 61 for details. + return bytes == "" ? Empty : new ByteString(Convert.FromBase64String(bytes)); + } + + /// + /// Constructs a from data in the given stream, synchronously. + /// + /// If successful, will be read completely, from the position + /// at the start of the call. + /// The stream to copy into a ByteString. + /// A ByteString with content read from the given stream. + public static ByteString FromStream(Stream stream) + { + ProtoPreconditions.CheckNotNull(stream, nameof(stream)); + int capacity = stream.CanSeek ? checked((int) (stream.Length - stream.Position)) : 0; + var memoryStream = new MemoryStream(capacity); + stream.CopyTo(memoryStream); +#if NETSTANDARD1_0 || NETSTANDARD2_0 + byte[] bytes = memoryStream.ToArray(); +#else + // Avoid an extra copy if we can. + byte[] bytes = memoryStream.Length == memoryStream.Capacity ? memoryStream.GetBuffer() : memoryStream.ToArray(); +#endif + return AttachBytes(bytes); + } + +#if !NET35 + /// + /// Constructs a from data in the given stream, asynchronously. + /// + /// If successful, will be read completely, from the position + /// at the start of the call. + /// The stream to copy into a ByteString. + /// The cancellation token to use when reading from the stream, if any. + /// A ByteString with content read from the given stream. + public async static Task FromStreamAsync(Stream stream, CancellationToken cancellationToken = default(CancellationToken)) + { + ProtoPreconditions.CheckNotNull(stream, nameof(stream)); + int capacity = stream.CanSeek ? checked((int) (stream.Length - stream.Position)) : 0; + var memoryStream = new MemoryStream(capacity); + // We have to specify the buffer size here, as there's no overload accepting the cancellation token + // alone. But it's documented to use 81920 by default if not specified. + await stream.CopyToAsync(memoryStream, 81920, cancellationToken); +#if NETSTANDARD1_0 || NETSTANDARD2_0 + byte[] bytes = memoryStream.ToArray(); +#else + // Avoid an extra copy if we can. + byte[] bytes = memoryStream.Length == memoryStream.Capacity ? memoryStream.GetBuffer() : memoryStream.ToArray(); +#endif + return AttachBytes(bytes); + } +#endif + + /// + /// Constructs a from the given array. The contents + /// are copied, so further modifications to the array will not + /// be reflected in the returned ByteString. + /// This method can also be invoked in ByteString.CopyFrom(0xaa, 0xbb, ...) form + /// which is primarily useful for testing. + /// + public static ByteString CopyFrom(params byte[] bytes) + { + return new ByteString((byte[]) bytes.Clone()); + } + + /// + /// Constructs a from a portion of a byte array. + /// + public static ByteString CopyFrom(byte[] bytes, int offset, int count) + { + byte[] portion = new byte[count]; + ByteArray.Copy(bytes, offset, portion, 0, count); + return new ByteString(portion); + } + +#if NETSTANDARD2_0 + /// + /// Constructs a from a read only span. The contents + /// are copied, so further modifications to the span will not + /// be reflected in the returned . + /// + public static ByteString CopyFrom(ReadOnlySpan bytes) + { + return new ByteString(bytes.ToArray()); + } +#endif + + /// + /// Creates a new by encoding the specified text with + /// the given encoding. + /// + public static ByteString CopyFrom(string text, Encoding encoding) + { + return new ByteString(encoding.GetBytes(text)); + } + + /// + /// Creates a new by encoding the specified text in UTF-8. + /// + public static ByteString CopyFromUtf8(string text) + { + return CopyFrom(text, Encoding.UTF8); + } + + /// + /// Retuns the byte at the given index. + /// + public byte this[int index] + { + get { return bytes[index]; } + } + + /// + /// Converts this into a string by applying the given encoding. + /// + /// + /// This method should only be used to convert binary data which was the result of encoding + /// text with the given encoding. + /// + /// The encoding to use to decode the binary data into text. + /// The result of decoding the binary data with the given decoding. + public string ToString(Encoding encoding) + { + return encoding.GetString(bytes, 0, bytes.Length); + } + + /// + /// Converts this into a string by applying the UTF-8 encoding. + /// + /// + /// This method should only be used to convert binary data which was the result of encoding + /// text with UTF-8. + /// + /// The result of decoding the binary data with the given decoding. + public string ToStringUtf8() + { + return ToString(Encoding.UTF8); + } + + /// + /// Returns an iterator over the bytes in this . + /// + /// An iterator over the bytes in this object. + public IEnumerator GetEnumerator() + { + return ((IEnumerable) bytes).GetEnumerator(); + } + + /// + /// Returns an iterator over the bytes in this . + /// + /// An iterator over the bytes in this object. + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// + /// Creates a CodedInputStream from this ByteString's data. + /// + public CodedInputStream CreateCodedInput() + { + // We trust CodedInputStream not to reveal the provided byte array or modify it + return new CodedInputStream(bytes); + } + + /// + /// Compares two byte strings for equality. + /// + /// The first byte string to compare. + /// The second byte string to compare. + /// true if the byte strings are equal; false otherwise. + public static bool operator ==(ByteString lhs, ByteString rhs) + { + if (ReferenceEquals(lhs, rhs)) + { + return true; + } + if (ReferenceEquals(lhs, null) || ReferenceEquals(rhs, null)) + { + return false; + } + if (lhs.bytes.Length != rhs.bytes.Length) + { + return false; + } + for (int i = 0; i < lhs.Length; i++) + { + if (rhs.bytes[i] != lhs.bytes[i]) + { + return false; + } + } + return true; + } + + /// + /// Compares two byte strings for inequality. + /// + /// The first byte string to compare. + /// The second byte string to compare. + /// false if the byte strings are equal; true otherwise. + public static bool operator !=(ByteString lhs, ByteString rhs) + { + return !(lhs == rhs); + } + + /// + /// Compares this byte string with another object. + /// + /// The object to compare this with. + /// true if refers to an equal ; false otherwise. + public override bool Equals(object obj) + { + return this == (obj as ByteString); + } + + /// + /// Returns a hash code for this object. Two equal byte strings + /// will return the same hash code. + /// + /// A hash code for this object. + public override int GetHashCode() + { + int ret = 23; + foreach (byte b in bytes) + { + ret = (ret * 31) + b; + } + return ret; + } + + /// + /// Compares this byte string with another. + /// + /// The to compare this with. + /// true if refers to an equal byte string; false otherwise. + public bool Equals(ByteString other) + { + return this == other; + } + + /// + /// Used internally by CodedOutputStream to avoid creating a copy for the write + /// + internal void WriteRawBytesTo(CodedOutputStream outputStream) + { + outputStream.WriteRawBytes(bytes, 0, bytes.Length); + } + + /// + /// Copies the entire byte array to the destination array provided at the offset specified. + /// + public void CopyTo(byte[] array, int position) + { + ByteArray.Copy(bytes, 0, array, position, bytes.Length); + } + + /// + /// Writes the entire byte array to the provided stream + /// + public void WriteTo(Stream outputStream) + { + outputStream.Write(bytes, 0, bytes.Length); + } + } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/CodedInputStream.cs b/third_party/protobuf/csharp/src/Google.Protobuf/CodedInputStream.cs index 3484457f6475..4d13f88ab95d 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/CodedInputStream.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/CodedInputStream.cs @@ -1,1277 +1,1306 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using Google.Protobuf.Collections; -using System; -using System.Collections.Generic; -using System.IO; - -namespace Google.Protobuf -{ - /// - /// Reads and decodes protocol message fields. - /// - /// - /// - /// This class is generally used by generated code to read appropriate - /// primitives from the stream. It effectively encapsulates the lowest - /// levels of protocol buffer format. - /// - /// - /// Repeated fields and map fields are not handled by this class; use - /// and to serialize such fields. - /// - /// - public sealed class CodedInputStream : IDisposable - { - /// - /// Whether to leave the underlying stream open when disposing of this stream. - /// This is always true when there's no stream. - /// - private readonly bool leaveOpen; - - /// - /// Buffer of data read from the stream or provided at construction time. - /// - private readonly byte[] buffer; - - /// - /// The index of the buffer at which we need to refill from the stream (if there is one). - /// - private int bufferSize; - - private int bufferSizeAfterLimit = 0; - /// - /// The position within the current buffer (i.e. the next byte to read) - /// - private int bufferPos = 0; - - /// - /// The stream to read further input from, or null if the byte array buffer was provided - /// directly on construction, with no further data available. - /// - private readonly Stream input; - - /// - /// The last tag we read. 0 indicates we've read to the end of the stream - /// (or haven't read anything yet). - /// - private uint lastTag = 0; - - /// - /// The next tag, used to store the value read by PeekTag. - /// - private uint nextTag = 0; - private bool hasNextTag = false; - - internal const int DefaultRecursionLimit = 64; - internal const int DefaultSizeLimit = 64 << 20; // 64MB - internal const int BufferSize = 4096; - - /// - /// The total number of bytes read before the current buffer. The - /// total bytes read up to the current position can be computed as - /// totalBytesRetired + bufferPos. - /// - private int totalBytesRetired = 0; - - /// - /// The absolute position of the end of the current message. - /// - private int currentLimit = int.MaxValue; - - private int recursionDepth = 0; - - private readonly int recursionLimit; - private readonly int sizeLimit; - - #region Construction - // Note that the checks are performed such that we don't end up checking obviously-valid things - // like non-null references for arrays we've just created. - - /// - /// Creates a new CodedInputStream reading data from the given byte array. - /// - public CodedInputStream(byte[] buffer) : this(null, ProtoPreconditions.CheckNotNull(buffer, "buffer"), 0, buffer.Length) - { - } - - /// - /// Creates a new that reads from the given byte array slice. - /// - public CodedInputStream(byte[] buffer, int offset, int length) - : this(null, ProtoPreconditions.CheckNotNull(buffer, "buffer"), offset, offset + length) - { - if (offset < 0 || offset > buffer.Length) - { - throw new ArgumentOutOfRangeException("offset", "Offset must be within the buffer"); - } - if (length < 0 || offset + length > buffer.Length) - { - throw new ArgumentOutOfRangeException("length", "Length must be non-negative and within the buffer"); - } - } - - /// - /// Creates a new reading data from the given stream, which will be disposed - /// when the returned object is disposed. - /// - /// The stream to read from. - public CodedInputStream(Stream input) : this(input, false) - { - } - - /// - /// Creates a new reading data from the given stream. - /// - /// The stream to read from. - /// true to leave open when the returned - /// is disposed; false to dispose of the given stream when the - /// returned object is disposed. - public CodedInputStream(Stream input, bool leaveOpen) - : this(ProtoPreconditions.CheckNotNull(input, "input"), new byte[BufferSize], 0, 0) - { - this.leaveOpen = leaveOpen; - } - - /// - /// Creates a new CodedInputStream reading data from the given - /// stream and buffer, using the default limits. - /// - internal CodedInputStream(Stream input, byte[] buffer, int bufferPos, int bufferSize) - { - this.input = input; - this.buffer = buffer; - this.bufferPos = bufferPos; - this.bufferSize = bufferSize; - this.sizeLimit = DefaultSizeLimit; - this.recursionLimit = DefaultRecursionLimit; - } - - /// - /// Creates a new CodedInputStream reading data from the given - /// stream and buffer, using the specified limits. - /// - /// - /// This chains to the version with the default limits instead of vice versa to avoid - /// having to check that the default values are valid every time. - /// - internal CodedInputStream(Stream input, byte[] buffer, int bufferPos, int bufferSize, int sizeLimit, int recursionLimit) - : this(input, buffer, bufferPos, bufferSize) - { - if (sizeLimit <= 0) - { - throw new ArgumentOutOfRangeException("sizeLimit", "Size limit must be positive"); - } - if (recursionLimit <= 0) - { - throw new ArgumentOutOfRangeException("recursionLimit!", "Recursion limit must be positive"); - } - this.sizeLimit = sizeLimit; - this.recursionLimit = recursionLimit; - } - #endregion - - /// - /// Creates a with the specified size and recursion limits, reading - /// from an input stream. - /// - /// - /// This method exists separately from the constructor to reduce the number of constructor overloads. - /// It is likely to be used considerably less frequently than the constructors, as the default limits - /// are suitable for most use cases. - /// - /// The input stream to read from - /// The total limit of data to read from the stream. - /// The maximum recursion depth to allow while reading. - /// A CodedInputStream reading from with the specified size - /// and recursion limits. - public static CodedInputStream CreateWithLimits(Stream input, int sizeLimit, int recursionLimit) - { - return new CodedInputStream(input, new byte[BufferSize], 0, 0, sizeLimit, recursionLimit); - } - - /// - /// Returns the current position in the input stream, or the position in the input buffer - /// - public long Position - { - get - { - if (input != null) - { - return input.Position - ((bufferSize + bufferSizeAfterLimit) - bufferPos); - } - return bufferPos; - } - } - - /// - /// Returns the last tag read, or 0 if no tags have been read or we've read beyond - /// the end of the stream. - /// - internal uint LastTag { get { return lastTag; } } - - /// - /// Returns the size limit for this stream. - /// - /// - /// This limit is applied when reading from the underlying stream, as a sanity check. It is - /// not applied when reading from a byte array data source without an underlying stream. - /// The default value is 64MB. - /// - /// - /// The size limit. - /// - public int SizeLimit { get { return sizeLimit; } } - - /// - /// Returns the recursion limit for this stream. This limit is applied whilst reading messages, - /// to avoid maliciously-recursive data. - /// - /// - /// The default limit is 64. - /// - /// - /// The recursion limit for this stream. - /// - public int RecursionLimit { get { return recursionLimit; } } - - /// - /// Disposes of this instance, potentially closing any underlying stream. - /// - /// - /// As there is no flushing to perform here, disposing of a which - /// was constructed with the leaveOpen option parameter set to true (or one which - /// was constructed to read from a byte array) has no effect. - /// - public void Dispose() - { - if (!leaveOpen) - { - input.Dispose(); - } - } - - #region Validation - /// - /// Verifies that the last call to ReadTag() returned tag 0 - in other words, - /// we've reached the end of the stream when we expected to. - /// - /// The - /// tag read was not the one specified - internal void CheckReadEndOfStreamTag() - { - if (lastTag != 0) - { - throw InvalidProtocolBufferException.MoreDataAvailable(); - } - } - #endregion - - #region Reading of tags etc - - /// - /// Peeks at the next field tag. This is like calling , but the - /// tag is not consumed. (So a subsequent call to will return the - /// same value.) - /// - public uint PeekTag() - { - if (hasNextTag) - { - return nextTag; - } - - uint savedLast = lastTag; - nextTag = ReadTag(); - hasNextTag = true; - lastTag = savedLast; // Undo the side effect of ReadTag - return nextTag; - } - - /// - /// Reads a field tag, returning the tag of 0 for "end of stream". - /// - /// - /// If this method returns 0, it doesn't necessarily mean the end of all - /// the data in this CodedInputStream; it may be the end of the logical stream - /// for an embedded message, for example. - /// - /// The next field tag, or 0 for end of stream. (0 is never a valid tag.) - public uint ReadTag() - { - if (hasNextTag) - { - lastTag = nextTag; - hasNextTag = false; - return lastTag; - } - - // Optimize for the incredibly common case of having at least two bytes left in the buffer, - // and those two bytes being enough to get the tag. This will be true for fields up to 4095. - if (bufferPos + 2 <= bufferSize) - { - int tmp = buffer[bufferPos++]; - if (tmp < 128) - { - lastTag = (uint)tmp; - } - else - { - int result = tmp & 0x7f; - if ((tmp = buffer[bufferPos++]) < 128) - { - result |= tmp << 7; - lastTag = (uint) result; - } - else - { - // Nope, rewind and go the potentially slow route. - bufferPos -= 2; - lastTag = ReadRawVarint32(); - } - } - } - else - { - if (IsAtEnd) - { - lastTag = 0; - return 0; // This is the only case in which we return 0. - } - - lastTag = ReadRawVarint32(); - } - if (lastTag == 0) - { - // If we actually read zero, that's not a valid tag. - throw InvalidProtocolBufferException.InvalidTag(); - } - return lastTag; - } - - /// - /// Skips the data for the field with the tag we've just read. - /// This should be called directly after , when - /// the caller wishes to skip an unknown field. - /// - /// - /// This method throws if the last-read tag was an end-group tag. - /// If a caller wishes to skip a group, they should skip the whole group, by calling this method after reading the - /// start-group tag. This behavior allows callers to call this method on any field they don't understand, correctly - /// resulting in an error if an end-group tag has not been paired with an earlier start-group tag. - /// - /// The last tag was an end-group tag - /// The last read operation read to the end of the logical stream - public void SkipLastField() - { - if (lastTag == 0) - { - throw new InvalidOperationException("SkipLastField cannot be called at the end of a stream"); - } - switch (WireFormat.GetTagWireType(lastTag)) - { - case WireFormat.WireType.StartGroup: - SkipGroup(lastTag); - break; - case WireFormat.WireType.EndGroup: - throw new InvalidProtocolBufferException( - "SkipLastField called on an end-group tag, indicating that the corresponding start-group was missing"); - case WireFormat.WireType.Fixed32: - ReadFixed32(); - break; - case WireFormat.WireType.Fixed64: - ReadFixed64(); - break; - case WireFormat.WireType.LengthDelimited: - var length = ReadLength(); - SkipRawBytes(length); - break; - case WireFormat.WireType.Varint: - ReadRawVarint32(); - break; - } - } - - private void SkipGroup(uint startGroupTag) - { - // Note: Currently we expect this to be the way that groups are read. We could put the recursion - // depth changes into the ReadTag method instead, potentially... - recursionDepth++; - if (recursionDepth >= recursionLimit) - { - throw InvalidProtocolBufferException.RecursionLimitExceeded(); - } - uint tag; - while (true) - { - tag = ReadTag(); - if (tag == 0) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - // Can't call SkipLastField for this case- that would throw. - if (WireFormat.GetTagWireType(tag) == WireFormat.WireType.EndGroup) - { - break; - } - // This recursion will allow us to handle nested groups. - SkipLastField(); - } - int startField = WireFormat.GetTagFieldNumber(startGroupTag); - int endField = WireFormat.GetTagFieldNumber(tag); - if (startField != endField) - { - throw new InvalidProtocolBufferException( - $"Mismatched end-group tag. Started with field {startField}; ended with field {endField}"); - } - recursionDepth--; - } - - /// - /// Reads a double field from the stream. - /// - public double ReadDouble() - { - return BitConverter.Int64BitsToDouble((long) ReadRawLittleEndian64()); - } - - /// - /// Reads a float field from the stream. - /// - public float ReadFloat() - { - if (BitConverter.IsLittleEndian && 4 <= bufferSize - bufferPos) - { - float ret = BitConverter.ToSingle(buffer, bufferPos); - bufferPos += 4; - return ret; - } - else - { - byte[] rawBytes = ReadRawBytes(4); - if (!BitConverter.IsLittleEndian) - { - ByteArray.Reverse(rawBytes); - } - return BitConverter.ToSingle(rawBytes, 0); - } - } - - /// - /// Reads a uint64 field from the stream. - /// - public ulong ReadUInt64() - { - return ReadRawVarint64(); - } - - /// - /// Reads an int64 field from the stream. - /// - public long ReadInt64() - { - return (long) ReadRawVarint64(); - } - - /// - /// Reads an int32 field from the stream. - /// - public int ReadInt32() - { - return (int) ReadRawVarint32(); - } - - /// - /// Reads a fixed64 field from the stream. - /// - public ulong ReadFixed64() - { - return ReadRawLittleEndian64(); - } - - /// - /// Reads a fixed32 field from the stream. - /// - public uint ReadFixed32() - { - return ReadRawLittleEndian32(); - } - - /// - /// Reads a bool field from the stream. - /// - public bool ReadBool() - { - return ReadRawVarint32() != 0; - } - - /// - /// Reads a string field from the stream. - /// - public string ReadString() - { - int length = ReadLength(); - // No need to read any data for an empty string. - if (length == 0) - { - return ""; - } - if (length <= bufferSize - bufferPos) - { - // Fast path: We already have the bytes in a contiguous buffer, so - // just copy directly from it. - String result = CodedOutputStream.Utf8Encoding.GetString(buffer, bufferPos, length); - bufferPos += length; - return result; - } - // Slow path: Build a byte array first then copy it. - return CodedOutputStream.Utf8Encoding.GetString(ReadRawBytes(length), 0, length); - } - - /// - /// Reads an embedded message field value from the stream. - /// - public void ReadMessage(IMessage builder) - { - int length = ReadLength(); - if (recursionDepth >= recursionLimit) - { - throw InvalidProtocolBufferException.RecursionLimitExceeded(); - } - int oldLimit = PushLimit(length); - ++recursionDepth; - builder.MergeFrom(this); - CheckReadEndOfStreamTag(); - // Check that we've read exactly as much data as expected. - if (!ReachedLimit) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - --recursionDepth; - PopLimit(oldLimit); - } - - /// - /// Reads a bytes field value from the stream. - /// - public ByteString ReadBytes() - { - int length = ReadLength(); - if (length <= bufferSize - bufferPos && length > 0) - { - // Fast path: We already have the bytes in a contiguous buffer, so - // just copy directly from it. - ByteString result = ByteString.CopyFrom(buffer, bufferPos, length); - bufferPos += length; - return result; - } - else - { - // Slow path: Build a byte array and attach it to a new ByteString. - return ByteString.AttachBytes(ReadRawBytes(length)); - } - } - - /// - /// Reads a uint32 field value from the stream. - /// - public uint ReadUInt32() - { - return ReadRawVarint32(); - } - - /// - /// Reads an enum field value from the stream. If the enum is valid for type T, - /// then the ref value is set and it returns true. Otherwise the unknown output - /// value is set and this method returns false. - /// - public int ReadEnum() - { - // Currently just a pass-through, but it's nice to separate it logically from WriteInt32. - return (int) ReadRawVarint32(); - } - - /// - /// Reads an sfixed32 field value from the stream. - /// - public int ReadSFixed32() - { - return (int) ReadRawLittleEndian32(); - } - - /// - /// Reads an sfixed64 field value from the stream. - /// - public long ReadSFixed64() - { - return (long) ReadRawLittleEndian64(); - } - - /// - /// Reads an sint32 field value from the stream. - /// - public int ReadSInt32() - { - return DecodeZigZag32(ReadRawVarint32()); - } - - /// - /// Reads an sint64 field value from the stream. - /// - public long ReadSInt64() - { - return DecodeZigZag64(ReadRawVarint64()); - } - - /// - /// Reads a length for length-delimited data. - /// - /// - /// This is internally just reading a varint, but this method exists - /// to make the calling code clearer. - /// - public int ReadLength() - { - return (int) ReadRawVarint32(); - } - - /// - /// Peeks at the next tag in the stream. If it matches , - /// the tag is consumed and the method returns true; otherwise, the - /// stream is left in the original position and the method returns false. - /// - public bool MaybeConsumeTag(uint tag) - { - if (PeekTag() == tag) - { - hasNextTag = false; - return true; - } - return false; - } - - #endregion - - #region Underlying reading primitives - - /// - /// Same code as ReadRawVarint32, but read each byte individually, checking for - /// buffer overflow. - /// - private uint SlowReadRawVarint32() - { - int tmp = ReadRawByte(); - if (tmp < 128) - { - return (uint) tmp; - } - int result = tmp & 0x7f; - if ((tmp = ReadRawByte()) < 128) - { - result |= tmp << 7; - } - else - { - result |= (tmp & 0x7f) << 7; - if ((tmp = ReadRawByte()) < 128) - { - result |= tmp << 14; - } - else - { - result |= (tmp & 0x7f) << 14; - if ((tmp = ReadRawByte()) < 128) - { - result |= tmp << 21; - } - else - { - result |= (tmp & 0x7f) << 21; - result |= (tmp = ReadRawByte()) << 28; - if (tmp >= 128) - { - // Discard upper 32 bits. - for (int i = 0; i < 5; i++) - { - if (ReadRawByte() < 128) - { - return (uint) result; - } - } - throw InvalidProtocolBufferException.MalformedVarint(); - } - } - } - } - return (uint) result; - } - - /// - /// Reads a raw Varint from the stream. If larger than 32 bits, discard the upper bits. - /// This method is optimised for the case where we've got lots of data in the buffer. - /// That means we can check the size just once, then just read directly from the buffer - /// without constant rechecking of the buffer length. - /// - internal uint ReadRawVarint32() - { - if (bufferPos + 5 > bufferSize) - { - return SlowReadRawVarint32(); - } - - int tmp = buffer[bufferPos++]; - if (tmp < 128) - { - return (uint) tmp; - } - int result = tmp & 0x7f; - if ((tmp = buffer[bufferPos++]) < 128) - { - result |= tmp << 7; - } - else - { - result |= (tmp & 0x7f) << 7; - if ((tmp = buffer[bufferPos++]) < 128) - { - result |= tmp << 14; - } - else - { - result |= (tmp & 0x7f) << 14; - if ((tmp = buffer[bufferPos++]) < 128) - { - result |= tmp << 21; - } - else - { - result |= (tmp & 0x7f) << 21; - result |= (tmp = buffer[bufferPos++]) << 28; - if (tmp >= 128) - { - // Discard upper 32 bits. - // Note that this has to use ReadRawByte() as we only ensure we've - // got at least 5 bytes at the start of the method. This lets us - // use the fast path in more cases, and we rarely hit this section of code. - for (int i = 0; i < 5; i++) - { - if (ReadRawByte() < 128) - { - return (uint) result; - } - } - throw InvalidProtocolBufferException.MalformedVarint(); - } - } - } - } - return (uint) result; - } - - /// - /// Reads a varint from the input one byte at a time, so that it does not - /// read any bytes after the end of the varint. If you simply wrapped the - /// stream in a CodedInputStream and used ReadRawVarint32(Stream) - /// then you would probably end up reading past the end of the varint since - /// CodedInputStream buffers its input. - /// - /// - /// - internal static uint ReadRawVarint32(Stream input) - { - int result = 0; - int offset = 0; - for (; offset < 32; offset += 7) - { - int b = input.ReadByte(); - if (b == -1) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - result |= (b & 0x7f) << offset; - if ((b & 0x80) == 0) - { - return (uint) result; - } - } - // Keep reading up to 64 bits. - for (; offset < 64; offset += 7) - { - int b = input.ReadByte(); - if (b == -1) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - if ((b & 0x80) == 0) - { - return (uint) result; - } - } - throw InvalidProtocolBufferException.MalformedVarint(); - } - - /// - /// Reads a raw varint from the stream. - /// - internal ulong ReadRawVarint64() - { - int shift = 0; - ulong result = 0; - while (shift < 64) - { - byte b = ReadRawByte(); - result |= (ulong) (b & 0x7F) << shift; - if ((b & 0x80) == 0) - { - return result; - } - shift += 7; - } - throw InvalidProtocolBufferException.MalformedVarint(); - } - - /// - /// Reads a 32-bit little-endian integer from the stream. - /// - internal uint ReadRawLittleEndian32() - { - uint b1 = ReadRawByte(); - uint b2 = ReadRawByte(); - uint b3 = ReadRawByte(); - uint b4 = ReadRawByte(); - return b1 | (b2 << 8) | (b3 << 16) | (b4 << 24); - } - - /// - /// Reads a 64-bit little-endian integer from the stream. - /// - internal ulong ReadRawLittleEndian64() - { - ulong b1 = ReadRawByte(); - ulong b2 = ReadRawByte(); - ulong b3 = ReadRawByte(); - ulong b4 = ReadRawByte(); - ulong b5 = ReadRawByte(); - ulong b6 = ReadRawByte(); - ulong b7 = ReadRawByte(); - ulong b8 = ReadRawByte(); - return b1 | (b2 << 8) | (b3 << 16) | (b4 << 24) - | (b5 << 32) | (b6 << 40) | (b7 << 48) | (b8 << 56); - } - - /// - /// Decode a 32-bit value with ZigZag encoding. - /// - /// - /// ZigZag encodes signed integers into values that can be efficiently - /// encoded with varint. (Otherwise, negative values must be - /// sign-extended to 64 bits to be varint encoded, thus always taking - /// 10 bytes on the wire.) - /// - internal static int DecodeZigZag32(uint n) - { - return (int)(n >> 1) ^ -(int)(n & 1); - } - - /// - /// Decode a 32-bit value with ZigZag encoding. - /// - /// - /// ZigZag encodes signed integers into values that can be efficiently - /// encoded with varint. (Otherwise, negative values must be - /// sign-extended to 64 bits to be varint encoded, thus always taking - /// 10 bytes on the wire.) - /// - internal static long DecodeZigZag64(ulong n) - { - return (long)(n >> 1) ^ -(long)(n & 1); - } - #endregion - - #region Internal reading and buffer management - - /// - /// Sets currentLimit to (current position) + byteLimit. This is called - /// when descending into a length-delimited embedded message. The previous - /// limit is returned. - /// - /// The old limit. - internal int PushLimit(int byteLimit) - { - if (byteLimit < 0) - { - throw InvalidProtocolBufferException.NegativeSize(); - } - byteLimit += totalBytesRetired + bufferPos; - int oldLimit = currentLimit; - if (byteLimit > oldLimit) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - currentLimit = byteLimit; - - RecomputeBufferSizeAfterLimit(); - - return oldLimit; - } - - private void RecomputeBufferSizeAfterLimit() - { - bufferSize += bufferSizeAfterLimit; - int bufferEnd = totalBytesRetired + bufferSize; - if (bufferEnd > currentLimit) - { - // Limit is in current buffer. - bufferSizeAfterLimit = bufferEnd - currentLimit; - bufferSize -= bufferSizeAfterLimit; - } - else - { - bufferSizeAfterLimit = 0; - } - } - - /// - /// Discards the current limit, returning the previous limit. - /// - internal void PopLimit(int oldLimit) - { - currentLimit = oldLimit; - RecomputeBufferSizeAfterLimit(); - } - - /// - /// Returns whether or not all the data before the limit has been read. - /// - /// - internal bool ReachedLimit - { - get - { - if (currentLimit == int.MaxValue) - { - return false; - } - int currentAbsolutePosition = totalBytesRetired + bufferPos; - return currentAbsolutePosition >= currentLimit; - } - } - - /// - /// Returns true if the stream has reached the end of the input. This is the - /// case if either the end of the underlying input source has been reached or - /// the stream has reached a limit created using PushLimit. - /// - public bool IsAtEnd - { - get { return bufferPos == bufferSize && !RefillBuffer(false); } - } - - /// - /// Called when buffer is empty to read more bytes from the - /// input. If is true, RefillBuffer() gurantees that - /// either there will be at least one byte in the buffer when it returns - /// or it will throw an exception. If is false, - /// RefillBuffer() returns false if no more bytes were available. - /// - /// - /// - private bool RefillBuffer(bool mustSucceed) - { - if (bufferPos < bufferSize) - { - throw new InvalidOperationException("RefillBuffer() called when buffer wasn't empty."); - } - - if (totalBytesRetired + bufferSize == currentLimit) - { - // Oops, we hit a limit. - if (mustSucceed) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - else - { - return false; - } - } - - totalBytesRetired += bufferSize; - - bufferPos = 0; - bufferSize = (input == null) ? 0 : input.Read(buffer, 0, buffer.Length); - if (bufferSize < 0) - { - throw new InvalidOperationException("Stream.Read returned a negative count"); - } - if (bufferSize == 0) - { - if (mustSucceed) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - else - { - return false; - } - } - else - { - RecomputeBufferSizeAfterLimit(); - int totalBytesRead = - totalBytesRetired + bufferSize + bufferSizeAfterLimit; - if (totalBytesRead > sizeLimit || totalBytesRead < 0) - { - throw InvalidProtocolBufferException.SizeLimitExceeded(); - } - return true; - } - } - - /// - /// Read one byte from the input. - /// - /// - /// the end of the stream or the current limit was reached - /// - internal byte ReadRawByte() - { - if (bufferPos == bufferSize) - { - RefillBuffer(true); - } - return buffer[bufferPos++]; - } - - /// - /// Reads a fixed size of bytes from the input. - /// - /// - /// the end of the stream or the current limit was reached - /// - internal byte[] ReadRawBytes(int size) - { - if (size < 0) - { - throw InvalidProtocolBufferException.NegativeSize(); - } - - if (totalBytesRetired + bufferPos + size > currentLimit) - { - // Read to the end of the stream (up to the current limit) anyway. - SkipRawBytes(currentLimit - totalBytesRetired - bufferPos); - // Then fail. - throw InvalidProtocolBufferException.TruncatedMessage(); - } - - if (size <= bufferSize - bufferPos) - { - // We have all the bytes we need already. - byte[] bytes = new byte[size]; - ByteArray.Copy(buffer, bufferPos, bytes, 0, size); - bufferPos += size; - return bytes; - } - else if (size < buffer.Length) - { - // Reading more bytes than are in the buffer, but not an excessive number - // of bytes. We can safely allocate the resulting array ahead of time. - - // First copy what we have. - byte[] bytes = new byte[size]; - int pos = bufferSize - bufferPos; - ByteArray.Copy(buffer, bufferPos, bytes, 0, pos); - bufferPos = bufferSize; - - // We want to use RefillBuffer() and then copy from the buffer into our - // byte array rather than reading directly into our byte array because - // the input may be unbuffered. - RefillBuffer(true); - - while (size - pos > bufferSize) - { - Buffer.BlockCopy(buffer, 0, bytes, pos, bufferSize); - pos += bufferSize; - bufferPos = bufferSize; - RefillBuffer(true); - } - - ByteArray.Copy(buffer, 0, bytes, pos, size - pos); - bufferPos = size - pos; - - return bytes; - } - else - { - // The size is very large. For security reasons, we can't allocate the - // entire byte array yet. The size comes directly from the input, so a - // maliciously-crafted message could provide a bogus very large size in - // order to trick the app into allocating a lot of memory. We avoid this - // by allocating and reading only a small chunk at a time, so that the - // malicious message must actually *be* extremely large to cause - // problems. Meanwhile, we limit the allowed size of a message elsewhere. - - // Remember the buffer markers since we'll have to copy the bytes out of - // it later. - int originalBufferPos = bufferPos; - int originalBufferSize = bufferSize; - - // Mark the current buffer consumed. - totalBytesRetired += bufferSize; - bufferPos = 0; - bufferSize = 0; - - // Read all the rest of the bytes we need. - int sizeLeft = size - (originalBufferSize - originalBufferPos); - List chunks = new List(); - - while (sizeLeft > 0) - { - byte[] chunk = new byte[Math.Min(sizeLeft, buffer.Length)]; - int pos = 0; - while (pos < chunk.Length) - { - int n = (input == null) ? -1 : input.Read(chunk, pos, chunk.Length - pos); - if (n <= 0) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - totalBytesRetired += n; - pos += n; - } - sizeLeft -= chunk.Length; - chunks.Add(chunk); - } - - // OK, got everything. Now concatenate it all into one buffer. - byte[] bytes = new byte[size]; - - // Start by copying the leftover bytes from this.buffer. - int newPos = originalBufferSize - originalBufferPos; - ByteArray.Copy(buffer, originalBufferPos, bytes, 0, newPos); - - // And now all the chunks. - foreach (byte[] chunk in chunks) - { - Buffer.BlockCopy(chunk, 0, bytes, newPos, chunk.Length); - newPos += chunk.Length; - } - - // Done. - return bytes; - } - } - - /// - /// Reads and discards bytes. - /// - /// the end of the stream - /// or the current limit was reached - private void SkipRawBytes(int size) - { - if (size < 0) - { - throw InvalidProtocolBufferException.NegativeSize(); - } - - if (totalBytesRetired + bufferPos + size > currentLimit) - { - // Read to the end of the stream anyway. - SkipRawBytes(currentLimit - totalBytesRetired - bufferPos); - // Then fail. - throw InvalidProtocolBufferException.TruncatedMessage(); - } - - if (size <= bufferSize - bufferPos) - { - // We have all the bytes we need already. - bufferPos += size; - } - else - { - // Skipping more bytes than are in the buffer. First skip what we have. - int pos = bufferSize - bufferPos; - - // ROK 5/7/2013 Issue #54: should retire all bytes in buffer (bufferSize) - // totalBytesRetired += pos; - totalBytesRetired += bufferSize; - - bufferPos = 0; - bufferSize = 0; - - // Then skip directly from the InputStream for the rest. - if (pos < size) - { - if (input == null) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - SkipImpl(size - pos); - totalBytesRetired += size - pos; - } - } - } - - /// - /// Abstraction of skipping to cope with streams which can't really skip. - /// - private void SkipImpl(int amountToSkip) - { - if (input.CanSeek) - { - long previousPosition = input.Position; - input.Position += amountToSkip; - if (input.Position != previousPosition + amountToSkip) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - } - else - { - byte[] skipBuffer = new byte[Math.Min(1024, amountToSkip)]; - while (amountToSkip > 0) - { - int bytesRead = input.Read(skipBuffer, 0, Math.Min(skipBuffer.Length, amountToSkip)); - if (bytesRead <= 0) - { - throw InvalidProtocolBufferException.TruncatedMessage(); - } - amountToSkip -= bytesRead; - } - } - } - - #endregion - } +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using Google.Protobuf.Collections; +using System; +using System.Collections.Generic; +using System.IO; + +namespace Google.Protobuf +{ + /// + /// Reads and decodes protocol message fields. + /// + /// + /// + /// This class is generally used by generated code to read appropriate + /// primitives from the stream. It effectively encapsulates the lowest + /// levels of protocol buffer format. + /// + /// + /// Repeated fields and map fields are not handled by this class; use + /// and to serialize such fields. + /// + /// + public sealed class CodedInputStream : IDisposable + { + /// + /// Whether to leave the underlying stream open when disposing of this stream. + /// This is always true when there's no stream. + /// + private readonly bool leaveOpen; + + /// + /// Buffer of data read from the stream or provided at construction time. + /// + private readonly byte[] buffer; + + /// + /// The index of the buffer at which we need to refill from the stream (if there is one). + /// + private int bufferSize; + + private int bufferSizeAfterLimit = 0; + /// + /// The position within the current buffer (i.e. the next byte to read) + /// + private int bufferPos = 0; + + /// + /// The stream to read further input from, or null if the byte array buffer was provided + /// directly on construction, with no further data available. + /// + private readonly Stream input; + + /// + /// The last tag we read. 0 indicates we've read to the end of the stream + /// (or haven't read anything yet). + /// + private uint lastTag = 0; + + /// + /// The next tag, used to store the value read by PeekTag. + /// + private uint nextTag = 0; + private bool hasNextTag = false; + + internal const int DefaultRecursionLimit = 100; + internal const int DefaultSizeLimit = Int32.MaxValue; + internal const int BufferSize = 4096; + + /// + /// The total number of bytes read before the current buffer. The + /// total bytes read up to the current position can be computed as + /// totalBytesRetired + bufferPos. + /// + private int totalBytesRetired = 0; + + /// + /// The absolute position of the end of the current message. + /// + private int currentLimit = int.MaxValue; + + private int recursionDepth = 0; + + private readonly int recursionLimit; + private readonly int sizeLimit; + + #region Construction + // Note that the checks are performed such that we don't end up checking obviously-valid things + // like non-null references for arrays we've just created. + + /// + /// Creates a new CodedInputStream reading data from the given byte array. + /// + public CodedInputStream(byte[] buffer) : this(null, ProtoPreconditions.CheckNotNull(buffer, "buffer"), 0, buffer.Length, true) + { + } + + /// + /// Creates a new that reads from the given byte array slice. + /// + public CodedInputStream(byte[] buffer, int offset, int length) + : this(null, ProtoPreconditions.CheckNotNull(buffer, "buffer"), offset, offset + length, true) + { + if (offset < 0 || offset > buffer.Length) + { + throw new ArgumentOutOfRangeException("offset", "Offset must be within the buffer"); + } + if (length < 0 || offset + length > buffer.Length) + { + throw new ArgumentOutOfRangeException("length", "Length must be non-negative and within the buffer"); + } + } + + /// + /// Creates a new reading data from the given stream, which will be disposed + /// when the returned object is disposed. + /// + /// The stream to read from. + public CodedInputStream(Stream input) : this(input, false) + { + } + + /// + /// Creates a new reading data from the given stream. + /// + /// The stream to read from. + /// true to leave open when the returned + /// is disposed; false to dispose of the given stream when the + /// returned object is disposed. + public CodedInputStream(Stream input, bool leaveOpen) + : this(ProtoPreconditions.CheckNotNull(input, "input"), new byte[BufferSize], 0, 0, leaveOpen) + { + } + + /// + /// Creates a new CodedInputStream reading data from the given + /// stream and buffer, using the default limits. + /// + internal CodedInputStream(Stream input, byte[] buffer, int bufferPos, int bufferSize, bool leaveOpen) + { + this.input = input; + this.buffer = buffer; + this.bufferPos = bufferPos; + this.bufferSize = bufferSize; + this.sizeLimit = DefaultSizeLimit; + this.recursionLimit = DefaultRecursionLimit; + this.leaveOpen = leaveOpen; + } + + /// + /// Creates a new CodedInputStream reading data from the given + /// stream and buffer, using the specified limits. + /// + /// + /// This chains to the version with the default limits instead of vice versa to avoid + /// having to check that the default values are valid every time. + /// + internal CodedInputStream(Stream input, byte[] buffer, int bufferPos, int bufferSize, int sizeLimit, int recursionLimit, bool leaveOpen) + : this(input, buffer, bufferPos, bufferSize, leaveOpen) + { + if (sizeLimit <= 0) + { + throw new ArgumentOutOfRangeException("sizeLimit", "Size limit must be positive"); + } + if (recursionLimit <= 0) + { + throw new ArgumentOutOfRangeException("recursionLimit!", "Recursion limit must be positive"); + } + this.sizeLimit = sizeLimit; + this.recursionLimit = recursionLimit; + } + #endregion + + /// + /// Creates a with the specified size and recursion limits, reading + /// from an input stream. + /// + /// + /// This method exists separately from the constructor to reduce the number of constructor overloads. + /// It is likely to be used considerably less frequently than the constructors, as the default limits + /// are suitable for most use cases. + /// + /// The input stream to read from + /// The total limit of data to read from the stream. + /// The maximum recursion depth to allow while reading. + /// A CodedInputStream reading from with the specified size + /// and recursion limits. + public static CodedInputStream CreateWithLimits(Stream input, int sizeLimit, int recursionLimit) + { + // Note: we may want an overload accepting leaveOpen + return new CodedInputStream(input, new byte[BufferSize], 0, 0, sizeLimit, recursionLimit, false); + } + + /// + /// Returns the current position in the input stream, or the position in the input buffer + /// + public long Position + { + get + { + if (input != null) + { + return input.Position - ((bufferSize + bufferSizeAfterLimit) - bufferPos); + } + return bufferPos; + } + } + + /// + /// Returns the last tag read, or 0 if no tags have been read or we've read beyond + /// the end of the stream. + /// + internal uint LastTag { get { return lastTag; } } + + /// + /// Returns the size limit for this stream. + /// + /// + /// This limit is applied when reading from the underlying stream, as a sanity check. It is + /// not applied when reading from a byte array data source without an underlying stream. + /// The default value is Int32.MaxValue. + /// + /// + /// The size limit. + /// + public int SizeLimit { get { return sizeLimit; } } + + /// + /// Returns the recursion limit for this stream. This limit is applied whilst reading messages, + /// to avoid maliciously-recursive data. + /// + /// + /// The default limit is 100. + /// + /// + /// The recursion limit for this stream. + /// + public int RecursionLimit { get { return recursionLimit; } } + + /// + /// Internal-only property; when set to true, unknown fields will be discarded while parsing. + /// + internal bool DiscardUnknownFields { get; set; } + + /// + /// Internal-only property; provides extension identifiers to compatible messages while parsing. + /// + internal ExtensionRegistry ExtensionRegistry { get; set; } + + /// + /// Disposes of this instance, potentially closing any underlying stream. + /// + /// + /// As there is no flushing to perform here, disposing of a which + /// was constructed with the leaveOpen option parameter set to true (or one which + /// was constructed to read from a byte array) has no effect. + /// + public void Dispose() + { + if (!leaveOpen) + { + input.Dispose(); + } + } + + #region Validation + /// + /// Verifies that the last call to ReadTag() returned tag 0 - in other words, + /// we've reached the end of the stream when we expected to. + /// + /// The + /// tag read was not the one specified + internal void CheckReadEndOfStreamTag() + { + if (lastTag != 0) + { + throw InvalidProtocolBufferException.MoreDataAvailable(); + } + } + #endregion + + #region Reading of tags etc + + /// + /// Peeks at the next field tag. This is like calling , but the + /// tag is not consumed. (So a subsequent call to will return the + /// same value.) + /// + public uint PeekTag() + { + if (hasNextTag) + { + return nextTag; + } + + uint savedLast = lastTag; + nextTag = ReadTag(); + hasNextTag = true; + lastTag = savedLast; // Undo the side effect of ReadTag + return nextTag; + } + + /// + /// Reads a field tag, returning the tag of 0 for "end of stream". + /// + /// + /// If this method returns 0, it doesn't necessarily mean the end of all + /// the data in this CodedInputStream; it may be the end of the logical stream + /// for an embedded message, for example. + /// + /// The next field tag, or 0 for end of stream. (0 is never a valid tag.) + public uint ReadTag() + { + if (hasNextTag) + { + lastTag = nextTag; + hasNextTag = false; + return lastTag; + } + + // Optimize for the incredibly common case of having at least two bytes left in the buffer, + // and those two bytes being enough to get the tag. This will be true for fields up to 4095. + if (bufferPos + 2 <= bufferSize) + { + int tmp = buffer[bufferPos++]; + if (tmp < 128) + { + lastTag = (uint)tmp; + } + else + { + int result = tmp & 0x7f; + if ((tmp = buffer[bufferPos++]) < 128) + { + result |= tmp << 7; + lastTag = (uint) result; + } + else + { + // Nope, rewind and go the potentially slow route. + bufferPos -= 2; + lastTag = ReadRawVarint32(); + } + } + } + else + { + if (IsAtEnd) + { + lastTag = 0; + return 0; + } + + lastTag = ReadRawVarint32(); + } + if (WireFormat.GetTagFieldNumber(lastTag) == 0) + { + // If we actually read a tag with a field of 0, that's not a valid tag. + throw InvalidProtocolBufferException.InvalidTag(); + } + if (ReachedLimit) + { + return 0; + } + return lastTag; + } + + /// + /// Skips the data for the field with the tag we've just read. + /// This should be called directly after , when + /// the caller wishes to skip an unknown field. + /// + /// + /// This method throws if the last-read tag was an end-group tag. + /// If a caller wishes to skip a group, they should skip the whole group, by calling this method after reading the + /// start-group tag. This behavior allows callers to call this method on any field they don't understand, correctly + /// resulting in an error if an end-group tag has not been paired with an earlier start-group tag. + /// + /// The last tag was an end-group tag + /// The last read operation read to the end of the logical stream + public void SkipLastField() + { + if (lastTag == 0) + { + throw new InvalidOperationException("SkipLastField cannot be called at the end of a stream"); + } + switch (WireFormat.GetTagWireType(lastTag)) + { + case WireFormat.WireType.StartGroup: + SkipGroup(lastTag); + break; + case WireFormat.WireType.EndGroup: + throw new InvalidProtocolBufferException( + "SkipLastField called on an end-group tag, indicating that the corresponding start-group was missing"); + case WireFormat.WireType.Fixed32: + ReadFixed32(); + break; + case WireFormat.WireType.Fixed64: + ReadFixed64(); + break; + case WireFormat.WireType.LengthDelimited: + var length = ReadLength(); + SkipRawBytes(length); + break; + case WireFormat.WireType.Varint: + ReadRawVarint32(); + break; + } + } + + /// + /// Skip a group. + /// + internal void SkipGroup(uint startGroupTag) + { + // Note: Currently we expect this to be the way that groups are read. We could put the recursion + // depth changes into the ReadTag method instead, potentially... + recursionDepth++; + if (recursionDepth >= recursionLimit) + { + throw InvalidProtocolBufferException.RecursionLimitExceeded(); + } + uint tag; + while (true) + { + tag = ReadTag(); + if (tag == 0) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + // Can't call SkipLastField for this case- that would throw. + if (WireFormat.GetTagWireType(tag) == WireFormat.WireType.EndGroup) + { + break; + } + // This recursion will allow us to handle nested groups. + SkipLastField(); + } + int startField = WireFormat.GetTagFieldNumber(startGroupTag); + int endField = WireFormat.GetTagFieldNumber(tag); + if (startField != endField) + { + throw new InvalidProtocolBufferException( + $"Mismatched end-group tag. Started with field {startField}; ended with field {endField}"); + } + recursionDepth--; + } + + /// + /// Reads a double field from the stream. + /// + public double ReadDouble() + { + return BitConverter.Int64BitsToDouble((long) ReadRawLittleEndian64()); + } + + /// + /// Reads a float field from the stream. + /// + public float ReadFloat() + { + if (BitConverter.IsLittleEndian && 4 <= bufferSize - bufferPos) + { + float ret = BitConverter.ToSingle(buffer, bufferPos); + bufferPos += 4; + return ret; + } + else + { + byte[] rawBytes = ReadRawBytes(4); + if (!BitConverter.IsLittleEndian) + { + ByteArray.Reverse(rawBytes); + } + return BitConverter.ToSingle(rawBytes, 0); + } + } + + /// + /// Reads a uint64 field from the stream. + /// + public ulong ReadUInt64() + { + return ReadRawVarint64(); + } + + /// + /// Reads an int64 field from the stream. + /// + public long ReadInt64() + { + return (long) ReadRawVarint64(); + } + + /// + /// Reads an int32 field from the stream. + /// + public int ReadInt32() + { + return (int) ReadRawVarint32(); + } + + /// + /// Reads a fixed64 field from the stream. + /// + public ulong ReadFixed64() + { + return ReadRawLittleEndian64(); + } + + /// + /// Reads a fixed32 field from the stream. + /// + public uint ReadFixed32() + { + return ReadRawLittleEndian32(); + } + + /// + /// Reads a bool field from the stream. + /// + public bool ReadBool() + { + return ReadRawVarint32() != 0; + } + + /// + /// Reads a string field from the stream. + /// + public string ReadString() + { + int length = ReadLength(); + // No need to read any data for an empty string. + if (length == 0) + { + return ""; + } + if (length <= bufferSize - bufferPos && length > 0) + { + // Fast path: We already have the bytes in a contiguous buffer, so + // just copy directly from it. + String result = CodedOutputStream.Utf8Encoding.GetString(buffer, bufferPos, length); + bufferPos += length; + return result; + } + // Slow path: Build a byte array first then copy it. + return CodedOutputStream.Utf8Encoding.GetString(ReadRawBytes(length), 0, length); + } + + /// + /// Reads an embedded message field value from the stream. + /// + public void ReadMessage(IMessage builder) + { + int length = ReadLength(); + if (recursionDepth >= recursionLimit) + { + throw InvalidProtocolBufferException.RecursionLimitExceeded(); + } + int oldLimit = PushLimit(length); + ++recursionDepth; + builder.MergeFrom(this); + CheckReadEndOfStreamTag(); + // Check that we've read exactly as much data as expected. + if (!ReachedLimit) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + --recursionDepth; + PopLimit(oldLimit); + } + + /// + /// Reads an embedded group field from the stream. + /// + public void ReadGroup(IMessage builder) + { + if (recursionDepth >= recursionLimit) + { + throw InvalidProtocolBufferException.RecursionLimitExceeded(); + } + ++recursionDepth; + builder.MergeFrom(this); + --recursionDepth; + } + + /// + /// Reads a bytes field value from the stream. + /// + public ByteString ReadBytes() + { + int length = ReadLength(); + if (length <= bufferSize - bufferPos && length > 0) + { + // Fast path: We already have the bytes in a contiguous buffer, so + // just copy directly from it. + ByteString result = ByteString.CopyFrom(buffer, bufferPos, length); + bufferPos += length; + return result; + } + else + { + // Slow path: Build a byte array and attach it to a new ByteString. + return ByteString.AttachBytes(ReadRawBytes(length)); + } + } + + /// + /// Reads a uint32 field value from the stream. + /// + public uint ReadUInt32() + { + return ReadRawVarint32(); + } + + /// + /// Reads an enum field value from the stream. + /// + public int ReadEnum() + { + // Currently just a pass-through, but it's nice to separate it logically from WriteInt32. + return (int) ReadRawVarint32(); + } + + /// + /// Reads an sfixed32 field value from the stream. + /// + public int ReadSFixed32() + { + return (int) ReadRawLittleEndian32(); + } + + /// + /// Reads an sfixed64 field value from the stream. + /// + public long ReadSFixed64() + { + return (long) ReadRawLittleEndian64(); + } + + /// + /// Reads an sint32 field value from the stream. + /// + public int ReadSInt32() + { + return DecodeZigZag32(ReadRawVarint32()); + } + + /// + /// Reads an sint64 field value from the stream. + /// + public long ReadSInt64() + { + return DecodeZigZag64(ReadRawVarint64()); + } + + /// + /// Reads a length for length-delimited data. + /// + /// + /// This is internally just reading a varint, but this method exists + /// to make the calling code clearer. + /// + public int ReadLength() + { + return (int) ReadRawVarint32(); + } + + /// + /// Peeks at the next tag in the stream. If it matches , + /// the tag is consumed and the method returns true; otherwise, the + /// stream is left in the original position and the method returns false. + /// + public bool MaybeConsumeTag(uint tag) + { + if (PeekTag() == tag) + { + hasNextTag = false; + return true; + } + return false; + } + + #endregion + + #region Underlying reading primitives + + /// + /// Same code as ReadRawVarint32, but read each byte individually, checking for + /// buffer overflow. + /// + private uint SlowReadRawVarint32() + { + int tmp = ReadRawByte(); + if (tmp < 128) + { + return (uint) tmp; + } + int result = tmp & 0x7f; + if ((tmp = ReadRawByte()) < 128) + { + result |= tmp << 7; + } + else + { + result |= (tmp & 0x7f) << 7; + if ((tmp = ReadRawByte()) < 128) + { + result |= tmp << 14; + } + else + { + result |= (tmp & 0x7f) << 14; + if ((tmp = ReadRawByte()) < 128) + { + result |= tmp << 21; + } + else + { + result |= (tmp & 0x7f) << 21; + result |= (tmp = ReadRawByte()) << 28; + if (tmp >= 128) + { + // Discard upper 32 bits. + for (int i = 0; i < 5; i++) + { + if (ReadRawByte() < 128) + { + return (uint) result; + } + } + throw InvalidProtocolBufferException.MalformedVarint(); + } + } + } + } + return (uint) result; + } + + /// + /// Reads a raw Varint from the stream. If larger than 32 bits, discard the upper bits. + /// This method is optimised for the case where we've got lots of data in the buffer. + /// That means we can check the size just once, then just read directly from the buffer + /// without constant rechecking of the buffer length. + /// + internal uint ReadRawVarint32() + { + if (bufferPos + 5 > bufferSize) + { + return SlowReadRawVarint32(); + } + + int tmp = buffer[bufferPos++]; + if (tmp < 128) + { + return (uint) tmp; + } + int result = tmp & 0x7f; + if ((tmp = buffer[bufferPos++]) < 128) + { + result |= tmp << 7; + } + else + { + result |= (tmp & 0x7f) << 7; + if ((tmp = buffer[bufferPos++]) < 128) + { + result |= tmp << 14; + } + else + { + result |= (tmp & 0x7f) << 14; + if ((tmp = buffer[bufferPos++]) < 128) + { + result |= tmp << 21; + } + else + { + result |= (tmp & 0x7f) << 21; + result |= (tmp = buffer[bufferPos++]) << 28; + if (tmp >= 128) + { + // Discard upper 32 bits. + // Note that this has to use ReadRawByte() as we only ensure we've + // got at least 5 bytes at the start of the method. This lets us + // use the fast path in more cases, and we rarely hit this section of code. + for (int i = 0; i < 5; i++) + { + if (ReadRawByte() < 128) + { + return (uint) result; + } + } + throw InvalidProtocolBufferException.MalformedVarint(); + } + } + } + } + return (uint) result; + } + + /// + /// Reads a varint from the input one byte at a time, so that it does not + /// read any bytes after the end of the varint. If you simply wrapped the + /// stream in a CodedInputStream and used ReadRawVarint32(Stream) + /// then you would probably end up reading past the end of the varint since + /// CodedInputStream buffers its input. + /// + /// + /// + internal static uint ReadRawVarint32(Stream input) + { + int result = 0; + int offset = 0; + for (; offset < 32; offset += 7) + { + int b = input.ReadByte(); + if (b == -1) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + result |= (b & 0x7f) << offset; + if ((b & 0x80) == 0) + { + return (uint) result; + } + } + // Keep reading up to 64 bits. + for (; offset < 64; offset += 7) + { + int b = input.ReadByte(); + if (b == -1) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + if ((b & 0x80) == 0) + { + return (uint) result; + } + } + throw InvalidProtocolBufferException.MalformedVarint(); + } + + /// + /// Reads a raw varint from the stream. + /// + internal ulong ReadRawVarint64() + { + int shift = 0; + ulong result = 0; + while (shift < 64) + { + byte b = ReadRawByte(); + result |= (ulong) (b & 0x7F) << shift; + if ((b & 0x80) == 0) + { + return result; + } + shift += 7; + } + throw InvalidProtocolBufferException.MalformedVarint(); + } + + /// + /// Reads a 32-bit little-endian integer from the stream. + /// + internal uint ReadRawLittleEndian32() + { + uint b1 = ReadRawByte(); + uint b2 = ReadRawByte(); + uint b3 = ReadRawByte(); + uint b4 = ReadRawByte(); + return b1 | (b2 << 8) | (b3 << 16) | (b4 << 24); + } + + /// + /// Reads a 64-bit little-endian integer from the stream. + /// + internal ulong ReadRawLittleEndian64() + { + ulong b1 = ReadRawByte(); + ulong b2 = ReadRawByte(); + ulong b3 = ReadRawByte(); + ulong b4 = ReadRawByte(); + ulong b5 = ReadRawByte(); + ulong b6 = ReadRawByte(); + ulong b7 = ReadRawByte(); + ulong b8 = ReadRawByte(); + return b1 | (b2 << 8) | (b3 << 16) | (b4 << 24) + | (b5 << 32) | (b6 << 40) | (b7 << 48) | (b8 << 56); + } + + /// + /// Decode a 32-bit value with ZigZag encoding. + /// + /// + /// ZigZag encodes signed integers into values that can be efficiently + /// encoded with varint. (Otherwise, negative values must be + /// sign-extended to 64 bits to be varint encoded, thus always taking + /// 10 bytes on the wire.) + /// + internal static int DecodeZigZag32(uint n) + { + return (int)(n >> 1) ^ -(int)(n & 1); + } + + /// + /// Decode a 32-bit value with ZigZag encoding. + /// + /// + /// ZigZag encodes signed integers into values that can be efficiently + /// encoded with varint. (Otherwise, negative values must be + /// sign-extended to 64 bits to be varint encoded, thus always taking + /// 10 bytes on the wire.) + /// + internal static long DecodeZigZag64(ulong n) + { + return (long)(n >> 1) ^ -(long)(n & 1); + } + #endregion + + #region Internal reading and buffer management + + /// + /// Sets currentLimit to (current position) + byteLimit. This is called + /// when descending into a length-delimited embedded message. The previous + /// limit is returned. + /// + /// The old limit. + internal int PushLimit(int byteLimit) + { + if (byteLimit < 0) + { + throw InvalidProtocolBufferException.NegativeSize(); + } + byteLimit += totalBytesRetired + bufferPos; + int oldLimit = currentLimit; + if (byteLimit > oldLimit) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + currentLimit = byteLimit; + + RecomputeBufferSizeAfterLimit(); + + return oldLimit; + } + + private void RecomputeBufferSizeAfterLimit() + { + bufferSize += bufferSizeAfterLimit; + int bufferEnd = totalBytesRetired + bufferSize; + if (bufferEnd > currentLimit) + { + // Limit is in current buffer. + bufferSizeAfterLimit = bufferEnd - currentLimit; + bufferSize -= bufferSizeAfterLimit; + } + else + { + bufferSizeAfterLimit = 0; + } + } + + /// + /// Discards the current limit, returning the previous limit. + /// + internal void PopLimit(int oldLimit) + { + currentLimit = oldLimit; + RecomputeBufferSizeAfterLimit(); + } + + /// + /// Returns whether or not all the data before the limit has been read. + /// + /// + internal bool ReachedLimit + { + get + { + if (currentLimit == int.MaxValue) + { + return false; + } + int currentAbsolutePosition = totalBytesRetired + bufferPos; + return currentAbsolutePosition >= currentLimit; + } + } + + /// + /// Returns true if the stream has reached the end of the input. This is the + /// case if either the end of the underlying input source has been reached or + /// the stream has reached a limit created using PushLimit. + /// + public bool IsAtEnd + { + get { return bufferPos == bufferSize && !RefillBuffer(false); } + } + + /// + /// Called when buffer is empty to read more bytes from the + /// input. If is true, RefillBuffer() gurantees that + /// either there will be at least one byte in the buffer when it returns + /// or it will throw an exception. If is false, + /// RefillBuffer() returns false if no more bytes were available. + /// + /// + /// + private bool RefillBuffer(bool mustSucceed) + { + if (bufferPos < bufferSize) + { + throw new InvalidOperationException("RefillBuffer() called when buffer wasn't empty."); + } + + if (totalBytesRetired + bufferSize == currentLimit) + { + // Oops, we hit a limit. + if (mustSucceed) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + else + { + return false; + } + } + + totalBytesRetired += bufferSize; + + bufferPos = 0; + bufferSize = (input == null) ? 0 : input.Read(buffer, 0, buffer.Length); + if (bufferSize < 0) + { + throw new InvalidOperationException("Stream.Read returned a negative count"); + } + if (bufferSize == 0) + { + if (mustSucceed) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + else + { + return false; + } + } + else + { + RecomputeBufferSizeAfterLimit(); + int totalBytesRead = + totalBytesRetired + bufferSize + bufferSizeAfterLimit; + if (totalBytesRead < 0 || totalBytesRead > sizeLimit) + { + throw InvalidProtocolBufferException.SizeLimitExceeded(); + } + return true; + } + } + + /// + /// Read one byte from the input. + /// + /// + /// the end of the stream or the current limit was reached + /// + internal byte ReadRawByte() + { + if (bufferPos == bufferSize) + { + RefillBuffer(true); + } + return buffer[bufferPos++]; + } + + /// + /// Reads a fixed size of bytes from the input. + /// + /// + /// the end of the stream or the current limit was reached + /// + internal byte[] ReadRawBytes(int size) + { + if (size < 0) + { + throw InvalidProtocolBufferException.NegativeSize(); + } + + if (totalBytesRetired + bufferPos + size > currentLimit) + { + // Read to the end of the stream (up to the current limit) anyway. + SkipRawBytes(currentLimit - totalBytesRetired - bufferPos); + // Then fail. + throw InvalidProtocolBufferException.TruncatedMessage(); + } + + if (size <= bufferSize - bufferPos) + { + // We have all the bytes we need already. + byte[] bytes = new byte[size]; + ByteArray.Copy(buffer, bufferPos, bytes, 0, size); + bufferPos += size; + return bytes; + } + else if (size < buffer.Length) + { + // Reading more bytes than are in the buffer, but not an excessive number + // of bytes. We can safely allocate the resulting array ahead of time. + + // First copy what we have. + byte[] bytes = new byte[size]; + int pos = bufferSize - bufferPos; + ByteArray.Copy(buffer, bufferPos, bytes, 0, pos); + bufferPos = bufferSize; + + // We want to use RefillBuffer() and then copy from the buffer into our + // byte array rather than reading directly into our byte array because + // the input may be unbuffered. + RefillBuffer(true); + + while (size - pos > bufferSize) + { + Buffer.BlockCopy(buffer, 0, bytes, pos, bufferSize); + pos += bufferSize; + bufferPos = bufferSize; + RefillBuffer(true); + } + + ByteArray.Copy(buffer, 0, bytes, pos, size - pos); + bufferPos = size - pos; + + return bytes; + } + else + { + // The size is very large. For security reasons, we can't allocate the + // entire byte array yet. The size comes directly from the input, so a + // maliciously-crafted message could provide a bogus very large size in + // order to trick the app into allocating a lot of memory. We avoid this + // by allocating and reading only a small chunk at a time, so that the + // malicious message must actually *be* extremely large to cause + // problems. Meanwhile, we limit the allowed size of a message elsewhere. + + // Remember the buffer markers since we'll have to copy the bytes out of + // it later. + int originalBufferPos = bufferPos; + int originalBufferSize = bufferSize; + + // Mark the current buffer consumed. + totalBytesRetired += bufferSize; + bufferPos = 0; + bufferSize = 0; + + // Read all the rest of the bytes we need. + int sizeLeft = size - (originalBufferSize - originalBufferPos); + List chunks = new List(); + + while (sizeLeft > 0) + { + byte[] chunk = new byte[Math.Min(sizeLeft, buffer.Length)]; + int pos = 0; + while (pos < chunk.Length) + { + int n = (input == null) ? -1 : input.Read(chunk, pos, chunk.Length - pos); + if (n <= 0) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + totalBytesRetired += n; + pos += n; + } + sizeLeft -= chunk.Length; + chunks.Add(chunk); + } + + // OK, got everything. Now concatenate it all into one buffer. + byte[] bytes = new byte[size]; + + // Start by copying the leftover bytes from this.buffer. + int newPos = originalBufferSize - originalBufferPos; + ByteArray.Copy(buffer, originalBufferPos, bytes, 0, newPos); + + // And now all the chunks. + foreach (byte[] chunk in chunks) + { + Buffer.BlockCopy(chunk, 0, bytes, newPos, chunk.Length); + newPos += chunk.Length; + } + + // Done. + return bytes; + } + } + + /// + /// Reads and discards bytes. + /// + /// the end of the stream + /// or the current limit was reached + private void SkipRawBytes(int size) + { + if (size < 0) + { + throw InvalidProtocolBufferException.NegativeSize(); + } + + if (totalBytesRetired + bufferPos + size > currentLimit) + { + // Read to the end of the stream anyway. + SkipRawBytes(currentLimit - totalBytesRetired - bufferPos); + // Then fail. + throw InvalidProtocolBufferException.TruncatedMessage(); + } + + if (size <= bufferSize - bufferPos) + { + // We have all the bytes we need already. + bufferPos += size; + } + else + { + // Skipping more bytes than are in the buffer. First skip what we have. + int pos = bufferSize - bufferPos; + + // ROK 5/7/2013 Issue #54: should retire all bytes in buffer (bufferSize) + // totalBytesRetired += pos; + totalBytesRetired += bufferSize; + + bufferPos = 0; + bufferSize = 0; + + // Then skip directly from the InputStream for the rest. + if (pos < size) + { + if (input == null) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + SkipImpl(size - pos); + totalBytesRetired += size - pos; + } + } + } + + /// + /// Abstraction of skipping to cope with streams which can't really skip. + /// + private void SkipImpl(int amountToSkip) + { + if (input.CanSeek) + { + long previousPosition = input.Position; + input.Position += amountToSkip; + if (input.Position != previousPosition + amountToSkip) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + } + else + { + byte[] skipBuffer = new byte[Math.Min(1024, amountToSkip)]; + while (amountToSkip > 0) + { + int bytesRead = input.Read(skipBuffer, 0, Math.Min(skipBuffer.Length, amountToSkip)); + if (bytesRead <= 0) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + amountToSkip -= bytesRead; + } + } + } + #endregion + } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/CodedOutputStream.ComputeSize.cs b/third_party/protobuf/csharp/src/Google.Protobuf/CodedOutputStream.ComputeSize.cs index e22937c13dd0..aa7932470ba3 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/CodedOutputStream.ComputeSize.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/CodedOutputStream.ComputeSize.cs @@ -1,304 +1,308 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; - -namespace Google.Protobuf -{ - // This part of CodedOutputStream provides all the static entry points that are used - // by generated code and internally to compute the size of messages prior to being - // written to an instance of CodedOutputStream. - public sealed partial class CodedOutputStream - { - private const int LittleEndian64Size = 8; - private const int LittleEndian32Size = 4; - - /// - /// Computes the number of bytes that would be needed to encode a - /// double field, including the tag. - /// - public static int ComputeDoubleSize(double value) - { - return LittleEndian64Size; - } - - /// - /// Computes the number of bytes that would be needed to encode a - /// float field, including the tag. - /// - public static int ComputeFloatSize(float value) - { - return LittleEndian32Size; - } - - /// - /// Computes the number of bytes that would be needed to encode a - /// uint64 field, including the tag. - /// - public static int ComputeUInt64Size(ulong value) - { - return ComputeRawVarint64Size(value); - } - - /// - /// Computes the number of bytes that would be needed to encode an - /// int64 field, including the tag. - /// - public static int ComputeInt64Size(long value) - { - return ComputeRawVarint64Size((ulong) value); - } - - /// - /// Computes the number of bytes that would be needed to encode an - /// int32 field, including the tag. - /// - public static int ComputeInt32Size(int value) - { - if (value >= 0) - { - return ComputeRawVarint32Size((uint) value); - } - else - { - // Must sign-extend. - return 10; - } - } - - /// - /// Computes the number of bytes that would be needed to encode a - /// fixed64 field, including the tag. - /// - public static int ComputeFixed64Size(ulong value) - { - return LittleEndian64Size; - } - - /// - /// Computes the number of bytes that would be needed to encode a - /// fixed32 field, including the tag. - /// - public static int ComputeFixed32Size(uint value) - { - return LittleEndian32Size; - } - - /// - /// Computes the number of bytes that would be needed to encode a - /// bool field, including the tag. - /// - public static int ComputeBoolSize(bool value) - { - return 1; - } - - /// - /// Computes the number of bytes that would be needed to encode a - /// string field, including the tag. - /// - public static int ComputeStringSize(String value) - { - int byteArraySize = Utf8Encoding.GetByteCount(value); - return ComputeLengthSize(byteArraySize) + byteArraySize; - } - - /// - /// Computes the number of bytes that would be needed to encode a - /// group field, including the tag. - /// - public static int ComputeGroupSize(IMessage value) - { - return value.CalculateSize(); - } - - /// - /// Computes the number of bytes that would be needed to encode an - /// embedded message field, including the tag. - /// - public static int ComputeMessageSize(IMessage value) - { - int size = value.CalculateSize(); - return ComputeLengthSize(size) + size; - } - - /// - /// Computes the number of bytes that would be needed to encode a - /// bytes field, including the tag. - /// - public static int ComputeBytesSize(ByteString value) - { - return ComputeLengthSize(value.Length) + value.Length; - } - - /// - /// Computes the number of bytes that would be needed to encode a - /// uint32 field, including the tag. - /// - public static int ComputeUInt32Size(uint value) - { - return ComputeRawVarint32Size(value); - } - - /// - /// Computes the number of bytes that would be needed to encode a - /// enum field, including the tag. The caller is responsible for - /// converting the enum value to its numeric value. - /// - public static int ComputeEnumSize(int value) - { - // Currently just a pass-through, but it's nice to separate it logically. - return ComputeInt32Size(value); - } - - /// - /// Computes the number of bytes that would be needed to encode an - /// sfixed32 field, including the tag. - /// - public static int ComputeSFixed32Size(int value) - { - return LittleEndian32Size; - } - - /// - /// Computes the number of bytes that would be needed to encode an - /// sfixed64 field, including the tag. - /// - public static int ComputeSFixed64Size(long value) - { - return LittleEndian64Size; - } - - /// - /// Computes the number of bytes that would be needed to encode an - /// sint32 field, including the tag. - /// - public static int ComputeSInt32Size(int value) - { - return ComputeRawVarint32Size(EncodeZigZag32(value)); - } - - /// - /// Computes the number of bytes that would be needed to encode an - /// sint64 field, including the tag. - /// - public static int ComputeSInt64Size(long value) - { - return ComputeRawVarint64Size(EncodeZigZag64(value)); - } - - /// - /// Computes the number of bytes that would be needed to encode a length, - /// as written by . - /// - public static int ComputeLengthSize(int length) - { - return ComputeRawVarint32Size((uint) length); - } - - /// - /// Computes the number of bytes that would be needed to encode a varint. - /// - public static int ComputeRawVarint32Size(uint value) - { - if ((value & (0xffffffff << 7)) == 0) - { - return 1; - } - if ((value & (0xffffffff << 14)) == 0) - { - return 2; - } - if ((value & (0xffffffff << 21)) == 0) - { - return 3; - } - if ((value & (0xffffffff << 28)) == 0) - { - return 4; - } - return 5; - } - - /// - /// Computes the number of bytes that would be needed to encode a varint. - /// - public static int ComputeRawVarint64Size(ulong value) - { - if ((value & (0xffffffffffffffffL << 7)) == 0) - { - return 1; - } - if ((value & (0xffffffffffffffffL << 14)) == 0) - { - return 2; - } - if ((value & (0xffffffffffffffffL << 21)) == 0) - { - return 3; - } - if ((value & (0xffffffffffffffffL << 28)) == 0) - { - return 4; - } - if ((value & (0xffffffffffffffffL << 35)) == 0) - { - return 5; - } - if ((value & (0xffffffffffffffffL << 42)) == 0) - { - return 6; - } - if ((value & (0xffffffffffffffffL << 49)) == 0) - { - return 7; - } - if ((value & (0xffffffffffffffffL << 56)) == 0) - { - return 8; - } - if ((value & (0xffffffffffffffffL << 63)) == 0) - { - return 9; - } - return 10; - } - - /// - /// Computes the number of bytes that would be needed to encode a tag. - /// - public static int ComputeTagSize(int fieldNumber) - { - return ComputeRawVarint32Size(WireFormat.MakeTag(fieldNumber, 0)); - } - } +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; + +namespace Google.Protobuf +{ + // This part of CodedOutputStream provides all the static entry points that are used + // by generated code and internally to compute the size of messages prior to being + // written to an instance of CodedOutputStream. + public sealed partial class CodedOutputStream + { + private const int LittleEndian64Size = 8; + private const int LittleEndian32Size = 4; + + internal const int DoubleSize = LittleEndian64Size; + internal const int FloatSize = LittleEndian32Size; + internal const int BoolSize = 1; + + /// + /// Computes the number of bytes that would be needed to encode a + /// double field, including the tag. + /// + public static int ComputeDoubleSize(double value) + { + return DoubleSize; + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// float field, including the tag. + /// + public static int ComputeFloatSize(float value) + { + return FloatSize; + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// uint64 field, including the tag. + /// + public static int ComputeUInt64Size(ulong value) + { + return ComputeRawVarint64Size(value); + } + + /// + /// Computes the number of bytes that would be needed to encode an + /// int64 field, including the tag. + /// + public static int ComputeInt64Size(long value) + { + return ComputeRawVarint64Size((ulong) value); + } + + /// + /// Computes the number of bytes that would be needed to encode an + /// int32 field, including the tag. + /// + public static int ComputeInt32Size(int value) + { + if (value >= 0) + { + return ComputeRawVarint32Size((uint) value); + } + else + { + // Must sign-extend. + return 10; + } + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// fixed64 field, including the tag. + /// + public static int ComputeFixed64Size(ulong value) + { + return LittleEndian64Size; + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// fixed32 field, including the tag. + /// + public static int ComputeFixed32Size(uint value) + { + return LittleEndian32Size; + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// bool field, including the tag. + /// + public static int ComputeBoolSize(bool value) + { + return BoolSize; + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// string field, including the tag. + /// + public static int ComputeStringSize(String value) + { + int byteArraySize = Utf8Encoding.GetByteCount(value); + return ComputeLengthSize(byteArraySize) + byteArraySize; + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// group field, including the tag. + /// + public static int ComputeGroupSize(IMessage value) + { + return value.CalculateSize(); + } + + /// + /// Computes the number of bytes that would be needed to encode an + /// embedded message field, including the tag. + /// + public static int ComputeMessageSize(IMessage value) + { + int size = value.CalculateSize(); + return ComputeLengthSize(size) + size; + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// bytes field, including the tag. + /// + public static int ComputeBytesSize(ByteString value) + { + return ComputeLengthSize(value.Length) + value.Length; + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// uint32 field, including the tag. + /// + public static int ComputeUInt32Size(uint value) + { + return ComputeRawVarint32Size(value); + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// enum field, including the tag. The caller is responsible for + /// converting the enum value to its numeric value. + /// + public static int ComputeEnumSize(int value) + { + // Currently just a pass-through, but it's nice to separate it logically. + return ComputeInt32Size(value); + } + + /// + /// Computes the number of bytes that would be needed to encode an + /// sfixed32 field, including the tag. + /// + public static int ComputeSFixed32Size(int value) + { + return LittleEndian32Size; + } + + /// + /// Computes the number of bytes that would be needed to encode an + /// sfixed64 field, including the tag. + /// + public static int ComputeSFixed64Size(long value) + { + return LittleEndian64Size; + } + + /// + /// Computes the number of bytes that would be needed to encode an + /// sint32 field, including the tag. + /// + public static int ComputeSInt32Size(int value) + { + return ComputeRawVarint32Size(EncodeZigZag32(value)); + } + + /// + /// Computes the number of bytes that would be needed to encode an + /// sint64 field, including the tag. + /// + public static int ComputeSInt64Size(long value) + { + return ComputeRawVarint64Size(EncodeZigZag64(value)); + } + + /// + /// Computes the number of bytes that would be needed to encode a length, + /// as written by . + /// + public static int ComputeLengthSize(int length) + { + return ComputeRawVarint32Size((uint) length); + } + + /// + /// Computes the number of bytes that would be needed to encode a varint. + /// + public static int ComputeRawVarint32Size(uint value) + { + if ((value & (0xffffffff << 7)) == 0) + { + return 1; + } + if ((value & (0xffffffff << 14)) == 0) + { + return 2; + } + if ((value & (0xffffffff << 21)) == 0) + { + return 3; + } + if ((value & (0xffffffff << 28)) == 0) + { + return 4; + } + return 5; + } + + /// + /// Computes the number of bytes that would be needed to encode a varint. + /// + public static int ComputeRawVarint64Size(ulong value) + { + if ((value & (0xffffffffffffffffL << 7)) == 0) + { + return 1; + } + if ((value & (0xffffffffffffffffL << 14)) == 0) + { + return 2; + } + if ((value & (0xffffffffffffffffL << 21)) == 0) + { + return 3; + } + if ((value & (0xffffffffffffffffL << 28)) == 0) + { + return 4; + } + if ((value & (0xffffffffffffffffL << 35)) == 0) + { + return 5; + } + if ((value & (0xffffffffffffffffL << 42)) == 0) + { + return 6; + } + if ((value & (0xffffffffffffffffL << 49)) == 0) + { + return 7; + } + if ((value & (0xffffffffffffffffL << 56)) == 0) + { + return 8; + } + if ((value & (0xffffffffffffffffL << 63)) == 0) + { + return 9; + } + return 10; + } + + /// + /// Computes the number of bytes that would be needed to encode a tag. + /// + public static int ComputeTagSize(int fieldNumber) + { + return ComputeRawVarint32Size(WireFormat.MakeTag(fieldNumber, 0)); + } + } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/CodedOutputStream.cs b/third_party/protobuf/csharp/src/Google.Protobuf/CodedOutputStream.cs index 827f0398cf84..f9ad29086bda 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/CodedOutputStream.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/CodedOutputStream.cs @@ -1,761 +1,770 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using Google.Protobuf.Collections; -using System; -using System.IO; -using System.Text; - -namespace Google.Protobuf -{ - /// - /// Encodes and writes protocol message fields. - /// - /// - /// - /// This class is generally used by generated code to write appropriate - /// primitives to the stream. It effectively encapsulates the lowest - /// levels of protocol buffer format. Unlike some other implementations, - /// this does not include combined "write tag and value" methods. Generated - /// code knows the exact byte representations of the tags they're going to write, - /// so there's no need to re-encode them each time. Manually-written code calling - /// this class should just call one of the WriteTag overloads before each value. - /// - /// - /// Repeated fields and map fields are not handled by this class; use RepeatedField<T> - /// and MapField<TKey, TValue> to serialize such fields. - /// - /// - public sealed partial class CodedOutputStream : IDisposable - { - // "Local" copy of Encoding.UTF8, for efficiency. (Yes, it makes a difference.) - internal static readonly Encoding Utf8Encoding = Encoding.UTF8; - - /// - /// The buffer size used by CreateInstance(Stream). - /// - public static readonly int DefaultBufferSize = 4096; - - private readonly bool leaveOpen; - private readonly byte[] buffer; - private readonly int limit; - private int position; - private readonly Stream output; - - #region Construction - /// - /// Creates a new CodedOutputStream that writes directly to the given - /// byte array. If more bytes are written than fit in the array, - /// OutOfSpaceException will be thrown. - /// - public CodedOutputStream(byte[] flatArray) : this(flatArray, 0, flatArray.Length) - { - } - - /// - /// Creates a new CodedOutputStream that writes directly to the given - /// byte array slice. If more bytes are written than fit in the array, - /// OutOfSpaceException will be thrown. - /// - private CodedOutputStream(byte[] buffer, int offset, int length) - { - this.output = null; - this.buffer = buffer; - this.position = offset; - this.limit = offset + length; - leaveOpen = true; // Simple way of avoiding trying to dispose of a null reference - } - - private CodedOutputStream(Stream output, byte[] buffer, bool leaveOpen) - { - this.output = ProtoPreconditions.CheckNotNull(output, nameof(output)); - this.buffer = buffer; - this.position = 0; - this.limit = buffer.Length; - this.leaveOpen = leaveOpen; - } - - /// - /// Creates a new which write to the given stream, and disposes of that - /// stream when the returned CodedOutputStream is disposed. - /// - /// The stream to write to. It will be disposed when the returned CodedOutputStream is disposed. - public CodedOutputStream(Stream output) : this(output, DefaultBufferSize, false) - { - } - - /// - /// Creates a new CodedOutputStream which write to the given stream and uses - /// the specified buffer size. - /// - /// The stream to write to. It will be disposed when the returned CodedOutputStream is disposed. - /// The size of buffer to use internally. - public CodedOutputStream(Stream output, int bufferSize) : this(output, new byte[bufferSize], false) - { - } - - /// - /// Creates a new CodedOutputStream which write to the given stream. - /// - /// The stream to write to. - /// If true, is left open when the returned CodedOutputStream is disposed; - /// if false, the provided stream is disposed as well. - public CodedOutputStream(Stream output, bool leaveOpen) : this(output, DefaultBufferSize, leaveOpen) - { - } - - /// - /// Creates a new CodedOutputStream which write to the given stream and uses - /// the specified buffer size. - /// - /// The stream to write to. - /// The size of buffer to use internally. - /// If true, is left open when the returned CodedOutputStream is disposed; - /// if false, the provided stream is disposed as well. - public CodedOutputStream(Stream output, int bufferSize, bool leaveOpen) : this(output, new byte[bufferSize], leaveOpen) - { - } - #endregion - - /// - /// Returns the current position in the stream, or the position in the output buffer - /// - public long Position - { - get - { - if (output != null) - { - return output.Position + position; - } - return position; - } - } - - #region Writing of values (not including tags) - - /// - /// Writes a double field value, without a tag, to the stream. - /// - /// The value to write - public void WriteDouble(double value) - { - WriteRawLittleEndian64((ulong)BitConverter.DoubleToInt64Bits(value)); - } - - /// - /// Writes a float field value, without a tag, to the stream. - /// - /// The value to write - public void WriteFloat(float value) - { - byte[] rawBytes = BitConverter.GetBytes(value); - if (!BitConverter.IsLittleEndian) - { - ByteArray.Reverse(rawBytes); - } - - if (limit - position >= 4) - { - buffer[position++] = rawBytes[0]; - buffer[position++] = rawBytes[1]; - buffer[position++] = rawBytes[2]; - buffer[position++] = rawBytes[3]; - } - else - { - WriteRawBytes(rawBytes, 0, 4); - } - } - - /// - /// Writes a uint64 field value, without a tag, to the stream. - /// - /// The value to write - public void WriteUInt64(ulong value) - { - WriteRawVarint64(value); - } - - /// - /// Writes an int64 field value, without a tag, to the stream. - /// - /// The value to write - public void WriteInt64(long value) - { - WriteRawVarint64((ulong) value); - } - - /// - /// Writes an int32 field value, without a tag, to the stream. - /// - /// The value to write - public void WriteInt32(int value) - { - if (value >= 0) - { - WriteRawVarint32((uint) value); - } - else - { - // Must sign-extend. - WriteRawVarint64((ulong) value); - } - } - - /// - /// Writes a fixed64 field value, without a tag, to the stream. - /// - /// The value to write - public void WriteFixed64(ulong value) - { - WriteRawLittleEndian64(value); - } - - /// - /// Writes a fixed32 field value, without a tag, to the stream. - /// - /// The value to write - public void WriteFixed32(uint value) - { - WriteRawLittleEndian32(value); - } - - /// - /// Writes a bool field value, without a tag, to the stream. - /// - /// The value to write - public void WriteBool(bool value) - { - WriteRawByte(value ? (byte) 1 : (byte) 0); - } - - /// - /// Writes a string field value, without a tag, to the stream. - /// The data is length-prefixed. - /// - /// The value to write - public void WriteString(string value) - { - // Optimise the case where we have enough space to write - // the string directly to the buffer, which should be common. - int length = Utf8Encoding.GetByteCount(value); - WriteLength(length); - if (limit - position >= length) - { - if (length == value.Length) // Must be all ASCII... - { - for (int i = 0; i < length; i++) - { - buffer[position + i] = (byte)value[i]; - } - } - else - { - Utf8Encoding.GetBytes(value, 0, value.Length, buffer, position); - } - position += length; - } - else - { - byte[] bytes = Utf8Encoding.GetBytes(value); - WriteRawBytes(bytes); - } - } - - /// - /// Writes a message, without a tag, to the stream. - /// The data is length-prefixed. - /// - /// The value to write - public void WriteMessage(IMessage value) - { - WriteLength(value.CalculateSize()); - value.WriteTo(this); - } - - /// - /// Write a byte string, without a tag, to the stream. - /// The data is length-prefixed. - /// - /// The value to write - public void WriteBytes(ByteString value) - { - WriteLength(value.Length); - value.WriteRawBytesTo(this); - } - - /// - /// Writes a uint32 value, without a tag, to the stream. - /// - /// The value to write - public void WriteUInt32(uint value) - { - WriteRawVarint32(value); - } - - /// - /// Writes an enum value, without a tag, to the stream. - /// - /// The value to write - public void WriteEnum(int value) - { - WriteInt32(value); - } - - /// - /// Writes an sfixed32 value, without a tag, to the stream. - /// - /// The value to write. - public void WriteSFixed32(int value) - { - WriteRawLittleEndian32((uint) value); - } - - /// - /// Writes an sfixed64 value, without a tag, to the stream. - /// - /// The value to write - public void WriteSFixed64(long value) - { - WriteRawLittleEndian64((ulong) value); - } - - /// - /// Writes an sint32 value, without a tag, to the stream. - /// - /// The value to write - public void WriteSInt32(int value) - { - WriteRawVarint32(EncodeZigZag32(value)); - } - - /// - /// Writes an sint64 value, without a tag, to the stream. - /// - /// The value to write - public void WriteSInt64(long value) - { - WriteRawVarint64(EncodeZigZag64(value)); - } - - /// - /// Writes a length (in bytes) for length-delimited data. - /// - /// - /// This method simply writes a rawint, but exists for clarity in calling code. - /// - /// Length value, in bytes. - public void WriteLength(int length) - { - WriteRawVarint32((uint) length); - } - - #endregion - - #region Raw tag writing - /// - /// Encodes and writes a tag. - /// - /// The number of the field to write the tag for - /// The wire format type of the tag to write - public void WriteTag(int fieldNumber, WireFormat.WireType type) - { - WriteRawVarint32(WireFormat.MakeTag(fieldNumber, type)); - } - - /// - /// Writes an already-encoded tag. - /// - /// The encoded tag - public void WriteTag(uint tag) - { - WriteRawVarint32(tag); - } - - /// - /// Writes the given single-byte tag directly to the stream. - /// - /// The encoded tag - public void WriteRawTag(byte b1) - { - WriteRawByte(b1); - } - - /// - /// Writes the given two-byte tag directly to the stream. - /// - /// The first byte of the encoded tag - /// The second byte of the encoded tag - public void WriteRawTag(byte b1, byte b2) - { - WriteRawByte(b1); - WriteRawByte(b2); - } - - /// - /// Writes the given three-byte tag directly to the stream. - /// - /// The first byte of the encoded tag - /// The second byte of the encoded tag - /// The third byte of the encoded tag - public void WriteRawTag(byte b1, byte b2, byte b3) - { - WriteRawByte(b1); - WriteRawByte(b2); - WriteRawByte(b3); - } - - /// - /// Writes the given four-byte tag directly to the stream. - /// - /// The first byte of the encoded tag - /// The second byte of the encoded tag - /// The third byte of the encoded tag - /// The fourth byte of the encoded tag - public void WriteRawTag(byte b1, byte b2, byte b3, byte b4) - { - WriteRawByte(b1); - WriteRawByte(b2); - WriteRawByte(b3); - WriteRawByte(b4); - } - - /// - /// Writes the given five-byte tag directly to the stream. - /// - /// The first byte of the encoded tag - /// The second byte of the encoded tag - /// The third byte of the encoded tag - /// The fourth byte of the encoded tag - /// The fifth byte of the encoded tag - public void WriteRawTag(byte b1, byte b2, byte b3, byte b4, byte b5) - { - WriteRawByte(b1); - WriteRawByte(b2); - WriteRawByte(b3); - WriteRawByte(b4); - WriteRawByte(b5); - } - #endregion - - #region Underlying writing primitives - /// - /// Writes a 32 bit value as a varint. The fast route is taken when - /// there's enough buffer space left to whizz through without checking - /// for each byte; otherwise, we resort to calling WriteRawByte each time. - /// - internal void WriteRawVarint32(uint value) - { - // Optimize for the common case of a single byte value - if (value < 128 && position < limit) - { - buffer[position++] = (byte)value; - return; - } - - while (value > 127 && position < limit) - { - buffer[position++] = (byte) ((value & 0x7F) | 0x80); - value >>= 7; - } - while (value > 127) - { - WriteRawByte((byte) ((value & 0x7F) | 0x80)); - value >>= 7; - } - if (position < limit) - { - buffer[position++] = (byte) value; - } - else - { - WriteRawByte((byte) value); - } - } - - internal void WriteRawVarint64(ulong value) - { - while (value > 127 && position < limit) - { - buffer[position++] = (byte) ((value & 0x7F) | 0x80); - value >>= 7; - } - while (value > 127) - { - WriteRawByte((byte) ((value & 0x7F) | 0x80)); - value >>= 7; - } - if (position < limit) - { - buffer[position++] = (byte) value; - } - else - { - WriteRawByte((byte) value); - } - } - - internal void WriteRawLittleEndian32(uint value) - { - if (position + 4 > limit) - { - WriteRawByte((byte) value); - WriteRawByte((byte) (value >> 8)); - WriteRawByte((byte) (value >> 16)); - WriteRawByte((byte) (value >> 24)); - } - else - { - buffer[position++] = ((byte) value); - buffer[position++] = ((byte) (value >> 8)); - buffer[position++] = ((byte) (value >> 16)); - buffer[position++] = ((byte) (value >> 24)); - } - } - - internal void WriteRawLittleEndian64(ulong value) - { - if (position + 8 > limit) - { - WriteRawByte((byte) value); - WriteRawByte((byte) (value >> 8)); - WriteRawByte((byte) (value >> 16)); - WriteRawByte((byte) (value >> 24)); - WriteRawByte((byte) (value >> 32)); - WriteRawByte((byte) (value >> 40)); - WriteRawByte((byte) (value >> 48)); - WriteRawByte((byte) (value >> 56)); - } - else - { - buffer[position++] = ((byte) value); - buffer[position++] = ((byte) (value >> 8)); - buffer[position++] = ((byte) (value >> 16)); - buffer[position++] = ((byte) (value >> 24)); - buffer[position++] = ((byte) (value >> 32)); - buffer[position++] = ((byte) (value >> 40)); - buffer[position++] = ((byte) (value >> 48)); - buffer[position++] = ((byte) (value >> 56)); - } - } - - internal void WriteRawByte(byte value) - { - if (position == limit) - { - RefreshBuffer(); - } - - buffer[position++] = value; - } - - internal void WriteRawByte(uint value) - { - WriteRawByte((byte) value); - } - - /// - /// Writes out an array of bytes. - /// - internal void WriteRawBytes(byte[] value) - { - WriteRawBytes(value, 0, value.Length); - } - - /// - /// Writes out part of an array of bytes. - /// - internal void WriteRawBytes(byte[] value, int offset, int length) - { - if (limit - position >= length) - { - ByteArray.Copy(value, offset, buffer, position, length); - // We have room in the current buffer. - position += length; - } - else - { - // Write extends past current buffer. Fill the rest of this buffer and - // flush. - int bytesWritten = limit - position; - ByteArray.Copy(value, offset, buffer, position, bytesWritten); - offset += bytesWritten; - length -= bytesWritten; - position = limit; - RefreshBuffer(); - - // Now deal with the rest. - // Since we have an output stream, this is our buffer - // and buffer offset == 0 - if (length <= limit) - { - // Fits in new buffer. - ByteArray.Copy(value, offset, buffer, 0, length); - position = length; - } - else - { - // Write is very big. Let's do it all at once. - output.Write(value, offset, length); - } - } - } - - #endregion - - /// - /// Encode a 32-bit value with ZigZag encoding. - /// - /// - /// ZigZag encodes signed integers into values that can be efficiently - /// encoded with varint. (Otherwise, negative values must be - /// sign-extended to 64 bits to be varint encoded, thus always taking - /// 10 bytes on the wire.) - /// - internal static uint EncodeZigZag32(int n) - { - // Note: the right-shift must be arithmetic - return (uint) ((n << 1) ^ (n >> 31)); - } - - /// - /// Encode a 64-bit value with ZigZag encoding. - /// - /// - /// ZigZag encodes signed integers into values that can be efficiently - /// encoded with varint. (Otherwise, negative values must be - /// sign-extended to 64 bits to be varint encoded, thus always taking - /// 10 bytes on the wire.) - /// - internal static ulong EncodeZigZag64(long n) - { - return (ulong) ((n << 1) ^ (n >> 63)); - } - - private void RefreshBuffer() - { - if (output == null) - { - // We're writing to a single buffer. - throw new OutOfSpaceException(); - } - - // Since we have an output stream, this is our buffer - // and buffer offset == 0 - output.Write(buffer, 0, position); - position = 0; - } - - /// - /// Indicates that a CodedOutputStream wrapping a flat byte array - /// ran out of space. - /// - public sealed class OutOfSpaceException : IOException - { - internal OutOfSpaceException() - : base("CodedOutputStream was writing to a flat byte array and ran out of space.") - { - } - } - - /// - /// Flushes any buffered data and optionally closes the underlying stream, if any. - /// - /// - /// - /// By default, any underlying stream is closed by this method. To configure this behaviour, - /// use a constructor overload with a leaveOpen parameter. If this instance does not - /// have an underlying stream, this method does nothing. - /// - /// - /// For the sake of efficiency, calling this method does not prevent future write calls - but - /// if a later write ends up writing to a stream which has been disposed, that is likely to - /// fail. It is recommend that you not call any other methods after this. - /// - /// - public void Dispose() - { - Flush(); - if (!leaveOpen) - { - output.Dispose(); - } - } - - /// - /// Flushes any buffered data to the underlying stream (if there is one). - /// - public void Flush() - { - if (output != null) - { - RefreshBuffer(); - } - } - - /// - /// Verifies that SpaceLeft returns zero. It's common to create a byte array - /// that is exactly big enough to hold a message, then write to it with - /// a CodedOutputStream. Calling CheckNoSpaceLeft after writing verifies that - /// the message was actually as big as expected, which can help bugs. - /// - public void CheckNoSpaceLeft() - { - if (SpaceLeft != 0) - { - throw new InvalidOperationException("Did not write as much data as expected."); - } - } - - /// - /// If writing to a flat array, returns the space left in the array. Otherwise, - /// throws an InvalidOperationException. - /// - public int SpaceLeft - { - get - { - if (output == null) - { - return limit - position; - } - else - { - throw new InvalidOperationException( - "SpaceLeft can only be called on CodedOutputStreams that are " + - "writing to a flat array."); - } - } - } - } -} +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using Google.Protobuf.Collections; +using System; +using System.IO; +using System.Text; + +namespace Google.Protobuf +{ + /// + /// Encodes and writes protocol message fields. + /// + /// + /// + /// This class is generally used by generated code to write appropriate + /// primitives to the stream. It effectively encapsulates the lowest + /// levels of protocol buffer format. Unlike some other implementations, + /// this does not include combined "write tag and value" methods. Generated + /// code knows the exact byte representations of the tags they're going to write, + /// so there's no need to re-encode them each time. Manually-written code calling + /// this class should just call one of the WriteTag overloads before each value. + /// + /// + /// Repeated fields and map fields are not handled by this class; use RepeatedField<T> + /// and MapField<TKey, TValue> to serialize such fields. + /// + /// + public sealed partial class CodedOutputStream : IDisposable + { + // "Local" copy of Encoding.UTF8, for efficiency. (Yes, it makes a difference.) + internal static readonly Encoding Utf8Encoding = Encoding.UTF8; + + /// + /// The buffer size used by CreateInstance(Stream). + /// + public static readonly int DefaultBufferSize = 4096; + + private readonly bool leaveOpen; + private readonly byte[] buffer; + private readonly int limit; + private int position; + private readonly Stream output; + + #region Construction + /// + /// Creates a new CodedOutputStream that writes directly to the given + /// byte array. If more bytes are written than fit in the array, + /// OutOfSpaceException will be thrown. + /// + public CodedOutputStream(byte[] flatArray) : this(flatArray, 0, flatArray.Length) + { + } + + /// + /// Creates a new CodedOutputStream that writes directly to the given + /// byte array slice. If more bytes are written than fit in the array, + /// OutOfSpaceException will be thrown. + /// + private CodedOutputStream(byte[] buffer, int offset, int length) + { + this.output = null; + this.buffer = buffer; + this.position = offset; + this.limit = offset + length; + leaveOpen = true; // Simple way of avoiding trying to dispose of a null reference + } + + private CodedOutputStream(Stream output, byte[] buffer, bool leaveOpen) + { + this.output = ProtoPreconditions.CheckNotNull(output, nameof(output)); + this.buffer = buffer; + this.position = 0; + this.limit = buffer.Length; + this.leaveOpen = leaveOpen; + } + + /// + /// Creates a new which write to the given stream, and disposes of that + /// stream when the returned CodedOutputStream is disposed. + /// + /// The stream to write to. It will be disposed when the returned CodedOutputStream is disposed. + public CodedOutputStream(Stream output) : this(output, DefaultBufferSize, false) + { + } + + /// + /// Creates a new CodedOutputStream which write to the given stream and uses + /// the specified buffer size. + /// + /// The stream to write to. It will be disposed when the returned CodedOutputStream is disposed. + /// The size of buffer to use internally. + public CodedOutputStream(Stream output, int bufferSize) : this(output, new byte[bufferSize], false) + { + } + + /// + /// Creates a new CodedOutputStream which write to the given stream. + /// + /// The stream to write to. + /// If true, is left open when the returned CodedOutputStream is disposed; + /// if false, the provided stream is disposed as well. + public CodedOutputStream(Stream output, bool leaveOpen) : this(output, DefaultBufferSize, leaveOpen) + { + } + + /// + /// Creates a new CodedOutputStream which write to the given stream and uses + /// the specified buffer size. + /// + /// The stream to write to. + /// The size of buffer to use internally. + /// If true, is left open when the returned CodedOutputStream is disposed; + /// if false, the provided stream is disposed as well. + public CodedOutputStream(Stream output, int bufferSize, bool leaveOpen) : this(output, new byte[bufferSize], leaveOpen) + { + } + #endregion + + /// + /// Returns the current position in the stream, or the position in the output buffer + /// + public long Position + { + get + { + if (output != null) + { + return output.Position + position; + } + return position; + } + } + + #region Writing of values (not including tags) + + /// + /// Writes a double field value, without a tag, to the stream. + /// + /// The value to write + public void WriteDouble(double value) + { + WriteRawLittleEndian64((ulong)BitConverter.DoubleToInt64Bits(value)); + } + + /// + /// Writes a float field value, without a tag, to the stream. + /// + /// The value to write + public void WriteFloat(float value) + { + byte[] rawBytes = BitConverter.GetBytes(value); + if (!BitConverter.IsLittleEndian) + { + ByteArray.Reverse(rawBytes); + } + + if (limit - position >= 4) + { + buffer[position++] = rawBytes[0]; + buffer[position++] = rawBytes[1]; + buffer[position++] = rawBytes[2]; + buffer[position++] = rawBytes[3]; + } + else + { + WriteRawBytes(rawBytes, 0, 4); + } + } + + /// + /// Writes a uint64 field value, without a tag, to the stream. + /// + /// The value to write + public void WriteUInt64(ulong value) + { + WriteRawVarint64(value); + } + + /// + /// Writes an int64 field value, without a tag, to the stream. + /// + /// The value to write + public void WriteInt64(long value) + { + WriteRawVarint64((ulong) value); + } + + /// + /// Writes an int32 field value, without a tag, to the stream. + /// + /// The value to write + public void WriteInt32(int value) + { + if (value >= 0) + { + WriteRawVarint32((uint) value); + } + else + { + // Must sign-extend. + WriteRawVarint64((ulong) value); + } + } + + /// + /// Writes a fixed64 field value, without a tag, to the stream. + /// + /// The value to write + public void WriteFixed64(ulong value) + { + WriteRawLittleEndian64(value); + } + + /// + /// Writes a fixed32 field value, without a tag, to the stream. + /// + /// The value to write + public void WriteFixed32(uint value) + { + WriteRawLittleEndian32(value); + } + + /// + /// Writes a bool field value, without a tag, to the stream. + /// + /// The value to write + public void WriteBool(bool value) + { + WriteRawByte(value ? (byte) 1 : (byte) 0); + } + + /// + /// Writes a string field value, without a tag, to the stream. + /// The data is length-prefixed. + /// + /// The value to write + public void WriteString(string value) + { + // Optimise the case where we have enough space to write + // the string directly to the buffer, which should be common. + int length = Utf8Encoding.GetByteCount(value); + WriteLength(length); + if (limit - position >= length) + { + if (length == value.Length) // Must be all ASCII... + { + for (int i = 0; i < length; i++) + { + buffer[position + i] = (byte)value[i]; + } + } + else + { + Utf8Encoding.GetBytes(value, 0, value.Length, buffer, position); + } + position += length; + } + else + { + byte[] bytes = Utf8Encoding.GetBytes(value); + WriteRawBytes(bytes); + } + } + + /// + /// Writes a message, without a tag, to the stream. + /// The data is length-prefixed. + /// + /// The value to write + public void WriteMessage(IMessage value) + { + WriteLength(value.CalculateSize()); + value.WriteTo(this); + } + + /// + /// Writes a group, without a tag, to the stream. + /// + /// The value to write + public void WriteGroup(IMessage value) + { + value.WriteTo(this); + } + + /// + /// Write a byte string, without a tag, to the stream. + /// The data is length-prefixed. + /// + /// The value to write + public void WriteBytes(ByteString value) + { + WriteLength(value.Length); + value.WriteRawBytesTo(this); + } + + /// + /// Writes a uint32 value, without a tag, to the stream. + /// + /// The value to write + public void WriteUInt32(uint value) + { + WriteRawVarint32(value); + } + + /// + /// Writes an enum value, without a tag, to the stream. + /// + /// The value to write + public void WriteEnum(int value) + { + WriteInt32(value); + } + + /// + /// Writes an sfixed32 value, without a tag, to the stream. + /// + /// The value to write. + public void WriteSFixed32(int value) + { + WriteRawLittleEndian32((uint) value); + } + + /// + /// Writes an sfixed64 value, without a tag, to the stream. + /// + /// The value to write + public void WriteSFixed64(long value) + { + WriteRawLittleEndian64((ulong) value); + } + + /// + /// Writes an sint32 value, without a tag, to the stream. + /// + /// The value to write + public void WriteSInt32(int value) + { + WriteRawVarint32(EncodeZigZag32(value)); + } + + /// + /// Writes an sint64 value, without a tag, to the stream. + /// + /// The value to write + public void WriteSInt64(long value) + { + WriteRawVarint64(EncodeZigZag64(value)); + } + + /// + /// Writes a length (in bytes) for length-delimited data. + /// + /// + /// This method simply writes a rawint, but exists for clarity in calling code. + /// + /// Length value, in bytes. + public void WriteLength(int length) + { + WriteRawVarint32((uint) length); + } + + #endregion + + #region Raw tag writing + /// + /// Encodes and writes a tag. + /// + /// The number of the field to write the tag for + /// The wire format type of the tag to write + public void WriteTag(int fieldNumber, WireFormat.WireType type) + { + WriteRawVarint32(WireFormat.MakeTag(fieldNumber, type)); + } + + /// + /// Writes an already-encoded tag. + /// + /// The encoded tag + public void WriteTag(uint tag) + { + WriteRawVarint32(tag); + } + + /// + /// Writes the given single-byte tag directly to the stream. + /// + /// The encoded tag + public void WriteRawTag(byte b1) + { + WriteRawByte(b1); + } + + /// + /// Writes the given two-byte tag directly to the stream. + /// + /// The first byte of the encoded tag + /// The second byte of the encoded tag + public void WriteRawTag(byte b1, byte b2) + { + WriteRawByte(b1); + WriteRawByte(b2); + } + + /// + /// Writes the given three-byte tag directly to the stream. + /// + /// The first byte of the encoded tag + /// The second byte of the encoded tag + /// The third byte of the encoded tag + public void WriteRawTag(byte b1, byte b2, byte b3) + { + WriteRawByte(b1); + WriteRawByte(b2); + WriteRawByte(b3); + } + + /// + /// Writes the given four-byte tag directly to the stream. + /// + /// The first byte of the encoded tag + /// The second byte of the encoded tag + /// The third byte of the encoded tag + /// The fourth byte of the encoded tag + public void WriteRawTag(byte b1, byte b2, byte b3, byte b4) + { + WriteRawByte(b1); + WriteRawByte(b2); + WriteRawByte(b3); + WriteRawByte(b4); + } + + /// + /// Writes the given five-byte tag directly to the stream. + /// + /// The first byte of the encoded tag + /// The second byte of the encoded tag + /// The third byte of the encoded tag + /// The fourth byte of the encoded tag + /// The fifth byte of the encoded tag + public void WriteRawTag(byte b1, byte b2, byte b3, byte b4, byte b5) + { + WriteRawByte(b1); + WriteRawByte(b2); + WriteRawByte(b3); + WriteRawByte(b4); + WriteRawByte(b5); + } + #endregion + + #region Underlying writing primitives + /// + /// Writes a 32 bit value as a varint. The fast route is taken when + /// there's enough buffer space left to whizz through without checking + /// for each byte; otherwise, we resort to calling WriteRawByte each time. + /// + internal void WriteRawVarint32(uint value) + { + // Optimize for the common case of a single byte value + if (value < 128 && position < limit) + { + buffer[position++] = (byte)value; + return; + } + + while (value > 127 && position < limit) + { + buffer[position++] = (byte) ((value & 0x7F) | 0x80); + value >>= 7; + } + while (value > 127) + { + WriteRawByte((byte) ((value & 0x7F) | 0x80)); + value >>= 7; + } + if (position < limit) + { + buffer[position++] = (byte) value; + } + else + { + WriteRawByte((byte) value); + } + } + + internal void WriteRawVarint64(ulong value) + { + while (value > 127 && position < limit) + { + buffer[position++] = (byte) ((value & 0x7F) | 0x80); + value >>= 7; + } + while (value > 127) + { + WriteRawByte((byte) ((value & 0x7F) | 0x80)); + value >>= 7; + } + if (position < limit) + { + buffer[position++] = (byte) value; + } + else + { + WriteRawByte((byte) value); + } + } + + internal void WriteRawLittleEndian32(uint value) + { + if (position + 4 > limit) + { + WriteRawByte((byte) value); + WriteRawByte((byte) (value >> 8)); + WriteRawByte((byte) (value >> 16)); + WriteRawByte((byte) (value >> 24)); + } + else + { + buffer[position++] = ((byte) value); + buffer[position++] = ((byte) (value >> 8)); + buffer[position++] = ((byte) (value >> 16)); + buffer[position++] = ((byte) (value >> 24)); + } + } + + internal void WriteRawLittleEndian64(ulong value) + { + if (position + 8 > limit) + { + WriteRawByte((byte) value); + WriteRawByte((byte) (value >> 8)); + WriteRawByte((byte) (value >> 16)); + WriteRawByte((byte) (value >> 24)); + WriteRawByte((byte) (value >> 32)); + WriteRawByte((byte) (value >> 40)); + WriteRawByte((byte) (value >> 48)); + WriteRawByte((byte) (value >> 56)); + } + else + { + buffer[position++] = ((byte) value); + buffer[position++] = ((byte) (value >> 8)); + buffer[position++] = ((byte) (value >> 16)); + buffer[position++] = ((byte) (value >> 24)); + buffer[position++] = ((byte) (value >> 32)); + buffer[position++] = ((byte) (value >> 40)); + buffer[position++] = ((byte) (value >> 48)); + buffer[position++] = ((byte) (value >> 56)); + } + } + + internal void WriteRawByte(byte value) + { + if (position == limit) + { + RefreshBuffer(); + } + + buffer[position++] = value; + } + + internal void WriteRawByte(uint value) + { + WriteRawByte((byte) value); + } + + /// + /// Writes out an array of bytes. + /// + internal void WriteRawBytes(byte[] value) + { + WriteRawBytes(value, 0, value.Length); + } + + /// + /// Writes out part of an array of bytes. + /// + internal void WriteRawBytes(byte[] value, int offset, int length) + { + if (limit - position >= length) + { + ByteArray.Copy(value, offset, buffer, position, length); + // We have room in the current buffer. + position += length; + } + else + { + // Write extends past current buffer. Fill the rest of this buffer and + // flush. + int bytesWritten = limit - position; + ByteArray.Copy(value, offset, buffer, position, bytesWritten); + offset += bytesWritten; + length -= bytesWritten; + position = limit; + RefreshBuffer(); + + // Now deal with the rest. + // Since we have an output stream, this is our buffer + // and buffer offset == 0 + if (length <= limit) + { + // Fits in new buffer. + ByteArray.Copy(value, offset, buffer, 0, length); + position = length; + } + else + { + // Write is very big. Let's do it all at once. + output.Write(value, offset, length); + } + } + } + + #endregion + + /// + /// Encode a 32-bit value with ZigZag encoding. + /// + /// + /// ZigZag encodes signed integers into values that can be efficiently + /// encoded with varint. (Otherwise, negative values must be + /// sign-extended to 64 bits to be varint encoded, thus always taking + /// 10 bytes on the wire.) + /// + internal static uint EncodeZigZag32(int n) + { + // Note: the right-shift must be arithmetic + return (uint) ((n << 1) ^ (n >> 31)); + } + + /// + /// Encode a 64-bit value with ZigZag encoding. + /// + /// + /// ZigZag encodes signed integers into values that can be efficiently + /// encoded with varint. (Otherwise, negative values must be + /// sign-extended to 64 bits to be varint encoded, thus always taking + /// 10 bytes on the wire.) + /// + internal static ulong EncodeZigZag64(long n) + { + return (ulong) ((n << 1) ^ (n >> 63)); + } + + private void RefreshBuffer() + { + if (output == null) + { + // We're writing to a single buffer. + throw new OutOfSpaceException(); + } + + // Since we have an output stream, this is our buffer + // and buffer offset == 0 + output.Write(buffer, 0, position); + position = 0; + } + + /// + /// Indicates that a CodedOutputStream wrapping a flat byte array + /// ran out of space. + /// + public sealed class OutOfSpaceException : IOException + { + internal OutOfSpaceException() + : base("CodedOutputStream was writing to a flat byte array and ran out of space.") + { + } + } + + /// + /// Flushes any buffered data and optionally closes the underlying stream, if any. + /// + /// + /// + /// By default, any underlying stream is closed by this method. To configure this behaviour, + /// use a constructor overload with a leaveOpen parameter. If this instance does not + /// have an underlying stream, this method does nothing. + /// + /// + /// For the sake of efficiency, calling this method does not prevent future write calls - but + /// if a later write ends up writing to a stream which has been disposed, that is likely to + /// fail. It is recommend that you not call any other methods after this. + /// + /// + public void Dispose() + { + Flush(); + if (!leaveOpen) + { + output.Dispose(); + } + } + + /// + /// Flushes any buffered data to the underlying stream (if there is one). + /// + public void Flush() + { + if (output != null) + { + RefreshBuffer(); + } + } + + /// + /// Verifies that SpaceLeft returns zero. It's common to create a byte array + /// that is exactly big enough to hold a message, then write to it with + /// a CodedOutputStream. Calling CheckNoSpaceLeft after writing verifies that + /// the message was actually as big as expected, which can help bugs. + /// + public void CheckNoSpaceLeft() + { + if (SpaceLeft != 0) + { + throw new InvalidOperationException("Did not write as much data as expected."); + } + } + + /// + /// If writing to a flat array, returns the space left in the array. Otherwise, + /// throws an InvalidOperationException. + /// + public int SpaceLeft + { + get + { + if (output == null) + { + return limit - position; + } + else + { + throw new InvalidOperationException( + "SpaceLeft can only be called on CodedOutputStreams that are " + + "writing to a flat array."); + } + } + } + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Collections/Lists.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Collections/Lists.cs new file mode 100644 index 000000000000..860795ceeff8 --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Collections/Lists.cs @@ -0,0 +1,89 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2017 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace Google.Protobuf.Collections +{ + /// + /// Utility to compare if two Lists are the same, and the hash code + /// of a List. + /// + public static class Lists + { + /// + /// Checks if two lists are equal. + /// + public static bool Equals(List left, List right) + { + if (left == right) + { + return true; + } + if (left == null || right == null) + { + return false; + } + if (left.Count != right.Count) + { + return false; + } + IEqualityComparer comparer = EqualityComparer.Default; + for (int i = 0; i < left.Count; i++) + { + if (!comparer.Equals(left[i], right[i])) + { + return false; + } + } + return true; + } + + /// + /// Gets the list's hash code. + /// + public static int GetHashCode(List list) + { + if (list == null) + { + return 0; + } + int hash = 31; + foreach (T element in list) + { + hash = hash * 29 + element.GetHashCode(); + } + return hash; + } + } +} \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Collections/MapField.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Collections/MapField.cs index 993a89d7765f..1924439e5cad 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Collections/MapField.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Collections/MapField.cs @@ -1,760 +1,771 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2015 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using Google.Protobuf.Reflection; -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using Google.Protobuf.Compatibility; - -namespace Google.Protobuf.Collections -{ - /// - /// Representation of a map field in a Protocol Buffer message. - /// - /// Key type in the map. Must be a type supported by Protocol Buffer map keys. - /// Value type in the map. Must be a type supported by Protocol Buffers. - /// - /// - /// This implementation preserves insertion order for simplicity of testing - /// code using maps fields. Overwriting an existing entry does not change the - /// position of that entry within the map. Equality is not order-sensitive. - /// For string keys, the equality comparison is provided by . - /// - /// - /// Null values are not permitted in the map, either for wrapper types or regular messages. - /// If a map is deserialized from a data stream and the value is missing from an entry, a default value - /// is created instead. For primitive types, that is the regular default value (0, the empty string and so - /// on); for message types, an empty instance of the message is created, as if the map entry contained a 0-length - /// encoded value for the field. - /// - /// - /// This implementation does not generally prohibit the use of key/value types which are not - /// supported by Protocol Buffers (e.g. using a key type of byte) but nor does it guarantee - /// that all operations will work in such cases. - /// - /// - public sealed class MapField : IDeepCloneable>, IDictionary, IEquatable>, IDictionary - { - // TODO: Don't create the map/list until we have an entry. (Assume many maps will be empty.) - private readonly Dictionary>> map = - new Dictionary>>(); - private readonly LinkedList> list = new LinkedList>(); - - /// - /// Creates a deep clone of this object. - /// - /// - /// A deep clone of this object. - /// - public MapField Clone() - { - var clone = new MapField(); - // Keys are never cloneable. Values might be. - if (typeof(IDeepCloneable).IsAssignableFrom(typeof(TValue))) - { - foreach (var pair in list) - { - clone.Add(pair.Key, ((IDeepCloneable)pair.Value).Clone()); - } - } - else - { - // Nothing is cloneable, so we don't need to worry. - clone.Add(this); - } - return clone; - } - - /// - /// Adds the specified key/value pair to the map. - /// - /// - /// This operation fails if the key already exists in the map. To replace an existing entry, use the indexer. - /// - /// The key to add - /// The value to add. - /// The given key already exists in map. - public void Add(TKey key, TValue value) - { - // Validation of arguments happens in ContainsKey and the indexer - if (ContainsKey(key)) - { - throw new ArgumentException("Key already exists in map", "key"); - } - this[key] = value; - } - - /// - /// Determines whether the specified key is present in the map. - /// - /// The key to check. - /// true if the map contains the given key; false otherwise. - public bool ContainsKey(TKey key) - { - ProtoPreconditions.CheckNotNullUnconstrained(key, "key"); - return map.ContainsKey(key); - } - - private bool ContainsValue(TValue value) - { - var comparer = EqualityComparer.Default; - return list.Any(pair => comparer.Equals(pair.Value, value)); - } - - /// - /// Removes the entry identified by the given key from the map. - /// - /// The key indicating the entry to remove from the map. - /// true if the map contained the given key before the entry was removed; false otherwise. - public bool Remove(TKey key) - { - ProtoPreconditions.CheckNotNullUnconstrained(key, "key"); - LinkedListNode> node; - if (map.TryGetValue(key, out node)) - { - map.Remove(key); - node.List.Remove(node); - return true; - } - else - { - return false; - } - } - - /// - /// Gets the value associated with the specified key. - /// - /// The key whose value to get. - /// When this method returns, the value associated with the specified key, if the key is found; - /// otherwise, the default value for the type of the parameter. - /// This parameter is passed uninitialized. - /// true if the map contains an element with the specified key; otherwise, false. - public bool TryGetValue(TKey key, out TValue value) - { - LinkedListNode> node; - if (map.TryGetValue(key, out node)) - { - value = node.Value.Value; - return true; - } - else - { - value = default(TValue); - return false; - } - } - - /// - /// Gets or sets the value associated with the specified key. - /// - /// The key of the value to get or set. - /// The property is retrieved and key does not exist in the collection. - /// The value associated with the specified key. If the specified key is not found, - /// a get operation throws a , and a set operation creates a new element with the specified key. - public TValue this[TKey key] - { - get - { - ProtoPreconditions.CheckNotNullUnconstrained(key, "key"); - TValue value; - if (TryGetValue(key, out value)) - { - return value; - } - throw new KeyNotFoundException(); - } - set - { - ProtoPreconditions.CheckNotNullUnconstrained(key, "key"); - // value == null check here is redundant, but avoids boxing. - if (value == null) - { - ProtoPreconditions.CheckNotNullUnconstrained(value, "value"); - } - LinkedListNode> node; - var pair = new KeyValuePair(key, value); - if (map.TryGetValue(key, out node)) - { - node.Value = pair; - } - else - { - node = list.AddLast(pair); - map[key] = node; - } - } - } - - /// - /// Gets a collection containing the keys in the map. - /// - public ICollection Keys { get { return new MapView(this, pair => pair.Key, ContainsKey); } } - - /// - /// Gets a collection containing the values in the map. - /// - public ICollection Values { get { return new MapView(this, pair => pair.Value, ContainsValue); } } - - /// - /// Adds the specified entries to the map. The keys and values are not automatically cloned. - /// - /// The entries to add to the map. - public void Add(IDictionary entries) - { - ProtoPreconditions.CheckNotNull(entries, "entries"); - foreach (var pair in entries) - { - Add(pair.Key, pair.Value); - } - } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// - /// An enumerator that can be used to iterate through the collection. - /// - public IEnumerator> GetEnumerator() - { - return list.GetEnumerator(); - } - - /// - /// Returns an enumerator that iterates through a collection. - /// - /// - /// An object that can be used to iterate through the collection. - /// - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - /// - /// Adds the specified item to the map. - /// - /// The item to add to the map. - void ICollection>.Add(KeyValuePair item) - { - Add(item.Key, item.Value); - } - - /// - /// Removes all items from the map. - /// - public void Clear() - { - list.Clear(); - map.Clear(); - } - - /// - /// Determines whether map contains an entry equivalent to the given key/value pair. - /// - /// The key/value pair to find. - /// - bool ICollection>.Contains(KeyValuePair item) - { - TValue value; - return TryGetValue(item.Key, out value) - && EqualityComparer.Default.Equals(item.Value, value); - } - - /// - /// Copies the key/value pairs in this map to an array. - /// - /// The array to copy the entries into. - /// The index of the array at which to start copying values. - void ICollection>.CopyTo(KeyValuePair[] array, int arrayIndex) - { - list.CopyTo(array, arrayIndex); - } - - /// - /// Removes the specified key/value pair from the map. - /// - /// Both the key and the value must be found for the entry to be removed. - /// The key/value pair to remove. - /// true if the key/value pair was found and removed; false otherwise. - bool ICollection>.Remove(KeyValuePair item) - { - if (item.Key == null) - { - throw new ArgumentException("Key is null", "item"); - } - LinkedListNode> node; - if (map.TryGetValue(item.Key, out node) && - EqualityComparer.Default.Equals(item.Value, node.Value.Value)) - { - map.Remove(item.Key); - node.List.Remove(node); - return true; - } - else - { - return false; - } - } - - /// - /// Gets the number of elements contained in the map. - /// - public int Count { get { return list.Count; } } - - /// - /// Gets a value indicating whether the map is read-only. - /// - public bool IsReadOnly { get { return false; } } - - /// - /// Determines whether the specified , is equal to this instance. - /// - /// The to compare with this instance. - /// - /// true if the specified is equal to this instance; otherwise, false. - /// - public override bool Equals(object other) - { - return Equals(other as MapField); - } - - /// - /// Returns a hash code for this instance. - /// - /// - /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - /// - public override int GetHashCode() - { - var valueComparer = EqualityComparer.Default; - int hash = 0; - foreach (var pair in list) - { - hash ^= pair.Key.GetHashCode() * 31 + valueComparer.GetHashCode(pair.Value); - } - return hash; - } - - /// - /// Compares this map with another for equality. - /// - /// - /// The order of the key/value pairs in the maps is not deemed significant in this comparison. - /// - /// The map to compare this with. - /// true if refers to an equal map; false otherwise. - public bool Equals(MapField other) - { - if (other == null) - { - return false; - } - if (other == this) - { - return true; - } - if (other.Count != this.Count) - { - return false; - } - var valueComparer = EqualityComparer.Default; - foreach (var pair in this) - { - TValue value; - if (!other.TryGetValue(pair.Key, out value)) - { - return false; - } - if (!valueComparer.Equals(value, pair.Value)) - { - return false; - } - } - return true; - } - - /// - /// Adds entries to the map from the given stream. - /// - /// - /// It is assumed that the stream is initially positioned after the tag specified by the codec. - /// This method will continue reading entries from the stream until the end is reached, or - /// a different tag is encountered. - /// - /// Stream to read from - /// Codec describing how the key/value pairs are encoded - public void AddEntriesFrom(CodedInputStream input, Codec codec) - { - var adapter = new Codec.MessageAdapter(codec); - do - { - adapter.Reset(); - input.ReadMessage(adapter); - this[adapter.Key] = adapter.Value; - } while (input.MaybeConsumeTag(codec.MapTag)); - } - - /// - /// Writes the contents of this map to the given coded output stream, using the specified codec - /// to encode each entry. - /// - /// The output stream to write to. - /// The codec to use for each entry. - public void WriteTo(CodedOutputStream output, Codec codec) - { - var message = new Codec.MessageAdapter(codec); - foreach (var entry in list) - { - message.Key = entry.Key; - message.Value = entry.Value; - output.WriteTag(codec.MapTag); - output.WriteMessage(message); - } - } - - /// - /// Calculates the size of this map based on the given entry codec. - /// - /// The codec to use to encode each entry. - /// - public int CalculateSize(Codec codec) - { - if (Count == 0) - { - return 0; - } - var message = new Codec.MessageAdapter(codec); - int size = 0; - foreach (var entry in list) - { - message.Key = entry.Key; - message.Value = entry.Value; - size += CodedOutputStream.ComputeRawVarint32Size(codec.MapTag); - size += CodedOutputStream.ComputeMessageSize(message); - } - return size; - } - - /// - /// Returns a string representation of this repeated field, in the same - /// way as it would be represented by the default JSON formatter. - /// - public override string ToString() - { - var writer = new StringWriter(); - JsonFormatter.Default.WriteDictionary(writer, this); - return writer.ToString(); - } - - #region IDictionary explicit interface implementation - void IDictionary.Add(object key, object value) - { - Add((TKey)key, (TValue)value); - } - - bool IDictionary.Contains(object key) - { - if (!(key is TKey)) - { - return false; - } - return ContainsKey((TKey)key); - } - - IDictionaryEnumerator IDictionary.GetEnumerator() - { - return new DictionaryEnumerator(GetEnumerator()); - } - - void IDictionary.Remove(object key) - { - ProtoPreconditions.CheckNotNull(key, "key"); - if (!(key is TKey)) - { - return; - } - Remove((TKey)key); - } - - void ICollection.CopyTo(Array array, int index) - { - // This is ugly and slow as heck, but with any luck it will never be used anyway. - ICollection temp = this.Select(pair => new DictionaryEntry(pair.Key, pair.Value)).ToList(); - temp.CopyTo(array, index); - } - - bool IDictionary.IsFixedSize { get { return false; } } - - ICollection IDictionary.Keys { get { return (ICollection)Keys; } } - - ICollection IDictionary.Values { get { return (ICollection)Values; } } - - bool ICollection.IsSynchronized { get { return false; } } - - object ICollection.SyncRoot { get { return this; } } - - object IDictionary.this[object key] - { - get - { - ProtoPreconditions.CheckNotNull(key, "key"); - if (!(key is TKey)) - { - return null; - } - TValue value; - TryGetValue((TKey)key, out value); - return value; - } - - set - { - this[(TKey)key] = (TValue)value; - } - } - #endregion - - private class DictionaryEnumerator : IDictionaryEnumerator - { - private readonly IEnumerator> enumerator; - - internal DictionaryEnumerator(IEnumerator> enumerator) - { - this.enumerator = enumerator; - } - - public bool MoveNext() - { - return enumerator.MoveNext(); - } - - public void Reset() - { - enumerator.Reset(); - } - - public object Current { get { return Entry; } } - public DictionaryEntry Entry { get { return new DictionaryEntry(Key, Value); } } - public object Key { get { return enumerator.Current.Key; } } - public object Value { get { return enumerator.Current.Value; } } - } - - /// - /// A codec for a specific map field. This contains all the information required to encode and - /// decode the nested messages. - /// - public sealed class Codec - { - private readonly FieldCodec keyCodec; - private readonly FieldCodec valueCodec; - private readonly uint mapTag; - - /// - /// Creates a new entry codec based on a separate key codec and value codec, - /// and the tag to use for each map entry. - /// - /// The key codec. - /// The value codec. - /// The map tag to use to introduce each map entry. - public Codec(FieldCodec keyCodec, FieldCodec valueCodec, uint mapTag) - { - this.keyCodec = keyCodec; - this.valueCodec = valueCodec; - this.mapTag = mapTag; - } - - /// - /// The tag used in the enclosing message to indicate map entries. - /// - internal uint MapTag { get { return mapTag; } } - - /// - /// A mutable message class, used for parsing and serializing. This - /// delegates the work to a codec, but implements the interface - /// for interop with and . - /// This is nested inside Codec as it's tightly coupled to the associated codec, - /// and it's simpler if it has direct access to all its fields. - /// - internal class MessageAdapter : IMessage - { - private static readonly byte[] ZeroLengthMessageStreamData = new byte[] { 0 }; - - private readonly Codec codec; - internal TKey Key { get; set; } - internal TValue Value { get; set; } - - internal MessageAdapter(Codec codec) - { - this.codec = codec; - } - - internal void Reset() - { - Key = codec.keyCodec.DefaultValue; - Value = codec.valueCodec.DefaultValue; - } - - public void MergeFrom(CodedInputStream input) - { - uint tag; - while ((tag = input.ReadTag()) != 0) - { - if (tag == codec.keyCodec.Tag) - { - Key = codec.keyCodec.Read(input); - } - else if (tag == codec.valueCodec.Tag) - { - Value = codec.valueCodec.Read(input); - } - else - { - input.SkipLastField(); - } - } - - // Corner case: a map entry with a key but no value, where the value type is a message. - // Read it as if we'd seen an input stream with no data (i.e. create a "default" message). - if (Value == null) - { - Value = codec.valueCodec.Read(new CodedInputStream(ZeroLengthMessageStreamData)); - } - } - - public void WriteTo(CodedOutputStream output) - { - codec.keyCodec.WriteTagAndValue(output, Key); - codec.valueCodec.WriteTagAndValue(output, Value); - } - - public int CalculateSize() - { - return codec.keyCodec.CalculateSizeWithTag(Key) + codec.valueCodec.CalculateSizeWithTag(Value); - } - - MessageDescriptor IMessage.Descriptor { get { return null; } } - } - } - - private class MapView : ICollection, ICollection - { - private readonly MapField parent; - private readonly Func, T> projection; - private readonly Func containsCheck; - - internal MapView( - MapField parent, - Func, T> projection, - Func containsCheck) - { - this.parent = parent; - this.projection = projection; - this.containsCheck = containsCheck; - } - - public int Count { get { return parent.Count; } } - - public bool IsReadOnly { get { return true; } } - - public bool IsSynchronized { get { return false; } } - - public object SyncRoot { get { return parent; } } - - public void Add(T item) - { - throw new NotSupportedException(); - } - - public void Clear() - { - throw new NotSupportedException(); - } - - public bool Contains(T item) - { - return containsCheck(item); - } - - public void CopyTo(T[] array, int arrayIndex) - { - if (arrayIndex < 0) - { - throw new ArgumentOutOfRangeException("arrayIndex"); - } - if (arrayIndex + Count >= array.Length) - { - throw new ArgumentException("Not enough space in the array", "array"); - } - foreach (var item in this) - { - array[arrayIndex++] = item; - } - } - - public IEnumerator GetEnumerator() - { - return parent.list.Select(projection).GetEnumerator(); - } - - public bool Remove(T item) - { - throw new NotSupportedException(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - public void CopyTo(Array array, int index) - { - if (index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - if (index + Count >= array.Length) - { - throw new ArgumentException("Not enough space in the array", "array"); - } - foreach (var item in this) - { - array.SetValue(item, index++); - } - } - } - } -} +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using Google.Protobuf.Compatibility; +using Google.Protobuf.Reflection; +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace Google.Protobuf.Collections +{ + /// + /// Representation of a map field in a Protocol Buffer message. + /// + /// Key type in the map. Must be a type supported by Protocol Buffer map keys. + /// Value type in the map. Must be a type supported by Protocol Buffers. + /// + /// + /// For string keys, the equality comparison is provided by . + /// + /// + /// Null values are not permitted in the map, either for wrapper types or regular messages. + /// If a map is deserialized from a data stream and the value is missing from an entry, a default value + /// is created instead. For primitive types, that is the regular default value (0, the empty string and so + /// on); for message types, an empty instance of the message is created, as if the map entry contained a 0-length + /// encoded value for the field. + /// + /// + /// This implementation does not generally prohibit the use of key/value types which are not + /// supported by Protocol Buffers (e.g. using a key type of byte) but nor does it guarantee + /// that all operations will work in such cases. + /// + /// + /// The order in which entries are returned when iterating over this object is undefined, and may change + /// in future versions. + /// + /// + public sealed class MapField : IDeepCloneable>, IDictionary, IEquatable>, IDictionary +#if !NET35 + , IReadOnlyDictionary +#endif + { + private static readonly EqualityComparer ValueEqualityComparer = ProtobufEqualityComparers.GetEqualityComparer(); + private static readonly EqualityComparer KeyEqualityComparer = ProtobufEqualityComparers.GetEqualityComparer(); + + // TODO: Don't create the map/list until we have an entry. (Assume many maps will be empty.) + private readonly Dictionary>> map = + new Dictionary>>(KeyEqualityComparer); + private readonly LinkedList> list = new LinkedList>(); + + /// + /// Creates a deep clone of this object. + /// + /// + /// A deep clone of this object. + /// + public MapField Clone() + { + var clone = new MapField(); + // Keys are never cloneable. Values might be. + if (typeof(IDeepCloneable).IsAssignableFrom(typeof(TValue))) + { + foreach (var pair in list) + { + clone.Add(pair.Key, ((IDeepCloneable)pair.Value).Clone()); + } + } + else + { + // Nothing is cloneable, so we don't need to worry. + clone.Add(this); + } + return clone; + } + + /// + /// Adds the specified key/value pair to the map. + /// + /// + /// This operation fails if the key already exists in the map. To replace an existing entry, use the indexer. + /// + /// The key to add + /// The value to add. + /// The given key already exists in map. + public void Add(TKey key, TValue value) + { + // Validation of arguments happens in ContainsKey and the indexer + if (ContainsKey(key)) + { + throw new ArgumentException("Key already exists in map", nameof(key)); + } + this[key] = value; + } + + /// + /// Determines whether the specified key is present in the map. + /// + /// The key to check. + /// true if the map contains the given key; false otherwise. + public bool ContainsKey(TKey key) + { + ProtoPreconditions.CheckNotNullUnconstrained(key, nameof(key)); + return map.ContainsKey(key); + } + + private bool ContainsValue(TValue value) => + list.Any(pair => ValueEqualityComparer.Equals(pair.Value, value)); + + /// + /// Removes the entry identified by the given key from the map. + /// + /// The key indicating the entry to remove from the map. + /// true if the map contained the given key before the entry was removed; false otherwise. + public bool Remove(TKey key) + { + ProtoPreconditions.CheckNotNullUnconstrained(key, nameof(key)); + LinkedListNode> node; + if (map.TryGetValue(key, out node)) + { + map.Remove(key); + node.List.Remove(node); + return true; + } + else + { + return false; + } + } + + /// + /// Gets the value associated with the specified key. + /// + /// The key whose value to get. + /// When this method returns, the value associated with the specified key, if the key is found; + /// otherwise, the default value for the type of the parameter. + /// This parameter is passed uninitialized. + /// true if the map contains an element with the specified key; otherwise, false. + public bool TryGetValue(TKey key, out TValue value) + { + LinkedListNode> node; + if (map.TryGetValue(key, out node)) + { + value = node.Value.Value; + return true; + } + else + { + value = default(TValue); + return false; + } + } + + /// + /// Gets or sets the value associated with the specified key. + /// + /// The key of the value to get or set. + /// The property is retrieved and key does not exist in the collection. + /// The value associated with the specified key. If the specified key is not found, + /// a get operation throws a , and a set operation creates a new element with the specified key. + public TValue this[TKey key] + { + get + { + ProtoPreconditions.CheckNotNullUnconstrained(key, nameof(key)); + TValue value; + if (TryGetValue(key, out value)) + { + return value; + } + throw new KeyNotFoundException(); + } + set + { + ProtoPreconditions.CheckNotNullUnconstrained(key, nameof(key)); + // value == null check here is redundant, but avoids boxing. + if (value == null) + { + ProtoPreconditions.CheckNotNullUnconstrained(value, nameof(value)); + } + LinkedListNode> node; + var pair = new KeyValuePair(key, value); + if (map.TryGetValue(key, out node)) + { + node.Value = pair; + } + else + { + node = list.AddLast(pair); + map[key] = node; + } + } + } + + /// + /// Gets a collection containing the keys in the map. + /// + public ICollection Keys { get { return new MapView(this, pair => pair.Key, ContainsKey); } } + + /// + /// Gets a collection containing the values in the map. + /// + public ICollection Values { get { return new MapView(this, pair => pair.Value, ContainsValue); } } + + /// + /// Adds the specified entries to the map. The keys and values are not automatically cloned. + /// + /// The entries to add to the map. + public void Add(IDictionary entries) + { + ProtoPreconditions.CheckNotNull(entries, nameof(entries)); + foreach (var pair in entries) + { + Add(pair.Key, pair.Value); + } + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// + /// An enumerator that can be used to iterate through the collection. + /// + public IEnumerator> GetEnumerator() + { + return list.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through a collection. + /// + /// + /// An object that can be used to iterate through the collection. + /// + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// + /// Adds the specified item to the map. + /// + /// The item to add to the map. + void ICollection>.Add(KeyValuePair item) + { + Add(item.Key, item.Value); + } + + /// + /// Removes all items from the map. + /// + public void Clear() + { + list.Clear(); + map.Clear(); + } + + /// + /// Determines whether map contains an entry equivalent to the given key/value pair. + /// + /// The key/value pair to find. + /// + bool ICollection>.Contains(KeyValuePair item) + { + TValue value; + return TryGetValue(item.Key, out value) && ValueEqualityComparer.Equals(item.Value, value); + } + + /// + /// Copies the key/value pairs in this map to an array. + /// + /// The array to copy the entries into. + /// The index of the array at which to start copying values. + void ICollection>.CopyTo(KeyValuePair[] array, int arrayIndex) + { + list.CopyTo(array, arrayIndex); + } + + /// + /// Removes the specified key/value pair from the map. + /// + /// Both the key and the value must be found for the entry to be removed. + /// The key/value pair to remove. + /// true if the key/value pair was found and removed; false otherwise. + bool ICollection>.Remove(KeyValuePair item) + { + if (item.Key == null) + { + throw new ArgumentException("Key is null", nameof(item)); + } + LinkedListNode> node; + if (map.TryGetValue(item.Key, out node) && + EqualityComparer.Default.Equals(item.Value, node.Value.Value)) + { + map.Remove(item.Key); + node.List.Remove(node); + return true; + } + else + { + return false; + } + } + + /// + /// Gets the number of elements contained in the map. + /// + public int Count { get { return list.Count; } } + + /// + /// Gets a value indicating whether the map is read-only. + /// + public bool IsReadOnly { get { return false; } } + + /// + /// Determines whether the specified , is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public override bool Equals(object other) + { + return Equals(other as MapField); + } + + /// + /// Returns a hash code for this instance. + /// + /// + /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. + /// + public override int GetHashCode() + { + var keyComparer = KeyEqualityComparer; + var valueComparer = ValueEqualityComparer; + int hash = 0; + foreach (var pair in list) + { + hash ^= keyComparer.GetHashCode(pair.Key) * 31 + valueComparer.GetHashCode(pair.Value); + } + return hash; + } + + /// + /// Compares this map with another for equality. + /// + /// + /// The order of the key/value pairs in the maps is not deemed significant in this comparison. + /// + /// The map to compare this with. + /// true if refers to an equal map; false otherwise. + public bool Equals(MapField other) + { + if (other == null) + { + return false; + } + if (other == this) + { + return true; + } + if (other.Count != this.Count) + { + return false; + } + var valueComparer = ValueEqualityComparer; + foreach (var pair in this) + { + TValue value; + if (!other.TryGetValue(pair.Key, out value)) + { + return false; + } + if (!valueComparer.Equals(value, pair.Value)) + { + return false; + } + } + return true; + } + + /// + /// Adds entries to the map from the given stream. + /// + /// + /// It is assumed that the stream is initially positioned after the tag specified by the codec. + /// This method will continue reading entries from the stream until the end is reached, or + /// a different tag is encountered. + /// + /// Stream to read from + /// Codec describing how the key/value pairs are encoded + public void AddEntriesFrom(CodedInputStream input, Codec codec) + { + var adapter = new Codec.MessageAdapter(codec); + do + { + adapter.Reset(); + input.ReadMessage(adapter); + this[adapter.Key] = adapter.Value; + } while (input.MaybeConsumeTag(codec.MapTag)); + } + + /// + /// Writes the contents of this map to the given coded output stream, using the specified codec + /// to encode each entry. + /// + /// The output stream to write to. + /// The codec to use for each entry. + public void WriteTo(CodedOutputStream output, Codec codec) + { + var message = new Codec.MessageAdapter(codec); + foreach (var entry in list) + { + message.Key = entry.Key; + message.Value = entry.Value; + output.WriteTag(codec.MapTag); + output.WriteMessage(message); + } + } + + /// + /// Calculates the size of this map based on the given entry codec. + /// + /// The codec to use to encode each entry. + /// + public int CalculateSize(Codec codec) + { + if (Count == 0) + { + return 0; + } + var message = new Codec.MessageAdapter(codec); + int size = 0; + foreach (var entry in list) + { + message.Key = entry.Key; + message.Value = entry.Value; + size += CodedOutputStream.ComputeRawVarint32Size(codec.MapTag); + size += CodedOutputStream.ComputeMessageSize(message); + } + return size; + } + + /// + /// Returns a string representation of this repeated field, in the same + /// way as it would be represented by the default JSON formatter. + /// + public override string ToString() + { + var writer = new StringWriter(); + JsonFormatter.Default.WriteDictionary(writer, this); + return writer.ToString(); + } + + #region IDictionary explicit interface implementation + void IDictionary.Add(object key, object value) + { + Add((TKey)key, (TValue)value); + } + + bool IDictionary.Contains(object key) + { + if (!(key is TKey)) + { + return false; + } + return ContainsKey((TKey)key); + } + + IDictionaryEnumerator IDictionary.GetEnumerator() + { + return new DictionaryEnumerator(GetEnumerator()); + } + + void IDictionary.Remove(object key) + { + ProtoPreconditions.CheckNotNull(key, nameof(key)); + if (!(key is TKey)) + { + return; + } + Remove((TKey)key); + } + + void ICollection.CopyTo(Array array, int index) + { + // This is ugly and slow as heck, but with any luck it will never be used anyway. + ICollection temp = this.Select(pair => new DictionaryEntry(pair.Key, pair.Value)).ToList(); + temp.CopyTo(array, index); + } + + bool IDictionary.IsFixedSize { get { return false; } } + + ICollection IDictionary.Keys { get { return (ICollection)Keys; } } + + ICollection IDictionary.Values { get { return (ICollection)Values; } } + + bool ICollection.IsSynchronized { get { return false; } } + + object ICollection.SyncRoot { get { return this; } } + + object IDictionary.this[object key] + { + get + { + ProtoPreconditions.CheckNotNull(key, nameof(key)); + if (!(key is TKey)) + { + return null; + } + TValue value; + TryGetValue((TKey)key, out value); + return value; + } + + set + { + this[(TKey)key] = (TValue)value; + } + } + #endregion + + #region IReadOnlyDictionary explicit interface implementation +#if !NET35 + IEnumerable IReadOnlyDictionary.Keys => Keys; + + IEnumerable IReadOnlyDictionary.Values => Values; +#endif + #endregion + + private class DictionaryEnumerator : IDictionaryEnumerator + { + private readonly IEnumerator> enumerator; + + internal DictionaryEnumerator(IEnumerator> enumerator) + { + this.enumerator = enumerator; + } + + public bool MoveNext() + { + return enumerator.MoveNext(); + } + + public void Reset() + { + enumerator.Reset(); + } + + public object Current { get { return Entry; } } + public DictionaryEntry Entry { get { return new DictionaryEntry(Key, Value); } } + public object Key { get { return enumerator.Current.Key; } } + public object Value { get { return enumerator.Current.Value; } } + } + + /// + /// A codec for a specific map field. This contains all the information required to encode and + /// decode the nested messages. + /// + public sealed class Codec + { + private readonly FieldCodec keyCodec; + private readonly FieldCodec valueCodec; + private readonly uint mapTag; + + /// + /// Creates a new entry codec based on a separate key codec and value codec, + /// and the tag to use for each map entry. + /// + /// The key codec. + /// The value codec. + /// The map tag to use to introduce each map entry. + public Codec(FieldCodec keyCodec, FieldCodec valueCodec, uint mapTag) + { + this.keyCodec = keyCodec; + this.valueCodec = valueCodec; + this.mapTag = mapTag; + } + + /// + /// The tag used in the enclosing message to indicate map entries. + /// + internal uint MapTag { get { return mapTag; } } + + /// + /// A mutable message class, used for parsing and serializing. This + /// delegates the work to a codec, but implements the interface + /// for interop with and . + /// This is nested inside Codec as it's tightly coupled to the associated codec, + /// and it's simpler if it has direct access to all its fields. + /// + internal class MessageAdapter : IMessage + { + private static readonly byte[] ZeroLengthMessageStreamData = new byte[] { 0 }; + + private readonly Codec codec; + internal TKey Key { get; set; } + internal TValue Value { get; set; } + + internal MessageAdapter(Codec codec) + { + this.codec = codec; + } + + internal void Reset() + { + Key = codec.keyCodec.DefaultValue; + Value = codec.valueCodec.DefaultValue; + } + + public void MergeFrom(CodedInputStream input) + { + uint tag; + while ((tag = input.ReadTag()) != 0) + { + if (tag == codec.keyCodec.Tag) + { + Key = codec.keyCodec.Read(input); + } + else if (tag == codec.valueCodec.Tag) + { + Value = codec.valueCodec.Read(input); + } + else + { + input.SkipLastField(); + } + } + + // Corner case: a map entry with a key but no value, where the value type is a message. + // Read it as if we'd seen an input stream with no data (i.e. create a "default" message). + if (Value == null) + { + Value = codec.valueCodec.Read(new CodedInputStream(ZeroLengthMessageStreamData)); + } + } + + public void WriteTo(CodedOutputStream output) + { + codec.keyCodec.WriteTagAndValue(output, Key); + codec.valueCodec.WriteTagAndValue(output, Value); + } + + public int CalculateSize() + { + return codec.keyCodec.CalculateSizeWithTag(Key) + codec.valueCodec.CalculateSizeWithTag(Value); + } + + MessageDescriptor IMessage.Descriptor { get { return null; } } + } + } + + private class MapView : ICollection, ICollection + { + private readonly MapField parent; + private readonly Func, T> projection; + private readonly Func containsCheck; + + internal MapView( + MapField parent, + Func, T> projection, + Func containsCheck) + { + this.parent = parent; + this.projection = projection; + this.containsCheck = containsCheck; + } + + public int Count { get { return parent.Count; } } + + public bool IsReadOnly { get { return true; } } + + public bool IsSynchronized { get { return false; } } + + public object SyncRoot { get { return parent; } } + + public void Add(T item) + { + throw new NotSupportedException(); + } + + public void Clear() + { + throw new NotSupportedException(); + } + + public bool Contains(T item) + { + return containsCheck(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + if (arrayIndex < 0) + { + throw new ArgumentOutOfRangeException(nameof(arrayIndex)); + } + if (arrayIndex + Count > array.Length) + { + throw new ArgumentException("Not enough space in the array", nameof(array)); + } + foreach (var item in this) + { + array[arrayIndex++] = item; + } + } + + public IEnumerator GetEnumerator() + { + return parent.list.Select(projection).GetEnumerator(); + } + + public bool Remove(T item) + { + throw new NotSupportedException(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void CopyTo(Array array, int index) + { + if (index < 0) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + if (index + Count > array.Length) + { + throw new ArgumentException("Not enough space in the array", nameof(array)); + } + foreach (var item in this) + { + array.SetValue(item, index++); + } + } + } + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Collections/ProtobufEqualityComparers.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Collections/ProtobufEqualityComparers.cs new file mode 100644 index 000000000000..13ef60fca56e --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Collections/ProtobufEqualityComparers.cs @@ -0,0 +1,130 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2017 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections.Generic; + +namespace Google.Protobuf.Collections +{ + /// + /// Provides a central place to implement equality comparisons, primarily for bitwise float/double equality. + /// + public static class ProtobufEqualityComparers + { + /// + /// Returns an equality comparer for suitable for Protobuf equality comparisons. + /// This is usually just the default equality comparer for the type, but floating point numbers are compared + /// bitwise. + /// + /// The type of equality comparer to return. + /// The equality comparer. + public static EqualityComparer GetEqualityComparer() + { + return typeof(T) == typeof(double) ? (EqualityComparer) (object) BitwiseDoubleEqualityComparer + : typeof(T) == typeof(float) ? (EqualityComparer) (object) BitwiseSingleEqualityComparer + : typeof(T) == typeof(double?) ? (EqualityComparer) (object) BitwiseNullableDoubleEqualityComparer + : typeof(T) == typeof(float?) ? (EqualityComparer) (object) BitwiseNullableSingleEqualityComparer + : EqualityComparer.Default; + } + + /// + /// Returns an equality comparer suitable for comparing 64-bit floating point values, by bitwise comparison. + /// (NaN values are considered equal, but only when they have the same representation.) + /// + public static EqualityComparer BitwiseDoubleEqualityComparer { get; } = new BitwiseDoubleEqualityComparerImpl(); + + /// + /// Returns an equality comparer suitable for comparing 32-bit floating point values, by bitwise comparison. + /// (NaN values are considered equal, but only when they have the same representation.) + /// + public static EqualityComparer BitwiseSingleEqualityComparer { get; } = new BitwiseSingleEqualityComparerImpl(); + + /// + /// Returns an equality comparer suitable for comparing nullable 64-bit floating point values, by bitwise comparison. + /// (NaN values are considered equal, but only when they have the same representation.) + /// + public static EqualityComparer BitwiseNullableDoubleEqualityComparer { get; } = new BitwiseNullableDoubleEqualityComparerImpl(); + + /// + /// Returns an equality comparer suitable for comparing nullable 32-bit floating point values, by bitwise comparison. + /// (NaN values are considered equal, but only when they have the same representation.) + /// + public static EqualityComparer BitwiseNullableSingleEqualityComparer { get; } = new BitwiseNullableSingleEqualityComparerImpl(); + + private class BitwiseDoubleEqualityComparerImpl : EqualityComparer + { + public override bool Equals(double x, double y) => + BitConverter.DoubleToInt64Bits(x) == BitConverter.DoubleToInt64Bits(y); + + public override int GetHashCode(double obj) => + BitConverter.DoubleToInt64Bits(obj).GetHashCode(); + } + + private class BitwiseSingleEqualityComparerImpl : EqualityComparer + { + // Just promote values to double and use BitConverter.DoubleToInt64Bits, + // as there's no BitConverter.SingleToInt32Bits, unfortunately. + + public override bool Equals(float x, float y) => + BitConverter.DoubleToInt64Bits(x) == BitConverter.DoubleToInt64Bits(y); + + public override int GetHashCode(float obj) => + BitConverter.DoubleToInt64Bits(obj).GetHashCode(); + } + + private class BitwiseNullableDoubleEqualityComparerImpl : EqualityComparer + { + public override bool Equals(double? x, double? y) => + x == null && y == null ? true + : x == null || y == null ? false + : BitwiseDoubleEqualityComparer.Equals(x.Value, y.Value); + + // The hash code for null is just a constant which is at least *unlikely* to be used + // elsewhere. (Compared with 0, say.) + public override int GetHashCode(double? obj) => + obj == null ? 293864 : BitwiseDoubleEqualityComparer.GetHashCode(obj.Value); + } + + private class BitwiseNullableSingleEqualityComparerImpl : EqualityComparer + { + public override bool Equals(float? x, float? y) => + x == null && y == null ? true + : x == null || y == null ? false + : BitwiseSingleEqualityComparer.Equals(x.Value, y.Value); + + // The hash code for null is just a constant which is at least *unlikely* to be used + // elsewhere. (Compared with 0, say.) + public override int GetHashCode(float? obj) => + obj == null ? 293864 : BitwiseSingleEqualityComparer.GetHashCode(obj.Value); + } + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Collections/ReadOnlyDictionary.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Collections/ReadOnlyDictionary.cs index 28530a29a846..84360667d8ae 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Collections/ReadOnlyDictionary.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Collections/ReadOnlyDictionary.cs @@ -1,147 +1,147 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; -using System.Collections; -using System.Collections.Generic; - -namespace Google.Protobuf.Collections -{ - /// - /// Read-only wrapper around another dictionary. - /// - internal sealed class ReadOnlyDictionary : IDictionary - { - private readonly IDictionary wrapped; - - public ReadOnlyDictionary(IDictionary wrapped) - { - this.wrapped = wrapped; - } - - public void Add(TKey key, TValue value) - { - throw new InvalidOperationException(); - } - - public bool ContainsKey(TKey key) - { - return wrapped.ContainsKey(key); - } - - public ICollection Keys - { - get { return wrapped.Keys; } - } - - public bool Remove(TKey key) - { - throw new InvalidOperationException(); - } - - public bool TryGetValue(TKey key, out TValue value) - { - return wrapped.TryGetValue(key, out value); - } - - public ICollection Values - { - get { return wrapped.Values; } - } - - public TValue this[TKey key] - { - get { return wrapped[key]; } - set { throw new InvalidOperationException(); } - } - - public void Add(KeyValuePair item) - { - throw new InvalidOperationException(); - } - - public void Clear() - { - throw new InvalidOperationException(); - } - - public bool Contains(KeyValuePair item) - { - return wrapped.Contains(item); - } - - public void CopyTo(KeyValuePair[] array, int arrayIndex) - { - wrapped.CopyTo(array, arrayIndex); - } - - public int Count - { - get { return wrapped.Count; } - } - - public bool IsReadOnly - { - get { return true; } - } - - public bool Remove(KeyValuePair item) - { - throw new InvalidOperationException(); - } - - public IEnumerator> GetEnumerator() - { - return wrapped.GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return ((IEnumerable) wrapped).GetEnumerator(); - } - - public override bool Equals(object obj) - { - return wrapped.Equals(obj); - } - - public override int GetHashCode() - { - return wrapped.GetHashCode(); - } - - public override string ToString() - { - return wrapped.ToString(); - } - } +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Google.Protobuf.Collections +{ + /// + /// Read-only wrapper around another dictionary. + /// + internal sealed class ReadOnlyDictionary : IDictionary + { + private readonly IDictionary wrapped; + + public ReadOnlyDictionary(IDictionary wrapped) + { + this.wrapped = wrapped; + } + + public void Add(TKey key, TValue value) + { + throw new InvalidOperationException(); + } + + public bool ContainsKey(TKey key) + { + return wrapped.ContainsKey(key); + } + + public ICollection Keys + { + get { return wrapped.Keys; } + } + + public bool Remove(TKey key) + { + throw new InvalidOperationException(); + } + + public bool TryGetValue(TKey key, out TValue value) + { + return wrapped.TryGetValue(key, out value); + } + + public ICollection Values + { + get { return wrapped.Values; } + } + + public TValue this[TKey key] + { + get { return wrapped[key]; } + set { throw new InvalidOperationException(); } + } + + public void Add(KeyValuePair item) + { + throw new InvalidOperationException(); + } + + public void Clear() + { + throw new InvalidOperationException(); + } + + public bool Contains(KeyValuePair item) + { + return wrapped.Contains(item); + } + + public void CopyTo(KeyValuePair[] array, int arrayIndex) + { + wrapped.CopyTo(array, arrayIndex); + } + + public int Count + { + get { return wrapped.Count; } + } + + public bool IsReadOnly + { + get { return true; } + } + + public bool Remove(KeyValuePair item) + { + throw new InvalidOperationException(); + } + + public IEnumerator> GetEnumerator() + { + return wrapped.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return ((IEnumerable) wrapped).GetEnumerator(); + } + + public override bool Equals(object obj) + { + return wrapped.Equals(obj); + } + + public override int GetHashCode() + { + return wrapped.GetHashCode(); + } + + public override string ToString() + { + return wrapped.ToString(); + } + } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Collections/RepeatedField.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Collections/RepeatedField.cs index d1db856c9c80..827bc711832b 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Collections/RepeatedField.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Collections/RepeatedField.cs @@ -1,568 +1,599 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2015 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace Google.Protobuf.Collections -{ - /// - /// The contents of a repeated field: essentially, a collection with some extra - /// restrictions (no null values) and capabilities (deep cloning). - /// - /// - /// This implementation does not generally prohibit the use of types which are not - /// supported by Protocol Buffers but nor does it guarantee that all operations will work in such cases. - /// - /// The element type of the repeated field. - public sealed class RepeatedField : IList, IList, IDeepCloneable>, IEquatable> - { - private static readonly T[] EmptyArray = new T[0]; - private const int MinArraySize = 8; - - private T[] array = EmptyArray; - private int count = 0; - - /// - /// Creates a deep clone of this repeated field. - /// - /// - /// If the field type is - /// a message type, each element is also cloned; otherwise, it is - /// assumed that the field type is primitive (including string and - /// bytes, both of which are immutable) and so a simple copy is - /// equivalent to a deep clone. - /// - /// A deep clone of this repeated field. - public RepeatedField Clone() - { - RepeatedField clone = new RepeatedField(); - if (array != EmptyArray) - { - clone.array = (T[])array.Clone(); - IDeepCloneable[] cloneableArray = clone.array as IDeepCloneable[]; - if (cloneableArray != null) - { - for (int i = 0; i < count; i++) - { - clone.array[i] = cloneableArray[i].Clone(); - } - } - } - clone.count = count; - return clone; - } - - /// - /// Adds the entries from the given input stream, decoding them with the specified codec. - /// - /// The input stream to read from. - /// The codec to use in order to read each entry. - public void AddEntriesFrom(CodedInputStream input, FieldCodec codec) - { - // TODO: Inline some of the Add code, so we can avoid checking the size on every - // iteration. - uint tag = input.LastTag; - var reader = codec.ValueReader; - // Non-nullable value types can be packed or not. - if (FieldCodec.IsPackedRepeatedField(tag)) - { - int length = input.ReadLength(); - if (length > 0) - { - int oldLimit = input.PushLimit(length); - while (!input.ReachedLimit) - { - Add(reader(input)); - } - input.PopLimit(oldLimit); - } - // Empty packed field. Odd, but valid - just ignore. - } - else - { - // Not packed... (possibly not packable) - do - { - Add(reader(input)); - } while (input.MaybeConsumeTag(tag)); - } - } - - /// - /// Calculates the size of this collection based on the given codec. - /// - /// The codec to use when encoding each field. - /// The number of bytes that would be written to a by , - /// using the same codec. - public int CalculateSize(FieldCodec codec) - { - if (count == 0) - { - return 0; - } - uint tag = codec.Tag; - if (codec.PackedRepeatedField) - { - int dataSize = CalculatePackedDataSize(codec); - return CodedOutputStream.ComputeRawVarint32Size(tag) + - CodedOutputStream.ComputeLengthSize(dataSize) + - dataSize; - } - else - { - var sizeCalculator = codec.ValueSizeCalculator; - int size = count * CodedOutputStream.ComputeRawVarint32Size(tag); - for (int i = 0; i < count; i++) - { - size += sizeCalculator(array[i]); - } - return size; - } - } - - private int CalculatePackedDataSize(FieldCodec codec) - { - int fixedSize = codec.FixedSize; - if (fixedSize == 0) - { - var calculator = codec.ValueSizeCalculator; - int tmp = 0; - for (int i = 0; i < count; i++) - { - tmp += calculator(array[i]); - } - return tmp; - } - else - { - return fixedSize * Count; - } - } - - /// - /// Writes the contents of this collection to the given , - /// encoding each value using the specified codec. - /// - /// The output stream to write to. - /// The codec to use when encoding each value. - public void WriteTo(CodedOutputStream output, FieldCodec codec) - { - if (count == 0) - { - return; - } - var writer = codec.ValueWriter; - var tag = codec.Tag; - if (codec.PackedRepeatedField) - { - // Packed primitive type - uint size = (uint)CalculatePackedDataSize(codec); - output.WriteTag(tag); - output.WriteRawVarint32(size); - for (int i = 0; i < count; i++) - { - writer(output, array[i]); - } - } - else - { - // Not packed: a simple tag/value pair for each value. - // Can't use codec.WriteTagAndValue, as that omits default values. - for (int i = 0; i < count; i++) - { - output.WriteTag(tag); - writer(output, array[i]); - } - } - } - - private void EnsureSize(int size) - { - if (array.Length < size) - { - size = Math.Max(size, MinArraySize); - int newSize = Math.Max(array.Length * 2, size); - var tmp = new T[newSize]; - Array.Copy(array, 0, tmp, 0, array.Length); - array = tmp; - } - } - - /// - /// Adds the specified item to the collection. - /// - /// The item to add. - public void Add(T item) - { - if (item == null) - { - throw new ArgumentNullException("item"); - } - EnsureSize(count + 1); - array[count++] = item; - } - - /// - /// Removes all items from the collection. - /// - public void Clear() - { - array = EmptyArray; - count = 0; - } - - /// - /// Determines whether this collection contains the given item. - /// - /// The item to find. - /// true if this collection contains the given item; false otherwise. - public bool Contains(T item) - { - return IndexOf(item) != -1; - } - - /// - /// Copies this collection to the given array. - /// - /// The array to copy to. - /// The first index of the array to copy to. - public void CopyTo(T[] array, int arrayIndex) - { - Array.Copy(this.array, 0, array, arrayIndex, count); - } - - /// - /// Removes the specified item from the collection - /// - /// The item to remove. - /// true if the item was found and removed; false otherwise. - public bool Remove(T item) - { - int index = IndexOf(item); - if (index == -1) - { - return false; - } - Array.Copy(array, index + 1, array, index, count - index - 1); - count--; - array[count] = default(T); - return true; - } - - /// - /// Gets the number of elements contained in the collection. - /// - public int Count { get { return count; } } - - /// - /// Gets a value indicating whether the collection is read-only. - /// - public bool IsReadOnly { get { return false; } } - - // TODO: Remove this overload and just handle it in the one below, at execution time? - - /// - /// Adds all of the specified values into this collection. - /// - /// The values to add to this collection. - public void Add(RepeatedField values) - { - if (values == null) - { - throw new ArgumentNullException("values"); - } - EnsureSize(count + values.count); - // We know that all the values will be valid, because it's a RepeatedField. - Array.Copy(values.array, 0, array, count, values.count); - count += values.count; - } - - /// - /// Adds all of the specified values into this collection. - /// - /// The values to add to this collection. - public void Add(IEnumerable values) - { - if (values == null) - { - throw new ArgumentNullException("values"); - } - // TODO: Check for ICollection and get the Count, to optimize? - foreach (T item in values) - { - Add(item); - } - } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// - /// An enumerator that can be used to iterate through the collection. - /// - public IEnumerator GetEnumerator() - { - for (int i = 0; i < count; i++) - { - yield return array[i]; - } - } - - /// - /// Determines whether the specified , is equal to this instance. - /// - /// The to compare with this instance. - /// - /// true if the specified is equal to this instance; otherwise, false. - /// - public override bool Equals(object obj) - { - return Equals(obj as RepeatedField); - } - - /// - /// Returns an enumerator that iterates through a collection. - /// - /// - /// An object that can be used to iterate through the collection. - /// - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - /// - /// Returns a hash code for this instance. - /// - /// - /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - /// - public override int GetHashCode() - { - int hash = 0; - for (int i = 0; i < count; i++) - { - hash = hash * 31 + array[i].GetHashCode(); - } - return hash; - } - - /// - /// Compares this repeated field with another for equality. - /// - /// The repeated field to compare this with. - /// true if refers to an equal repeated field; false otherwise. - public bool Equals(RepeatedField other) - { - if (ReferenceEquals(other, null)) - { - return false; - } - if (ReferenceEquals(other, this)) - { - return true; - } - if (other.Count != this.Count) - { - return false; - } - EqualityComparer comparer = EqualityComparer.Default; - for (int i = 0; i < count; i++) - { - if (!comparer.Equals(array[i], other.array[i])) - { - return false; - } - } - return true; - } - - /// - /// Returns the index of the given item within the collection, or -1 if the item is not - /// present. - /// - /// The item to find in the collection. - /// The zero-based index of the item, or -1 if it is not found. - public int IndexOf(T item) - { - if (item == null) - { - throw new ArgumentNullException("item"); - } - EqualityComparer comparer = EqualityComparer.Default; - for (int i = 0; i < count; i++) - { - if (comparer.Equals(array[i], item)) - { - return i; - } - } - return -1; - } - - /// - /// Inserts the given item at the specified index. - /// - /// The index at which to insert the item. - /// The item to insert. - public void Insert(int index, T item) - { - if (item == null) - { - throw new ArgumentNullException("item"); - } - if (index < 0 || index > count) - { - throw new ArgumentOutOfRangeException("index"); - } - EnsureSize(count + 1); - Array.Copy(array, index, array, index + 1, count - index); - array[index] = item; - count++; - } - - /// - /// Removes the item at the given index. - /// - /// The zero-based index of the item to remove. - public void RemoveAt(int index) - { - if (index < 0 || index >= count) - { - throw new ArgumentOutOfRangeException("index"); - } - Array.Copy(array, index + 1, array, index, count - index - 1); - count--; - array[count] = default(T); - } - - /// - /// Returns a string representation of this repeated field, in the same - /// way as it would be represented by the default JSON formatter. - /// - public override string ToString() - { - var writer = new StringWriter(); - JsonFormatter.Default.WriteList(writer, this); - return writer.ToString(); - } - - /// - /// Gets or sets the item at the specified index. - /// - /// - /// The element at the specified index. - /// - /// The zero-based index of the element to get or set. - /// The item at the specified index. - public T this[int index] - { - get - { - if (index < 0 || index >= count) - { - throw new ArgumentOutOfRangeException("index"); - } - return array[index]; - } - set - { - if (index < 0 || index >= count) - { - throw new ArgumentOutOfRangeException("index"); - } - if (value == null) - { - throw new ArgumentNullException("value"); - } - array[index] = value; - } - } - - #region Explicit interface implementation for IList and ICollection. - bool IList.IsFixedSize { get { return false; } } - - void ICollection.CopyTo(Array array, int index) - { - Array.Copy(this.array, 0, array, index, count); - } - - bool ICollection.IsSynchronized { get { return false; } } - - object ICollection.SyncRoot { get { return this; } } - - object IList.this[int index] - { - get { return this[index]; } - set { this[index] = (T)value; } - } - - int IList.Add(object value) - { - Add((T) value); - return count - 1; - } - - bool IList.Contains(object value) - { - return (value is T && Contains((T)value)); - } - - int IList.IndexOf(object value) - { - if (!(value is T)) - { - return -1; - } - return IndexOf((T)value); - } - - void IList.Insert(int index, object value) - { - Insert(index, (T) value); - } - - void IList.Remove(object value) - { - if (!(value is T)) - { - return; - } - Remove((T)value); - } - #endregion - } -} +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; + +namespace Google.Protobuf.Collections +{ + /// + /// The contents of a repeated field: essentially, a collection with some extra + /// restrictions (no null values) and capabilities (deep cloning). + /// + /// + /// This implementation does not generally prohibit the use of types which are not + /// supported by Protocol Buffers but nor does it guarantee that all operations will work in such cases. + /// + /// The element type of the repeated field. + public sealed class RepeatedField : IList, IList, IDeepCloneable>, IEquatable> +#if !NET35 + , IReadOnlyList +#endif + { + private static readonly EqualityComparer EqualityComparer = ProtobufEqualityComparers.GetEqualityComparer(); + private static readonly T[] EmptyArray = new T[0]; + private const int MinArraySize = 8; + + private T[] array = EmptyArray; + private int count = 0; + + /// + /// Creates a deep clone of this repeated field. + /// + /// + /// If the field type is + /// a message type, each element is also cloned; otherwise, it is + /// assumed that the field type is primitive (including string and + /// bytes, both of which are immutable) and so a simple copy is + /// equivalent to a deep clone. + /// + /// A deep clone of this repeated field. + public RepeatedField Clone() + { + RepeatedField clone = new RepeatedField(); + if (array != EmptyArray) + { + clone.array = (T[])array.Clone(); + IDeepCloneable[] cloneableArray = clone.array as IDeepCloneable[]; + if (cloneableArray != null) + { + for (int i = 0; i < count; i++) + { + clone.array[i] = cloneableArray[i].Clone(); + } + } + } + clone.count = count; + return clone; + } + + /// + /// Adds the entries from the given input stream, decoding them with the specified codec. + /// + /// The input stream to read from. + /// The codec to use in order to read each entry. + public void AddEntriesFrom(CodedInputStream input, FieldCodec codec) + { + // TODO: Inline some of the Add code, so we can avoid checking the size on every + // iteration. + uint tag = input.LastTag; + var reader = codec.ValueReader; + // Non-nullable value types can be packed or not. + if (FieldCodec.IsPackedRepeatedField(tag)) + { + int length = input.ReadLength(); + if (length > 0) + { + int oldLimit = input.PushLimit(length); + while (!input.ReachedLimit) + { + Add(reader(input)); + } + input.PopLimit(oldLimit); + } + // Empty packed field. Odd, but valid - just ignore. + } + else + { + // Not packed... (possibly not packable) + do + { + Add(reader(input)); + } while (input.MaybeConsumeTag(tag)); + } + } + + /// + /// Calculates the size of this collection based on the given codec. + /// + /// The codec to use when encoding each field. + /// The number of bytes that would be written to a by , + /// using the same codec. + public int CalculateSize(FieldCodec codec) + { + if (count == 0) + { + return 0; + } + uint tag = codec.Tag; + if (codec.PackedRepeatedField) + { + int dataSize = CalculatePackedDataSize(codec); + return CodedOutputStream.ComputeRawVarint32Size(tag) + + CodedOutputStream.ComputeLengthSize(dataSize) + + dataSize; + } + else + { + var sizeCalculator = codec.ValueSizeCalculator; + int size = count * CodedOutputStream.ComputeRawVarint32Size(tag); + for (int i = 0; i < count; i++) + { + size += sizeCalculator(array[i]); + } + return size; + } + } + + private int CalculatePackedDataSize(FieldCodec codec) + { + int fixedSize = codec.FixedSize; + if (fixedSize == 0) + { + var calculator = codec.ValueSizeCalculator; + int tmp = 0; + for (int i = 0; i < count; i++) + { + tmp += calculator(array[i]); + } + return tmp; + } + else + { + return fixedSize * Count; + } + } + + /// + /// Writes the contents of this collection to the given , + /// encoding each value using the specified codec. + /// + /// The output stream to write to. + /// The codec to use when encoding each value. + public void WriteTo(CodedOutputStream output, FieldCodec codec) + { + if (count == 0) + { + return; + } + var writer = codec.ValueWriter; + var tag = codec.Tag; + if (codec.PackedRepeatedField) + { + // Packed primitive type + uint size = (uint)CalculatePackedDataSize(codec); + output.WriteTag(tag); + output.WriteRawVarint32(size); + for (int i = 0; i < count; i++) + { + writer(output, array[i]); + } + } + else + { + // Not packed: a simple tag/value pair for each value. + // Can't use codec.WriteTagAndValue, as that omits default values. + for (int i = 0; i < count; i++) + { + output.WriteTag(tag); + writer(output, array[i]); + if (codec.EndTag != 0) + { + output.WriteTag(codec.EndTag); + } + } + } + } + + private void EnsureSize(int size) + { + if (array.Length < size) + { + size = Math.Max(size, MinArraySize); + int newSize = Math.Max(array.Length * 2, size); + var tmp = new T[newSize]; + Array.Copy(array, 0, tmp, 0, array.Length); + array = tmp; + } + } + + /// + /// Adds the specified item to the collection. + /// + /// The item to add. + public void Add(T item) + { + ProtoPreconditions.CheckNotNullUnconstrained(item, nameof(item)); + EnsureSize(count + 1); + array[count++] = item; + } + + /// + /// Removes all items from the collection. + /// + public void Clear() + { + array = EmptyArray; + count = 0; + } + + /// + /// Determines whether this collection contains the given item. + /// + /// The item to find. + /// true if this collection contains the given item; false otherwise. + public bool Contains(T item) + { + return IndexOf(item) != -1; + } + + /// + /// Copies this collection to the given array. + /// + /// The array to copy to. + /// The first index of the array to copy to. + public void CopyTo(T[] array, int arrayIndex) + { + Array.Copy(this.array, 0, array, arrayIndex, count); + } + + /// + /// Removes the specified item from the collection + /// + /// The item to remove. + /// true if the item was found and removed; false otherwise. + public bool Remove(T item) + { + int index = IndexOf(item); + if (index == -1) + { + return false; + } + Array.Copy(array, index + 1, array, index, count - index - 1); + count--; + array[count] = default(T); + return true; + } + + /// + /// Gets the number of elements contained in the collection. + /// + public int Count => count; + + /// + /// Gets a value indicating whether the collection is read-only. + /// + public bool IsReadOnly => false; + + /// + /// Adds all of the specified values into this collection. + /// + /// The values to add to this collection. + public void AddRange(IEnumerable values) + { + ProtoPreconditions.CheckNotNull(values, nameof(values)); + + // Optimization 1: If the collection we're adding is already a RepeatedField, + // we know the values are valid. + var otherRepeatedField = values as RepeatedField; + if (otherRepeatedField != null) + { + EnsureSize(count + otherRepeatedField.count); + Array.Copy(otherRepeatedField.array, 0, array, count, otherRepeatedField.count); + count += otherRepeatedField.count; + return; + } + + // Optimization 2: The collection is an ICollection, so we can expand + // just once and ask the collection to copy itself into the array. + var collection = values as ICollection; + if (collection != null) + { + var extraCount = collection.Count; + // For reference types and nullable value types, we need to check that there are no nulls + // present. (This isn't a thread-safe approach, but we don't advertise this is thread-safe.) + // We expect the JITter to optimize this test to true/false, so it's effectively conditional + // specialization. + if (default(T) == null) + { + // TODO: Measure whether iterating once to check and then letting the collection copy + // itself is faster or slower than iterating and adding as we go. For large + // collections this will not be great in terms of cache usage... but the optimized + // copy may be significantly faster than doing it one at a time. + foreach (var item in collection) + { + if (item == null) + { + throw new ArgumentException("Sequence contained null element", nameof(values)); + } + } + } + EnsureSize(count + extraCount); + collection.CopyTo(array, count); + count += extraCount; + return; + } + + // We *could* check for ICollection as well, but very very few collections implement + // ICollection but not ICollection. (HashSet does, for one...) + + // Fall back to a slower path of adding items one at a time. + foreach (T item in values) + { + Add(item); + } + } + + /// + /// Adds all of the specified values into this collection. This method is present to + /// allow repeated fields to be constructed from queries within collection initializers. + /// Within non-collection-initializer code, consider using the equivalent + /// method instead for clarity. + /// + /// The values to add to this collection. + public void Add(IEnumerable values) + { + AddRange(values); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// + /// An enumerator that can be used to iterate through the collection. + /// + public IEnumerator GetEnumerator() + { + for (int i = 0; i < count; i++) + { + yield return array[i]; + } + } + + /// + /// Determines whether the specified , is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public override bool Equals(object obj) + { + return Equals(obj as RepeatedField); + } + + /// + /// Returns an enumerator that iterates through a collection. + /// + /// + /// An object that can be used to iterate through the collection. + /// + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// + /// Returns a hash code for this instance. + /// + /// + /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. + /// + public override int GetHashCode() + { + int hash = 0; + for (int i = 0; i < count; i++) + { + hash = hash * 31 + array[i].GetHashCode(); + } + return hash; + } + + /// + /// Compares this repeated field with another for equality. + /// + /// The repeated field to compare this with. + /// true if refers to an equal repeated field; false otherwise. + public bool Equals(RepeatedField other) + { + if (ReferenceEquals(other, null)) + { + return false; + } + if (ReferenceEquals(other, this)) + { + return true; + } + if (other.Count != this.Count) + { + return false; + } + EqualityComparer comparer = EqualityComparer; + for (int i = 0; i < count; i++) + { + if (!comparer.Equals(array[i], other.array[i])) + { + return false; + } + } + return true; + } + + /// + /// Returns the index of the given item within the collection, or -1 if the item is not + /// present. + /// + /// The item to find in the collection. + /// The zero-based index of the item, or -1 if it is not found. + public int IndexOf(T item) + { + ProtoPreconditions.CheckNotNullUnconstrained(item, nameof(item)); + EqualityComparer comparer = EqualityComparer; + for (int i = 0; i < count; i++) + { + if (comparer.Equals(array[i], item)) + { + return i; + } + } + return -1; + } + + /// + /// Inserts the given item at the specified index. + /// + /// The index at which to insert the item. + /// The item to insert. + public void Insert(int index, T item) + { + ProtoPreconditions.CheckNotNullUnconstrained(item, nameof(item)); + if (index < 0 || index > count) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureSize(count + 1); + Array.Copy(array, index, array, index + 1, count - index); + array[index] = item; + count++; + } + + /// + /// Removes the item at the given index. + /// + /// The zero-based index of the item to remove. + public void RemoveAt(int index) + { + if (index < 0 || index >= count) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + Array.Copy(array, index + 1, array, index, count - index - 1); + count--; + array[count] = default(T); + } + + /// + /// Returns a string representation of this repeated field, in the same + /// way as it would be represented by the default JSON formatter. + /// + public override string ToString() + { + var writer = new StringWriter(); + JsonFormatter.Default.WriteList(writer, this); + return writer.ToString(); + } + + /// + /// Gets or sets the item at the specified index. + /// + /// + /// The element at the specified index. + /// + /// The zero-based index of the element to get or set. + /// The item at the specified index. + public T this[int index] + { + get + { + if (index < 0 || index >= count) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return array[index]; + } + set + { + if (index < 0 || index >= count) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + ProtoPreconditions.CheckNotNullUnconstrained(value, nameof(value)); + array[index] = value; + } + } + + #region Explicit interface implementation for IList and ICollection. + bool IList.IsFixedSize => false; + + void ICollection.CopyTo(Array array, int index) + { + Array.Copy(this.array, 0, array, index, count); + } + + bool ICollection.IsSynchronized => false; + + object ICollection.SyncRoot => this; + + object IList.this[int index] + { + get { return this[index]; } + set { this[index] = (T)value; } + } + + int IList.Add(object value) + { + Add((T) value); + return count - 1; + } + + bool IList.Contains(object value) + { + return (value is T && Contains((T)value)); + } + + int IList.IndexOf(object value) + { + if (!(value is T)) + { + return -1; + } + return IndexOf((T)value); + } + + void IList.Insert(int index, object value) + { + Insert(index, (T) value); + } + + void IList.Remove(object value) + { + if (!(value is T)) + { + return; + } + Remove((T)value); + } + #endregion + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Compatibility/MethodInfoExtensions.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Compatibility/MethodInfoExtensions.cs new file mode 100644 index 000000000000..7b946cb631fa --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Compatibility/MethodInfoExtensions.cs @@ -0,0 +1,47 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2017 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +#if NET35 +using System; +using System.Reflection; + +namespace Google.Protobuf.Compatibility +{ + // .NET Core (at least netstandard1.0) doesn't have Delegate.CreateDelegate, and .NET 3.5 doesn't have + // MethodInfo.CreateDelegate. Proxy from one to the other on .NET 3.5... + internal static class MethodInfoExtensions + { + internal static Delegate CreateDelegate(this MethodInfo method, Type type) => + Delegate.CreateDelegate(type, method); + } +} +#endif diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs index 8a6fefa74e88..95a02c727f7e 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs @@ -47,7 +47,11 @@ internal static class PropertyInfoExtensions /// internal static MethodInfo GetGetMethod(this PropertyInfo target) { +#if NET35 + var method = target.GetGetMethod(); +#else var method = target.GetMethod; +#endif return method != null && method.IsPublic ? method : null; } @@ -57,7 +61,11 @@ internal static MethodInfo GetGetMethod(this PropertyInfo target) /// internal static MethodInfo GetSetMethod(this PropertyInfo target) { +#if NET35 + var method = target.GetSetMethod(); +#else var method = target.SetMethod; +#endif return method != null && method.IsPublic ? method : null; } } diff --git a/third_party/protobuf/javanano/src/main/java/com/google/protobuf/nano/MapFactories.java b/third_party/protobuf/csharp/src/Google.Protobuf/Compatibility/StreamExtensions.cs similarity index 59% rename from third_party/protobuf/javanano/src/main/java/com/google/protobuf/nano/MapFactories.java rename to third_party/protobuf/csharp/src/Google.Protobuf/Compatibility/StreamExtensions.cs index 98fa4877bc40..bf4bf22018e4 100644 --- a/third_party/protobuf/javanano/src/main/java/com/google/protobuf/nano/MapFactories.java +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Compatibility/StreamExtensions.cs @@ -1,5 +1,6 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format -// Copyright 2013 Google Inc. All rights reserved. +// Copyright 2015 Google Inc. All rights reserved. // https://developers.google.com/protocol-buffers/ // // Redistribution and use in source and binary forms, with or without @@ -27,41 +28,39 @@ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion -package com.google.protobuf.nano; +#if NET35 +using System; +using System.IO; -import java.util.HashMap; -import java.util.Map; +namespace Google.Protobuf.Compatibility +{ + /// + /// Extension methods for in order to provide + /// backwards compatibility with .NET 3.5 + /// + public static class StreamExtensions + { + // 81920 seems to be the default buffer size used in .NET 4.5.1 + private const int BUFFER_SIZE = 81920; -/** - * Utility class for maps support. - */ -public final class MapFactories { - public static interface MapFactory { - Map forMap(Map oldMap); - } + /// + /// Write the contents of the current stream to the destination stream + /// + public static void CopyTo(this Stream source, Stream destination) + { + if (destination == null) + { + throw new ArgumentNullException(nameof(destination)); + } - // NOTE(liujisi): The factory setter is temporarily marked as package private. - // The way to provide customized implementations of maps for different - // platforms are still under discussion. Mark it as private to avoid exposing - // the API in proto3 alpha release. - /* public */ static void setMapFactory(MapFactory newMapFactory) { - mapFactory = newMapFactory; - } - - public static MapFactory getMapFactory() { - return mapFactory; - } - - private static class DefaultMapFactory implements MapFactory { - public Map forMap(Map oldMap) { - if (oldMap == null) { - return new HashMap(); - } - return oldMap; + byte[] buffer = new byte[BUFFER_SIZE]; + int numBytesRead; + while ((numBytesRead = source.Read(buffer, 0, buffer.Length)) > 0) { + destination.Write(buffer, 0, numBytesRead); + } + } } - } - private static volatile MapFactory mapFactory = new DefaultMapFactory(); - - private MapFactories() {} } +#endif diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs index 762a29eb0a30..2f23713819f6 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs @@ -33,6 +33,7 @@ using System; using System.Reflection; +#if !NET35 namespace Google.Protobuf.Compatibility { /// @@ -45,15 +46,6 @@ namespace Google.Protobuf.Compatibility /// internal static class TypeExtensions { - /// - /// Returns true if the target type is a value type, including a nullable value type or an enum, or false - /// if it's a reference type (class, delegate, interface - including System.ValueType and System.Enum). - /// - internal static bool IsValueType(this Type target) - { - return target.GetTypeInfo().IsValueType; - } - /// /// See https://msdn.microsoft.com/en-us/library/system.type.isassignablefrom /// @@ -111,3 +103,4 @@ internal static MethodInfo GetMethod(this Type target, string name) } } } +#endif diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Extension.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Extension.cs new file mode 100644 index 000000000000..ddeb97795aae --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Extension.cs @@ -0,0 +1,111 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; + +namespace Google.Protobuf +{ + /// + /// Represents a non-generic extension definition + /// + public abstract class Extension + { + internal abstract Type TargetType { get; } + + /// + /// Internal use. Creates a new extension with the specified field number. + /// + protected Extension(int number) + { + FieldNumber = number; + } + + internal abstract IExtensionValue CreateValue(); + + /// + /// Gets the field number of this extension + /// + public int FieldNumber { get; } + } + + /// + /// Represents a type-safe extension identifier used for getting and setting single extension values in instances + /// + /// The message type this field applies to + /// The field value type of this extension + public sealed class Extension : Extension where TTarget : IExtendableMessage + { + private readonly FieldCodec codec; + + /// + /// Creates a new extension identifier with the specified field number and codec + /// + public Extension(int number, FieldCodec codec) : base(number) + { + this.codec = codec; + } + + internal TValue DefaultValue => codec.DefaultValue; + + internal override Type TargetType => typeof(TTarget); + + internal override IExtensionValue CreateValue() + { + return new ExtensionValue(codec); + } + } + + /// + /// Represents a type-safe extension identifier used for getting repeated extension values in instances + /// + /// The message type this field applies to + /// The repeated field value type of this extension + public sealed class RepeatedExtension : Extension where TTarget : IExtendableMessage + { + private readonly FieldCodec codec; + + /// + /// Creates a new repeated extension identifier with the specified field number and codec + /// + public RepeatedExtension(int number, FieldCodec codec) : base(number) + { + this.codec = codec; + } + + internal override Type TargetType => typeof(TTarget); + + internal override IExtensionValue CreateValue() + { + return new RepeatedExtensionValue(codec); + } + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/ExtensionRegistry.cs b/third_party/protobuf/csharp/src/Google.Protobuf/ExtensionRegistry.cs new file mode 100644 index 000000000000..ea655c123e2c --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf/ExtensionRegistry.cs @@ -0,0 +1,175 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Google.Protobuf +{ + /// + /// Provides extensions to messages while parsing + /// + public sealed class ExtensionRegistry : ICollection, IDeepCloneable + { + private IDictionary, Extension> extensions; + + /// + /// Creates a new empty extension registry + /// + public ExtensionRegistry() + { + extensions = new Dictionary, Extension>(); + } + + private ExtensionRegistry(IDictionary, Extension> collection) + { + extensions = collection.ToDictionary(k => k.Key, v => v.Value); + } + + /// + /// Gets the total number of extensions in this extension registry + /// + public int Count => extensions.Count; + + /// + /// Returns whether the registry is readonly + /// + bool ICollection.IsReadOnly => false; + + internal bool ContainsInputField(CodedInputStream stream, Type target, out Extension extension) + { + return extensions.TryGetValue(new ObjectIntPair(target, WireFormat.GetTagFieldNumber(stream.LastTag)), out extension); + } + + /// + /// Adds the specified extension to the registry + /// + public void Add(Extension extension) + { + ProtoPreconditions.CheckNotNull(extension, nameof(extension)); + + extensions.Add(new ObjectIntPair(extension.TargetType, extension.FieldNumber), extension); + } + + /// + /// Adds the specified extensions to the registry + /// + public void Add(params Extension[] newExtensions) + { + ProtoPreconditions.CheckNotNull(newExtensions, nameof(newExtensions)); + + Add((IEnumerable)newExtensions); + } + + /// + /// Adds the specified extensions to the reigstry + /// + public void Add(IEnumerable newExtensions) + { + ProtoPreconditions.CheckNotNull(newExtensions, nameof(newExtensions)); + + foreach (var extension in newExtensions) + Add(extension); + } + + /// + /// Clears the registry of all values + /// + public void Clear() + { + extensions.Clear(); + } + + /// + /// Gets whether the extension registry contains the specified extension + /// + public bool Contains(Extension item) + { + ProtoPreconditions.CheckNotNull(item, nameof(item)); + + return extensions.ContainsKey(new ObjectIntPair(item.TargetType, item.FieldNumber)); + } + + /// + /// Copies the arrays in the registry set to the specified array at the specified index + /// + /// The array to copy to + /// The array index to start at + void ICollection.CopyTo(Extension[] array, int arrayIndex) + { + ProtoPreconditions.CheckNotNull(array, nameof(array)); + if (arrayIndex < 0 || arrayIndex >= array.Length) + throw new ArgumentOutOfRangeException(nameof(arrayIndex)); + if (array.Length - arrayIndex < Count) + throw new ArgumentException("The provided array is shorter than the number of elements in the registry"); + + for (int i = 0; i < array.Length; i++) + { + Extension extension = array[i]; + extensions.Add(new ObjectIntPair(extension.TargetType, extension.FieldNumber), extension); + } + } + + /// + /// Returns an enumerator to enumerate through the items in the registry + /// + /// Returns an enumerator for the extensions in this registry + public IEnumerator GetEnumerator() + { + return extensions.Values.GetEnumerator(); + } + + /// + /// Removes the specified extension from the set + /// + /// The extension + /// true if the extension was removed, otherwise false + public bool Remove(Extension item) + { + ProtoPreconditions.CheckNotNull(item, nameof(item)); + + return extensions.Remove(new ObjectIntPair(item.TargetType, item.FieldNumber)); + } + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + /// + /// Clones the registry into a new registry + /// + public ExtensionRegistry Clone() + { + return new ExtensionRegistry(extensions); + } + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/ExtensionSet.cs b/third_party/protobuf/csharp/src/Google.Protobuf/ExtensionSet.cs new file mode 100644 index 000000000000..fa81e6a633a0 --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf/ExtensionSet.cs @@ -0,0 +1,341 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using Google.Protobuf.Collections; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Google.Protobuf +{ + /// + /// Methods for managing s with null checking. + /// + /// Most users will not use this class directly + /// + public static class ExtensionSet + { + private static bool GetValue(ref ExtensionSet set, Extension extension, out IExtensionValue value) where TTarget : IExtendableMessage + { + if (set == null) + { + value = null; + return false; + } + return set.ValuesByNumber.TryGetValue(extension.FieldNumber, out value); + } + + /// + /// Gets the value of the specified extension + /// + public static TValue Get(ref ExtensionSet set, Extension extension) where TTarget : IExtendableMessage + { + IExtensionValue value; + if (GetValue(ref set, extension, out value)) + { + return ((ExtensionValue)value).GetValue(); + } + else + { + return extension.DefaultValue; + } + } + + /// + /// Gets the value of the specified repeated extension or null if it doesn't exist in this set + /// + public static RepeatedField Get(ref ExtensionSet set, RepeatedExtension extension) where TTarget : IExtendableMessage + { + IExtensionValue value; + if (GetValue(ref set, extension, out value)) + { + return ((RepeatedExtensionValue)value).GetValue(); + } + else + { + return null; + } + } + + /// + /// Gets the value of the specified repeated extension, registering it if it doesn't exist + /// + public static RepeatedField GetOrRegister(ref ExtensionSet set, RepeatedExtension extension) where TTarget : IExtendableMessage + { + IExtensionValue value; + if (set == null) + { + value = extension.CreateValue(); + set = new ExtensionSet(); + set.ValuesByNumber.Add(extension.FieldNumber, value); + } + else + { + if (!set.ValuesByNumber.TryGetValue(extension.FieldNumber, out value)) + { + value = extension.CreateValue(); + set.ValuesByNumber.Add(extension.FieldNumber, value); + } + } + + return ((RepeatedExtensionValue)value).GetValue(); + } + + /// + /// Sets the value of the specified extension + /// + public static void Set(ref ExtensionSet set, Extension extension, TValue value) where TTarget : IExtendableMessage + { + IExtensionValue extensionValue; + if (set == null) + { + extensionValue = extension.CreateValue(); + set = new ExtensionSet(); + set.ValuesByNumber.Add(extension.FieldNumber, extensionValue); + } + else + { + if (!set.ValuesByNumber.TryGetValue(extension.FieldNumber, out extensionValue)) + { + extensionValue = extension.CreateValue(); + set.ValuesByNumber.Add(extension.FieldNumber, extensionValue); + } + } + + ((ExtensionValue)extensionValue).SetValue(value); + } + + /// + /// Gets whether the value of the specified extension is set + /// + public static bool Has(ref ExtensionSet set, Extension extension) where TTarget : IExtendableMessage + { + IExtensionValue value; + if (GetValue(ref set, extension, out value)) + { + return ((ExtensionValue)value).HasValue; + } + else + { + return false; + } + } + + /// + /// Clears the value of the specified extension + /// + public static void Clear(ref ExtensionSet set, Extension extension) where TTarget : IExtendableMessage + { + if (set == null) + { + return; + } + set.ValuesByNumber.Remove(extension.FieldNumber); + if (set.ValuesByNumber.Count == 0) + { + set = null; + } + } + + /// + /// Clears the value of the specified extension + /// + public static void Clear(ref ExtensionSet set, RepeatedExtension extension) where TTarget : IExtendableMessage + { + if (set == null) + { + return; + } + set.ValuesByNumber.Remove(extension.FieldNumber); + if (set.ValuesByNumber.Count == 0) + { + set = null; + } + } + + /// + /// Tries to merge a field from the coded input, returning true if the field was merged. + /// If the set is null or the field was not otherwise merged, this returns false. + /// + public static bool TryMergeFieldFrom(ref ExtensionSet set, CodedInputStream stream) where TTarget : IExtendableMessage + { + Extension extension; + int lastFieldNumber = WireFormat.GetTagFieldNumber(stream.LastTag); + + IExtensionValue extensionValue; + if (set != null && set.ValuesByNumber.TryGetValue(lastFieldNumber, out extensionValue)) + { + extensionValue.MergeFrom(stream); + return true; + } + else if (stream.ExtensionRegistry != null && stream.ExtensionRegistry.ContainsInputField(stream, typeof(TTarget), out extension)) + { + IExtensionValue value = extension.CreateValue(); + value.MergeFrom(stream); + set = (set ?? new ExtensionSet()); + set.ValuesByNumber.Add(extension.FieldNumber, value); + return true; + } + else + { + return false; + } + } + + /// + /// Merges the second set into the first set, creating a new instance if first is null + /// + public static void MergeFrom(ref ExtensionSet first, ExtensionSet second) where TTarget : IExtendableMessage + { + if (second == null) + { + return; + } + if (first == null) + { + first = new ExtensionSet(); + } + foreach (var pair in second.ValuesByNumber) + { + IExtensionValue value; + if (first.ValuesByNumber.TryGetValue(pair.Key, out value)) + { + value.MergeFrom(pair.Value); + } + else + { + var cloned = pair.Value.Clone(); + first.ValuesByNumber[pair.Key] = cloned; + } + } + } + + /// + /// Clones the set into a new set. If the set is null, this returns null + /// + public static ExtensionSet Clone(ExtensionSet set) where TTarget : IExtendableMessage + { + if (set == null) + { + return null; + } + + var newSet = new ExtensionSet(); + foreach (var pair in set.ValuesByNumber) + { + var cloned = pair.Value.Clone(); + newSet.ValuesByNumber[pair.Key] = cloned; + } + return newSet; + } + } + + /// + /// Used for keeping track of extensions in messages. + /// methods route to this set. + /// + /// Most users will not need to use this class directly + /// + /// The message type that extensions in this set target + public sealed class ExtensionSet where TTarget : IExtendableMessage + { + internal Dictionary ValuesByNumber { get; } = new Dictionary(); + + /// + /// Gets a hash code of the set + /// + public override int GetHashCode() + { + int ret = typeof(TTarget).GetHashCode(); + foreach (KeyValuePair field in ValuesByNumber) + { + // Use ^ here to make the field order irrelevant. + int hash = field.Key.GetHashCode() ^ field.Value.GetHashCode(); + ret ^= hash; + } + return ret; + } + + /// + /// Returns whether this set is equal to the other object + /// + public override bool Equals(object other) + { + if (ReferenceEquals(this, other)) + { + return true; + } + ExtensionSet otherSet = other as ExtensionSet; + if (ValuesByNumber.Count != otherSet.ValuesByNumber.Count) + { + return false; + } + foreach (var pair in ValuesByNumber) + { + IExtensionValue secondValue; + if (!otherSet.ValuesByNumber.TryGetValue(pair.Key, out secondValue)) + { + return false; + } + if (!pair.Value.Equals(secondValue)) + { + return false; + } + } + return true; + } + + /// + /// Calculates the size of this extension set + /// + public int CalculateSize() + { + int size = 0; + foreach (var value in ValuesByNumber.Values) + { + size += value.CalculateSize(); + } + return size; + } + + /// + /// Writes the extension values in this set to the output stream + /// + public void WriteTo(CodedOutputStream stream) + { + foreach (var value in ValuesByNumber.Values) + { + value.WriteTo(stream); + } + } + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/ExtensionValue.cs b/third_party/protobuf/csharp/src/Google.Protobuf/ExtensionValue.cs new file mode 100644 index 000000000000..181e88264c59 --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf/ExtensionValue.cs @@ -0,0 +1,207 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using Google.Protobuf.Collections; +using System; + +namespace Google.Protobuf +{ + internal interface IExtensionValue : IEquatable, IDeepCloneable + { + void MergeFrom(CodedInputStream input); + void MergeFrom(IExtensionValue value); + void WriteTo(CodedOutputStream output); + int CalculateSize(); + } + + internal sealed class ExtensionValue : IExtensionValue + { + private bool hasValue; + private T field; + private FieldCodec codec; + + internal ExtensionValue(FieldCodec codec) + { + this.codec = codec; + field = codec.DefaultValue; + } + + public int CalculateSize() + { + if (!hasValue) + { + return 0; + } + return codec.CalculateSizeWithTag(field); + } + + public IExtensionValue Clone() + { + return new ExtensionValue(codec) + { + hasValue = hasValue, + field = field is IDeepCloneable ? (field as IDeepCloneable).Clone() : field + }; + } + + public bool Equals(IExtensionValue other) + { + if (ReferenceEquals(this, other)) + return true; + + return other is ExtensionValue + && codec.Equals((other as ExtensionValue).codec) + && hasValue.Equals((other as ExtensionValue).hasValue) + && Equals(field, (other as ExtensionValue).field); + // we check for equality in the codec since we could have equal field values however the values could be written in different ways + } + + public override int GetHashCode() + { + unchecked + { + int hash = 17; + hash = hash * 31 + hasValue.GetHashCode(); + hash = hash * 31 + field.GetHashCode(); + hash = hash * 31 + codec.GetHashCode(); + return hash; + } + } + + public void MergeFrom(CodedInputStream input) + { + hasValue = true; + codec.ValueMerger(input, ref field); + } + + public void MergeFrom(IExtensionValue value) + { + if (value is ExtensionValue) + { + var extensionValue = value as ExtensionValue; + if (extensionValue.hasValue) + { + hasValue |= codec.FieldMerger(ref field, extensionValue.field); + } + } + } + + public void WriteTo(CodedOutputStream output) + { + if (hasValue) + { + output.WriteTag(codec.Tag); + codec.ValueWriter(output, field); + if (codec.EndTag != 0) + { + output.WriteTag(codec.EndTag); + } + } + } + + public T GetValue() => field; + + public void SetValue(T value) + { + hasValue = true; + field = value; + } + + public bool HasValue => hasValue; + } + + internal sealed class RepeatedExtensionValue : IExtensionValue + { + private RepeatedField field; + private readonly FieldCodec codec; + + internal RepeatedExtensionValue(FieldCodec codec) + { + this.codec = codec; + field = new RepeatedField(); + } + + public int CalculateSize() + { + return field.CalculateSize(codec); + } + + public IExtensionValue Clone() + { + return new RepeatedExtensionValue(codec) + { + field = field.Clone() + }; + } + + public bool Equals(IExtensionValue other) + { + if (ReferenceEquals(this, other)) + return true; + + return other is RepeatedExtensionValue + && field.Equals((other as RepeatedExtensionValue).field) + && codec.Equals((other as RepeatedExtensionValue).codec); + } + + public override int GetHashCode() + { + unchecked + { + int hash = 17; + hash = hash * 31 + field.GetHashCode(); + hash = hash * 31 + codec.GetHashCode(); + return hash; + } + } + + public void MergeFrom(CodedInputStream input) + { + field.AddEntriesFrom(input, codec); + } + + public void MergeFrom(IExtensionValue value) + { + if (value is RepeatedExtensionValue) + { + field.Add((value as RepeatedExtensionValue).field); + } + } + + public void WriteTo(CodedOutputStream output) + { + field.WriteTo(output, codec); + } + + public RepeatedField GetValue() => field; + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/FieldCodec.cs b/third_party/protobuf/csharp/src/Google.Protobuf/FieldCodec.cs index 9831308882b0..60e64effd40b 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/FieldCodec.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/FieldCodec.cs @@ -30,6 +30,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion +using Google.Protobuf.Collections; using Google.Protobuf.Compatibility; using Google.Protobuf.WellKnownTypes; using System; @@ -48,8 +49,9 @@ public static class FieldCodec /// Retrieves a codec suitable for a string field with the given tag. /// /// The tag. + /// The default value. /// A codec for the given tag. - public static FieldCodec ForString(uint tag) + public static FieldCodec ForString(uint tag, string defaultValue = "") { return new FieldCodec(input => input.ReadString(), (output, value) => output.WriteString(value), CodedOutputStream.ComputeStringSize, tag); } @@ -58,8 +60,9 @@ public static FieldCodec ForString(uint tag) /// Retrieves a codec suitable for a bytes field with the given tag. /// /// The tag. + /// The default value. /// A codec for the given tag. - public static FieldCodec ForBytes(uint tag) + public static FieldCodec ForBytes(uint tag, ByteString defaultValue = null) { return new FieldCodec(input => input.ReadBytes(), (output, value) => output.WriteBytes(value), CodedOutputStream.ComputeBytesSize, tag); } @@ -68,18 +71,20 @@ public static FieldCodec ForBytes(uint tag) /// Retrieves a codec suitable for a bool field with the given tag. /// /// The tag. + /// The default value. /// A codec for the given tag. - public static FieldCodec ForBool(uint tag) + public static FieldCodec ForBool(uint tag, bool defaultValue = false) { - return new FieldCodec(input => input.ReadBool(), (output, value) => output.WriteBool(value), CodedOutputStream.ComputeBoolSize, tag); + return new FieldCodec(input => input.ReadBool(), (output, value) => output.WriteBool(value), CodedOutputStream.BoolSize, tag); } /// /// Retrieves a codec suitable for an int32 field with the given tag. /// /// The tag. + /// The default value. /// A codec for the given tag. - public static FieldCodec ForInt32(uint tag) + public static FieldCodec ForInt32(uint tag, int defaultValue = 0) { return new FieldCodec(input => input.ReadInt32(), (output, value) => output.WriteInt32(value), CodedOutputStream.ComputeInt32Size, tag); } @@ -88,8 +93,9 @@ public static FieldCodec ForInt32(uint tag) /// Retrieves a codec suitable for an sint32 field with the given tag. /// /// The tag. + /// The default value. /// A codec for the given tag. - public static FieldCodec ForSInt32(uint tag) + public static FieldCodec ForSInt32(uint tag, int defaultValue = 0) { return new FieldCodec(input => input.ReadSInt32(), (output, value) => output.WriteSInt32(value), CodedOutputStream.ComputeSInt32Size, tag); } @@ -98,8 +104,9 @@ public static FieldCodec ForSInt32(uint tag) /// Retrieves a codec suitable for a fixed32 field with the given tag. /// /// The tag. + /// The default value. /// A codec for the given tag. - public static FieldCodec ForFixed32(uint tag) + public static FieldCodec ForFixed32(uint tag, uint defaultValue = 0) { return new FieldCodec(input => input.ReadFixed32(), (output, value) => output.WriteFixed32(value), 4, tag); } @@ -108,8 +115,9 @@ public static FieldCodec ForFixed32(uint tag) /// Retrieves a codec suitable for an sfixed32 field with the given tag. /// /// The tag. + /// The default value. /// A codec for the given tag. - public static FieldCodec ForSFixed32(uint tag) + public static FieldCodec ForSFixed32(uint tag, int defaultValue = 0) { return new FieldCodec(input => input.ReadSFixed32(), (output, value) => output.WriteSFixed32(value), 4, tag); } @@ -118,8 +126,9 @@ public static FieldCodec ForSFixed32(uint tag) /// Retrieves a codec suitable for a uint32 field with the given tag. /// /// The tag. + /// The default value. /// A codec for the given tag. - public static FieldCodec ForUInt32(uint tag) + public static FieldCodec ForUInt32(uint tag, uint defaultValue = 0) { return new FieldCodec(input => input.ReadUInt32(), (output, value) => output.WriteUInt32(value), CodedOutputStream.ComputeUInt32Size, tag); } @@ -128,8 +137,9 @@ public static FieldCodec ForUInt32(uint tag) /// Retrieves a codec suitable for an int64 field with the given tag. /// /// The tag. + /// The default value. /// A codec for the given tag. - public static FieldCodec ForInt64(uint tag) + public static FieldCodec ForInt64(uint tag, long defaultValue = 0) { return new FieldCodec(input => input.ReadInt64(), (output, value) => output.WriteInt64(value), CodedOutputStream.ComputeInt64Size, tag); } @@ -138,8 +148,9 @@ public static FieldCodec ForInt64(uint tag) /// Retrieves a codec suitable for an sint64 field with the given tag. /// /// The tag. + /// The default value. /// A codec for the given tag. - public static FieldCodec ForSInt64(uint tag) + public static FieldCodec ForSInt64(uint tag, long defaultValue = 0) { return new FieldCodec(input => input.ReadSInt64(), (output, value) => output.WriteSInt64(value), CodedOutputStream.ComputeSInt64Size, tag); } @@ -148,8 +159,9 @@ public static FieldCodec ForSInt64(uint tag) /// Retrieves a codec suitable for a fixed64 field with the given tag. /// /// The tag. + /// The default value. /// A codec for the given tag. - public static FieldCodec ForFixed64(uint tag) + public static FieldCodec ForFixed64(uint tag, ulong defaultValue = 0) { return new FieldCodec(input => input.ReadFixed64(), (output, value) => output.WriteFixed64(value), 8, tag); } @@ -158,8 +170,9 @@ public static FieldCodec ForFixed64(uint tag) /// Retrieves a codec suitable for an sfixed64 field with the given tag. /// /// The tag. + /// The default value. /// A codec for the given tag. - public static FieldCodec ForSFixed64(uint tag) + public static FieldCodec ForSFixed64(uint tag, long defaultValue = 0) { return new FieldCodec(input => input.ReadSFixed64(), (output, value) => output.WriteSFixed64(value), 8, tag); } @@ -168,8 +181,9 @@ public static FieldCodec ForSFixed64(uint tag) /// Retrieves a codec suitable for a uint64 field with the given tag. /// /// The tag. + /// The default value. /// A codec for the given tag. - public static FieldCodec ForUInt64(uint tag) + public static FieldCodec ForUInt64(uint tag, ulong defaultValue = 0) { return new FieldCodec(input => input.ReadUInt64(), (output, value) => output.WriteUInt64(value), CodedOutputStream.ComputeUInt64Size, tag); } @@ -178,20 +192,22 @@ public static FieldCodec ForUInt64(uint tag) /// Retrieves a codec suitable for a float field with the given tag. /// /// The tag. + /// The default value. /// A codec for the given tag. - public static FieldCodec ForFloat(uint tag) + public static FieldCodec ForFloat(uint tag, float defaultValue = 0) { - return new FieldCodec(input => input.ReadFloat(), (output, value) => output.WriteFloat(value), CodedOutputStream.ComputeFloatSize, tag); + return new FieldCodec(input => input.ReadFloat(), (output, value) => output.WriteFloat(value), CodedOutputStream.FloatSize, tag); } /// /// Retrieves a codec suitable for a double field with the given tag. /// /// The tag. + /// The default value. /// A codec for the given tag. - public static FieldCodec ForDouble(uint tag) + public static FieldCodec ForDouble(uint tag, double defaultValue = 0) { - return new FieldCodec(input => input.ReadDouble(), (output, value) => output.WriteDouble(value), CodedOutputStream.ComputeDoubleSize, tag); + return new FieldCodec(input => input.ReadDouble(), (output, value) => output.WriteDouble(value), CodedOutputStream.DoubleSize, tag); } // Enums are tricky. We can probably use expression trees to build these delegates automatically, @@ -203,8 +219,9 @@ public static FieldCodec ForDouble(uint tag) /// The tag. /// A conversion function from to the enum type. /// A conversion function from the enum type to . + /// The default value. /// A codec for the given tag. - public static FieldCodec ForEnum(uint tag, Func toInt32, Func fromInt32) + public static FieldCodec ForEnum(uint tag, Func toInt32, Func fromInt32, T defaultValue = default(T)) { return new FieldCodec(input => fromInt32( input.ReadEnum()), @@ -218,10 +235,70 @@ public static FieldCodec ForEnum(uint tag, Func toInt32, FuncThe tag. /// A parser to use for the message type. /// A codec for the given tag. - public static FieldCodec ForMessage(uint tag, MessageParser parser) where T : IMessage + public static FieldCodec ForMessage(uint tag, MessageParser parser) where T : class, IMessage { return new FieldCodec(input => { T message = parser.CreateTemplate(); input.ReadMessage(message); return message; }, - (output, value) => output.WriteMessage(value), message => CodedOutputStream.ComputeMessageSize(message), tag); + (output, value) => output.WriteMessage(value), (CodedInputStream i, ref T v) => + { + if (v == null) + { + v = parser.CreateTemplate(); + } + + i.ReadMessage(v); + }, + (ref T v, T v2) => + { + if (v2 == null) + { + return false; + } + else if (v == null) + { + v = v2.Clone(); + } + else + { + v.MergeFrom(v2); + } + return true; + }, message => CodedOutputStream.ComputeMessageSize(message), tag); + } + + /// + /// Retrieves a codec suitable for a group field with the given tag. + /// + /// The start group tag. + /// The end group tag. + /// A parser to use for the group message type. + /// A codec for given tag + public static FieldCodec ForGroup(uint startTag, uint endTag, MessageParser parser) where T : class, IMessage + { + return new FieldCodec(input => { T message = parser.CreateTemplate(); input.ReadGroup(message); return message; }, + (output, value) => output.WriteGroup(value), (CodedInputStream i, ref T v) => { + if (v == null) + { + v = parser.CreateTemplate(); + } + + i.ReadGroup(v); + }, + (ref T v, T v2) => + { + if (v2 == null) + { + return v == null; + } + else if (v == null) + { + v = v2.Clone(); + } + else + { + v.MergeFrom(v2); + } + return true; + }, message => CodedOutputStream.ComputeGroupSize(message), startTag, endTag); } /// @@ -233,8 +310,10 @@ public static FieldCodec ForClassWrapper(uint tag) where T : class return new FieldCodec( input => WrapperCodecs.Read(input, nestedCodec), (output, value) => WrapperCodecs.Write(output, value, nestedCodec), + (CodedInputStream i, ref T v) => v = WrapperCodecs.Read(i, nestedCodec), + (ref T v, T v2) => { v = v2; return v == null; }, value => WrapperCodecs.CalculateSize(value, nestedCodec), - tag, + tag, 0, null); // Default value for the wrapper } @@ -248,8 +327,10 @@ public static FieldCodec ForClassWrapper(uint tag) where T : class return new FieldCodec( input => WrapperCodecs.Read(input, nestedCodec), (output, value) => WrapperCodecs.Write(output, value.Value, nestedCodec), + (CodedInputStream i, ref T? v) => v = WrapperCodecs.Read(i, nestedCodec), + (ref T? v, T? v2) => { if (v2.HasValue) { v = v2; } return v.HasValue; }, value => value == null ? 0 : WrapperCodecs.CalculateSize(value.Value, nestedCodec), - tag, + tag, 0, null); // Default value for the wrapper } @@ -278,7 +359,7 @@ private static class WrapperCodecs /// /// Returns a field codec which effectively wraps a value of type T in a message. - /// + /// /// internal static FieldCodec GetCodec() { @@ -346,8 +427,20 @@ internal static int CalculateSize(T value, FieldCodec codec) /// public sealed class FieldCodec { + private static readonly EqualityComparer EqualityComparer = ProtobufEqualityComparers.GetEqualityComparer(); private static readonly T DefaultDefault; - private static readonly bool TypeSupportsPacking = typeof(T).IsValueType() && Nullable.GetUnderlyingType(typeof(T)) == null; + // Only non-nullable value types support packing. This is the simplest way of detecting that. + private static readonly bool TypeSupportsPacking = default(T) != null; + + /// + /// Merges an input stream into a value + /// + internal delegate void InputMerger(CodedInputStream input, ref T value); + + /// + /// Merges a value into a reference to another value, returning a boolean if the value was set + /// + internal delegate bool ValuesMerger(ref T value, T other); static FieldCodec() { @@ -383,6 +476,17 @@ internal static bool IsPackedRepeatedField(uint tag) => /// internal Func ValueReader { get; } + /// + /// Returns a delegate to merge a value from a coded input stream. + /// It is assumed that the stream is already positioned on the appropriate tag + /// + internal InputMerger ValueMerger { get; } + + /// + /// Returns a delegate to merge two values together. + /// + internal ValuesMerger FieldMerger { get; } + /// /// Returns the fixed size for an entry, or 0 if sizes vary. /// @@ -396,6 +500,14 @@ internal static bool IsPackedRepeatedField(uint tag) => /// internal uint Tag { get; } + /// + /// Gets the end tag of the codec or 0 if there is no end tag + /// + /// + /// The end tag of the codec. + /// + internal uint EndTag { get; } + /// /// Default value for this codec. Usually the same for every instance of the same type, but /// for string/ByteString wrapper fields the codec's default value is null, whereas for @@ -407,7 +519,7 @@ internal static bool IsPackedRepeatedField(uint tag) => internal T DefaultValue { get; } private readonly int tagSize; - + internal FieldCodec( Func reader, Action writer, @@ -421,24 +533,43 @@ internal FieldCodec( Func reader, Action writer, Func sizeCalculator, - uint tag) : this(reader, writer, sizeCalculator, tag, DefaultDefault) + uint tag, + uint endTag = 0) : this(reader, writer, (CodedInputStream i, ref T v) => v = reader(i), (ref T v, T v2) => { v = v2; return true; }, sizeCalculator, tag, endTag, DefaultDefault) + { + } + + internal FieldCodec( + Func reader, + Action writer, + InputMerger inputMerger, + ValuesMerger valuesMerger, + Func sizeCalculator, + uint tag, + uint endTag = 0) : this(reader, writer, inputMerger, valuesMerger, sizeCalculator, tag, endTag, DefaultDefault) { } internal FieldCodec( Func reader, Action writer, + InputMerger inputMerger, + ValuesMerger valuesMerger, Func sizeCalculator, uint tag, + uint endTag, T defaultValue) { ValueReader = reader; ValueWriter = writer; + ValueMerger = inputMerger; + FieldMerger = valuesMerger; ValueSizeCalculator = sizeCalculator; FixedSize = 0; Tag = tag; DefaultValue = defaultValue; tagSize = CodedOutputStream.ComputeRawVarint32Size(tag); + if (endTag != 0) + tagSize += CodedOutputStream.ComputeRawVarint32Size(endTag); // Detect packed-ness once, so we can check for it within RepeatedField. PackedRepeatedField = IsPackedRepeatedField(tag); } @@ -452,6 +583,10 @@ public void WriteTagAndValue(CodedOutputStream output, T value) { output.WriteTag(Tag); ValueWriter(output, value); + if (EndTag != 0) + { + output.WriteTag(EndTag); + } } } @@ -468,6 +603,6 @@ public void WriteTagAndValue(CodedOutputStream output, T value) /// public int CalculateSizeWithTag(T value) => IsDefault(value) ? 0 : ValueSizeCalculator(value) + tagSize; - private bool IsDefault(T value) => EqualityComparer.Default.Equals(value, DefaultValue); + private bool IsDefault(T value) => EqualityComparer.Equals(value, DefaultValue); } } diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/FieldMaskTree.cs b/third_party/protobuf/csharp/src/Google.Protobuf/FieldMaskTree.cs new file mode 100644 index 000000000000..2297e7a119d5 --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf/FieldMaskTree.cs @@ -0,0 +1,365 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using Google.Protobuf.Reflection; +using Google.Protobuf.WellKnownTypes; + +namespace Google.Protobuf +{ + /// + /// A tree representation of a FieldMask. Each leaf node in this tree represent + /// a field path in the FieldMask. + /// + /// For example, FieldMask "foo.bar,foo.baz,bar.baz" as a tree will be: + /// + /// [root] -+- foo -+- bar + /// | | + /// | +- baz + /// | + /// +- bar --- baz + /// + /// + /// By representing FieldMasks with this tree structure we can easily convert + /// a FieldMask to a canonical form, merge two FieldMasks, calculate the + /// intersection to two FieldMasks and traverse all fields specified by the + /// FieldMask in a message tree. + /// + internal sealed class FieldMaskTree + { + private const char FIELD_PATH_SEPARATOR = '.'; + + internal sealed class Node + { + public Dictionary Children { get; } = new Dictionary(); + } + + private readonly Node root = new Node(); + + /// + /// Creates an empty FieldMaskTree. + /// + public FieldMaskTree() + { + } + + /// + /// Creates a FieldMaskTree for a given FieldMask. + /// + public FieldMaskTree(FieldMask mask) + { + MergeFromFieldMask(mask); + } + + public override string ToString() + { + return ToFieldMask().ToString(); + } + + /// + /// Adds a field path to the tree. In a FieldMask, every field path matches the + /// specified field as well as all its sub-fields. For example, a field path + /// "foo.bar" matches field "foo.bar" and also "foo.bar.baz", etc. When adding + /// a field path to the tree, redundant sub-paths will be removed. That is, + /// after adding "foo.bar" to the tree, "foo.bar.baz" will be removed if it + /// exists, which will turn the tree node for "foo.bar" to a leaf node. + /// Likewise, if the field path to add is a sub-path of an existing leaf node, + /// nothing will be changed in the tree. + /// + public FieldMaskTree AddFieldPath(string path) + { + var parts = path.Split(FIELD_PATH_SEPARATOR); + if (parts.Length == 0) + { + return this; + } + + var node = root; + var createNewBranch = false; + + // Find the matching node in the tree. + foreach (var part in parts) + { + // Check whether the path matches an existing leaf node. + if (!createNewBranch + && node != root + && node.Children.Count == 0) + { + // The path to add is a sub-path of an existing leaf node. + return this; + } + + Node childNode; + if (!node.Children.TryGetValue(part, out childNode)) + { + createNewBranch = true; + childNode = new Node(); + node.Children.Add(part, childNode); + } + node = childNode; + } + + // Turn the matching node into a leaf node (i.e., remove sub-paths). + node.Children.Clear(); + return this; + } + + /// + /// Merges all field paths in a FieldMask into this tree. + /// + public FieldMaskTree MergeFromFieldMask(FieldMask mask) + { + foreach (var path in mask.Paths) + { + AddFieldPath(path); + } + + return this; + } + + /// + /// Converts this tree to a FieldMask. + /// + public FieldMask ToFieldMask() + { + var mask = new FieldMask(); + if (root.Children.Count != 0) + { + var paths = new List(); + GetFieldPaths(root, "", paths); + mask.Paths.AddRange(paths); + } + + return mask; + } + + /// + /// Gathers all field paths in a sub-tree. + /// + private void GetFieldPaths(Node node, string path, List paths) + { + if (node.Children.Count == 0) + { + paths.Add(path); + return; + } + + foreach (var entry in node.Children) + { + var childPath = path.Length == 0 ? entry.Key : path + "." + entry.Key; + GetFieldPaths(entry.Value, childPath, paths); + } + } + + /// + /// Adds the intersection of this tree with the given to . + /// + public void IntersectFieldPath(string path, FieldMaskTree output) + { + if (root.Children.Count == 0) + { + return; + } + + var parts = path.Split(FIELD_PATH_SEPARATOR); + if (parts.Length == 0) + { + return; + } + + var node = root; + foreach (var part in parts) + { + if (node != root + && node.Children.Count == 0) + { + // The given path is a sub-path of an existing leaf node in the tree. + output.AddFieldPath(path); + return; + } + + if (!node.Children.TryGetValue(part, out node)) + { + return; + } + } + + // We found a matching node for the path. All leaf children of this matching + // node is in the intersection. + var paths = new List(); + GetFieldPaths(node, path, paths); + foreach (var value in paths) + { + output.AddFieldPath(value); + } + } + + /// + /// Merges all fields specified by this FieldMaskTree from to . + /// + public void Merge(IMessage source, IMessage destination, FieldMask.MergeOptions options) + { + if (source.Descriptor != destination.Descriptor) + { + throw new InvalidProtocolBufferException("Cannot merge messages of different types."); + } + + if (root.Children.Count == 0) + { + return; + } + + Merge(root, "", source, destination, options); + } + + /// + /// Merges all fields specified by a sub-tree from to . + /// + private void Merge( + Node node, + string path, + IMessage source, + IMessage destination, + FieldMask.MergeOptions options) + { + if (source.Descriptor != destination.Descriptor) + { + throw new InvalidProtocolBufferException($"source ({source.Descriptor}) and destination ({destination.Descriptor}) descriptor must be equal"); + } + + var descriptor = source.Descriptor; + foreach (var entry in node.Children) + { + var field = descriptor.FindFieldByName(entry.Key); + if (field == null) + { + Debug.WriteLine($"Cannot find field \"{entry.Key}\" in message type \"{descriptor.FullName}\""); + continue; + } + + if (entry.Value.Children.Count != 0) + { + if (field.IsRepeated + || field.FieldType != FieldType.Message) + { + Debug.WriteLine($"Field \"{field.FullName}\" is not a singular message field and cannot have sub-fields."); + continue; + } + + var sourceField = field.Accessor.GetValue(source); + var destinationField = field.Accessor.GetValue(destination); + if (sourceField == null + && destinationField == null) + { + // If the message field is not present in both source and destination, skip recursing + // so we don't create unnecessary empty messages. + continue; + } + + if (destinationField == null) + { + // If we have to merge but the destination does not contain the field, create it. + destinationField = field.MessageType.Parser.CreateTemplate(); + field.Accessor.SetValue(destination, destinationField); + } + + var childPath = path.Length == 0 ? entry.Key : path + "." + entry.Key; + Merge(entry.Value, childPath, (IMessage)sourceField, (IMessage)destinationField, options); + continue; + } + + if (field.IsRepeated) + { + if (options.ReplaceRepeatedFields) + { + field.Accessor.Clear(destination); + } + + var sourceField = (IList)field.Accessor.GetValue(source); + var destinationField = (IList)field.Accessor.GetValue(destination); + foreach (var element in sourceField) + { + destinationField.Add(element); + } + } + else + { + var sourceField = field.Accessor.GetValue(source); + if (field.FieldType == FieldType.Message) + { + if (options.ReplaceMessageFields) + { + if (sourceField == null) + { + field.Accessor.Clear(destination); + } + else + { + field.Accessor.SetValue(destination, sourceField); + } + } + else + { + if (sourceField != null) + { + var sourceByteString = ((IMessage)sourceField).ToByteString(); + var destinationValue = (IMessage)field.Accessor.GetValue(destination); + if (destinationValue != null) + { + destinationValue.MergeFrom(sourceByteString); + } + else + { + field.Accessor.SetValue(destination, field.MessageType.Parser.ParseFrom(sourceByteString)); + } + } + } + } + else + { + if (sourceField != null + || !options.ReplacePrimitiveFields) + { + field.Accessor.SetValue(destination, sourceField); + } + else + { + field.Accessor.Clear(destination); + } + } + } + } + } + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/FrameworkPortability.cs b/third_party/protobuf/csharp/src/Google.Protobuf/FrameworkPortability.cs index c8060f6ca8ee..9498dbe4ccc2 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/FrameworkPortability.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/FrameworkPortability.cs @@ -1,49 +1,49 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; -using System.Text.RegularExpressions; - -namespace Google.Protobuf -{ - /// - /// Class containing helpful workarounds for various platform compatibility - /// - internal static class FrameworkPortability - { - // The value of RegexOptions.Compiled is 8. We can test for the presence at - // execution time using Enum.IsDefined, so a single build will do the right thing - // on each platform. (RegexOptions.Compiled isn't supported by PCLs.) - internal static readonly RegexOptions CompiledRegexWhereAvailable = - Enum.IsDefined(typeof(RegexOptions), 8) ? (RegexOptions)8 : RegexOptions.None; - } +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Text.RegularExpressions; + +namespace Google.Protobuf +{ + /// + /// Class containing helpful workarounds for various platform compatibility + /// + internal static class FrameworkPortability + { + // The value of RegexOptions.Compiled is 8. We can test for the presence at + // execution time using Enum.IsDefined, so a single build will do the right thing + // on each platform. (RegexOptions.Compiled isn't supported by PCLs.) + internal static readonly RegexOptions CompiledRegexWhereAvailable = + Enum.IsDefined(typeof(RegexOptions), 8) ? (RegexOptions)8 : RegexOptions.None; + } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/third_party/protobuf/csharp/src/Google.Protobuf/Google.Protobuf.csproj index fdd97ddf741a..2802f226ebdb 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -1,168 +1,42 @@ - - + + - Debug - AnyCPU - 9.0.30729 - 2.0 - {6908BDCE-D925-43F3-94AC-A531E6DF2591} - Library - Properties - Google.Protobuf - Google.Protobuf - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Profile259 - v4.5 - 512 - 3.5 - 10.0 - - + C# runtime library for Protocol Buffers - Google's data interchange format. + Copyright 2015, Google Inc. + Google Protocol Buffers + 3.9.0 + 6 + Google Inc. + netstandard1.0;netstandard2.0;net45 + true + ../../keys/Google.Protobuf.snk + true + true + Protocol;Buffers;Binary;Serialization;Format;Google;proto;proto3 + C# proto3 support + https://github.com/protocolbuffers/protobuf + https://github.com/protocolbuffers/protobuf/blob/master/LICENSE + git + https://github.com/protocolbuffers/protobuf.git + + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - - true - full - false - bin\Debug - obj\Debug\ - bin\Debug\Google.Protobuf.xml - - - DEBUG;TRACE - prompt - 4 - true - Off - true + + + + netstandard1.0;netstandard2.0 - - pdbonly - true - bin\Release - obj\Release\ - $(OutputPath)\$(AssemblyName).xml - - - TRACE - prompt - 4 - true - Off - true - - - pdbonly - true - bin\ReleaseSigned - obj\ReleaseSigned\ - $(OutputPath)\$(AssemblyName).xml - - - TRACE;SIGNED - prompt - 4 - true - Off - True - ..\..\keys\Google.Protobuf.snk - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - + - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file + + diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Google.Protobuf.nuspec b/third_party/protobuf/csharp/src/Google.Protobuf/Google.Protobuf.nuspec deleted file mode 100644 index 90e3da3d0e5c..000000000000 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Google.Protobuf.nuspec +++ /dev/null @@ -1,54 +0,0 @@ - - - - Google.Protobuf - Google Protocol Buffers C# - C# runtime library for Protocol Buffers - Google's data interchange format. - See project site for more info. - 3.0.0-beta3 - Google Inc. - protobuf-packages - https://github.com/google/protobuf/blob/master/LICENSE - https://github.com/google/protobuf - false - C# proto3 support - Copyright 2015, Google Inc. - Protocol Buffers Binary Serialization Format Google proto proto3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/IExtendableMessage.cs b/third_party/protobuf/csharp/src/Google.Protobuf/IExtendableMessage.cs new file mode 100644 index 000000000000..5cc2ae31a6da --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf/IExtendableMessage.cs @@ -0,0 +1,78 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using Google.Protobuf.Collections; + +namespace Google.Protobuf +{ + /// + /// Generic interface for a Protocol Buffers message containing one or more extensions, where the type parameter is expected to be the same type as the implementation class + /// + public interface IExtendableMessage : IMessage where T : IExtendableMessage + { + /// + /// Gets the value of the specified extension + /// + TValue GetExtension(Extension extension); + + /// + /// Gets the value of the specified repeated extension or null if the extension isn't registered in this set. + /// For a version of this method that never returns null, use + /// + RepeatedField GetExtension(RepeatedExtension extension); + + /// + /// Gets the value of the specified repeated extension, registering it if it isn't + /// + RepeatedField GetOrRegisterExtension(RepeatedExtension extension); + + /// + /// Sets the value of the specified extension + /// + void SetExtension(Extension extension, TValue value); + + /// + /// Gets whether the value of the specified extension is set + /// + bool HasExtension(Extension extension); + + /// + /// Clears the value of the specified extension + /// + void ClearExtension(Extension extension); + + /// + /// Clears the value of the specified repeated extension + /// + void ClearExtension(RepeatedExtension extension); + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/IMessage.cs b/third_party/protobuf/csharp/src/Google.Protobuf/IMessage.cs index 3e644c177382..d089f9463985 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/IMessage.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/IMessage.cs @@ -1,87 +1,87 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; -using Google.Protobuf.Reflection; - -namespace Google.Protobuf -{ - /// - /// Interface for a Protocol Buffers message, supporting - /// basic operations required for serialization. - /// - public interface IMessage - { - /// - /// Merges the data from the specified coded input stream with the current message. - /// - /// See the user guide for precise merge semantics. - /// - void MergeFrom(CodedInputStream input); - - /// - /// Writes the data to the given coded output stream. - /// - /// Coded output stream to write the data to. Must not be null. - void WriteTo(CodedOutputStream output); - - /// - /// Calculates the size of this message in Protocol Buffer wire format, in bytes. - /// - /// The number of bytes required to write this message - /// to a coded output stream. - int CalculateSize(); - - /// - /// Descriptor for this message. All instances are expected to return the same descriptor, - /// and for generated types this will be an explicitly-implemented member, returning the - /// same value as the static property declared on the type. - /// - MessageDescriptor Descriptor { get; } - } - - /// - /// Generic interface for a Protocol Buffers message, - /// where the type parameter is expected to be the same type as - /// the implementation class. - /// - /// The message type. - public interface IMessage : IMessage, IEquatable, IDeepCloneable where T : IMessage - { - /// - /// Merges the given message into this one. - /// - /// See the user guide for precise merge semantics. - /// The message to merge with this one. Must not be null. - void MergeFrom(T message); - } -} +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using Google.Protobuf.Reflection; + +namespace Google.Protobuf +{ + /// + /// Interface for a Protocol Buffers message, supporting + /// basic operations required for serialization. + /// + public interface IMessage + { + /// + /// Merges the data from the specified coded input stream with the current message. + /// + /// See the user guide for precise merge semantics. + /// + void MergeFrom(CodedInputStream input); + + /// + /// Writes the data to the given coded output stream. + /// + /// Coded output stream to write the data to. Must not be null. + void WriteTo(CodedOutputStream output); + + /// + /// Calculates the size of this message in Protocol Buffer wire format, in bytes. + /// + /// The number of bytes required to write this message + /// to a coded output stream. + int CalculateSize(); + + /// + /// Descriptor for this message. All instances are expected to return the same descriptor, + /// and for generated types this will be an explicitly-implemented member, returning the + /// same value as the static property declared on the type. + /// + MessageDescriptor Descriptor { get; } + } + + /// + /// Generic interface for a Protocol Buffers message, + /// where the type parameter is expected to be the same type as + /// the implementation class. + /// + /// The message type. + public interface IMessage : IMessage, IEquatable, IDeepCloneable where T : IMessage + { + /// + /// Merges the given message into this one. + /// + /// See the user guide for precise merge semantics. + /// The message to merge with this one. Must not be null. + void MergeFrom(T message); + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs b/third_party/protobuf/csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs index a6aefb6fa4ed..c5ffe9bbf83d 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs @@ -1,129 +1,140 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; -using System.IO; - -namespace Google.Protobuf -{ - /// - /// Thrown when a protocol message being parsed is invalid in some way, - /// e.g. it contains a malformed varint or a negative byte length. - /// - public sealed class InvalidProtocolBufferException : IOException - { - internal InvalidProtocolBufferException(string message) - : base(message) - { - } - - internal InvalidProtocolBufferException(string message, Exception innerException) - : base(message, innerException) - { - } - - internal static InvalidProtocolBufferException MoreDataAvailable() - { - return new InvalidProtocolBufferException( - "Completed reading a message while more data was available in the stream."); - } - - internal static InvalidProtocolBufferException TruncatedMessage() - { - return new InvalidProtocolBufferException( - "While parsing a protocol message, the input ended unexpectedly " + - "in the middle of a field. This could mean either than the " + - "input has been truncated or that an embedded message " + - "misreported its own length."); - } - - internal static InvalidProtocolBufferException NegativeSize() - { - return new InvalidProtocolBufferException( - "CodedInputStream encountered an embedded string or message " + - "which claimed to have negative size."); - } - - internal static InvalidProtocolBufferException MalformedVarint() - { - return new InvalidProtocolBufferException( - "CodedInputStream encountered a malformed varint."); - } - - /// - /// Creates an exception for an error condition of an invalid tag being encountered. - /// - internal static InvalidProtocolBufferException InvalidTag() - { - return new InvalidProtocolBufferException( - "Protocol message contained an invalid tag (zero)."); - } - - internal static InvalidProtocolBufferException InvalidBase64(Exception innerException) - { - return new InvalidProtocolBufferException("Invalid base64 data", innerException); - } - - internal static InvalidProtocolBufferException InvalidEndTag() - { - return new InvalidProtocolBufferException( - "Protocol message end-group tag did not match expected tag."); - } - - internal static InvalidProtocolBufferException RecursionLimitExceeded() - { - return new InvalidProtocolBufferException( - "Protocol message had too many levels of nesting. May be malicious. " + - "Use CodedInputStream.SetRecursionLimit() to increase the depth limit."); - } - - internal static InvalidProtocolBufferException JsonRecursionLimitExceeded() - { - return new InvalidProtocolBufferException( - "Protocol message had too many levels of nesting. May be malicious. " + - "Use JsonParser.Settings to increase the depth limit."); - } - - internal static InvalidProtocolBufferException SizeLimitExceeded() - { - return new InvalidProtocolBufferException( - "Protocol message was too large. May be malicious. " + - "Use CodedInputStream.SetSizeLimit() to increase the size limit."); - } - - internal static InvalidProtocolBufferException InvalidMessageStreamTag() - { - return new InvalidProtocolBufferException( - "Stream of protocol messages had invalid tag. Expected tag is length-delimited field 1."); - } - } +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.IO; + +namespace Google.Protobuf +{ + /// + /// Thrown when a protocol message being parsed is invalid in some way, + /// e.g. it contains a malformed varint or a negative byte length. + /// + public sealed class InvalidProtocolBufferException : IOException + { + internal InvalidProtocolBufferException(string message) + : base(message) + { + } + + internal InvalidProtocolBufferException(string message, Exception innerException) + : base(message, innerException) + { + } + + internal static InvalidProtocolBufferException MoreDataAvailable() + { + return new InvalidProtocolBufferException( + "Completed reading a message while more data was available in the stream."); + } + + internal static InvalidProtocolBufferException TruncatedMessage() + { + return new InvalidProtocolBufferException( + "While parsing a protocol message, the input ended unexpectedly " + + "in the middle of a field. This could mean either that the " + + "input has been truncated or that an embedded message " + + "misreported its own length."); + } + + internal static InvalidProtocolBufferException NegativeSize() + { + return new InvalidProtocolBufferException( + "CodedInputStream encountered an embedded string or message " + + "which claimed to have negative size."); + } + + internal static InvalidProtocolBufferException MalformedVarint() + { + return new InvalidProtocolBufferException( + "CodedInputStream encountered a malformed varint."); + } + + /// + /// Creates an exception for an error condition of an invalid tag being encountered. + /// + internal static InvalidProtocolBufferException InvalidTag() + { + return new InvalidProtocolBufferException( + "Protocol message contained an invalid tag (zero)."); + } + + internal static InvalidProtocolBufferException InvalidWireType() + { + return new InvalidProtocolBufferException( + "Protocol message contained a tag with an invalid wire type."); + } + + internal static InvalidProtocolBufferException InvalidBase64(Exception innerException) + { + return new InvalidProtocolBufferException("Invalid base64 data", innerException); + } + + internal static InvalidProtocolBufferException InvalidEndTag() + { + return new InvalidProtocolBufferException( + "Protocol message end-group tag did not match expected tag."); + } + + internal static InvalidProtocolBufferException RecursionLimitExceeded() + { + return new InvalidProtocolBufferException( + "Protocol message had too many levels of nesting. May be malicious. " + + "Use CodedInputStream.SetRecursionLimit() to increase the depth limit."); + } + + internal static InvalidProtocolBufferException JsonRecursionLimitExceeded() + { + return new InvalidProtocolBufferException( + "Protocol message had too many levels of nesting. May be malicious. " + + "Use JsonParser.Settings to increase the depth limit."); + } + + internal static InvalidProtocolBufferException SizeLimitExceeded() + { + return new InvalidProtocolBufferException( + "Protocol message was too large. May be malicious. " + + "Use CodedInputStream.SetSizeLimit() to increase the size limit."); + } + + internal static InvalidProtocolBufferException InvalidMessageStreamTag() + { + return new InvalidProtocolBufferException( + "Stream of protocol messages had invalid tag. Expected tag is length-delimited field 1."); + } + + internal static InvalidProtocolBufferException MissingFields() + { + return new InvalidProtocolBufferException("Message was missing required fields"); + } +} } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/JsonFormatter.cs b/third_party/protobuf/csharp/src/Google.Protobuf/JsonFormatter.cs index 83772473260d..2b4c5f0a8038 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/JsonFormatter.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/JsonFormatter.cs @@ -70,7 +70,7 @@ public sealed class JsonFormatter /// public static JsonFormatter Default { get; } = new JsonFormatter(Settings.Default); - // A JSON formatter which *only* exists + // A JSON formatter which *only* exists private static readonly JsonFormatter diagnosticFormatter = new JsonFormatter(Settings.Default); /// @@ -248,84 +248,48 @@ private bool WriteMessageFields(TextWriter writer, IMessage message, bool assume return !first; } - /// - /// Camel-case converter with added strictness for field mask formatting. - /// - /// The field mask is invalid for JSON representation - private static string ToCamelCaseForFieldMask(string input) + // Converted from java/core/src/main/java/com/google/protobuf/Descriptors.java + internal static string ToJsonName(string name) { - for (int i = 0; i < input.Length; i++) + StringBuilder result = new StringBuilder(name.Length); + bool isNextUpperCase = false; + foreach (char ch in name) { - char c = input[i]; - if (c >= 'A' && c <= 'Z') + if (ch == '_') { - throw new InvalidOperationException($"Invalid field mask to be converted to JSON: {input}"); + isNextUpperCase = true; } - if (c == '_' && i < input.Length - 1) + else if (isNextUpperCase) { - char next = input[i + 1]; - if (next < 'a' || next > 'z') - { - throw new InvalidOperationException($"Invalid field mask to be converted to JSON: {input}"); - } + result.Append(char.ToUpperInvariant(ch)); + isNextUpperCase = false; + } + else + { + result.Append(ch); } } - return ToCamelCase(input); + return result.ToString(); } - // Converted from src/google/protobuf/util/internal/utility.cc ToCamelCase - // TODO: Use the new field in FieldDescriptor. - internal static string ToCamelCase(string input) + internal static string FromJsonName(string name) { - bool capitalizeNext = false; - bool wasCap = true; - bool isCap = false; - bool firstWord = true; - StringBuilder result = new StringBuilder(input.Length); - - for (int i = 0; i < input.Length; i++, wasCap = isCap) + StringBuilder result = new StringBuilder(name.Length); + foreach (char ch in name) { - isCap = char.IsUpper(input[i]); - if (input[i] == '_') + if (char.IsUpper(ch)) { - capitalizeNext = true; - if (result.Length != 0) - { - firstWord = false; - } - continue; - } - else if (firstWord) - { - // Consider when the current character B is capitalized, - // first word ends when: - // 1) following a lowercase: "...aB..." - // 2) followed by a lowercase: "...ABc..." - if (result.Length != 0 && isCap && - (!wasCap || (i + 1 < input.Length && char.IsLower(input[i + 1])))) - { - firstWord = false; - } - else - { - result.Append(char.ToLowerInvariant(input[i])); - continue; - } + result.Append('_'); + result.Append(char.ToLowerInvariant(ch)); } - else if (capitalizeNext) + else { - capitalizeNext = false; - if (char.IsLower(input[i])) - { - result.Append(char.ToUpperInvariant(input[i])); - continue; - } + result.Append(ch); } - result.Append(input[i]); } return result.ToString(); } - + private static void WriteNull(TextWriter writer) { writer.Write("null"); @@ -377,8 +341,16 @@ private static bool IsDefaultValue(IFieldAccessor accessor, object value) throw new ArgumentException("Invalid field type"); } } - - private void WriteValue(TextWriter writer, object value) + + /// + /// Writes a single value to the given writer as JSON. Only types understood by + /// Protocol Buffers can be written in this way. This method is only exposed for + /// advanced use cases; most users should be using + /// or . + /// + /// The writer to write the value to. Must not be null. + /// The value to write. May be null. + public void WriteValue(TextWriter writer, object value) { if (value == null) { @@ -421,14 +393,21 @@ private void WriteValue(TextWriter writer, object value) } else if (value is System.Enum) { - string name = OriginalEnumValueHelper.GetOriginalName(value); - if (name != null) + if (settings.FormatEnumsAsIntegers) { - WriteString(writer, name); + WriteValue(writer, (int)value); } else { - WriteValue(writer, (int)value); + string name = OriginalEnumValueHelper.GetOriginalName(value); + if (name != null) + { + WriteString(writer, name); + } + else + { + WriteValue(writer, (int)value); + } } } else if (value is float || value is double) @@ -447,15 +426,7 @@ private void WriteValue(TextWriter writer, object value) } else if (value is IMessage) { - IMessage message = (IMessage) value; - if (message.Descriptor.IsWellKnownType) - { - WriteWellKnownTypeValue(writer, message.Descriptor, value); - } - else - { - WriteMessage(writer, (IMessage)value); - } + Format((IMessage)value, writer); } else { @@ -608,7 +579,7 @@ private void WriteDiagnosticOnlyAny(TextWriter writer, IMessage value) writer.Write(data.ToBase64()); writer.Write('"'); writer.Write(" }"); - } + } private void WriteStruct(TextWriter writer, IMessage message) { @@ -645,7 +616,7 @@ private void WriteStructFieldValue(TextWriter writer, IMessage message) } object value = specifiedField.Accessor.GetValue(message); - + switch (specifiedField.FieldNumber) { case Value.BoolValueFieldNumber: @@ -723,20 +694,6 @@ internal void WriteDictionary(TextWriter writer, IDictionary dictionary) writer.Write(first ? "}" : " }"); } - /// - /// Returns whether or not a singular value can be represented in JSON. - /// Currently only relevant for enums, where unknown values can't be represented. - /// For repeated/map fields, this always returns true. - /// - private bool CanWriteSingleValue(object value) - { - if (value is System.Enum) - { - return System.Enum.IsDefined(value.GetType(), value); - } - return true; - } - /// /// Writes a string (including leading and trailing double quotes) to a builder, escaping as required. /// @@ -846,7 +803,11 @@ static Settings() /// public TypeRegistry TypeRegistry { get; } - // TODO: Work out how we're going to scale this to multiple settings. "WithXyz" methods? + /// + /// Whether to format enums as ints. Defaults to false. + /// + public bool FormatEnumsAsIntegers { get; } + /// /// Creates a new object with the specified formatting of default values @@ -863,11 +824,42 @@ public Settings(bool formatDefaultValues) : this(formatDefaultValues, TypeRegist /// /// true if default values (0, empty strings etc) should be formatted; false otherwise. /// The to use when formatting messages. - public Settings(bool formatDefaultValues, TypeRegistry typeRegistry) + public Settings(bool formatDefaultValues, TypeRegistry typeRegistry) : this(formatDefaultValues, typeRegistry, false) + { + } + + /// + /// Creates a new object with the specified parameters. + /// + /// true if default values (0, empty strings etc) should be formatted; false otherwise. + /// The to use when formatting messages. TypeRegistry.Empty will be used if it is null. + /// true to format the enums as integers; false to format enums as enum names. + private Settings(bool formatDefaultValues, + TypeRegistry typeRegistry, + bool formatEnumsAsIntegers) { FormatDefaultValues = formatDefaultValues; - TypeRegistry = ProtoPreconditions.CheckNotNull(typeRegistry, nameof(typeRegistry)); + TypeRegistry = typeRegistry ?? TypeRegistry.Empty; + FormatEnumsAsIntegers = formatEnumsAsIntegers; } + + /// + /// Creates a new object with the specified formatting of default values and the current settings. + /// + /// true if default values (0, empty strings etc) should be formatted; false otherwise. + public Settings WithFormatDefaultValues(bool formatDefaultValues) => new Settings(formatDefaultValues, TypeRegistry, FormatEnumsAsIntegers); + + /// + /// Creates a new object with the specified type registry and the current settings. + /// + /// The to use when formatting messages. + public Settings WithTypeRegistry(TypeRegistry typeRegistry) => new Settings(FormatDefaultValues, typeRegistry, FormatEnumsAsIntegers); + + /// + /// Creates a new object with the specified enums formatting option and the current settings. + /// + /// true to format the enums as integers; false to format enums as enum names. + public Settings WithFormatEnumsAsIntegers(bool formatEnumsAsIntegers) => new Settings(FormatDefaultValues, TypeRegistry, formatEnumsAsIntegers); } // Effectively a cache of mapping from enum values to the original name as specified in the proto file, @@ -879,7 +871,7 @@ private static class OriginalEnumValueHelper // the platforms we target have it. private static readonly Dictionary> dictionaries = new Dictionary>(); - + internal static string GetOriginalName(object value) { var enumType = value.GetType(); @@ -899,14 +891,30 @@ internal static string GetOriginalName(object value) return originalName; } +#if NET35 + // TODO: Consider adding functionality to TypeExtensions to avoid this difference. + private static Dictionary GetNameMapping(System.Type enumType) => + enumType.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static) + .Where(f => (f.GetCustomAttributes(typeof(OriginalNameAttribute), false) + .FirstOrDefault() as OriginalNameAttribute) + ?.PreferredAlias ?? true) + .ToDictionary(f => f.GetValue(null), + f => (f.GetCustomAttributes(typeof(OriginalNameAttribute), false) + .FirstOrDefault() as OriginalNameAttribute) + // If the attribute hasn't been applied, fall back to the name of the field. + ?.Name ?? f.Name); +#else private static Dictionary GetNameMapping(System.Type enumType) => enumType.GetTypeInfo().DeclaredFields .Where(f => f.IsStatic) + .Where(f => f.GetCustomAttributes() + .FirstOrDefault()?.PreferredAlias ?? true) .ToDictionary(f => f.GetValue(null), f => f.GetCustomAttributes() .FirstOrDefault() // If the attribute hasn't been applied, fall back to the name of the field. ?.Name ?? f.Name); +#endif } } } diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/JsonParser.cs b/third_party/protobuf/csharp/src/Google.Protobuf/JsonParser.cs index d738ebb04b17..fb594f2a4343 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/JsonParser.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/JsonParser.cs @@ -86,7 +86,8 @@ private static readonly Dictionary public TypeRegistry TypeRegistry { get; } + /// + /// Whether the parser should ignore unknown fields (true) or throw an exception when + /// they are encountered (false). + /// + public bool IgnoreUnknownFields { get; } + + private Settings(int recursionLimit, TypeRegistry typeRegistry, bool ignoreUnknownFields) + { + RecursionLimit = recursionLimit; + TypeRegistry = ProtoPreconditions.CheckNotNull(typeRegistry, nameof(typeRegistry)); + IgnoreUnknownFields = ignoreUnknownFields; + } + /// /// Creates a new object with the specified recursion limit. /// @@ -1008,11 +1027,34 @@ public Settings(int recursionLimit) : this(recursionLimit, TypeRegistry.Empty) /// /// The maximum depth of messages to parse /// The type registry used to parse messages - public Settings(int recursionLimit, TypeRegistry typeRegistry) + public Settings(int recursionLimit, TypeRegistry typeRegistry) : this(recursionLimit, typeRegistry, false) { - RecursionLimit = recursionLimit; - TypeRegistry = ProtoPreconditions.CheckNotNull(typeRegistry, nameof(typeRegistry)); } + + /// + /// Creates a new object set to either ignore unknown fields, or throw an exception + /// when unknown fields are encountered. + /// + /// true if unknown fields should be ignored when parsing; false to throw an exception. + public Settings WithIgnoreUnknownFields(bool ignoreUnknownFields) => + new Settings(RecursionLimit, TypeRegistry, ignoreUnknownFields); + + /// + /// Creates a new object based on this one, but with the specified recursion limit. + /// + /// The new recursion limit. + public Settings WithRecursionLimit(int recursionLimit) => + new Settings(recursionLimit, TypeRegistry, IgnoreUnknownFields); + + /// + /// Creates a new object based on this one, but with the specified type registry. + /// + /// The new type registry. Must not be null. + public Settings WithTypeRegistry(TypeRegistry typeRegistry) => + new Settings( + RecursionLimit, + ProtoPreconditions.CheckNotNull(typeRegistry, nameof(typeRegistry)), + IgnoreUnknownFields); } } } diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/JsonTokenizer.cs b/third_party/protobuf/csharp/src/Google.Protobuf/JsonTokenizer.cs index 09a6d43b7bed..4725e7cc5119 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/JsonTokenizer.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/JsonTokenizer.cs @@ -137,6 +137,34 @@ internal JsonToken Next() /// The input text does not comply with RFC 7159 protected abstract JsonToken NextImpl(); + /// + /// Skips the value we're about to read. This must only be called immediately after reading a property name. + /// If the value is an object or an array, the complete object/array is skipped. + /// + internal void SkipValue() + { + // We'll assume that Next() makes sure that the end objects and end arrays are all valid. + // All we care about is the total nesting depth we need to close. + int depth = 0; + + // do/while rather than while loop so that we read at least one token. + do + { + var token = Next(); + switch (token.Type) + { + case JsonToken.TokenType.EndArray: + case JsonToken.TokenType.EndObject: + depth--; + break; + case JsonToken.TokenType.StartArray: + case JsonToken.TokenType.StartObject: + depth++; + break; + } + } while (depth != 0); + } + /// /// Tokenizer which first exhausts a list of tokens, then consults another tokenizer. /// @@ -217,7 +245,7 @@ protected override JsonToken NextImpl() state = State.ObjectAfterColon; break; case ',': - ValidateState(State.ObjectAfterProperty | State.ArrayAfterValue, "Invalid state to read a colon: "); + ValidateState(State.ObjectAfterProperty | State.ArrayAfterValue, "Invalid state to read a comma: "); state = state == State.ObjectAfterProperty ? State.ObjectAfterComma : State.ArrayAfterComma; break; case '"': @@ -586,7 +614,7 @@ private enum ContainerType /// where ^ represents the current position within the text stream. The examples all use string values, /// but could be any value, including nested objects/arrays. /// The complete state of the tokenizer also includes a stack to indicate the contexts (arrays/objects). - /// Any additional notional state of "AfterValue" indicates that a value has been completed, at which + /// Any additional notional state of "AfterValue" indicates that a value has been completed, at which /// point there's an immediate transition to ExpectedEndOfDocument, ObjectAfterProperty or ArrayAfterValue. /// /// @@ -627,7 +655,7 @@ private enum State /// /// { "foo" : ^ "bar", "x": "y" } /// Before any property other than the first in an object. - /// (Equivalently: after any property in an object) + /// (Equivalently: after any property in an object) /// Next states: /// "AfterValue" (value is simple) /// ObjectStart (value is object) diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/LimitedInputStream.cs b/third_party/protobuf/csharp/src/Google.Protobuf/LimitedInputStream.cs index f11d19d94406..50ead9c9929e 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/LimitedInputStream.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/LimitedInputStream.cs @@ -29,7 +29,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion - + using System; using System.IO; diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/MessageExtensions.cs b/third_party/protobuf/csharp/src/Google.Protobuf/MessageExtensions.cs index 047156c3ee71..5ca772f58e8d 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/MessageExtensions.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/MessageExtensions.cs @@ -30,7 +30,10 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion +using Google.Protobuf.Reflection; +using System.Collections; using System.IO; +using System.Linq; namespace Google.Protobuf { @@ -44,42 +47,34 @@ public static class MessageExtensions /// /// The message to merge the data into. /// The data to merge, which must be protobuf-encoded binary data. - public static void MergeFrom(this IMessage message, byte[] data) - { - ProtoPreconditions.CheckNotNull(message, "message"); - ProtoPreconditions.CheckNotNull(data, "data"); - CodedInputStream input = new CodedInputStream(data); - message.MergeFrom(input); - input.CheckReadEndOfStreamTag(); - } + public static void MergeFrom(this IMessage message, byte[] data) => + MergeFrom(message, data, false, null); + + /// + /// Merges data from the given byte array slice into an existing message. + /// + /// The message to merge the data into. + /// The data containing the slice to merge, which must be protobuf-encoded binary data. + /// The offset of the slice to merge. + /// The length of the slice to merge. + public static void MergeFrom(this IMessage message, byte[] data, int offset, int length) => + MergeFrom(message, data, offset, length, false, null); /// /// Merges data from the given byte string into an existing message. /// /// The message to merge the data into. /// The data to merge, which must be protobuf-encoded binary data. - public static void MergeFrom(this IMessage message, ByteString data) - { - ProtoPreconditions.CheckNotNull(message, "message"); - ProtoPreconditions.CheckNotNull(data, "data"); - CodedInputStream input = data.CreateCodedInput(); - message.MergeFrom(input); - input.CheckReadEndOfStreamTag(); - } + public static void MergeFrom(this IMessage message, ByteString data) => + MergeFrom(message, data, false, null); /// /// Merges data from the given stream into an existing message. /// /// The message to merge the data into. /// Stream containing the data to merge, which must be protobuf-encoded binary data. - public static void MergeFrom(this IMessage message, Stream input) - { - ProtoPreconditions.CheckNotNull(message, "message"); - ProtoPreconditions.CheckNotNull(input, "input"); - CodedInputStream codedInput = new CodedInputStream(input); - message.MergeFrom(codedInput); - codedInput.CheckReadEndOfStreamTag(); - } + public static void MergeFrom(this IMessage message, Stream input) => + MergeFrom(message, input, false, null); /// /// Merges length-delimited data from the given stream into an existing message. @@ -90,14 +85,8 @@ public static void MergeFrom(this IMessage message, Stream input) /// /// The message to merge the data into. /// Stream containing the data to merge, which must be protobuf-encoded binary data. - public static void MergeDelimitedFrom(this IMessage message, Stream input) - { - ProtoPreconditions.CheckNotNull(message, "message"); - ProtoPreconditions.CheckNotNull(input, "input"); - int size = (int) CodedInputStream.ReadRawVarint32(input); - Stream limitedStream = new LimitedInputStream(input, size); - message.MergeFrom(limitedStream); - } + public static void MergeDelimitedFrom(this IMessage message, Stream input) => + MergeDelimitedFrom(message, input, false, null); /// /// Converts the given message into a byte array in protobuf encoding. @@ -152,6 +141,107 @@ public static ByteString ToByteString(this IMessage message) { ProtoPreconditions.CheckNotNull(message, "message"); return ByteString.AttachBytes(message.ToByteArray()); - } + } + + /// + /// Checks if all required fields in a message have values set. For proto3 messages, this returns true + /// + public static bool IsInitialized(this IMessage message) + { + if (message.Descriptor.File.Proto.Syntax != "proto2") + { + return true; + } + + return message.Descriptor + .Fields + .InDeclarationOrder() + .All(f => + { + if (f.IsMap) + { + var map = (IDictionary)f.Accessor.GetValue(message); + return map.Values.OfType().All(IsInitialized); + } + else if (f.IsRepeated && f.FieldType == FieldType.Message || f.FieldType == FieldType.Group) + { + var enumerable = (IEnumerable)f.Accessor.GetValue(message); + return enumerable.Cast().All(IsInitialized); + } + else if (f.FieldType == FieldType.Message || f.FieldType == FieldType.Group) + { + if (f.Accessor.HasValue(message)) + { + return ((IMessage)f.Accessor.GetValue(message)).IsInitialized(); + } + else + { + return !f.IsRequired; + } + } + else if (f.IsRequired) + { + return f.Accessor.HasValue(message); + } + else + { + return true; + } + }); + } + + // Implementations allowing unknown fields to be discarded. + internal static void MergeFrom(this IMessage message, byte[] data, bool discardUnknownFields, ExtensionRegistry registry) + { + ProtoPreconditions.CheckNotNull(message, "message"); + ProtoPreconditions.CheckNotNull(data, "data"); + CodedInputStream input = new CodedInputStream(data); + input.DiscardUnknownFields = discardUnknownFields; + input.ExtensionRegistry = registry; + message.MergeFrom(input); + input.CheckReadEndOfStreamTag(); + } + + internal static void MergeFrom(this IMessage message, byte[] data, int offset, int length, bool discardUnknownFields, ExtensionRegistry registry) + { + ProtoPreconditions.CheckNotNull(message, "message"); + ProtoPreconditions.CheckNotNull(data, "data"); + CodedInputStream input = new CodedInputStream(data, offset, length); + input.DiscardUnknownFields = discardUnknownFields; + input.ExtensionRegistry = registry; + message.MergeFrom(input); + input.CheckReadEndOfStreamTag(); + } + + internal static void MergeFrom(this IMessage message, ByteString data, bool discardUnknownFields, ExtensionRegistry registry) + { + ProtoPreconditions.CheckNotNull(message, "message"); + ProtoPreconditions.CheckNotNull(data, "data"); + CodedInputStream input = data.CreateCodedInput(); + input.DiscardUnknownFields = discardUnknownFields; + input.ExtensionRegistry = registry; + message.MergeFrom(input); + input.CheckReadEndOfStreamTag(); + } + + internal static void MergeFrom(this IMessage message, Stream input, bool discardUnknownFields, ExtensionRegistry registry) + { + ProtoPreconditions.CheckNotNull(message, "message"); + ProtoPreconditions.CheckNotNull(input, "input"); + CodedInputStream codedInput = new CodedInputStream(input); + codedInput.DiscardUnknownFields = discardUnknownFields; + codedInput.ExtensionRegistry = registry; + message.MergeFrom(codedInput); + codedInput.CheckReadEndOfStreamTag(); + } + + internal static void MergeDelimitedFrom(this IMessage message, Stream input, bool discardUnknownFields, ExtensionRegistry registry) + { + ProtoPreconditions.CheckNotNull(message, "message"); + ProtoPreconditions.CheckNotNull(input, "input"); + int size = (int) CodedInputStream.ReadRawVarint32(input); + Stream limitedStream = new LimitedInputStream(input, size); + MergeFrom(message, limitedStream, discardUnknownFields, registry); + } } } diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/MessageParser.cs b/third_party/protobuf/csharp/src/Google.Protobuf/MessageParser.cs index 8889638b20a2..76a350ce4c61 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/MessageParser.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/MessageParser.cs @@ -29,7 +29,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion - + using System; using System.IO; @@ -42,10 +42,16 @@ namespace Google.Protobuf public class MessageParser { private Func factory; + // TODO: When we use a C# 7.1 compiler, make this private protected. + internal bool DiscardUnknownFields { get; } + + internal ExtensionRegistry Extensions { get; } - internal MessageParser(Func factory) + internal MessageParser(Func factory, bool discardUnknownFields, ExtensionRegistry extensions) { this.factory = factory; + DiscardUnknownFields = discardUnknownFields; + Extensions = extensions; } /// @@ -64,9 +70,24 @@ internal IMessage CreateTemplate() /// The newly parsed message. public IMessage ParseFrom(byte[] data) { - ProtoPreconditions.CheckNotNull(data, "data"); IMessage message = factory(); - message.MergeFrom(data); + message.MergeFrom(data, DiscardUnknownFields, Extensions); + CheckMergedRequiredFields(message); + return message; + } + + /// + /// Parses a message from a byte array slice. + /// + /// The byte array containing the message. Must not be null. + /// The offset of the slice to parse. + /// The length of the slice to parse. + /// The newly parsed message. + public IMessage ParseFrom(byte[] data, int offset, int length) + { + IMessage message = factory(); + message.MergeFrom(data, offset, length, DiscardUnknownFields, Extensions); + CheckMergedRequiredFields(message); return message; } @@ -77,9 +98,9 @@ public IMessage ParseFrom(byte[] data) /// The parsed message. public IMessage ParseFrom(ByteString data) { - ProtoPreconditions.CheckNotNull(data, "data"); IMessage message = factory(); - message.MergeFrom(data); + message.MergeFrom(data, DiscardUnknownFields, Extensions); + CheckMergedRequiredFields(message); return message; } @@ -91,7 +112,8 @@ public IMessage ParseFrom(ByteString data) public IMessage ParseFrom(Stream input) { IMessage message = factory(); - message.MergeFrom(input); + message.MergeFrom(input, DiscardUnknownFields, Extensions); + CheckMergedRequiredFields(message); return message; } @@ -107,7 +129,8 @@ public IMessage ParseFrom(Stream input) public IMessage ParseDelimitedFrom(Stream input) { IMessage message = factory(); - message.MergeDelimitedFrom(input); + message.MergeDelimitedFrom(input, DiscardUnknownFields, Extensions); + CheckMergedRequiredFields(message); return message; } @@ -119,7 +142,8 @@ public IMessage ParseDelimitedFrom(Stream input) public IMessage ParseFrom(CodedInputStream input) { IMessage message = factory(); - message.MergeFrom(input); + MergeFrom(message, input); + CheckMergedRequiredFields(message); return message; } @@ -136,6 +160,43 @@ public IMessage ParseJson(string json) JsonParser.Default.Merge(message, json); return message; } + + // TODO: When we're using a C# 7.1 compiler, make this private protected. + internal void MergeFrom(IMessage message, CodedInputStream codedInput) + { + bool originalDiscard = codedInput.DiscardUnknownFields; + try + { + codedInput.DiscardUnknownFields = DiscardUnknownFields; + message.MergeFrom(codedInput); + } + finally + { + codedInput.DiscardUnknownFields = originalDiscard; + } + } + + internal static void CheckMergedRequiredFields(IMessage message) + { + if (!message.IsInitialized()) + throw new InvalidOperationException("Parsed message does not contain all required fields"); + } + + /// + /// Creates a new message parser which optionally discards unknown fields when parsing. + /// + /// Whether or not to discard unknown fields when parsing. + /// A newly configured message parser. + public MessageParser WithDiscardUnknownFields(bool discardUnknownFields) => + new MessageParser(factory, discardUnknownFields, Extensions); + + /// + /// Creates a new message parser which registers extensions from the specified registry upon creating the message instance + /// + /// The extensions to register + /// A newly configured message parser. + public MessageParser WithExtensionRegistry(ExtensionRegistry registry) => + new MessageParser(factory, DiscardUnknownFields, registry); } /// @@ -160,7 +221,7 @@ public sealed class MessageParser : MessageParser where T : IMessage // The current implementation avoids a virtual method call and a cast, which *may* be significant in some cases. // Benchmarking work is required to measure the significance - but it's only a few lines of code in any case. // The API wouldn't change anyway - just the implementation - so this work can be deferred. - private readonly Func factory; + private readonly Func factory; /// /// Creates a new parser. @@ -170,7 +231,11 @@ public sealed class MessageParser : MessageParser where T : IMessage /// to require a parameterless constructor: delegates are significantly faster to execute. /// /// Function to invoke when a new, empty message is required. - public MessageParser(Func factory) : base(() => factory()) + public MessageParser(Func factory) : this(factory, false, null) + { + } + + internal MessageParser(Func factory, bool discardUnknownFields, ExtensionRegistry extensions) : base(() => factory(), discardUnknownFields, extensions) { this.factory = factory; } @@ -191,9 +256,22 @@ public MessageParser(Func factory) : base(() => factory()) /// The newly parsed message. public new T ParseFrom(byte[] data) { - ProtoPreconditions.CheckNotNull(data, "data"); T message = factory(); - message.MergeFrom(data); + message.MergeFrom(data, DiscardUnknownFields, Extensions); + return message; + } + + /// + /// Parses a message from a byte array slice. + /// + /// The byte array containing the message. Must not be null. + /// The offset of the slice to parse. + /// The length of the slice to parse. + /// The newly parsed message. + public new T ParseFrom(byte[] data, int offset, int length) + { + T message = factory(); + message.MergeFrom(data, offset, length, DiscardUnknownFields, Extensions); return message; } @@ -204,9 +282,8 @@ public MessageParser(Func factory) : base(() => factory()) /// The parsed message. public new T ParseFrom(ByteString data) { - ProtoPreconditions.CheckNotNull(data, "data"); T message = factory(); - message.MergeFrom(data); + message.MergeFrom(data, DiscardUnknownFields, Extensions); return message; } @@ -218,7 +295,7 @@ public MessageParser(Func factory) : base(() => factory()) public new T ParseFrom(Stream input) { T message = factory(); - message.MergeFrom(input); + message.MergeFrom(input, DiscardUnknownFields, Extensions); return message; } @@ -234,7 +311,7 @@ public MessageParser(Func factory) : base(() => factory()) public new T ParseDelimitedFrom(Stream input) { T message = factory(); - message.MergeDelimitedFrom(input); + message.MergeDelimitedFrom(input, DiscardUnknownFields, Extensions); return message; } @@ -246,7 +323,7 @@ public MessageParser(Func factory) : base(() => factory()) public new T ParseFrom(CodedInputStream input) { T message = factory(); - message.MergeFrom(input); + MergeFrom(message, input); return message; } @@ -263,5 +340,21 @@ public MessageParser(Func factory) : base(() => factory()) JsonParser.Default.Merge(message, json); return message; } + + /// + /// Creates a new message parser which optionally discards unknown fields when parsing. + /// + /// Whether or not to discard unknown fields when parsing. + /// A newly configured message parser. + public new MessageParser WithDiscardUnknownFields(bool discardUnknownFields) => + new MessageParser(factory, discardUnknownFields, Extensions); + + /// + /// Creates a new message parser which registers extensions from the specified registry upon creating the message instance + /// + /// The extensions to register + /// A newly configured message parser. + public new MessageParser WithExtensionRegistry(ExtensionRegistry registry) => + new MessageParser(factory, DiscardUnknownFields, registry); } } diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/ObjectIntPair.cs b/third_party/protobuf/csharp/src/Google.Protobuf/ObjectIntPair.cs new file mode 100644 index 000000000000..b98d93a517c4 --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf/ObjectIntPair.cs @@ -0,0 +1,40 @@ +using System; + +namespace Google.Protobuf +{ + /// + /// Struct used to hold the keys for the fieldByNumber table in DescriptorPool and the keys for the + /// extensionByNumber table in ExtensionRegistry. + /// + internal struct ObjectIntPair : IEquatable> where T : class + { + private readonly int number; + private readonly T obj; + + internal ObjectIntPair(T obj, int number) + { + this.number = number; + this.obj = obj; + } + + public bool Equals(ObjectIntPair other) + { + return obj == other.obj + && number == other.number; + } + + public override bool Equals(object obj) + { + if (obj is ObjectIntPair) + { + return Equals((ObjectIntPair)obj); + } + return false; + } + + public override int GetHashCode() + { + return obj.GetHashCode() * ((1 << 16) - 1) + number; + } + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs index ad852eba5d67..9b179bd7cd60 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs @@ -1,67 +1,49 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("Google.Protobuf")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Google.Protobuf")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -#if !NCRUNCH -[assembly: AllowPartiallyTrustedCallers] -#endif - -#if SIGNED -[assembly: InternalsVisibleTo("Google.Protobuf.Test, PublicKey=" + - "002400000480000094000000060200000024000052534131000400000100010025800fbcfc63a1" + - "7c66b303aae80b03a6beaa176bb6bef883be436f2a1579edd80ce23edf151a1f4ced97af83abcd" + - "981207041fd5b2da3b498346fcfcd94910d52f25537c4a43ce3fbe17dc7d43e6cbdb4d8f1242dc" + - "b6bd9b5906be74da8daa7d7280f97130f318a16c07baf118839b156299a48522f9fae2371c9665" + - "c5ae9cb6")] -#else -[assembly: InternalsVisibleTo("Google.Protobuf.Test")] -#endif - -[assembly: AssemblyVersion("3.0.0.0")] -[assembly: AssemblyFileVersion("3.0.0.0")] -[assembly: AssemblyInformationalVersion("3.0.0-beta3")] +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System.Runtime.CompilerServices; +using System.Security; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +#if !NCRUNCH +[assembly: AllowPartiallyTrustedCallers] +#endif + +[assembly: InternalsVisibleTo("Google.Protobuf.Test, PublicKey=" + + "002400000480000094000000060200000024000052534131000400000100010025800fbcfc63a1" + + "7c66b303aae80b03a6beaa176bb6bef883be436f2a1579edd80ce23edf151a1f4ced97af83abcd" + + "981207041fd5b2da3b498346fcfcd94910d52f25537c4a43ce3fbe17dc7d43e6cbdb4d8f1242dc" + + "b6bd9b5906be74da8daa7d7280f97130f318a16c07baf118839b156299a48522f9fae2371c9665" + + "c5ae9cb6")] diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/ProtoPreconditions.cs b/third_party/protobuf/csharp/src/Google.Protobuf/ProtoPreconditions.cs index abaeb9b481d4..590a3bb20fc9 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/ProtoPreconditions.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/ProtoPreconditions.cs @@ -1,79 +1,79 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#endregion - -using System; - -namespace Google.Protobuf -{ - /// - /// Helper methods for throwing exceptions when preconditions are not met. - /// - /// - /// This class is used internally and by generated code; it is not particularly - /// expected to be used from application code, although nothing prevents it - /// from being used that way. - /// - public static class ProtoPreconditions - { - /// - /// Throws an ArgumentNullException if the given value is null, otherwise - /// return the value to the caller. - /// - public static T CheckNotNull(T value, string name) where T : class - { - if (value == null) - { - throw new ArgumentNullException(name); - } - return value; - } - - /// - /// Throws an ArgumentNullException if the given value is null, otherwise - /// return the value to the caller. - /// - /// - /// This is equivalent to but without the type parameter - /// constraint. In most cases, the constraint is useful to prevent you from calling CheckNotNull - /// with a value type - but it gets in the way if either you want to use it with a nullable - /// value type, or you want to use it with an unconstrained type parameter. - /// - internal static T CheckNotNullUnconstrained(T value, string name) - { - if (value == null) - { - throw new ArgumentNullException(name); - } - return value; - } - } +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; + +namespace Google.Protobuf +{ + /// + /// Helper methods for throwing exceptions when preconditions are not met. + /// + /// + /// This class is used internally and by generated code; it is not particularly + /// expected to be used from application code, although nothing prevents it + /// from being used that way. + /// + public static class ProtoPreconditions + { + /// + /// Throws an ArgumentNullException if the given value is null, otherwise + /// return the value to the caller. + /// + public static T CheckNotNull(T value, string name) where T : class + { + if (value == null) + { + throw new ArgumentNullException(name); + } + return value; + } + + /// + /// Throws an ArgumentNullException if the given value is null, otherwise + /// return the value to the caller. + /// + /// + /// This is equivalent to but without the type parameter + /// constraint. In most cases, the constraint is useful to prevent you from calling CheckNotNull + /// with a value type - but it gets in the way if either you want to use it with a nullable + /// value type, or you want to use it with an unconstrained type parameter. + /// + internal static T CheckNotNullUnconstrained(T value, string name) + { + if (value == null) + { + throw new ArgumentNullException(name); + } + return value; + } + } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/CustomOptions.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/CustomOptions.cs new file mode 100644 index 000000000000..57df2ed4a8ab --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/CustomOptions.cs @@ -0,0 +1,310 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2017 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using Google.Protobuf.Collections; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace Google.Protobuf.Reflection +{ + /// + /// Container for a set of custom options specified within a message, field etc. + /// + /// + /// + /// This type is publicly immutable, but internally mutable. It is only populated + /// by the descriptor parsing code - by the time any user code is able to see an instance, + /// it will be fully initialized. + /// + /// + /// If an option is requested using the incorrect method, an answer may still be returned: all + /// of the numeric types are represented internally using 64-bit integers, for example. It is up to + /// the caller to ensure that they make the appropriate method call for the option they're interested in. + /// Note that enum options are simply stored as integers, so the value should be fetched using + /// and then cast appropriately. + /// + /// + /// Repeated options are currently not supported. Asking for a single value of an option + /// which was actually repeated will return the last value, except for message types where + /// all the set values are merged together. + /// + /// + public sealed class CustomOptions + { + private static readonly object[] EmptyParameters = new object[0]; + private readonly IDictionary values; + + internal CustomOptions(IDictionary values) + { + this.values = values; + } + + /// + /// Retrieves a Boolean value for the specified option field. + /// + /// The field to fetch the value for. + /// The output variable to populate. + /// true if a suitable value for the field was found; false otherwise. + public bool TryGetBool(int field, out bool value) => TryGetPrimitiveValue(field, out value); + + /// + /// Retrieves a signed 32-bit integer value for the specified option field. + /// + /// The field to fetch the value for. + /// The output variable to populate. + /// true if a suitable value for the field was found; false otherwise. + public bool TryGetInt32(int field, out int value) => TryGetPrimitiveValue(field, out value); + + /// + /// Retrieves a signed 64-bit integer value for the specified option field. + /// + /// The field to fetch the value for. + /// The output variable to populate. + /// true if a suitable value for the field was found; false otherwise. + public bool TryGetInt64(int field, out long value) => TryGetPrimitiveValue(field, out value); + + /// + /// Retrieves an unsigned 32-bit integer value for the specified option field, + /// assuming a fixed-length representation. + /// + /// The field to fetch the value for. + /// The output variable to populate. + /// true if a suitable value for the field was found; false otherwise. + public bool TryGetFixed32(int field, out uint value) => TryGetUInt32(field, out value); + + /// + /// Retrieves an unsigned 64-bit integer value for the specified option field, + /// assuming a fixed-length representation. + /// + /// The field to fetch the value for. + /// The output variable to populate. + /// true if a suitable value for the field was found; false otherwise. + public bool TryGetFixed64(int field, out ulong value) => TryGetUInt64(field, out value); + + /// + /// Retrieves a signed 32-bit integer value for the specified option field, + /// assuming a fixed-length representation. + /// + /// The field to fetch the value for. + /// The output variable to populate. + /// true if a suitable value for the field was found; false otherwise. + public bool TryGetSFixed32(int field, out int value) => TryGetInt32(field, out value); + + /// + /// Retrieves a signed 64-bit integer value for the specified option field, + /// assuming a fixed-length representation. + /// + /// The field to fetch the value for. + /// The output variable to populate. + /// true if a suitable value for the field was found; false otherwise. + public bool TryGetSFixed64(int field, out long value) => TryGetInt64(field, out value); + + /// + /// Retrieves a signed 32-bit integer value for the specified option field, + /// assuming a zigzag encoding. + /// + /// The field to fetch the value for. + /// The output variable to populate. + /// true if a suitable value for the field was found; false otherwise. + public bool TryGetSInt32(int field, out int value) => TryGetPrimitiveValue(field, out value); + + /// + /// Retrieves a signed 64-bit integer value for the specified option field, + /// assuming a zigzag encoding. + /// + /// The field to fetch the value for. + /// The output variable to populate. + /// true if a suitable value for the field was found; false otherwise. + public bool TryGetSInt64(int field, out long value) => TryGetPrimitiveValue(field, out value); + + /// + /// Retrieves an unsigned 32-bit integer value for the specified option field. + /// + /// The field to fetch the value for. + /// The output variable to populate. + /// true if a suitable value for the field was found; false otherwise. + public bool TryGetUInt32(int field, out uint value) => TryGetPrimitiveValue(field, out value); + + /// + /// Retrieves an unsigned 64-bit integer value for the specified option field. + /// + /// The field to fetch the value for. + /// The output variable to populate. + /// true if a suitable value for the field was found; false otherwise. + public bool TryGetUInt64(int field, out ulong value) => TryGetPrimitiveValue(field, out value); + + /// + /// Retrieves a 32-bit floating point value for the specified option field. + /// + /// The field to fetch the value for. + /// The output variable to populate. + /// true if a suitable value for the field was found; false otherwise. + public bool TryGetFloat(int field, out float value) => TryGetPrimitiveValue(field, out value); + + /// + /// Retrieves a 64-bit floating point value for the specified option field. + /// + /// The field to fetch the value for. + /// The output variable to populate. + /// true if a suitable value for the field was found; false otherwise. + public bool TryGetDouble(int field, out double value) => TryGetPrimitiveValue(field, out value); + + /// + /// Retrieves a string value for the specified option field. + /// + /// The field to fetch the value for. + /// The output variable to populate. + /// true if a suitable value for the field was found; false otherwise. + public bool TryGetString(int field, out string value) => TryGetPrimitiveValue(field, out value); + + /// + /// Retrieves a bytes value for the specified option field. + /// + /// The field to fetch the value for. + /// The output variable to populate. + /// true if a suitable value for the field was found; false otherwise. + public bool TryGetBytes(int field, out ByteString value) => TryGetPrimitiveValue(field, out value); + + /// + /// Retrieves a message value for the specified option field. + /// + /// The field to fetch the value for. + /// The output variable to populate. + /// true if a suitable value for the field was found; false otherwise. + public bool TryGetMessage(int field, out T value) where T : class, IMessage, new() + { + if (values == null) + { + value = default(T); + return false; + } + + IExtensionValue extensionValue; + if (values.TryGetValue(field, out extensionValue)) + { + if (extensionValue is ExtensionValue) + { + ExtensionValue single = extensionValue as ExtensionValue; + ByteString bytes = single.GetValue().ToByteString(); + value = new T(); + value.MergeFrom(bytes); + return true; + } + else if (extensionValue is RepeatedExtensionValue) + { + RepeatedExtensionValue repeated = extensionValue as RepeatedExtensionValue; + value = repeated.GetValue() + .Select(v => v.ToByteString()) + .Aggregate(new T(), (t, b) => + { + t.MergeFrom(b); + return t; + }); + return true; + } + } + + value = null; + return false; + } + + private bool TryGetPrimitiveValue(int field, out T value) + { + if (values == null) + { + value = default(T); + return false; + } + + IExtensionValue extensionValue; + if (values.TryGetValue(field, out extensionValue)) + { + if (extensionValue is ExtensionValue) + { + ExtensionValue single = extensionValue as ExtensionValue; + if (single.HasValue) + { + value = single.GetValue(); + return true; + } + } + else if (extensionValue is RepeatedExtensionValue) + { + RepeatedExtensionValue repeated = extensionValue as RepeatedExtensionValue; + if (repeated.GetValue().Count != 0) + { + RepeatedField repeatedField = repeated.GetValue(); + value = repeatedField[repeatedField.Count - 1]; + return true; + } + } + else // and here we find explicit enum handling since T : Enum ! x is ExtensionValue + { + var type = extensionValue.GetType(); + if (type.GetGenericTypeDefinition() == typeof(ExtensionValue<>)) + { + var typeInfo = type.GetTypeInfo(); + var typeArgs = typeInfo.GenericTypeArguments; + if (typeArgs.Length == 1 && typeArgs[0].GetTypeInfo().IsEnum) + { + if ((bool)typeInfo.GetDeclaredProperty(nameof(ExtensionValue.HasValue)).GetValue(extensionValue)) + { + value = (T)typeInfo.GetDeclaredMethod(nameof(ExtensionValue.GetValue)).Invoke(extensionValue, EmptyParameters); + return true; + } + } + } + else if (type.GetGenericTypeDefinition() == typeof(RepeatedExtensionValue<>)) + { + var typeInfo = type.GetTypeInfo(); + var typeArgs = typeInfo.GenericTypeArguments; + if (typeArgs.Length == 1 && typeArgs[0].GetTypeInfo().IsEnum) + { + var values = (IList)typeInfo.GetDeclaredMethod(nameof(RepeatedExtensionValue.GetValue)).Invoke(extensionValue, EmptyParameters); + if (values.Count != 0) + { + value = (T)values[values.Count - 1]; + return true; + } + } + } + } + } + + value = default(T); + return false; + } + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/Descriptor.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/Descriptor.cs index fa138dfe912c..162f17512e62 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/Descriptor.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/Descriptor.cs @@ -1,5 +1,7 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/descriptor.proto +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/descriptor.proto +// #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -10,7 +12,6 @@ namespace Google.Protobuf.Reflection { /// Holder for reflection information generated from google/protobuf/descriptor.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal static partial class DescriptorReflection { #region Descriptor @@ -36,7 +37,7 @@ static DescriptorReflection() { "LnByb3RvYnVmLkZpZWxkRGVzY3JpcHRvclByb3RvEi0KB29wdGlvbnMYCCAB", "KAsyHC5nb29nbGUucHJvdG9idWYuRmlsZU9wdGlvbnMSOQoQc291cmNlX2Nv", "ZGVfaW5mbxgJIAEoCzIfLmdvb2dsZS5wcm90b2J1Zi5Tb3VyY2VDb2RlSW5m", - "bxIOCgZzeW50YXgYDCABKAki8AQKD0Rlc2NyaXB0b3JQcm90bxIMCgRuYW1l", + "bxIOCgZzeW50YXgYDCABKAkiqQUKD0Rlc2NyaXB0b3JQcm90bxIMCgRuYW1l", "GAEgASgJEjQKBWZpZWxkGAIgAygLMiUuZ29vZ2xlLnByb3RvYnVmLkZpZWxk", "RGVzY3JpcHRvclByb3RvEjgKCWV4dGVuc2lvbhgGIAMoCzIlLmdvb2dsZS5w", "cm90b2J1Zi5GaWVsZERlc2NyaXB0b3JQcm90bxI1CgtuZXN0ZWRfdHlwZRgD", @@ -48,119 +49,140 @@ static DescriptorReflection() { "b3RvEjAKB29wdGlvbnMYByABKAsyHy5nb29nbGUucHJvdG9idWYuTWVzc2Fn", "ZU9wdGlvbnMSRgoOcmVzZXJ2ZWRfcmFuZ2UYCSADKAsyLi5nb29nbGUucHJv", "dG9idWYuRGVzY3JpcHRvclByb3RvLlJlc2VydmVkUmFuZ2USFQoNcmVzZXJ2", - "ZWRfbmFtZRgKIAMoCRosCg5FeHRlbnNpb25SYW5nZRINCgVzdGFydBgBIAEo", - "BRILCgNlbmQYAiABKAUaKwoNUmVzZXJ2ZWRSYW5nZRINCgVzdGFydBgBIAEo", - "BRILCgNlbmQYAiABKAUivAUKFEZpZWxkRGVzY3JpcHRvclByb3RvEgwKBG5h", - "bWUYASABKAkSDgoGbnVtYmVyGAMgASgFEjoKBWxhYmVsGAQgASgOMisuZ29v", - "Z2xlLnByb3RvYnVmLkZpZWxkRGVzY3JpcHRvclByb3RvLkxhYmVsEjgKBHR5", - "cGUYBSABKA4yKi5nb29nbGUucHJvdG9idWYuRmllbGREZXNjcmlwdG9yUHJv", - "dG8uVHlwZRIRCgl0eXBlX25hbWUYBiABKAkSEAoIZXh0ZW5kZWUYAiABKAkS", - "FQoNZGVmYXVsdF92YWx1ZRgHIAEoCRITCgtvbmVvZl9pbmRleBgJIAEoBRIR", - "Cglqc29uX25hbWUYCiABKAkSLgoHb3B0aW9ucxgIIAEoCzIdLmdvb2dsZS5w", - "cm90b2J1Zi5GaWVsZE9wdGlvbnMitgIKBFR5cGUSDwoLVFlQRV9ET1VCTEUQ", - "ARIOCgpUWVBFX0ZMT0FUEAISDgoKVFlQRV9JTlQ2NBADEg8KC1RZUEVfVUlO", - "VDY0EAQSDgoKVFlQRV9JTlQzMhAFEhAKDFRZUEVfRklYRUQ2NBAGEhAKDFRZ", - "UEVfRklYRUQzMhAHEg0KCVRZUEVfQk9PTBAIEg8KC1RZUEVfU1RSSU5HEAkS", - "DgoKVFlQRV9HUk9VUBAKEhAKDFRZUEVfTUVTU0FHRRALEg4KClRZUEVfQllU", - "RVMQDBIPCgtUWVBFX1VJTlQzMhANEg0KCVRZUEVfRU5VTRAOEhEKDVRZUEVf", - "U0ZJWEVEMzIQDxIRCg1UWVBFX1NGSVhFRDY0EBASDwoLVFlQRV9TSU5UMzIQ", - "ERIPCgtUWVBFX1NJTlQ2NBASIkMKBUxhYmVsEhIKDkxBQkVMX09QVElPTkFM", - "EAESEgoOTEFCRUxfUkVRVUlSRUQQAhISCg5MQUJFTF9SRVBFQVRFRBADIiQK", - "FE9uZW9mRGVzY3JpcHRvclByb3RvEgwKBG5hbWUYASABKAkijAEKE0VudW1E", - "ZXNjcmlwdG9yUHJvdG8SDAoEbmFtZRgBIAEoCRI4CgV2YWx1ZRgCIAMoCzIp", - "Lmdvb2dsZS5wcm90b2J1Zi5FbnVtVmFsdWVEZXNjcmlwdG9yUHJvdG8SLQoH", - "b3B0aW9ucxgDIAEoCzIcLmdvb2dsZS5wcm90b2J1Zi5FbnVtT3B0aW9ucyJs", - "ChhFbnVtVmFsdWVEZXNjcmlwdG9yUHJvdG8SDAoEbmFtZRgBIAEoCRIOCgZu", - "dW1iZXIYAiABKAUSMgoHb3B0aW9ucxgDIAEoCzIhLmdvb2dsZS5wcm90b2J1", - "Zi5FbnVtVmFsdWVPcHRpb25zIpABChZTZXJ2aWNlRGVzY3JpcHRvclByb3Rv", - "EgwKBG5hbWUYASABKAkSNgoGbWV0aG9kGAIgAygLMiYuZ29vZ2xlLnByb3Rv", - "YnVmLk1ldGhvZERlc2NyaXB0b3JQcm90bxIwCgdvcHRpb25zGAMgASgLMh8u", - "Z29vZ2xlLnByb3RvYnVmLlNlcnZpY2VPcHRpb25zIsEBChVNZXRob2REZXNj", - "cmlwdG9yUHJvdG8SDAoEbmFtZRgBIAEoCRISCgppbnB1dF90eXBlGAIgASgJ", - "EhMKC291dHB1dF90eXBlGAMgASgJEi8KB29wdGlvbnMYBCABKAsyHi5nb29n", - "bGUucHJvdG9idWYuTWV0aG9kT3B0aW9ucxIfChBjbGllbnRfc3RyZWFtaW5n", - "GAUgASgIOgVmYWxzZRIfChBzZXJ2ZXJfc3RyZWFtaW5nGAYgASgIOgVmYWxz", - "ZSKHBQoLRmlsZU9wdGlvbnMSFAoMamF2YV9wYWNrYWdlGAEgASgJEhwKFGph", - "dmFfb3V0ZXJfY2xhc3NuYW1lGAggASgJEiIKE2phdmFfbXVsdGlwbGVfZmls", - "ZXMYCiABKAg6BWZhbHNlEiwKHWphdmFfZ2VuZXJhdGVfZXF1YWxzX2FuZF9o", - "YXNoGBQgASgIOgVmYWxzZRIlChZqYXZhX3N0cmluZ19jaGVja191dGY4GBsg", - "ASgIOgVmYWxzZRJGCgxvcHRpbWl6ZV9mb3IYCSABKA4yKS5nb29nbGUucHJv", - "dG9idWYuRmlsZU9wdGlvbnMuT3B0aW1pemVNb2RlOgVTUEVFRBISCgpnb19w", - "YWNrYWdlGAsgASgJEiIKE2NjX2dlbmVyaWNfc2VydmljZXMYECABKAg6BWZh", - "bHNlEiQKFWphdmFfZ2VuZXJpY19zZXJ2aWNlcxgRIAEoCDoFZmFsc2USIgoT", - "cHlfZ2VuZXJpY19zZXJ2aWNlcxgSIAEoCDoFZmFsc2USGQoKZGVwcmVjYXRl", - "ZBgXIAEoCDoFZmFsc2USHwoQY2NfZW5hYmxlX2FyZW5hcxgfIAEoCDoFZmFs", - "c2USGQoRb2JqY19jbGFzc19wcmVmaXgYJCABKAkSGAoQY3NoYXJwX25hbWVz", - "cGFjZRglIAEoCRJDChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5n", - "b29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbiI6CgxPcHRpbWl6", - "ZU1vZGUSCQoFU1BFRUQQARINCglDT0RFX1NJWkUQAhIQCgxMSVRFX1JVTlRJ", - "TUUQAyoJCOgHEICAgIACSgQIJhAnIuYBCg5NZXNzYWdlT3B0aW9ucxImChdt", - "ZXNzYWdlX3NldF93aXJlX2Zvcm1hdBgBIAEoCDoFZmFsc2USLgofbm9fc3Rh", - "bmRhcmRfZGVzY3JpcHRvcl9hY2Nlc3NvchgCIAEoCDoFZmFsc2USGQoKZGVw", - "cmVjYXRlZBgDIAEoCDoFZmFsc2USEQoJbWFwX2VudHJ5GAcgASgIEkMKFHVu", - "aW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5V", - "bmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIimAMKDEZpZWxkT3B0aW9u", - "cxI6CgVjdHlwZRgBIAEoDjIjLmdvb2dsZS5wcm90b2J1Zi5GaWVsZE9wdGlv", - "bnMuQ1R5cGU6BlNUUklORxIOCgZwYWNrZWQYAiABKAgSPwoGanN0eXBlGAYg", - "ASgOMiQuZ29vZ2xlLnByb3RvYnVmLkZpZWxkT3B0aW9ucy5KU1R5cGU6CUpT", - "X05PUk1BTBITCgRsYXp5GAUgASgIOgVmYWxzZRIZCgpkZXByZWNhdGVkGAMg", - "ASgIOgVmYWxzZRITCgR3ZWFrGAogASgIOgVmYWxzZRJDChR1bmludGVycHJl", - "dGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnBy", - "ZXRlZE9wdGlvbiIvCgVDVHlwZRIKCgZTVFJJTkcQABIICgRDT1JEEAESEAoM", - "U1RSSU5HX1BJRUNFEAIiNQoGSlNUeXBlEg0KCUpTX05PUk1BTBAAEg0KCUpT", - "X1NUUklORxABEg0KCUpTX05VTUJFUhACKgkI6AcQgICAgAIijQEKC0VudW1P", - "cHRpb25zEhMKC2FsbG93X2FsaWFzGAIgASgIEhkKCmRlcHJlY2F0ZWQYAyAB", - "KAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdv", - "b2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIi", - "fQoQRW51bVZhbHVlT3B0aW9ucxIZCgpkZXByZWNhdGVkGAEgASgIOgVmYWxz", - "ZRJDChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJv", - "dG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbioJCOgHEICAgIACInsKDlNlcnZp", - "Y2VPcHRpb25zEhkKCmRlcHJlY2F0ZWQYISABKAg6BWZhbHNlEkMKFHVuaW50", + "ZWRfbmFtZRgKIAMoCRplCg5FeHRlbnNpb25SYW5nZRINCgVzdGFydBgBIAEo", + "BRILCgNlbmQYAiABKAUSNwoHb3B0aW9ucxgDIAEoCzImLmdvb2dsZS5wcm90", + "b2J1Zi5FeHRlbnNpb25SYW5nZU9wdGlvbnMaKwoNUmVzZXJ2ZWRSYW5nZRIN", + "CgVzdGFydBgBIAEoBRILCgNlbmQYAiABKAUiZwoVRXh0ZW5zaW9uUmFuZ2VP", + "cHRpb25zEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2ds", + "ZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIivAUK", + "FEZpZWxkRGVzY3JpcHRvclByb3RvEgwKBG5hbWUYASABKAkSDgoGbnVtYmVy", + "GAMgASgFEjoKBWxhYmVsGAQgASgOMisuZ29vZ2xlLnByb3RvYnVmLkZpZWxk", + "RGVzY3JpcHRvclByb3RvLkxhYmVsEjgKBHR5cGUYBSABKA4yKi5nb29nbGUu", + "cHJvdG9idWYuRmllbGREZXNjcmlwdG9yUHJvdG8uVHlwZRIRCgl0eXBlX25h", + "bWUYBiABKAkSEAoIZXh0ZW5kZWUYAiABKAkSFQoNZGVmYXVsdF92YWx1ZRgH", + "IAEoCRITCgtvbmVvZl9pbmRleBgJIAEoBRIRCglqc29uX25hbWUYCiABKAkS", + "LgoHb3B0aW9ucxgIIAEoCzIdLmdvb2dsZS5wcm90b2J1Zi5GaWVsZE9wdGlv", + "bnMitgIKBFR5cGUSDwoLVFlQRV9ET1VCTEUQARIOCgpUWVBFX0ZMT0FUEAIS", + "DgoKVFlQRV9JTlQ2NBADEg8KC1RZUEVfVUlOVDY0EAQSDgoKVFlQRV9JTlQz", + "MhAFEhAKDFRZUEVfRklYRUQ2NBAGEhAKDFRZUEVfRklYRUQzMhAHEg0KCVRZ", + "UEVfQk9PTBAIEg8KC1RZUEVfU1RSSU5HEAkSDgoKVFlQRV9HUk9VUBAKEhAK", + "DFRZUEVfTUVTU0FHRRALEg4KClRZUEVfQllURVMQDBIPCgtUWVBFX1VJTlQz", + "MhANEg0KCVRZUEVfRU5VTRAOEhEKDVRZUEVfU0ZJWEVEMzIQDxIRCg1UWVBF", + "X1NGSVhFRDY0EBASDwoLVFlQRV9TSU5UMzIQERIPCgtUWVBFX1NJTlQ2NBAS", + "IkMKBUxhYmVsEhIKDkxBQkVMX09QVElPTkFMEAESEgoOTEFCRUxfUkVRVUlS", + "RUQQAhISCg5MQUJFTF9SRVBFQVRFRBADIlQKFE9uZW9mRGVzY3JpcHRvclBy", + "b3RvEgwKBG5hbWUYASABKAkSLgoHb3B0aW9ucxgCIAEoCzIdLmdvb2dsZS5w", + "cm90b2J1Zi5PbmVvZk9wdGlvbnMipAIKE0VudW1EZXNjcmlwdG9yUHJvdG8S", + "DAoEbmFtZRgBIAEoCRI4CgV2YWx1ZRgCIAMoCzIpLmdvb2dsZS5wcm90b2J1", + "Zi5FbnVtVmFsdWVEZXNjcmlwdG9yUHJvdG8SLQoHb3B0aW9ucxgDIAEoCzIc", + "Lmdvb2dsZS5wcm90b2J1Zi5FbnVtT3B0aW9ucxJOCg5yZXNlcnZlZF9yYW5n", + "ZRgEIAMoCzI2Lmdvb2dsZS5wcm90b2J1Zi5FbnVtRGVzY3JpcHRvclByb3Rv", + "LkVudW1SZXNlcnZlZFJhbmdlEhUKDXJlc2VydmVkX25hbWUYBSADKAkaLwoR", + "RW51bVJlc2VydmVkUmFuZ2USDQoFc3RhcnQYASABKAUSCwoDZW5kGAIgASgF", + "ImwKGEVudW1WYWx1ZURlc2NyaXB0b3JQcm90bxIMCgRuYW1lGAEgASgJEg4K", + "Bm51bWJlchgCIAEoBRIyCgdvcHRpb25zGAMgASgLMiEuZ29vZ2xlLnByb3Rv", + "YnVmLkVudW1WYWx1ZU9wdGlvbnMikAEKFlNlcnZpY2VEZXNjcmlwdG9yUHJv", + "dG8SDAoEbmFtZRgBIAEoCRI2CgZtZXRob2QYAiADKAsyJi5nb29nbGUucHJv", + "dG9idWYuTWV0aG9kRGVzY3JpcHRvclByb3RvEjAKB29wdGlvbnMYAyABKAsy", + "Hy5nb29nbGUucHJvdG9idWYuU2VydmljZU9wdGlvbnMiwQEKFU1ldGhvZERl", + "c2NyaXB0b3JQcm90bxIMCgRuYW1lGAEgASgJEhIKCmlucHV0X3R5cGUYAiAB", + "KAkSEwoLb3V0cHV0X3R5cGUYAyABKAkSLwoHb3B0aW9ucxgEIAEoCzIeLmdv", + "b2dsZS5wcm90b2J1Zi5NZXRob2RPcHRpb25zEh8KEGNsaWVudF9zdHJlYW1p", + "bmcYBSABKAg6BWZhbHNlEh8KEHNlcnZlcl9zdHJlYW1pbmcYBiABKAg6BWZh", + "bHNlIqYGCgtGaWxlT3B0aW9ucxIUCgxqYXZhX3BhY2thZ2UYASABKAkSHAoU", + "amF2YV9vdXRlcl9jbGFzc25hbWUYCCABKAkSIgoTamF2YV9tdWx0aXBsZV9m", + "aWxlcxgKIAEoCDoFZmFsc2USKQodamF2YV9nZW5lcmF0ZV9lcXVhbHNfYW5k", + "X2hhc2gYFCABKAhCAhgBEiUKFmphdmFfc3RyaW5nX2NoZWNrX3V0ZjgYGyAB", + "KAg6BWZhbHNlEkYKDG9wdGltaXplX2ZvchgJIAEoDjIpLmdvb2dsZS5wcm90", + "b2J1Zi5GaWxlT3B0aW9ucy5PcHRpbWl6ZU1vZGU6BVNQRUVEEhIKCmdvX3Bh", + "Y2thZ2UYCyABKAkSIgoTY2NfZ2VuZXJpY19zZXJ2aWNlcxgQIAEoCDoFZmFs", + "c2USJAoVamF2YV9nZW5lcmljX3NlcnZpY2VzGBEgASgIOgVmYWxzZRIiChNw", + "eV9nZW5lcmljX3NlcnZpY2VzGBIgASgIOgVmYWxzZRIjChRwaHBfZ2VuZXJp", + "Y19zZXJ2aWNlcxgqIAEoCDoFZmFsc2USGQoKZGVwcmVjYXRlZBgXIAEoCDoF", + "ZmFsc2USHwoQY2NfZW5hYmxlX2FyZW5hcxgfIAEoCDoFZmFsc2USGQoRb2Jq", + "Y19jbGFzc19wcmVmaXgYJCABKAkSGAoQY3NoYXJwX25hbWVzcGFjZRglIAEo", + "CRIUCgxzd2lmdF9wcmVmaXgYJyABKAkSGAoQcGhwX2NsYXNzX3ByZWZpeBgo", + "IAEoCRIVCg1waHBfbmFtZXNwYWNlGCkgASgJEh4KFnBocF9tZXRhZGF0YV9u", + "YW1lc3BhY2UYLCABKAkSFAoMcnVieV9wYWNrYWdlGC0gASgJEkMKFHVuaW50", "ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5Vbmlu", - "dGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIiegoNTWV0aG9kT3B0aW9ucxIZ", - "CgpkZXByZWNhdGVkGCEgASgIOgVmYWxzZRJDChR1bmludGVycHJldGVkX29w", - "dGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9w", - "dGlvbioJCOgHEICAgIACIp4CChNVbmludGVycHJldGVkT3B0aW9uEjsKBG5h", - "bWUYAiADKAsyLS5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlv", - "bi5OYW1lUGFydBIYChBpZGVudGlmaWVyX3ZhbHVlGAMgASgJEhoKEnBvc2l0", - "aXZlX2ludF92YWx1ZRgEIAEoBBIaChJuZWdhdGl2ZV9pbnRfdmFsdWUYBSAB", - "KAMSFAoMZG91YmxlX3ZhbHVlGAYgASgBEhQKDHN0cmluZ192YWx1ZRgHIAEo", - "DBIXCg9hZ2dyZWdhdGVfdmFsdWUYCCABKAkaMwoITmFtZVBhcnQSEQoJbmFt", - "ZV9wYXJ0GAEgAigJEhQKDGlzX2V4dGVuc2lvbhgCIAIoCCLVAQoOU291cmNl", - "Q29kZUluZm8SOgoIbG9jYXRpb24YASADKAsyKC5nb29nbGUucHJvdG9idWYu", - "U291cmNlQ29kZUluZm8uTG9jYXRpb24ahgEKCExvY2F0aW9uEhAKBHBhdGgY", - "ASADKAVCAhABEhAKBHNwYW4YAiADKAVCAhABEhgKEGxlYWRpbmdfY29tbWVu", - "dHMYAyABKAkSGQoRdHJhaWxpbmdfY29tbWVudHMYBCABKAkSIQoZbGVhZGlu", - "Z19kZXRhY2hlZF9jb21tZW50cxgGIAMoCSKnAQoRR2VuZXJhdGVkQ29kZUlu", - "Zm8SQQoKYW5ub3RhdGlvbhgBIAMoCzItLmdvb2dsZS5wcm90b2J1Zi5HZW5l", - "cmF0ZWRDb2RlSW5mby5Bbm5vdGF0aW9uGk8KCkFubm90YXRpb24SEAoEcGF0", - "aBgBIAMoBUICEAESEwoLc291cmNlX2ZpbGUYAiABKAkSDQoFYmVnaW4YAyAB", - "KAUSCwoDZW5kGAQgASgFQlgKE2NvbS5nb29nbGUucHJvdG9idWZCEERlc2Ny", - "aXB0b3JQcm90b3NIAVoKZGVzY3JpcHRvcqICA0dQQqoCGkdvb2dsZS5Qcm90", - "b2J1Zi5SZWZsZWN0aW9u")); + "dGVycHJldGVkT3B0aW9uIjoKDE9wdGltaXplTW9kZRIJCgVTUEVFRBABEg0K", + "CUNPREVfU0laRRACEhAKDExJVEVfUlVOVElNRRADKgkI6AcQgICAgAJKBAgm", + "ECci8gEKDk1lc3NhZ2VPcHRpb25zEiYKF21lc3NhZ2Vfc2V0X3dpcmVfZm9y", + "bWF0GAEgASgIOgVmYWxzZRIuCh9ub19zdGFuZGFyZF9kZXNjcmlwdG9yX2Fj", + "Y2Vzc29yGAIgASgIOgVmYWxzZRIZCgpkZXByZWNhdGVkGAMgASgIOgVmYWxz", + "ZRIRCgltYXBfZW50cnkYByABKAgSQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y", + "5wcgAygLMiQuZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24q", + "CQjoBxCAgICAAkoECAgQCUoECAkQCiKeAwoMRmllbGRPcHRpb25zEjoKBWN0", + "eXBlGAEgASgOMiMuZ29vZ2xlLnByb3RvYnVmLkZpZWxkT3B0aW9ucy5DVHlw", + "ZToGU1RSSU5HEg4KBnBhY2tlZBgCIAEoCBI/CgZqc3R5cGUYBiABKA4yJC5n", + "b29nbGUucHJvdG9idWYuRmllbGRPcHRpb25zLkpTVHlwZToJSlNfTk9STUFM", + "EhMKBGxhenkYBSABKAg6BWZhbHNlEhkKCmRlcHJlY2F0ZWQYAyABKAg6BWZh", + "bHNlEhMKBHdlYWsYCiABKAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0", + "aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0", + "aW9uIi8KBUNUeXBlEgoKBlNUUklORxAAEggKBENPUkQQARIQCgxTVFJJTkdf", + "UElFQ0UQAiI1CgZKU1R5cGUSDQoJSlNfTk9STUFMEAASDQoJSlNfU1RSSU5H", + "EAESDQoJSlNfTlVNQkVSEAIqCQjoBxCAgICAAkoECAQQBSJeCgxPbmVvZk9w", + "dGlvbnMSQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xl", + "LnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAiKTAQoL", + "RW51bU9wdGlvbnMSEwoLYWxsb3dfYWxpYXMYAiABKAgSGQoKZGVwcmVjYXRl", + "ZBgDIAEoCDoFZmFsc2USQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygL", + "MiQuZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCA", + "gICAAkoECAUQBiJ9ChBFbnVtVmFsdWVPcHRpb25zEhkKCmRlcHJlY2F0ZWQY", + "ASABKAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIk", + "Lmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI6AcQgICA", + "gAIiewoOU2VydmljZU9wdGlvbnMSGQoKZGVwcmVjYXRlZBghIAEoCDoFZmFs", + "c2USQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnBy", + "b3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAiKtAgoNTWV0", + "aG9kT3B0aW9ucxIZCgpkZXByZWNhdGVkGCEgASgIOgVmYWxzZRJfChFpZGVt", + "cG90ZW5jeV9sZXZlbBgiIAEoDjIvLmdvb2dsZS5wcm90b2J1Zi5NZXRob2RP", + "cHRpb25zLklkZW1wb3RlbmN5TGV2ZWw6E0lERU1QT1RFTkNZX1VOS05PV04S", + "QwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnByb3Rv", + "YnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24iUAoQSWRlbXBvdGVuY3lMZXZlbBIX", + "ChNJREVNUE9URU5DWV9VTktOT1dOEAASEwoPTk9fU0lERV9FRkZFQ1RTEAES", + "DgoKSURFTVBPVEVOVBACKgkI6AcQgICAgAIingIKE1VuaW50ZXJwcmV0ZWRP", + "cHRpb24SOwoEbmFtZRgCIAMoCzItLmdvb2dsZS5wcm90b2J1Zi5VbmludGVy", + "cHJldGVkT3B0aW9uLk5hbWVQYXJ0EhgKEGlkZW50aWZpZXJfdmFsdWUYAyAB", + "KAkSGgoScG9zaXRpdmVfaW50X3ZhbHVlGAQgASgEEhoKEm5lZ2F0aXZlX2lu", + "dF92YWx1ZRgFIAEoAxIUCgxkb3VibGVfdmFsdWUYBiABKAESFAoMc3RyaW5n", + "X3ZhbHVlGAcgASgMEhcKD2FnZ3JlZ2F0ZV92YWx1ZRgIIAEoCRozCghOYW1l", + "UGFydBIRCgluYW1lX3BhcnQYASACKAkSFAoMaXNfZXh0ZW5zaW9uGAIgAigI", + "ItUBCg5Tb3VyY2VDb2RlSW5mbxI6Cghsb2NhdGlvbhgBIAMoCzIoLmdvb2ds", + "ZS5wcm90b2J1Zi5Tb3VyY2VDb2RlSW5mby5Mb2NhdGlvbhqGAQoITG9jYXRp", + "b24SEAoEcGF0aBgBIAMoBUICEAESEAoEc3BhbhgCIAMoBUICEAESGAoQbGVh", + "ZGluZ19jb21tZW50cxgDIAEoCRIZChF0cmFpbGluZ19jb21tZW50cxgEIAEo", + "CRIhChlsZWFkaW5nX2RldGFjaGVkX2NvbW1lbnRzGAYgAygJIqcBChFHZW5l", + "cmF0ZWRDb2RlSW5mbxJBCgphbm5vdGF0aW9uGAEgAygLMi0uZ29vZ2xlLnBy", + "b3RvYnVmLkdlbmVyYXRlZENvZGVJbmZvLkFubm90YXRpb24aTwoKQW5ub3Rh", + "dGlvbhIQCgRwYXRoGAEgAygFQgIQARITCgtzb3VyY2VfZmlsZRgCIAEoCRIN", + "CgViZWdpbhgDIAEoBRILCgNlbmQYBCABKAVCjwEKE2NvbS5nb29nbGUucHJv", + "dG9idWZCEERlc2NyaXB0b3JQcm90b3NIAVo+Z2l0aHViLmNvbS9nb2xhbmcv", + "cHJvdG9idWYvcHJvdG9jLWdlbi1nby9kZXNjcmlwdG9yO2Rlc2NyaXB0b3L4", + "AQGiAgNHUEKqAhpHb29nbGUuUHJvdG9idWYuUmVmbGVjdGlvbg==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileDescriptorSet), global::Google.Protobuf.Reflection.FileDescriptorSet.Parser, new[]{ "File" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileDescriptorProto), global::Google.Protobuf.Reflection.FileDescriptorProto.Parser, new[]{ "Name", "Package", "Dependency", "PublicDependency", "WeakDependency", "MessageType", "EnumType", "Service", "Extension", "Options", "SourceCodeInfo", "Syntax" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.DescriptorProto), global::Google.Protobuf.Reflection.DescriptorProto.Parser, new[]{ "Name", "Field", "Extension", "NestedType", "EnumType", "ExtensionRange", "OneofDecl", "Options", "ReservedRange", "ReservedName" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.DescriptorProto.Types.ExtensionRange), global::Google.Protobuf.Reflection.DescriptorProto.Types.ExtensionRange.Parser, new[]{ "Start", "End" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.DescriptorProto.Types.ReservedRange), global::Google.Protobuf.Reflection.DescriptorProto.Types.ReservedRange.Parser, new[]{ "Start", "End" }, null, null, null)}), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto), global::Google.Protobuf.Reflection.FieldDescriptorProto.Parser, new[]{ "Name", "Number", "Label", "Type", "TypeName", "Extendee", "DefaultValue", "OneofIndex", "JsonName", "Options" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type), typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label) }, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.OneofDescriptorProto), global::Google.Protobuf.Reflection.OneofDescriptorProto.Parser, new[]{ "Name" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumDescriptorProto), global::Google.Protobuf.Reflection.EnumDescriptorProto.Parser, new[]{ "Name", "Value", "Options" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueDescriptorProto), global::Google.Protobuf.Reflection.EnumValueDescriptorProto.Parser, new[]{ "Name", "Number", "Options" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.ServiceDescriptorProto), global::Google.Protobuf.Reflection.ServiceDescriptorProto.Parser, new[]{ "Name", "Method", "Options" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MethodDescriptorProto), global::Google.Protobuf.Reflection.MethodDescriptorProto.Parser, new[]{ "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), global::Google.Protobuf.Reflection.FileOptions.Parser, new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MessageOptions), global::Google.Protobuf.Reflection.MessageOptions.Parser, new[]{ "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FieldOptions), global::Google.Protobuf.Reflection.FieldOptions.Parser, new[]{ "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.CType), typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.JSType) }, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumOptions), global::Google.Protobuf.Reflection.EnumOptions.Parser, new[]{ "AllowAlias", "Deprecated", "UninterpretedOption" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueOptions), global::Google.Protobuf.Reflection.EnumValueOptions.Parser, new[]{ "Deprecated", "UninterpretedOption" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.ServiceOptions), global::Google.Protobuf.Reflection.ServiceOptions.Parser, new[]{ "Deprecated", "UninterpretedOption" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MethodOptions), global::Google.Protobuf.Reflection.MethodOptions.Parser, new[]{ "Deprecated", "UninterpretedOption" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.UninterpretedOption), global::Google.Protobuf.Reflection.UninterpretedOption.Parser, new[]{ "Name", "IdentifierValue", "PositiveIntValue", "NegativeIntValue", "DoubleValue", "StringValue", "AggregateValue" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.UninterpretedOption.Types.NamePart), global::Google.Protobuf.Reflection.UninterpretedOption.Types.NamePart.Parser, new[]{ "NamePart_", "IsExtension" }, null, null, null)}), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.SourceCodeInfo), global::Google.Protobuf.Reflection.SourceCodeInfo.Parser, new[]{ "Location" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location), global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location.Parser, new[]{ "Path", "Span", "LeadingComments", "TrailingComments", "LeadingDetachedComments" }, null, null, null)}), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.GeneratedCodeInfo), global::Google.Protobuf.Reflection.GeneratedCodeInfo.Parser, new[]{ "Annotation" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.GeneratedCodeInfo.Types.Annotation), global::Google.Protobuf.Reflection.GeneratedCodeInfo.Types.Annotation.Parser, new[]{ "Path", "SourceFile", "Begin", "End" }, null, null, null)}) + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileDescriptorSet), global::Google.Protobuf.Reflection.FileDescriptorSet.Parser, new[]{ "File" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileDescriptorProto), global::Google.Protobuf.Reflection.FileDescriptorProto.Parser, new[]{ "Name", "Package", "Dependency", "PublicDependency", "WeakDependency", "MessageType", "EnumType", "Service", "Extension", "Options", "SourceCodeInfo", "Syntax" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.DescriptorProto), global::Google.Protobuf.Reflection.DescriptorProto.Parser, new[]{ "Name", "Field", "Extension", "NestedType", "EnumType", "ExtensionRange", "OneofDecl", "Options", "ReservedRange", "ReservedName" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.DescriptorProto.Types.ExtensionRange), global::Google.Protobuf.Reflection.DescriptorProto.Types.ExtensionRange.Parser, new[]{ "Start", "End", "Options" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.DescriptorProto.Types.ReservedRange), global::Google.Protobuf.Reflection.DescriptorProto.Types.ReservedRange.Parser, new[]{ "Start", "End" }, null, null, null, null)}), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.ExtensionRangeOptions), global::Google.Protobuf.Reflection.ExtensionRangeOptions.Parser, new[]{ "UninterpretedOption" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto), global::Google.Protobuf.Reflection.FieldDescriptorProto.Parser, new[]{ "Name", "Number", "Label", "Type", "TypeName", "Extendee", "DefaultValue", "OneofIndex", "JsonName", "Options" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type), typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label) }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.OneofDescriptorProto), global::Google.Protobuf.Reflection.OneofDescriptorProto.Parser, new[]{ "Name", "Options" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumDescriptorProto), global::Google.Protobuf.Reflection.EnumDescriptorProto.Parser, new[]{ "Name", "Value", "Options", "ReservedRange", "ReservedName" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumDescriptorProto.Types.EnumReservedRange), global::Google.Protobuf.Reflection.EnumDescriptorProto.Types.EnumReservedRange.Parser, new[]{ "Start", "End" }, null, null, null, null)}), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueDescriptorProto), global::Google.Protobuf.Reflection.EnumValueDescriptorProto.Parser, new[]{ "Name", "Number", "Options" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.ServiceDescriptorProto), global::Google.Protobuf.Reflection.ServiceDescriptorProto.Parser, new[]{ "Name", "Method", "Options" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MethodDescriptorProto), global::Google.Protobuf.Reflection.MethodDescriptorProto.Parser, new[]{ "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), global::Google.Protobuf.Reflection.FileOptions.Parser, new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "PhpGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "SwiftPrefix", "PhpClassPrefix", "PhpNamespace", "PhpMetadataNamespace", "RubyPackage", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MessageOptions), global::Google.Protobuf.Reflection.MessageOptions.Parser, new[]{ "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FieldOptions), global::Google.Protobuf.Reflection.FieldOptions.Parser, new[]{ "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.CType), typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.JSType) }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.OneofOptions), global::Google.Protobuf.Reflection.OneofOptions.Parser, new[]{ "UninterpretedOption" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumOptions), global::Google.Protobuf.Reflection.EnumOptions.Parser, new[]{ "AllowAlias", "Deprecated", "UninterpretedOption" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueOptions), global::Google.Protobuf.Reflection.EnumValueOptions.Parser, new[]{ "Deprecated", "UninterpretedOption" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.ServiceOptions), global::Google.Protobuf.Reflection.ServiceOptions.Parser, new[]{ "Deprecated", "UninterpretedOption" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MethodOptions), global::Google.Protobuf.Reflection.MethodOptions.Parser, new[]{ "Deprecated", "IdempotencyLevel", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.MethodOptions.Types.IdempotencyLevel) }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.UninterpretedOption), global::Google.Protobuf.Reflection.UninterpretedOption.Parser, new[]{ "Name", "IdentifierValue", "PositiveIntValue", "NegativeIntValue", "DoubleValue", "StringValue", "AggregateValue" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.UninterpretedOption.Types.NamePart), global::Google.Protobuf.Reflection.UninterpretedOption.Types.NamePart.Parser, new[]{ "NamePart_", "IsExtension" }, null, null, null, null)}), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.SourceCodeInfo), global::Google.Protobuf.Reflection.SourceCodeInfo.Parser, new[]{ "Location" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location), global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location.Parser, new[]{ "Path", "Span", "LeadingComments", "TrailingComments", "LeadingDetachedComments" }, null, null, null, null)}), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.GeneratedCodeInfo), global::Google.Protobuf.Reflection.GeneratedCodeInfo.Parser, new[]{ "Annotation" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.GeneratedCodeInfo.Types.Annotation), global::Google.Protobuf.Reflection.GeneratedCodeInfo.Types.Annotation.Parser, new[]{ "Path", "SourceFile", "Begin", "End" }, null, null, null, null)}) })); } #endregion @@ -168,32 +190,39 @@ static DescriptorReflection() { } #region Messages /// - /// The protocol compiler can output a FileDescriptorSet containing the .proto - /// files it parses. + /// The protocol compiler can output a FileDescriptorSet containing the .proto + /// files it parses. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal sealed partial class FileDescriptorSet : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileDescriptorSet()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FileDescriptorSet() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FileDescriptorSet(FileDescriptorSet other) : this() { file_ = other.file_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FileDescriptorSet Clone() { return new FileDescriptorSet(this); } @@ -203,14 +232,17 @@ public FileDescriptorSet Clone() { private static readonly pb::FieldCodec _repeated_file_codec = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.Reflection.FileDescriptorProto.Parser); private readonly pbc::RepeatedField file_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField File { get { return file_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as FileDescriptorSet); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(FileDescriptorSet other) { if (ReferenceEquals(other, null)) { return false; @@ -219,42 +251,58 @@ public bool Equals(FileDescriptorSet other) { return true; } if(!file_.Equals(other.file_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= file_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { file_.WriteTo(output, _repeated_file_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += file_.CalculateSize(_repeated_file_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(FileDescriptorSet other) { if (other == null) { return; } file_.Add(other.file_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { file_.AddEntriesFrom(input, _repeated_file_codec); @@ -267,27 +315,32 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Describes a complete .proto file. + /// Describes a complete .proto file. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal sealed partial class FileDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileDescriptorProto()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FileDescriptorProto() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FileDescriptorProto(FileDescriptorProto other) : this() { name_ = other.name_; package_ = other.package_; @@ -298,40 +351,68 @@ public FileDescriptorProto(FileDescriptorProto other) : this() { enumType_ = other.enumType_.Clone(); service_ = other.service_.Clone(); extension_ = other.extension_.Clone(); - Options = other.options_ != null ? other.Options.Clone() : null; - SourceCodeInfo = other.sourceCodeInfo_ != null ? other.SourceCodeInfo.Clone() : null; + options_ = other.HasOptions ? other.options_.Clone() : null; + sourceCodeInfo_ = other.HasSourceCodeInfo ? other.sourceCodeInfo_.Clone() : null; syntax_ = other.syntax_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FileDescriptorProto Clone() { return new FileDescriptorProto(this); } /// Field number for the "name" field. public const int NameFieldNumber = 1; - private string name_ = ""; + private readonly static string NameDefaultValue = ""; + + private string name_; /// - /// file name, relative to root of source tree + /// file name, relative to root of source tree /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { - get { return name_; } + get { return name_ ?? NameDefaultValue; } set { name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "name" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasName { + get { return name_ != null; } + } + /// Clears the value of the "name" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearName() { + name_ = null; + } /// Field number for the "package" field. public const int PackageFieldNumber = 2; - private string package_ = ""; + private readonly static string PackageDefaultValue = ""; + + private string package_; /// - /// e.g. "foo", "foo.bar", etc. + /// e.g. "foo", "foo.bar", etc. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Package { - get { return package_; } + get { return package_ ?? PackageDefaultValue; } set { package_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "package" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasPackage { + get { return package_ != null; } + } + /// Clears the value of the "package" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearPackage() { + package_ = null; + } /// Field number for the "dependency" field. public const int DependencyFieldNumber = 3; @@ -339,8 +420,9 @@ public string Package { = pb::FieldCodec.ForString(26); private readonly pbc::RepeatedField dependency_ = new pbc::RepeatedField(); /// - /// Names of files imported by this file. + /// Names of files imported by this file. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Dependency { get { return dependency_; } } @@ -351,8 +433,9 @@ public string Package { = pb::FieldCodec.ForInt32(80); private readonly pbc::RepeatedField publicDependency_ = new pbc::RepeatedField(); /// - /// Indexes of the public imported files in the dependency list above. + /// Indexes of the public imported files in the dependency list above. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField PublicDependency { get { return publicDependency_; } } @@ -363,9 +446,10 @@ public string Package { = pb::FieldCodec.ForInt32(88); private readonly pbc::RepeatedField weakDependency_ = new pbc::RepeatedField(); /// - /// Indexes of the weak imported files in the dependency list. - /// For Google-internal migration only. Do not use. + /// Indexes of the weak imported files in the dependency list. + /// For Google-internal migration only. Do not use. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField WeakDependency { get { return weakDependency_; } } @@ -376,8 +460,9 @@ public string Package { = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.Reflection.DescriptorProto.Parser); private readonly pbc::RepeatedField messageType_ = new pbc::RepeatedField(); /// - /// All top-level definitions in this file. + /// All top-level definitions in this file. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField MessageType { get { return messageType_; } } @@ -387,6 +472,7 @@ public string Package { private static readonly pb::FieldCodec _repeated_enumType_codec = pb::FieldCodec.ForMessage(42, global::Google.Protobuf.Reflection.EnumDescriptorProto.Parser); private readonly pbc::RepeatedField enumType_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField EnumType { get { return enumType_; } } @@ -396,6 +482,7 @@ public string Package { private static readonly pb::FieldCodec _repeated_service_codec = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.Reflection.ServiceDescriptorProto.Parser); private readonly pbc::RepeatedField service_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Service { get { return service_; } } @@ -405,6 +492,7 @@ public string Package { private static readonly pb::FieldCodec _repeated_extension_codec = pb::FieldCodec.ForMessage(58, global::Google.Protobuf.Reflection.FieldDescriptorProto.Parser); private readonly pbc::RepeatedField extension_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Extension { get { return extension_; } } @@ -412,47 +500,84 @@ public string Package { /// Field number for the "options" field. public const int OptionsFieldNumber = 8; private global::Google.Protobuf.Reflection.FileOptions options_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.Reflection.FileOptions Options { get { return options_; } set { options_ = value; } } + /// Gets whether the options field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasOptions { + get { return options_ != null; } + } + /// Clears the value of the options field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearOptions() { + options_ = null; + } /// Field number for the "source_code_info" field. public const int SourceCodeInfoFieldNumber = 9; private global::Google.Protobuf.Reflection.SourceCodeInfo sourceCodeInfo_; /// - /// This field contains optional information about the original source code. - /// You may safely remove this entire field without harming runtime - /// functionality of the descriptors -- the information is needed only by - /// development tools. + /// This field contains optional information about the original source code. + /// You may safely remove this entire field without harming runtime + /// functionality of the descriptors -- the information is needed only by + /// development tools. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.Reflection.SourceCodeInfo SourceCodeInfo { get { return sourceCodeInfo_; } set { sourceCodeInfo_ = value; } } + /// Gets whether the source_code_info field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasSourceCodeInfo { + get { return sourceCodeInfo_ != null; } + } + /// Clears the value of the source_code_info field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearSourceCodeInfo() { + sourceCodeInfo_ = null; + } /// Field number for the "syntax" field. public const int SyntaxFieldNumber = 12; - private string syntax_ = ""; + private readonly static string SyntaxDefaultValue = ""; + + private string syntax_; /// - /// The syntax of the proto file. - /// The supported values are "proto2" and "proto3". + /// The syntax of the proto file. + /// The supported values are "proto2" and "proto3". /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Syntax { - get { return syntax_; } + get { return syntax_ ?? SyntaxDefaultValue; } set { syntax_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "syntax" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasSyntax { + get { return syntax_ != null; } + } + /// Clears the value of the "syntax" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearSyntax() { + syntax_ = null; + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as FileDescriptorProto); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(FileDescriptorProto other) { if (ReferenceEquals(other, null)) { return false; @@ -472,13 +597,14 @@ public bool Equals(FileDescriptorProto other) { if (!object.Equals(Options, other.Options)) return false; if (!object.Equals(SourceCodeInfo, other.SourceCodeInfo)) return false; if (Syntax != other.Syntax) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (Name.Length != 0) hash ^= Name.GetHashCode(); - if (Package.Length != 0) hash ^= Package.GetHashCode(); + if (HasName) hash ^= Name.GetHashCode(); + if (HasPackage) hash ^= Package.GetHashCode(); hash ^= dependency_.GetHashCode(); hash ^= publicDependency_.GetHashCode(); hash ^= weakDependency_.GetHashCode(); @@ -486,22 +612,27 @@ public override int GetHashCode() { hash ^= enumType_.GetHashCode(); hash ^= service_.GetHashCode(); hash ^= extension_.GetHashCode(); - if (options_ != null) hash ^= Options.GetHashCode(); - if (sourceCodeInfo_ != null) hash ^= SourceCodeInfo.GetHashCode(); - if (Syntax.Length != 0) hash ^= Syntax.GetHashCode(); + if (HasOptions) hash ^= Options.GetHashCode(); + if (HasSourceCodeInfo) hash ^= SourceCodeInfo.GetHashCode(); + if (HasSyntax) hash ^= Syntax.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (Name.Length != 0) { + if (HasName) { output.WriteRawTag(10); output.WriteString(Name); } - if (Package.Length != 0) { + if (HasPackage) { output.WriteRawTag(18); output.WriteString(Package); } @@ -510,28 +641,32 @@ public void WriteTo(pb::CodedOutputStream output) { enumType_.WriteTo(output, _repeated_enumType_codec); service_.WriteTo(output, _repeated_service_codec); extension_.WriteTo(output, _repeated_extension_codec); - if (options_ != null) { + if (HasOptions) { output.WriteRawTag(66); output.WriteMessage(Options); } - if (sourceCodeInfo_ != null) { + if (HasSourceCodeInfo) { output.WriteRawTag(74); output.WriteMessage(SourceCodeInfo); } publicDependency_.WriteTo(output, _repeated_publicDependency_codec); weakDependency_.WriteTo(output, _repeated_weakDependency_codec); - if (Syntax.Length != 0) { + if (HasSyntax) { output.WriteRawTag(98); output.WriteString(Syntax); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (Name.Length != 0) { + if (HasName) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } - if (Package.Length != 0) { + if (HasPackage) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Package); } size += dependency_.CalculateSize(_repeated_dependency_codec); @@ -541,26 +676,30 @@ public int CalculateSize() { size += enumType_.CalculateSize(_repeated_enumType_codec); size += service_.CalculateSize(_repeated_service_codec); size += extension_.CalculateSize(_repeated_extension_codec); - if (options_ != null) { + if (HasOptions) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } - if (sourceCodeInfo_ != null) { + if (HasSourceCodeInfo) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceCodeInfo); } - if (Syntax.Length != 0) { + if (HasSyntax) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Syntax); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(FileDescriptorProto other) { if (other == null) { return; } - if (other.Name.Length != 0) { + if (other.HasName) { Name = other.Name; } - if (other.Package.Length != 0) { + if (other.HasPackage) { Package = other.Package; } dependency_.Add(other.dependency_); @@ -570,29 +709,31 @@ public void MergeFrom(FileDescriptorProto other) { enumType_.Add(other.enumType_); service_.Add(other.service_); extension_.Add(other.extension_); - if (other.options_ != null) { - if (options_ == null) { - options_ = new global::Google.Protobuf.Reflection.FileOptions(); + if (other.HasOptions) { + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.FileOptions(); } Options.MergeFrom(other.Options); } - if (other.sourceCodeInfo_ != null) { - if (sourceCodeInfo_ == null) { - sourceCodeInfo_ = new global::Google.Protobuf.Reflection.SourceCodeInfo(); + if (other.HasSourceCodeInfo) { + if (!HasSourceCodeInfo) { + SourceCodeInfo = new global::Google.Protobuf.Reflection.SourceCodeInfo(); } SourceCodeInfo.MergeFrom(other.SourceCodeInfo); } - if (other.Syntax.Length != 0) { + if (other.HasSyntax) { Syntax = other.Syntax; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Name = input.ReadString(); @@ -623,17 +764,17 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 66: { - if (options_ == null) { - options_ = new global::Google.Protobuf.Reflection.FileOptions(); + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.FileOptions(); } - input.ReadMessage(options_); + input.ReadMessage(Options); break; } case 74: { - if (sourceCodeInfo_ == null) { - sourceCodeInfo_ = new global::Google.Protobuf.Reflection.SourceCodeInfo(); + if (!HasSourceCodeInfo) { + SourceCodeInfo = new global::Google.Protobuf.Reflection.SourceCodeInfo(); } - input.ReadMessage(sourceCodeInfo_); + input.ReadMessage(SourceCodeInfo); break; } case 82: @@ -657,27 +798,32 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Describes a message type. + /// Describes a message type. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal sealed partial class DescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DescriptorProto()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[2]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public DescriptorProto() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public DescriptorProto(DescriptorProto other) : this() { name_ = other.name_; field_ = other.field_.Clone(); @@ -686,30 +832,46 @@ public DescriptorProto(DescriptorProto other) : this() { enumType_ = other.enumType_.Clone(); extensionRange_ = other.extensionRange_.Clone(); oneofDecl_ = other.oneofDecl_.Clone(); - Options = other.options_ != null ? other.Options.Clone() : null; + options_ = other.HasOptions ? other.options_.Clone() : null; reservedRange_ = other.reservedRange_.Clone(); reservedName_ = other.reservedName_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public DescriptorProto Clone() { return new DescriptorProto(this); } /// Field number for the "name" field. public const int NameFieldNumber = 1; - private string name_ = ""; + private readonly static string NameDefaultValue = ""; + + private string name_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { - get { return name_; } + get { return name_ ?? NameDefaultValue; } set { name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "name" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasName { + get { return name_ != null; } + } + /// Clears the value of the "name" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearName() { + name_ = null; + } /// Field number for the "field" field. public const int FieldFieldNumber = 2; private static readonly pb::FieldCodec _repeated_field_codec = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.Reflection.FieldDescriptorProto.Parser); private readonly pbc::RepeatedField field_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Field { get { return field_; } } @@ -719,6 +881,7 @@ public string Name { private static readonly pb::FieldCodec _repeated_extension_codec = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.Reflection.FieldDescriptorProto.Parser); private readonly pbc::RepeatedField extension_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Extension { get { return extension_; } } @@ -728,6 +891,7 @@ public string Name { private static readonly pb::FieldCodec _repeated_nestedType_codec = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.Reflection.DescriptorProto.Parser); private readonly pbc::RepeatedField nestedType_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField NestedType { get { return nestedType_; } } @@ -737,6 +901,7 @@ public string Name { private static readonly pb::FieldCodec _repeated_enumType_codec = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.Reflection.EnumDescriptorProto.Parser); private readonly pbc::RepeatedField enumType_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField EnumType { get { return enumType_; } } @@ -746,6 +911,7 @@ public string Name { private static readonly pb::FieldCodec _repeated_extensionRange_codec = pb::FieldCodec.ForMessage(42, global::Google.Protobuf.Reflection.DescriptorProto.Types.ExtensionRange.Parser); private readonly pbc::RepeatedField extensionRange_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField ExtensionRange { get { return extensionRange_; } } @@ -755,6 +921,7 @@ public string Name { private static readonly pb::FieldCodec _repeated_oneofDecl_codec = pb::FieldCodec.ForMessage(66, global::Google.Protobuf.Reflection.OneofDescriptorProto.Parser); private readonly pbc::RepeatedField oneofDecl_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField OneofDecl { get { return oneofDecl_; } } @@ -762,18 +929,30 @@ public string Name { /// Field number for the "options" field. public const int OptionsFieldNumber = 7; private global::Google.Protobuf.Reflection.MessageOptions options_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.Reflection.MessageOptions Options { get { return options_; } set { options_ = value; } } + /// Gets whether the options field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasOptions { + get { return options_ != null; } + } + /// Clears the value of the options field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearOptions() { + options_ = null; + } /// Field number for the "reserved_range" field. public const int ReservedRangeFieldNumber = 9; private static readonly pb::FieldCodec _repeated_reservedRange_codec = pb::FieldCodec.ForMessage(74, global::Google.Protobuf.Reflection.DescriptorProto.Types.ReservedRange.Parser); private readonly pbc::RepeatedField reservedRange_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField ReservedRange { get { return reservedRange_; } } @@ -784,17 +963,20 @@ public string Name { = pb::FieldCodec.ForString(82); private readonly pbc::RepeatedField reservedName_ = new pbc::RepeatedField(); /// - /// Reserved field names, which may not be used by fields in the same message. - /// A given name may only be reserved once. + /// Reserved field names, which may not be used by fields in the same message. + /// A given name may only be reserved once. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField ReservedName { get { return reservedName_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as DescriptorProto); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(DescriptorProto other) { if (ReferenceEquals(other, null)) { return false; @@ -812,30 +994,36 @@ public bool Equals(DescriptorProto other) { if (!object.Equals(Options, other.Options)) return false; if(!reservedRange_.Equals(other.reservedRange_)) return false; if(!reservedName_.Equals(other.reservedName_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (HasName) hash ^= Name.GetHashCode(); hash ^= field_.GetHashCode(); hash ^= extension_.GetHashCode(); hash ^= nestedType_.GetHashCode(); hash ^= enumType_.GetHashCode(); hash ^= extensionRange_.GetHashCode(); hash ^= oneofDecl_.GetHashCode(); - if (options_ != null) hash ^= Options.GetHashCode(); + if (HasOptions) hash ^= Options.GetHashCode(); hash ^= reservedRange_.GetHashCode(); hash ^= reservedName_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (Name.Length != 0) { + if (HasName) { output.WriteRawTag(10); output.WriteString(Name); } @@ -844,18 +1032,22 @@ public void WriteTo(pb::CodedOutputStream output) { enumType_.WriteTo(output, _repeated_enumType_codec); extensionRange_.WriteTo(output, _repeated_extensionRange_codec); extension_.WriteTo(output, _repeated_extension_codec); - if (options_ != null) { + if (HasOptions) { output.WriteRawTag(58); output.WriteMessage(Options); } oneofDecl_.WriteTo(output, _repeated_oneofDecl_codec); reservedRange_.WriteTo(output, _repeated_reservedRange_codec); reservedName_.WriteTo(output, _repeated_reservedName_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (Name.Length != 0) { + if (HasName) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } size += field_.CalculateSize(_repeated_field_codec); @@ -864,19 +1056,23 @@ public int CalculateSize() { size += enumType_.CalculateSize(_repeated_enumType_codec); size += extensionRange_.CalculateSize(_repeated_extensionRange_codec); size += oneofDecl_.CalculateSize(_repeated_oneofDecl_codec); - if (options_ != null) { + if (HasOptions) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } size += reservedRange_.CalculateSize(_repeated_reservedRange_codec); size += reservedName_.CalculateSize(_repeated_reservedName_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(DescriptorProto other) { if (other == null) { return; } - if (other.Name.Length != 0) { + if (other.HasName) { Name = other.Name; } field_.Add(other.field_); @@ -885,22 +1081,24 @@ public void MergeFrom(DescriptorProto other) { enumType_.Add(other.enumType_); extensionRange_.Add(other.extensionRange_); oneofDecl_.Add(other.oneofDecl_); - if (other.options_ != null) { - if (options_ == null) { - options_ = new global::Google.Protobuf.Reflection.MessageOptions(); + if (other.HasOptions) { + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.MessageOptions(); } Options.MergeFrom(other.Options); } reservedRange_.Add(other.reservedRange_); reservedName_.Add(other.reservedName_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Name = input.ReadString(); @@ -927,10 +1125,10 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 58: { - if (options_ == null) { - options_ = new global::Google.Protobuf.Reflection.MessageOptions(); + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.MessageOptions(); } - input.ReadMessage(options_); + input.ReadMessage(Options); break; } case 66: { @@ -951,60 +1149,127 @@ public void MergeFrom(pb::CodedInputStream input) { #region Nested types /// Container for nested types declared in the DescriptorProto message type. - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal sealed partial class ExtensionRange : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ExtensionRange()); + private pb::UnknownFieldSet _unknownFields; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.Reflection.DescriptorProto.Descriptor.NestedTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ExtensionRange() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ExtensionRange(ExtensionRange other) : this() { + _hasBits0 = other._hasBits0; start_ = other.start_; end_ = other.end_; + options_ = other.HasOptions ? other.options_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ExtensionRange Clone() { return new ExtensionRange(this); } /// Field number for the "start" field. public const int StartFieldNumber = 1; + private readonly static int StartDefaultValue = 0; + private int start_; + /// + /// Inclusive. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Start { - get { return start_; } + get { if ((_hasBits0 & 1) != 0) { return start_; } else { return StartDefaultValue; } } set { + _hasBits0 |= 1; start_ = value; } } + /// Gets whether the "start" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasStart { + get { return (_hasBits0 & 1) != 0; } + } + /// Clears the value of the "start" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearStart() { + _hasBits0 &= ~1; + } /// Field number for the "end" field. public const int EndFieldNumber = 2; + private readonly static int EndDefaultValue = 0; + private int end_; + /// + /// Exclusive. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int End { - get { return end_; } + get { if ((_hasBits0 & 2) != 0) { return end_; } else { return EndDefaultValue; } } set { + _hasBits0 |= 2; end_ = value; } } + /// Gets whether the "end" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasEnd { + get { return (_hasBits0 & 2) != 0; } + } + /// Clears the value of the "end" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearEnd() { + _hasBits0 &= ~2; + } + + /// Field number for the "options" field. + public const int OptionsFieldNumber = 3; + private global::Google.Protobuf.Reflection.ExtensionRangeOptions options_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.Reflection.ExtensionRangeOptions Options { + get { return options_; } + set { + options_ = value; + } + } + /// Gets whether the options field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasOptions { + get { return options_ != null; } + } + /// Clears the value of the options field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearOptions() { + options_ = null; + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ExtensionRange); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(ExtensionRange other) { if (ReferenceEquals(other, null)) { return false; @@ -1014,60 +1279,91 @@ public bool Equals(ExtensionRange other) { } if (Start != other.Start) return false; if (End != other.End) return false; - return true; + if (!object.Equals(Options, other.Options)) return false; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (Start != 0) hash ^= Start.GetHashCode(); - if (End != 0) hash ^= End.GetHashCode(); + if (HasStart) hash ^= Start.GetHashCode(); + if (HasEnd) hash ^= End.GetHashCode(); + if (HasOptions) hash ^= Options.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (Start != 0) { + if (HasStart) { output.WriteRawTag(8); output.WriteInt32(Start); } - if (End != 0) { + if (HasEnd) { output.WriteRawTag(16); output.WriteInt32(End); } + if (HasOptions) { + output.WriteRawTag(26); + output.WriteMessage(Options); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (Start != 0) { + if (HasStart) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(Start); } - if (End != 0) { + if (HasEnd) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(End); } + if (HasOptions) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(ExtensionRange other) { if (other == null) { return; } - if (other.Start != 0) { + if (other.HasStart) { Start = other.Start; } - if (other.End != 0) { + if (other.HasEnd) { End = other.End; } + if (other.HasOptions) { + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.ExtensionRangeOptions(); + } + Options.MergeFrom(other.Options); + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { Start = input.ReadInt32(); @@ -1077,6 +1373,13 @@ public void MergeFrom(pb::CodedInputStream input) { End = input.ReadInt32(); break; } + case 26: { + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.ExtensionRangeOptions(); + } + input.ReadMessage(Options); + break; + } } } } @@ -1084,68 +1387,107 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Range of reserved tag numbers. Reserved tag numbers may not be used by - /// fields or extension ranges in the same message. Reserved ranges may - /// not overlap. + /// Range of reserved tag numbers. Reserved tag numbers may not be used by + /// fields or extension ranges in the same message. Reserved ranges may + /// not overlap. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal sealed partial class ReservedRange : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ReservedRange()); + private pb::UnknownFieldSet _unknownFields; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.Reflection.DescriptorProto.Descriptor.NestedTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ReservedRange() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ReservedRange(ReservedRange other) : this() { + _hasBits0 = other._hasBits0; start_ = other.start_; end_ = other.end_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ReservedRange Clone() { return new ReservedRange(this); } /// Field number for the "start" field. public const int StartFieldNumber = 1; + private readonly static int StartDefaultValue = 0; + private int start_; /// - /// Inclusive. + /// Inclusive. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Start { - get { return start_; } + get { if ((_hasBits0 & 1) != 0) { return start_; } else { return StartDefaultValue; } } set { + _hasBits0 |= 1; start_ = value; } } + /// Gets whether the "start" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasStart { + get { return (_hasBits0 & 1) != 0; } + } + /// Clears the value of the "start" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearStart() { + _hasBits0 &= ~1; + } /// Field number for the "end" field. public const int EndFieldNumber = 2; + private readonly static int EndDefaultValue = 0; + private int end_; /// - /// Exclusive. + /// Exclusive. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int End { - get { return end_; } + get { if ((_hasBits0 & 2) != 0) { return end_; } else { return EndDefaultValue; } } set { + _hasBits0 |= 2; end_ = value; } } + /// Gets whether the "end" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasEnd { + get { return (_hasBits0 & 2) != 0; } + } + /// Clears the value of the "end" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearEnd() { + _hasBits0 &= ~2; + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ReservedRange); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(ReservedRange other) { if (ReferenceEquals(other, null)) { return false; @@ -1155,60 +1497,76 @@ public bool Equals(ReservedRange other) { } if (Start != other.Start) return false; if (End != other.End) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (Start != 0) hash ^= Start.GetHashCode(); - if (End != 0) hash ^= End.GetHashCode(); + if (HasStart) hash ^= Start.GetHashCode(); + if (HasEnd) hash ^= End.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (Start != 0) { + if (HasStart) { output.WriteRawTag(8); output.WriteInt32(Start); } - if (End != 0) { + if (HasEnd) { output.WriteRawTag(16); output.WriteInt32(End); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (Start != 0) { + if (HasStart) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(Start); } - if (End != 0) { + if (HasEnd) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(End); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(ReservedRange other) { if (other == null) { return; } - if (other.Start != 0) { + if (other.HasStart) { Start = other.Start; } - if (other.End != 0) { + if (other.HasEnd) { End = other.End; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { Start = input.ReadInt32(); @@ -1229,29 +1587,199 @@ public void MergeFrom(pb::CodedInputStream input) { } + internal sealed partial class ExtensionRangeOptions : pb::IExtendableMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ExtensionRangeOptions()); + private pb::UnknownFieldSet _unknownFields; + internal pb::ExtensionSet _extensions; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[3]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExtensionRangeOptions() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExtensionRangeOptions(ExtensionRangeOptions other) : this() { + uninterpretedOption_ = other.uninterpretedOption_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + _extensions = pb::ExtensionSet.Clone(other._extensions); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExtensionRangeOptions Clone() { + return new ExtensionRangeOptions(this); + } + + /// Field number for the "uninterpreted_option" field. + public const int UninterpretedOptionFieldNumber = 999; + private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); + private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); + /// + /// The parser stores options it doesn't recognize here. See above. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField UninterpretedOption { + get { return uninterpretedOption_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ExtensionRangeOptions); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ExtensionRangeOptions other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; + if (!Equals(_extensions, other._extensions)) { + return false; + } + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + hash ^= uninterpretedOption_.GetHashCode(); + if (_extensions != null) { + hash ^= _extensions.GetHashCode(); + } + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); + if (_extensions != null) { + _extensions.WriteTo(output); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); + if (_extensions != null) { + size += _extensions.CalculateSize(); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ExtensionRangeOptions other) { + if (other == null) { + return; + } + uninterpretedOption_.Add(other.uninterpretedOption_); + pb::ExtensionSet.MergeFrom(ref _extensions, other._extensions); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + } + break; + case 7994: { + uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); + break; + } + } + } + } + + public TValue GetExtension(pb::Extension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetOrRegisterExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.GetOrRegister(ref _extensions, extension); + } + public void SetExtension(pb::Extension extension, TValue value) { + pb::ExtensionSet.Set(ref _extensions, extension, value); + } + public bool HasExtension(pb::Extension extension) { + return pb::ExtensionSet.Has(ref _extensions, extension); + } + public void ClearExtension(pb::Extension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); + } + public void ClearExtension(pb::RepeatedExtension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); + } + + } + /// - /// Describes a field within a message. + /// Describes a field within a message. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal sealed partial class FieldDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FieldDescriptorProto()); + private pb::UnknownFieldSet _unknownFields; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[3]; } + get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[4]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FieldDescriptorProto() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FieldDescriptorProto(FieldDescriptorProto other) : this() { + _hasBits0 = other._hasBits0; name_ = other.name_; number_ = other.number_; label_ = other.label_; @@ -1261,149 +1789,285 @@ public FieldDescriptorProto(FieldDescriptorProto other) : this() { defaultValue_ = other.defaultValue_; oneofIndex_ = other.oneofIndex_; jsonName_ = other.jsonName_; - Options = other.options_ != null ? other.Options.Clone() : null; + options_ = other.HasOptions ? other.options_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FieldDescriptorProto Clone() { return new FieldDescriptorProto(this); } /// Field number for the "name" field. public const int NameFieldNumber = 1; - private string name_ = ""; + private readonly static string NameDefaultValue = ""; + + private string name_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { - get { return name_; } + get { return name_ ?? NameDefaultValue; } set { name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "name" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasName { + get { return name_ != null; } + } + /// Clears the value of the "name" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearName() { + name_ = null; + } /// Field number for the "number" field. public const int NumberFieldNumber = 3; + private readonly static int NumberDefaultValue = 0; + private int number_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Number { - get { return number_; } + get { if ((_hasBits0 & 1) != 0) { return number_; } else { return NumberDefaultValue; } } set { + _hasBits0 |= 1; number_ = value; } } + /// Gets whether the "number" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasNumber { + get { return (_hasBits0 & 1) != 0; } + } + /// Clears the value of the "number" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearNumber() { + _hasBits0 &= ~1; + } /// Field number for the "label" field. public const int LabelFieldNumber = 4; - private global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label label_ = 0; + private readonly static global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label LabelDefaultValue = global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.Optional; + + private global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label label_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label Label { - get { return label_; } + get { if ((_hasBits0 & 2) != 0) { return label_; } else { return LabelDefaultValue; } } set { + _hasBits0 |= 2; label_ = value; } } + /// Gets whether the "label" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasLabel { + get { return (_hasBits0 & 2) != 0; } + } + /// Clears the value of the "label" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearLabel() { + _hasBits0 &= ~2; + } /// Field number for the "type" field. public const int TypeFieldNumber = 5; - private global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type type_ = 0; + private readonly static global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type TypeDefaultValue = global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.Double; + + private global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type type_; /// - /// If type_name is set, this need not be set. If both this and type_name - /// are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + /// If type_name is set, this need not be set. If both this and type_name + /// are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type Type { - get { return type_; } + get { if ((_hasBits0 & 4) != 0) { return type_; } else { return TypeDefaultValue; } } set { + _hasBits0 |= 4; type_ = value; } } + /// Gets whether the "type" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasType { + get { return (_hasBits0 & 4) != 0; } + } + /// Clears the value of the "type" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearType() { + _hasBits0 &= ~4; + } /// Field number for the "type_name" field. public const int TypeNameFieldNumber = 6; - private string typeName_ = ""; + private readonly static string TypeNameDefaultValue = ""; + + private string typeName_; /// - /// For message and enum types, this is the name of the type. If the name - /// starts with a '.', it is fully-qualified. Otherwise, C++-like scoping - /// rules are used to find the type (i.e. first the nested types within this - /// message are searched, then within the parent, on up to the root - /// namespace). + /// For message and enum types, this is the name of the type. If the name + /// starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + /// rules are used to find the type (i.e. first the nested types within this + /// message are searched, then within the parent, on up to the root + /// namespace). /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string TypeName { - get { return typeName_; } + get { return typeName_ ?? TypeNameDefaultValue; } set { typeName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "type_name" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasTypeName { + get { return typeName_ != null; } + } + /// Clears the value of the "type_name" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearTypeName() { + typeName_ = null; + } /// Field number for the "extendee" field. public const int ExtendeeFieldNumber = 2; - private string extendee_ = ""; + private readonly static string ExtendeeDefaultValue = ""; + + private string extendee_; /// - /// For extensions, this is the name of the type being extended. It is - /// resolved in the same manner as type_name. + /// For extensions, this is the name of the type being extended. It is + /// resolved in the same manner as type_name. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Extendee { - get { return extendee_; } + get { return extendee_ ?? ExtendeeDefaultValue; } set { extendee_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "extendee" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasExtendee { + get { return extendee_ != null; } + } + /// Clears the value of the "extendee" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearExtendee() { + extendee_ = null; + } /// Field number for the "default_value" field. public const int DefaultValueFieldNumber = 7; - private string defaultValue_ = ""; + private readonly static string DefaultValueDefaultValue = ""; + + private string defaultValue_; /// - /// For numeric types, contains the original text representation of the value. - /// For booleans, "true" or "false". - /// For strings, contains the default text contents (not escaped in any way). - /// For bytes, contains the C escaped value. All bytes >= 128 are escaped. - /// TODO(kenton): Base-64 encode? + /// For numeric types, contains the original text representation of the value. + /// For booleans, "true" or "false". + /// For strings, contains the default text contents (not escaped in any way). + /// For bytes, contains the C escaped value. All bytes >= 128 are escaped. + /// TODO(kenton): Base-64 encode? /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string DefaultValue { - get { return defaultValue_; } + get { return defaultValue_ ?? DefaultValueDefaultValue; } set { defaultValue_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "default_value" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasDefaultValue { + get { return defaultValue_ != null; } + } + /// Clears the value of the "default_value" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearDefaultValue() { + defaultValue_ = null; + } /// Field number for the "oneof_index" field. public const int OneofIndexFieldNumber = 9; + private readonly static int OneofIndexDefaultValue = 0; + private int oneofIndex_; /// - /// If set, gives the index of a oneof in the containing type's oneof_decl - /// list. This field is a member of that oneof. + /// If set, gives the index of a oneof in the containing type's oneof_decl + /// list. This field is a member of that oneof. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int OneofIndex { - get { return oneofIndex_; } + get { if ((_hasBits0 & 8) != 0) { return oneofIndex_; } else { return OneofIndexDefaultValue; } } set { + _hasBits0 |= 8; oneofIndex_ = value; } } + /// Gets whether the "oneof_index" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasOneofIndex { + get { return (_hasBits0 & 8) != 0; } + } + /// Clears the value of the "oneof_index" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearOneofIndex() { + _hasBits0 &= ~8; + } /// Field number for the "json_name" field. public const int JsonNameFieldNumber = 10; - private string jsonName_ = ""; + private readonly static string JsonNameDefaultValue = ""; + + private string jsonName_; /// - /// JSON name of this field. The value is set by protocol compiler. If the - /// user has set a "json_name" option on this field, that option's value - /// will be used. Otherwise, it's deduced from the field's name by converting - /// it to camelCase. + /// JSON name of this field. The value is set by protocol compiler. If the + /// user has set a "json_name" option on this field, that option's value + /// will be used. Otherwise, it's deduced from the field's name by converting + /// it to camelCase. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string JsonName { - get { return jsonName_; } + get { return jsonName_ ?? JsonNameDefaultValue; } set { jsonName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "json_name" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasJsonName { + get { return jsonName_ != null; } + } + /// Clears the value of the "json_name" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearJsonName() { + jsonName_ = null; + } /// Field number for the "options" field. public const int OptionsFieldNumber = 8; private global::Google.Protobuf.Reflection.FieldOptions options_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.Reflection.FieldOptions Options { get { return options_; } set { options_ = value; } } + /// Gets whether the options field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasOptions { + get { return options_ != null; } + } + /// Clears the value of the options field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearOptions() { + options_ = null; + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as FieldDescriptorProto); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(FieldDescriptorProto other) { if (ReferenceEquals(other, null)) { return false; @@ -1421,151 +2085,167 @@ public bool Equals(FieldDescriptorProto other) { if (OneofIndex != other.OneofIndex) return false; if (JsonName != other.JsonName) return false; if (!object.Equals(Options, other.Options)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (Name.Length != 0) hash ^= Name.GetHashCode(); - if (Number != 0) hash ^= Number.GetHashCode(); - if (Label != 0) hash ^= Label.GetHashCode(); - if (Type != 0) hash ^= Type.GetHashCode(); - if (TypeName.Length != 0) hash ^= TypeName.GetHashCode(); - if (Extendee.Length != 0) hash ^= Extendee.GetHashCode(); - if (DefaultValue.Length != 0) hash ^= DefaultValue.GetHashCode(); - if (OneofIndex != 0) hash ^= OneofIndex.GetHashCode(); - if (JsonName.Length != 0) hash ^= JsonName.GetHashCode(); - if (options_ != null) hash ^= Options.GetHashCode(); + if (HasName) hash ^= Name.GetHashCode(); + if (HasNumber) hash ^= Number.GetHashCode(); + if (HasLabel) hash ^= Label.GetHashCode(); + if (HasType) hash ^= Type.GetHashCode(); + if (HasTypeName) hash ^= TypeName.GetHashCode(); + if (HasExtendee) hash ^= Extendee.GetHashCode(); + if (HasDefaultValue) hash ^= DefaultValue.GetHashCode(); + if (HasOneofIndex) hash ^= OneofIndex.GetHashCode(); + if (HasJsonName) hash ^= JsonName.GetHashCode(); + if (HasOptions) hash ^= Options.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (Name.Length != 0) { + if (HasName) { output.WriteRawTag(10); output.WriteString(Name); } - if (Extendee.Length != 0) { + if (HasExtendee) { output.WriteRawTag(18); output.WriteString(Extendee); } - if (Number != 0) { + if (HasNumber) { output.WriteRawTag(24); output.WriteInt32(Number); } - if (Label != 0) { + if (HasLabel) { output.WriteRawTag(32); output.WriteEnum((int) Label); } - if (Type != 0) { + if (HasType) { output.WriteRawTag(40); output.WriteEnum((int) Type); } - if (TypeName.Length != 0) { + if (HasTypeName) { output.WriteRawTag(50); output.WriteString(TypeName); } - if (DefaultValue.Length != 0) { + if (HasDefaultValue) { output.WriteRawTag(58); output.WriteString(DefaultValue); } - if (options_ != null) { + if (HasOptions) { output.WriteRawTag(66); output.WriteMessage(Options); } - if (OneofIndex != 0) { + if (HasOneofIndex) { output.WriteRawTag(72); output.WriteInt32(OneofIndex); } - if (JsonName.Length != 0) { + if (HasJsonName) { output.WriteRawTag(82); output.WriteString(JsonName); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (Name.Length != 0) { + if (HasName) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } - if (Number != 0) { + if (HasNumber) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number); } - if (Label != 0) { + if (HasLabel) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Label); } - if (Type != 0) { + if (HasType) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type); } - if (TypeName.Length != 0) { + if (HasTypeName) { size += 1 + pb::CodedOutputStream.ComputeStringSize(TypeName); } - if (Extendee.Length != 0) { + if (HasExtendee) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Extendee); } - if (DefaultValue.Length != 0) { + if (HasDefaultValue) { size += 1 + pb::CodedOutputStream.ComputeStringSize(DefaultValue); } - if (OneofIndex != 0) { + if (HasOneofIndex) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(OneofIndex); } - if (JsonName.Length != 0) { + if (HasJsonName) { size += 1 + pb::CodedOutputStream.ComputeStringSize(JsonName); } - if (options_ != null) { + if (HasOptions) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(FieldDescriptorProto other) { if (other == null) { return; } - if (other.Name.Length != 0) { + if (other.HasName) { Name = other.Name; } - if (other.Number != 0) { + if (other.HasNumber) { Number = other.Number; } - if (other.Label != 0) { + if (other.HasLabel) { Label = other.Label; } - if (other.Type != 0) { + if (other.HasType) { Type = other.Type; } - if (other.TypeName.Length != 0) { + if (other.HasTypeName) { TypeName = other.TypeName; } - if (other.Extendee.Length != 0) { + if (other.HasExtendee) { Extendee = other.Extendee; } - if (other.DefaultValue.Length != 0) { + if (other.HasDefaultValue) { DefaultValue = other.DefaultValue; } - if (other.OneofIndex != 0) { + if (other.HasOneofIndex) { OneofIndex = other.OneofIndex; } - if (other.JsonName.Length != 0) { + if (other.HasJsonName) { JsonName = other.JsonName; } - if (other.options_ != null) { - if (options_ == null) { - options_ = new global::Google.Protobuf.Reflection.FieldOptions(); + if (other.HasOptions) { + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.FieldOptions(); } Options.MergeFrom(other.Options); } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Name = input.ReadString(); @@ -1580,11 +2260,11 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 32: { - label_ = (global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label) input.ReadEnum(); + Label = (global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label) input.ReadEnum(); break; } case 40: { - type_ = (global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type) input.ReadEnum(); + Type = (global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type) input.ReadEnum(); break; } case 50: { @@ -1596,10 +2276,10 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 66: { - if (options_ == null) { - options_ = new global::Google.Protobuf.Reflection.FieldOptions(); + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.FieldOptions(); } - input.ReadMessage(options_); + input.ReadMessage(Options); break; } case 72: { @@ -1616,24 +2296,24 @@ public void MergeFrom(pb::CodedInputStream input) { #region Nested types /// Container for nested types declared in the FieldDescriptorProto message type. - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { internal enum Type { /// - /// 0 is reserved for errors. - /// Order is weird for historical reasons. + /// 0 is reserved for errors. + /// Order is weird for historical reasons. /// [pbr::OriginalName("TYPE_DOUBLE")] Double = 1, [pbr::OriginalName("TYPE_FLOAT")] Float = 2, /// - /// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if - /// negative values are likely. + /// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + /// negative values are likely. /// [pbr::OriginalName("TYPE_INT64")] Int64 = 3, [pbr::OriginalName("TYPE_UINT64")] Uint64 = 4, /// - /// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if - /// negative values are likely. + /// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + /// negative values are likely. /// [pbr::OriginalName("TYPE_INT32")] Int32 = 5, [pbr::OriginalName("TYPE_FIXED64")] Fixed64 = 6, @@ -1641,15 +2321,18 @@ internal enum Type { [pbr::OriginalName("TYPE_BOOL")] Bool = 8, [pbr::OriginalName("TYPE_STRING")] String = 9, /// - /// Tag-delimited aggregate. + /// Tag-delimited aggregate. + /// Group type is deprecated and not supported in proto3. However, Proto3 + /// implementations should still be able to parse the group wire format and + /// treat group fields as unknown fields. /// [pbr::OriginalName("TYPE_GROUP")] Group = 10, /// - /// Length-delimited aggregate. + /// Length-delimited aggregate. /// [pbr::OriginalName("TYPE_MESSAGE")] Message = 11, /// - /// New in version 2. + /// New in version 2. /// [pbr::OriginalName("TYPE_BYTES")] Bytes = 12, [pbr::OriginalName("TYPE_UINT32")] Uint32 = 13, @@ -1657,24 +2340,21 @@ internal enum Type { [pbr::OriginalName("TYPE_SFIXED32")] Sfixed32 = 15, [pbr::OriginalName("TYPE_SFIXED64")] Sfixed64 = 16, /// - /// Uses ZigZag encoding. + /// Uses ZigZag encoding. /// [pbr::OriginalName("TYPE_SINT32")] Sint32 = 17, /// - /// Uses ZigZag encoding. + /// Uses ZigZag encoding. /// [pbr::OriginalName("TYPE_SINT64")] Sint64 = 18, } internal enum Label { /// - /// 0 is reserved for errors + /// 0 is reserved for errors /// [pbr::OriginalName("LABEL_OPTIONAL")] Optional = 1, [pbr::OriginalName("LABEL_REQUIRED")] Required = 2, - /// - /// TODO(sanjay): Should we add LABEL_MAP? - /// [pbr::OriginalName("LABEL_REPEATED")] Repeated = 3, } @@ -1684,49 +2364,93 @@ internal enum Label { } /// - /// Describes a oneof. + /// Describes a oneof. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal sealed partial class OneofDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneofDescriptorProto()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[4]; } + get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[5]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public OneofDescriptorProto() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public OneofDescriptorProto(OneofDescriptorProto other) : this() { name_ = other.name_; + options_ = other.HasOptions ? other.options_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public OneofDescriptorProto Clone() { return new OneofDescriptorProto(this); } /// Field number for the "name" field. public const int NameFieldNumber = 1; - private string name_ = ""; + private readonly static string NameDefaultValue = ""; + + private string name_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { - get { return name_; } + get { return name_ ?? NameDefaultValue; } set { name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "name" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasName { + get { return name_ != null; } + } + /// Clears the value of the "name" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearName() { + name_ = null; + } + + /// Field number for the "options" field. + public const int OptionsFieldNumber = 2; + private global::Google.Protobuf.Reflection.OneofOptions options_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.Reflection.OneofOptions Options { + get { return options_; } + set { + options_ = value; + } + } + /// Gets whether the options field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasOptions { + get { return options_ != null; } + } + /// Clears the value of the options field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearOptions() { + options_ = null; + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as OneofDescriptorProto); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(OneofDescriptorProto other) { if (ReferenceEquals(other, null)) { return false; @@ -1735,54 +2459,92 @@ public bool Equals(OneofDescriptorProto other) { return true; } if (Name != other.Name) return false; - return true; + if (!object.Equals(Options, other.Options)) return false; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (HasName) hash ^= Name.GetHashCode(); + if (HasOptions) hash ^= Options.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (Name.Length != 0) { + if (HasName) { output.WriteRawTag(10); output.WriteString(Name); } + if (HasOptions) { + output.WriteRawTag(18); + output.WriteMessage(Options); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (Name.Length != 0) { + if (HasName) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } + if (HasOptions) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(OneofDescriptorProto other) { if (other == null) { return; } - if (other.Name.Length != 0) { + if (other.HasName) { Name = other.Name; } + if (other.HasOptions) { + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.OneofOptions(); + } + Options.MergeFrom(other.Options); + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Name = input.ReadString(); break; } + case 18: { + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.OneofOptions(); + } + input.ReadMessage(Options); + break; + } } } } @@ -1790,52 +2552,75 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Describes an enum type. + /// Describes an enum type. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal sealed partial class EnumDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumDescriptorProto()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[5]; } + get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[6]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public EnumDescriptorProto() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public EnumDescriptorProto(EnumDescriptorProto other) : this() { name_ = other.name_; value_ = other.value_.Clone(); - Options = other.options_ != null ? other.Options.Clone() : null; + options_ = other.HasOptions ? other.options_.Clone() : null; + reservedRange_ = other.reservedRange_.Clone(); + reservedName_ = other.reservedName_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public EnumDescriptorProto Clone() { return new EnumDescriptorProto(this); } /// Field number for the "name" field. public const int NameFieldNumber = 1; - private string name_ = ""; + private readonly static string NameDefaultValue = ""; + + private string name_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { - get { return name_; } + get { return name_ ?? NameDefaultValue; } set { name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "name" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasName { + get { return name_ != null; } + } + /// Clears the value of the "name" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearName() { + name_ = null; + } /// Field number for the "value" field. public const int ValueFieldNumber = 2; private static readonly pb::FieldCodec _repeated_value_codec = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.Reflection.EnumValueDescriptorProto.Parser); private readonly pbc::RepeatedField value_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Value { get { return value_; } } @@ -1843,88 +2628,156 @@ public string Name { /// Field number for the "options" field. public const int OptionsFieldNumber = 3; private global::Google.Protobuf.Reflection.EnumOptions options_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.Reflection.EnumOptions Options { get { return options_; } set { options_ = value; } } - - public override bool Equals(object other) { - return Equals(other as EnumDescriptorProto); + /// Gets whether the options field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasOptions { + get { return options_ != null; } } - - public bool Equals(EnumDescriptorProto other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Name != other.Name) return false; - if(!value_.Equals(other.value_)) return false; - if (!object.Equals(Options, other.Options)) return false; - return true; + /// Clears the value of the options field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearOptions() { + options_ = null; } + /// Field number for the "reserved_range" field. + public const int ReservedRangeFieldNumber = 4; + private static readonly pb::FieldCodec _repeated_reservedRange_codec + = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.Reflection.EnumDescriptorProto.Types.EnumReservedRange.Parser); + private readonly pbc::RepeatedField reservedRange_ = new pbc::RepeatedField(); + /// + /// Range of reserved numeric values. Reserved numeric values may not be used + /// by enum values in the same enum declaration. Reserved ranges may not + /// overlap. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField ReservedRange { + get { return reservedRange_; } + } + + /// Field number for the "reserved_name" field. + public const int ReservedNameFieldNumber = 5; + private static readonly pb::FieldCodec _repeated_reservedName_codec + = pb::FieldCodec.ForString(42); + private readonly pbc::RepeatedField reservedName_ = new pbc::RepeatedField(); + /// + /// Reserved enum value names, which may not be reused. A given name may only + /// be reserved once. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField ReservedName { + get { return reservedName_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as EnumDescriptorProto); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(EnumDescriptorProto other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if(!value_.Equals(other.value_)) return false; + if (!object.Equals(Options, other.Options)) return false; + if(!reservedRange_.Equals(other.reservedRange_)) return false; + if(!reservedName_.Equals(other.reservedName_)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (HasName) hash ^= Name.GetHashCode(); hash ^= value_.GetHashCode(); - if (options_ != null) hash ^= Options.GetHashCode(); + if (HasOptions) hash ^= Options.GetHashCode(); + hash ^= reservedRange_.GetHashCode(); + hash ^= reservedName_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (Name.Length != 0) { + if (HasName) { output.WriteRawTag(10); output.WriteString(Name); } value_.WriteTo(output, _repeated_value_codec); - if (options_ != null) { + if (HasOptions) { output.WriteRawTag(26); output.WriteMessage(Options); } + reservedRange_.WriteTo(output, _repeated_reservedRange_codec); + reservedName_.WriteTo(output, _repeated_reservedName_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (Name.Length != 0) { + if (HasName) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } size += value_.CalculateSize(_repeated_value_codec); - if (options_ != null) { + if (HasOptions) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } + size += reservedRange_.CalculateSize(_repeated_reservedRange_codec); + size += reservedName_.CalculateSize(_repeated_reservedName_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(EnumDescriptorProto other) { if (other == null) { return; } - if (other.Name.Length != 0) { + if (other.HasName) { Name = other.Name; } value_.Add(other.value_); - if (other.options_ != null) { - if (options_ == null) { - options_ = new global::Google.Protobuf.Reflection.EnumOptions(); + if (other.HasOptions) { + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.EnumOptions(); } Options.MergeFrom(other.Options); } + reservedRange_.Add(other.reservedRange_); + reservedName_.Add(other.reservedName_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Name = input.ReadString(); @@ -1935,84 +2788,347 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 26: { - if (options_ == null) { - options_ = new global::Google.Protobuf.Reflection.EnumOptions(); + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.EnumOptions(); } - input.ReadMessage(options_); + input.ReadMessage(Options); + break; + } + case 34: { + reservedRange_.AddEntriesFrom(input, _repeated_reservedRange_codec); break; } + case 42: { + reservedName_.AddEntriesFrom(input, _repeated_reservedName_codec); + break; + } + } + } + } + + #region Nested types + /// Container for nested types declared in the EnumDescriptorProto message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + /// + /// Range of reserved numeric values. Reserved values may not be used by + /// entries in the same enum. Reserved ranges may not overlap. + /// + /// Note that this is distinct from DescriptorProto.ReservedRange in that it + /// is inclusive such that it can appropriately represent the entire int32 + /// domain. + /// + internal sealed partial class EnumReservedRange : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumReservedRange()); + private pb::UnknownFieldSet _unknownFields; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.EnumDescriptorProto.Descriptor.NestedTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public EnumReservedRange() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public EnumReservedRange(EnumReservedRange other) : this() { + _hasBits0 = other._hasBits0; + start_ = other.start_; + end_ = other.end_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public EnumReservedRange Clone() { + return new EnumReservedRange(this); + } + + /// Field number for the "start" field. + public const int StartFieldNumber = 1; + private readonly static int StartDefaultValue = 0; + + private int start_; + /// + /// Inclusive. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Start { + get { if ((_hasBits0 & 1) != 0) { return start_; } else { return StartDefaultValue; } } + set { + _hasBits0 |= 1; + start_ = value; + } + } + /// Gets whether the "start" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasStart { + get { return (_hasBits0 & 1) != 0; } + } + /// Clears the value of the "start" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearStart() { + _hasBits0 &= ~1; + } + + /// Field number for the "end" field. + public const int EndFieldNumber = 2; + private readonly static int EndDefaultValue = 0; + + private int end_; + /// + /// Inclusive. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int End { + get { if ((_hasBits0 & 2) != 0) { return end_; } else { return EndDefaultValue; } } + set { + _hasBits0 |= 2; + end_ = value; + } + } + /// Gets whether the "end" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasEnd { + get { return (_hasBits0 & 2) != 0; } + } + /// Clears the value of the "end" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearEnd() { + _hasBits0 &= ~2; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as EnumReservedRange); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(EnumReservedRange other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Start != other.Start) return false; + if (End != other.End) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (HasStart) hash ^= Start.GetHashCode(); + if (HasEnd) hash ^= End.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (HasStart) { + output.WriteRawTag(8); + output.WriteInt32(Start); + } + if (HasEnd) { + output.WriteRawTag(16); + output.WriteInt32(End); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (HasStart) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Start); + } + if (HasEnd) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(End); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(EnumReservedRange other) { + if (other == null) { + return; + } + if (other.HasStart) { + Start = other.Start; + } + if (other.HasEnd) { + End = other.End; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + Start = input.ReadInt32(); + break; + } + case 16: { + End = input.ReadInt32(); + break; + } + } + } } + } + } + #endregion } /// - /// Describes a value within an enum. + /// Describes a value within an enum. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal sealed partial class EnumValueDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumValueDescriptorProto()); + private pb::UnknownFieldSet _unknownFields; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[6]; } + get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[7]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public EnumValueDescriptorProto() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public EnumValueDescriptorProto(EnumValueDescriptorProto other) : this() { + _hasBits0 = other._hasBits0; name_ = other.name_; number_ = other.number_; - Options = other.options_ != null ? other.Options.Clone() : null; + options_ = other.HasOptions ? other.options_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public EnumValueDescriptorProto Clone() { return new EnumValueDescriptorProto(this); } /// Field number for the "name" field. public const int NameFieldNumber = 1; - private string name_ = ""; + private readonly static string NameDefaultValue = ""; + + private string name_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { - get { return name_; } + get { return name_ ?? NameDefaultValue; } set { name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "name" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasName { + get { return name_ != null; } + } + /// Clears the value of the "name" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearName() { + name_ = null; + } /// Field number for the "number" field. public const int NumberFieldNumber = 2; + private readonly static int NumberDefaultValue = 0; + private int number_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Number { - get { return number_; } + get { if ((_hasBits0 & 1) != 0) { return number_; } else { return NumberDefaultValue; } } set { + _hasBits0 |= 1; number_ = value; } } + /// Gets whether the "number" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasNumber { + get { return (_hasBits0 & 1) != 0; } + } + /// Clears the value of the "number" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearNumber() { + _hasBits0 &= ~1; + } /// Field number for the "options" field. public const int OptionsFieldNumber = 3; private global::Google.Protobuf.Reflection.EnumValueOptions options_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.Reflection.EnumValueOptions Options { get { return options_; } set { options_ = value; } } + /// Gets whether the options field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasOptions { + get { return options_ != null; } + } + /// Clears the value of the options field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearOptions() { + options_ = null; + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as EnumValueDescriptorProto); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(EnumValueDescriptorProto other) { if (ReferenceEquals(other, null)) { return false; @@ -2023,74 +3139,90 @@ public bool Equals(EnumValueDescriptorProto other) { if (Name != other.Name) return false; if (Number != other.Number) return false; if (!object.Equals(Options, other.Options)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (Name.Length != 0) hash ^= Name.GetHashCode(); - if (Number != 0) hash ^= Number.GetHashCode(); - if (options_ != null) hash ^= Options.GetHashCode(); + if (HasName) hash ^= Name.GetHashCode(); + if (HasNumber) hash ^= Number.GetHashCode(); + if (HasOptions) hash ^= Options.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (Name.Length != 0) { + if (HasName) { output.WriteRawTag(10); output.WriteString(Name); } - if (Number != 0) { + if (HasNumber) { output.WriteRawTag(16); output.WriteInt32(Number); } - if (options_ != null) { + if (HasOptions) { output.WriteRawTag(26); output.WriteMessage(Options); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (Name.Length != 0) { + if (HasName) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } - if (Number != 0) { + if (HasNumber) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number); } - if (options_ != null) { + if (HasOptions) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(EnumValueDescriptorProto other) { if (other == null) { return; } - if (other.Name.Length != 0) { + if (other.HasName) { Name = other.Name; } - if (other.Number != 0) { + if (other.HasNumber) { Number = other.Number; } - if (other.options_ != null) { - if (options_ == null) { - options_ = new global::Google.Protobuf.Reflection.EnumValueOptions(); + if (other.HasOptions) { + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.EnumValueOptions(); } Options.MergeFrom(other.Options); } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Name = input.ReadString(); @@ -2101,10 +3233,10 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 26: { - if (options_ == null) { - options_ = new global::Google.Protobuf.Reflection.EnumValueOptions(); + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.EnumValueOptions(); } - input.ReadMessage(options_); + input.ReadMessage(Options); break; } } @@ -2114,52 +3246,73 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Describes a service. + /// Describes a service. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal sealed partial class ServiceDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServiceDescriptorProto()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[7]; } + get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[8]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ServiceDescriptorProto() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ServiceDescriptorProto(ServiceDescriptorProto other) : this() { name_ = other.name_; method_ = other.method_.Clone(); - Options = other.options_ != null ? other.Options.Clone() : null; + options_ = other.HasOptions ? other.options_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ServiceDescriptorProto Clone() { return new ServiceDescriptorProto(this); } /// Field number for the "name" field. public const int NameFieldNumber = 1; - private string name_ = ""; + private readonly static string NameDefaultValue = ""; + + private string name_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { - get { return name_; } + get { return name_ ?? NameDefaultValue; } set { name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "name" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasName { + get { return name_ != null; } + } + /// Clears the value of the "name" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearName() { + name_ = null; + } /// Field number for the "method" field. public const int MethodFieldNumber = 2; private static readonly pb::FieldCodec _repeated_method_codec = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.Reflection.MethodDescriptorProto.Parser); private readonly pbc::RepeatedField method_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Method { get { return method_; } } @@ -2167,17 +3320,30 @@ public string Name { /// Field number for the "options" field. public const int OptionsFieldNumber = 3; private global::Google.Protobuf.Reflection.ServiceOptions options_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.Reflection.ServiceOptions Options { get { return options_; } set { options_ = value; } } + /// Gets whether the options field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasOptions { + get { return options_ != null; } + } + /// Clears the value of the options field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearOptions() { + options_ = null; + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ServiceDescriptorProto); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(ServiceDescriptorProto other) { if (ReferenceEquals(other, null)) { return false; @@ -2188,67 +3354,83 @@ public bool Equals(ServiceDescriptorProto other) { if (Name != other.Name) return false; if(!method_.Equals(other.method_)) return false; if (!object.Equals(Options, other.Options)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (HasName) hash ^= Name.GetHashCode(); hash ^= method_.GetHashCode(); - if (options_ != null) hash ^= Options.GetHashCode(); + if (HasOptions) hash ^= Options.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (Name.Length != 0) { + if (HasName) { output.WriteRawTag(10); output.WriteString(Name); } method_.WriteTo(output, _repeated_method_codec); - if (options_ != null) { + if (HasOptions) { output.WriteRawTag(26); output.WriteMessage(Options); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (Name.Length != 0) { + if (HasName) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } size += method_.CalculateSize(_repeated_method_codec); - if (options_ != null) { + if (HasOptions) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(ServiceDescriptorProto other) { if (other == null) { return; } - if (other.Name.Length != 0) { + if (other.HasName) { Name = other.Name; } method_.Add(other.method_); - if (other.options_ != null) { - if (options_ == null) { - options_ = new global::Google.Protobuf.Reflection.ServiceOptions(); + if (other.HasOptions) { + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.ServiceOptions(); } Options.MergeFrom(other.Options); } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Name = input.ReadString(); @@ -2259,10 +3441,10 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 26: { - if (options_ == null) { - options_ = new global::Google.Protobuf.Reflection.ServiceOptions(); + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.ServiceOptions(); } - input.ReadMessage(options_); + input.ReadMessage(Options); break; } } @@ -2272,114 +3454,203 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Describes a method of a service. + /// Describes a method of a service. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal sealed partial class MethodDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MethodDescriptorProto()); + private pb::UnknownFieldSet _unknownFields; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[8]; } + get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[9]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MethodDescriptorProto() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MethodDescriptorProto(MethodDescriptorProto other) : this() { + _hasBits0 = other._hasBits0; name_ = other.name_; inputType_ = other.inputType_; outputType_ = other.outputType_; - Options = other.options_ != null ? other.Options.Clone() : null; + options_ = other.HasOptions ? other.options_.Clone() : null; clientStreaming_ = other.clientStreaming_; serverStreaming_ = other.serverStreaming_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MethodDescriptorProto Clone() { return new MethodDescriptorProto(this); } /// Field number for the "name" field. public const int NameFieldNumber = 1; - private string name_ = ""; + private readonly static string NameDefaultValue = ""; + + private string name_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { - get { return name_; } + get { return name_ ?? NameDefaultValue; } set { name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "name" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasName { + get { return name_ != null; } + } + /// Clears the value of the "name" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearName() { + name_ = null; + } /// Field number for the "input_type" field. public const int InputTypeFieldNumber = 2; - private string inputType_ = ""; + private readonly static string InputTypeDefaultValue = ""; + + private string inputType_; /// - /// Input and output type names. These are resolved in the same way as - /// FieldDescriptorProto.type_name, but must refer to a message type. + /// Input and output type names. These are resolved in the same way as + /// FieldDescriptorProto.type_name, but must refer to a message type. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string InputType { - get { return inputType_; } + get { return inputType_ ?? InputTypeDefaultValue; } set { inputType_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "input_type" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasInputType { + get { return inputType_ != null; } + } + /// Clears the value of the "input_type" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearInputType() { + inputType_ = null; + } /// Field number for the "output_type" field. public const int OutputTypeFieldNumber = 3; - private string outputType_ = ""; + private readonly static string OutputTypeDefaultValue = ""; + + private string outputType_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string OutputType { - get { return outputType_; } + get { return outputType_ ?? OutputTypeDefaultValue; } set { outputType_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "output_type" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasOutputType { + get { return outputType_ != null; } + } + /// Clears the value of the "output_type" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearOutputType() { + outputType_ = null; + } /// Field number for the "options" field. public const int OptionsFieldNumber = 4; private global::Google.Protobuf.Reflection.MethodOptions options_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.Reflection.MethodOptions Options { get { return options_; } set { options_ = value; } } + /// Gets whether the options field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasOptions { + get { return options_ != null; } + } + /// Clears the value of the options field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearOptions() { + options_ = null; + } /// Field number for the "client_streaming" field. public const int ClientStreamingFieldNumber = 5; + private readonly static bool ClientStreamingDefaultValue = false; + private bool clientStreaming_; /// - /// Identifies if client streams multiple client messages + /// Identifies if client streams multiple client messages /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool ClientStreaming { - get { return clientStreaming_; } + get { if ((_hasBits0 & 1) != 0) { return clientStreaming_; } else { return ClientStreamingDefaultValue; } } set { + _hasBits0 |= 1; clientStreaming_ = value; } } + /// Gets whether the "client_streaming" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasClientStreaming { + get { return (_hasBits0 & 1) != 0; } + } + /// Clears the value of the "client_streaming" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearClientStreaming() { + _hasBits0 &= ~1; + } /// Field number for the "server_streaming" field. public const int ServerStreamingFieldNumber = 6; + private readonly static bool ServerStreamingDefaultValue = false; + private bool serverStreaming_; /// - /// Identifies if server streams multiple server messages + /// Identifies if server streams multiple server messages /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool ServerStreaming { - get { return serverStreaming_; } + get { if ((_hasBits0 & 2) != 0) { return serverStreaming_; } else { return ServerStreamingDefaultValue; } } set { + _hasBits0 |= 2; serverStreaming_ = value; } } + /// Gets whether the "server_streaming" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasServerStreaming { + get { return (_hasBits0 & 2) != 0; } + } + /// Clears the value of the "server_streaming" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearServerStreaming() { + _hasBits0 &= ~2; + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as MethodDescriptorProto); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(MethodDescriptorProto other) { if (ReferenceEquals(other, null)) { return false; @@ -2393,107 +3664,123 @@ public bool Equals(MethodDescriptorProto other) { if (!object.Equals(Options, other.Options)) return false; if (ClientStreaming != other.ClientStreaming) return false; if (ServerStreaming != other.ServerStreaming) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (Name.Length != 0) hash ^= Name.GetHashCode(); - if (InputType.Length != 0) hash ^= InputType.GetHashCode(); - if (OutputType.Length != 0) hash ^= OutputType.GetHashCode(); - if (options_ != null) hash ^= Options.GetHashCode(); - if (ClientStreaming != false) hash ^= ClientStreaming.GetHashCode(); - if (ServerStreaming != false) hash ^= ServerStreaming.GetHashCode(); + if (HasName) hash ^= Name.GetHashCode(); + if (HasInputType) hash ^= InputType.GetHashCode(); + if (HasOutputType) hash ^= OutputType.GetHashCode(); + if (HasOptions) hash ^= Options.GetHashCode(); + if (HasClientStreaming) hash ^= ClientStreaming.GetHashCode(); + if (HasServerStreaming) hash ^= ServerStreaming.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (Name.Length != 0) { + if (HasName) { output.WriteRawTag(10); output.WriteString(Name); } - if (InputType.Length != 0) { + if (HasInputType) { output.WriteRawTag(18); output.WriteString(InputType); } - if (OutputType.Length != 0) { + if (HasOutputType) { output.WriteRawTag(26); output.WriteString(OutputType); } - if (options_ != null) { + if (HasOptions) { output.WriteRawTag(34); output.WriteMessage(Options); } - if (ClientStreaming != false) { + if (HasClientStreaming) { output.WriteRawTag(40); output.WriteBool(ClientStreaming); } - if (ServerStreaming != false) { + if (HasServerStreaming) { output.WriteRawTag(48); output.WriteBool(ServerStreaming); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (Name.Length != 0) { + if (HasName) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } - if (InputType.Length != 0) { + if (HasInputType) { size += 1 + pb::CodedOutputStream.ComputeStringSize(InputType); } - if (OutputType.Length != 0) { + if (HasOutputType) { size += 1 + pb::CodedOutputStream.ComputeStringSize(OutputType); } - if (options_ != null) { + if (HasOptions) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } - if (ClientStreaming != false) { + if (HasClientStreaming) { size += 1 + 1; } - if (ServerStreaming != false) { + if (HasServerStreaming) { size += 1 + 1; } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(MethodDescriptorProto other) { if (other == null) { return; } - if (other.Name.Length != 0) { + if (other.HasName) { Name = other.Name; } - if (other.InputType.Length != 0) { + if (other.HasInputType) { InputType = other.InputType; } - if (other.OutputType.Length != 0) { + if (other.HasOutputType) { OutputType = other.OutputType; } - if (other.options_ != null) { - if (options_ == null) { - options_ = new global::Google.Protobuf.Reflection.MethodOptions(); + if (other.HasOptions) { + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.MethodOptions(); } Options.MergeFrom(other.Options); } - if (other.ClientStreaming != false) { + if (other.HasClientStreaming) { ClientStreaming = other.ClientStreaming; } - if (other.ServerStreaming != false) { + if (other.HasServerStreaming) { ServerStreaming = other.ServerStreaming; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Name = input.ReadString(); @@ -2508,10 +3795,10 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 34: { - if (options_ == null) { - options_ = new global::Google.Protobuf.Reflection.MethodOptions(); + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.MethodOptions(); } - input.ReadMessage(options_); + input.ReadMessage(Options); break; } case 40: { @@ -2528,26 +3815,34 @@ public void MergeFrom(pb::CodedInputStream input) { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - internal sealed partial class FileOptions : pb::IMessage { + internal sealed partial class FileOptions : pb::IExtendableMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileOptions()); + private pb::UnknownFieldSet _unknownFields; + internal pb::ExtensionSet _extensions; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[9]; } + get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[10]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FileOptions() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FileOptions(FileOptions other) : this() { + _hasBits0 = other._hasBits0; javaPackage_ = other.javaPackage_; javaOuterClassname_ = other.javaOuterClassname_; javaMultipleFiles_ = other.javaMultipleFiles_; @@ -2558,235 +3853,591 @@ public FileOptions(FileOptions other) : this() { ccGenericServices_ = other.ccGenericServices_; javaGenericServices_ = other.javaGenericServices_; pyGenericServices_ = other.pyGenericServices_; + phpGenericServices_ = other.phpGenericServices_; deprecated_ = other.deprecated_; ccEnableArenas_ = other.ccEnableArenas_; objcClassPrefix_ = other.objcClassPrefix_; csharpNamespace_ = other.csharpNamespace_; + swiftPrefix_ = other.swiftPrefix_; + phpClassPrefix_ = other.phpClassPrefix_; + phpNamespace_ = other.phpNamespace_; + phpMetadataNamespace_ = other.phpMetadataNamespace_; + rubyPackage_ = other.rubyPackage_; uninterpretedOption_ = other.uninterpretedOption_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + _extensions = pb::ExtensionSet.Clone(other._extensions); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FileOptions Clone() { return new FileOptions(this); } /// Field number for the "java_package" field. public const int JavaPackageFieldNumber = 1; - private string javaPackage_ = ""; + private readonly static string JavaPackageDefaultValue = ""; + + private string javaPackage_; /// - /// Sets the Java package where classes generated from this .proto will be - /// placed. By default, the proto package is used, but this is often - /// inappropriate because proto packages do not normally start with backwards - /// domain names. + /// Sets the Java package where classes generated from this .proto will be + /// placed. By default, the proto package is used, but this is often + /// inappropriate because proto packages do not normally start with backwards + /// domain names. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string JavaPackage { - get { return javaPackage_; } + get { return javaPackage_ ?? JavaPackageDefaultValue; } set { javaPackage_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "java_package" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasJavaPackage { + get { return javaPackage_ != null; } + } + /// Clears the value of the "java_package" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearJavaPackage() { + javaPackage_ = null; + } /// Field number for the "java_outer_classname" field. public const int JavaOuterClassnameFieldNumber = 8; - private string javaOuterClassname_ = ""; + private readonly static string JavaOuterClassnameDefaultValue = ""; + + private string javaOuterClassname_; /// - /// If set, all the classes from the .proto file are wrapped in a single - /// outer class with the given name. This applies to both Proto1 - /// (equivalent to the old "--one_java_file" option) and Proto2 (where - /// a .proto always translates to a single class, but you may want to - /// explicitly choose the class name). + /// If set, all the classes from the .proto file are wrapped in a single + /// outer class with the given name. This applies to both Proto1 + /// (equivalent to the old "--one_java_file" option) and Proto2 (where + /// a .proto always translates to a single class, but you may want to + /// explicitly choose the class name). /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string JavaOuterClassname { - get { return javaOuterClassname_; } + get { return javaOuterClassname_ ?? JavaOuterClassnameDefaultValue; } set { javaOuterClassname_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "java_outer_classname" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasJavaOuterClassname { + get { return javaOuterClassname_ != null; } + } + /// Clears the value of the "java_outer_classname" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearJavaOuterClassname() { + javaOuterClassname_ = null; + } /// Field number for the "java_multiple_files" field. public const int JavaMultipleFilesFieldNumber = 10; + private readonly static bool JavaMultipleFilesDefaultValue = false; + private bool javaMultipleFiles_; /// - /// If set true, then the Java code generator will generate a separate .java - /// file for each top-level message, enum, and service defined in the .proto - /// file. Thus, these types will *not* be nested inside the outer class - /// named by java_outer_classname. However, the outer class will still be - /// generated to contain the file's getDescriptor() method as well as any - /// top-level extensions defined in the file. + /// If set true, then the Java code generator will generate a separate .java + /// file for each top-level message, enum, and service defined in the .proto + /// file. Thus, these types will *not* be nested inside the outer class + /// named by java_outer_classname. However, the outer class will still be + /// generated to contain the file's getDescriptor() method as well as any + /// top-level extensions defined in the file. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool JavaMultipleFiles { - get { return javaMultipleFiles_; } + get { if ((_hasBits0 & 2) != 0) { return javaMultipleFiles_; } else { return JavaMultipleFilesDefaultValue; } } set { + _hasBits0 |= 2; javaMultipleFiles_ = value; } } + /// Gets whether the "java_multiple_files" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasJavaMultipleFiles { + get { return (_hasBits0 & 2) != 0; } + } + /// Clears the value of the "java_multiple_files" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearJavaMultipleFiles() { + _hasBits0 &= ~2; + } /// Field number for the "java_generate_equals_and_hash" field. public const int JavaGenerateEqualsAndHashFieldNumber = 20; + private readonly static bool JavaGenerateEqualsAndHashDefaultValue = false; + private bool javaGenerateEqualsAndHash_; /// - /// If set true, then the Java code generator will generate equals() and - /// hashCode() methods for all messages defined in the .proto file. - /// This increases generated code size, potentially substantially for large - /// protos, which may harm a memory-constrained application. - /// - In the full runtime this is a speed optimization, as the - /// AbstractMessage base class includes reflection-based implementations of - /// these methods. - /// - In the lite runtime, setting this option changes the semantics of - /// equals() and hashCode() to more closely match those of the full runtime; - /// the generated methods compute their results based on field values rather - /// than object identity. (Implementations should not assume that hashcodes - /// will be consistent across runtimes or versions of the protocol compiler.) + /// This option does nothing. /// + [global::System.ObsoleteAttribute] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool JavaGenerateEqualsAndHash { - get { return javaGenerateEqualsAndHash_; } + get { if ((_hasBits0 & 32) != 0) { return javaGenerateEqualsAndHash_; } else { return JavaGenerateEqualsAndHashDefaultValue; } } set { + _hasBits0 |= 32; javaGenerateEqualsAndHash_ = value; } } + /// Gets whether the "java_generate_equals_and_hash" field is set + [global::System.ObsoleteAttribute] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasJavaGenerateEqualsAndHash { + get { return (_hasBits0 & 32) != 0; } + } + /// Clears the value of the "java_generate_equals_and_hash" field + [global::System.ObsoleteAttribute] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearJavaGenerateEqualsAndHash() { + _hasBits0 &= ~32; + } /// Field number for the "java_string_check_utf8" field. public const int JavaStringCheckUtf8FieldNumber = 27; + private readonly static bool JavaStringCheckUtf8DefaultValue = false; + private bool javaStringCheckUtf8_; /// - /// If set true, then the Java2 code generator will generate code that - /// throws an exception whenever an attempt is made to assign a non-UTF-8 - /// byte sequence to a string field. - /// Message reflection will do the same. - /// However, an extension field still accepts non-UTF-8 byte sequences. - /// This option has no effect on when used with the lite runtime. + /// If set true, then the Java2 code generator will generate code that + /// throws an exception whenever an attempt is made to assign a non-UTF-8 + /// byte sequence to a string field. + /// Message reflection will do the same. + /// However, an extension field still accepts non-UTF-8 byte sequences. + /// This option has no effect on when used with the lite runtime. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool JavaStringCheckUtf8 { - get { return javaStringCheckUtf8_; } + get { if ((_hasBits0 & 128) != 0) { return javaStringCheckUtf8_; } else { return JavaStringCheckUtf8DefaultValue; } } set { + _hasBits0 |= 128; javaStringCheckUtf8_ = value; } } + /// Gets whether the "java_string_check_utf8" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasJavaStringCheckUtf8 { + get { return (_hasBits0 & 128) != 0; } + } + /// Clears the value of the "java_string_check_utf8" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearJavaStringCheckUtf8() { + _hasBits0 &= ~128; + } /// Field number for the "optimize_for" field. public const int OptimizeForFieldNumber = 9; - private global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode optimizeFor_ = 0; + private readonly static global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode OptimizeForDefaultValue = global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.Speed; + + private global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode optimizeFor_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode OptimizeFor { - get { return optimizeFor_; } + get { if ((_hasBits0 & 1) != 0) { return optimizeFor_; } else { return OptimizeForDefaultValue; } } set { + _hasBits0 |= 1; optimizeFor_ = value; } } + /// Gets whether the "optimize_for" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasOptimizeFor { + get { return (_hasBits0 & 1) != 0; } + } + /// Clears the value of the "optimize_for" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearOptimizeFor() { + _hasBits0 &= ~1; + } /// Field number for the "go_package" field. public const int GoPackageFieldNumber = 11; - private string goPackage_ = ""; + private readonly static string GoPackageDefaultValue = ""; + + private string goPackage_; /// - /// Sets the Go package where structs generated from this .proto will be - /// placed. If omitted, the Go package will be derived from the following: - /// - The basename of the package import path, if provided. - /// - Otherwise, the package statement in the .proto file, if present. - /// - Otherwise, the basename of the .proto file, without extension. + /// Sets the Go package where structs generated from this .proto will be + /// placed. If omitted, the Go package will be derived from the following: + /// - The basename of the package import path, if provided. + /// - Otherwise, the package statement in the .proto file, if present. + /// - Otherwise, the basename of the .proto file, without extension. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string GoPackage { - get { return goPackage_; } + get { return goPackage_ ?? GoPackageDefaultValue; } set { goPackage_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "go_package" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasGoPackage { + get { return goPackage_ != null; } + } + /// Clears the value of the "go_package" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearGoPackage() { + goPackage_ = null; + } /// Field number for the "cc_generic_services" field. public const int CcGenericServicesFieldNumber = 16; + private readonly static bool CcGenericServicesDefaultValue = false; + private bool ccGenericServices_; /// - /// Should generic services be generated in each language? "Generic" services - /// are not specific to any particular RPC system. They are generated by the - /// main code generators in each language (without additional plugins). - /// Generic services were the only kind of service generation supported by - /// early versions of google.protobuf. + /// Should generic services be generated in each language? "Generic" services + /// are not specific to any particular RPC system. They are generated by the + /// main code generators in each language (without additional plugins). + /// Generic services were the only kind of service generation supported by + /// early versions of google.protobuf. /// - /// Generic services are now considered deprecated in favor of using plugins - /// that generate code specific to your particular RPC system. Therefore, - /// these default to false. Old code which depends on generic services should - /// explicitly set them to true. + /// Generic services are now considered deprecated in favor of using plugins + /// that generate code specific to your particular RPC system. Therefore, + /// these default to false. Old code which depends on generic services should + /// explicitly set them to true. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool CcGenericServices { - get { return ccGenericServices_; } + get { if ((_hasBits0 & 4) != 0) { return ccGenericServices_; } else { return CcGenericServicesDefaultValue; } } set { + _hasBits0 |= 4; ccGenericServices_ = value; } } + /// Gets whether the "cc_generic_services" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasCcGenericServices { + get { return (_hasBits0 & 4) != 0; } + } + /// Clears the value of the "cc_generic_services" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearCcGenericServices() { + _hasBits0 &= ~4; + } /// Field number for the "java_generic_services" field. public const int JavaGenericServicesFieldNumber = 17; + private readonly static bool JavaGenericServicesDefaultValue = false; + private bool javaGenericServices_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool JavaGenericServices { - get { return javaGenericServices_; } + get { if ((_hasBits0 & 8) != 0) { return javaGenericServices_; } else { return JavaGenericServicesDefaultValue; } } set { + _hasBits0 |= 8; javaGenericServices_ = value; } } + /// Gets whether the "java_generic_services" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasJavaGenericServices { + get { return (_hasBits0 & 8) != 0; } + } + /// Clears the value of the "java_generic_services" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearJavaGenericServices() { + _hasBits0 &= ~8; + } /// Field number for the "py_generic_services" field. public const int PyGenericServicesFieldNumber = 18; + private readonly static bool PyGenericServicesDefaultValue = false; + private bool pyGenericServices_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool PyGenericServices { - get { return pyGenericServices_; } + get { if ((_hasBits0 & 16) != 0) { return pyGenericServices_; } else { return PyGenericServicesDefaultValue; } } set { + _hasBits0 |= 16; pyGenericServices_ = value; } } - + /// Gets whether the "py_generic_services" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasPyGenericServices { + get { return (_hasBits0 & 16) != 0; } + } + /// Clears the value of the "py_generic_services" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearPyGenericServices() { + _hasBits0 &= ~16; + } + + /// Field number for the "php_generic_services" field. + public const int PhpGenericServicesFieldNumber = 42; + private readonly static bool PhpGenericServicesDefaultValue = false; + + private bool phpGenericServices_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool PhpGenericServices { + get { if ((_hasBits0 & 512) != 0) { return phpGenericServices_; } else { return PhpGenericServicesDefaultValue; } } + set { + _hasBits0 |= 512; + phpGenericServices_ = value; + } + } + /// Gets whether the "php_generic_services" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasPhpGenericServices { + get { return (_hasBits0 & 512) != 0; } + } + /// Clears the value of the "php_generic_services" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearPhpGenericServices() { + _hasBits0 &= ~512; + } + /// Field number for the "deprecated" field. public const int DeprecatedFieldNumber = 23; + private readonly static bool DeprecatedDefaultValue = false; + private bool deprecated_; /// - /// Is this file deprecated? - /// Depending on the target platform, this can emit Deprecated annotations - /// for everything in the file, or it will be completely ignored; in the very - /// least, this is a formalization for deprecating files. + /// Is this file deprecated? + /// Depending on the target platform, this can emit Deprecated annotations + /// for everything in the file, or it will be completely ignored; in the very + /// least, this is a formalization for deprecating files. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Deprecated { - get { return deprecated_; } + get { if ((_hasBits0 & 64) != 0) { return deprecated_; } else { return DeprecatedDefaultValue; } } set { + _hasBits0 |= 64; deprecated_ = value; } } + /// Gets whether the "deprecated" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasDeprecated { + get { return (_hasBits0 & 64) != 0; } + } + /// Clears the value of the "deprecated" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearDeprecated() { + _hasBits0 &= ~64; + } /// Field number for the "cc_enable_arenas" field. public const int CcEnableArenasFieldNumber = 31; + private readonly static bool CcEnableArenasDefaultValue = false; + private bool ccEnableArenas_; /// - /// Enables the use of arenas for the proto messages in this file. This applies - /// only to generated classes for C++. + /// Enables the use of arenas for the proto messages in this file. This applies + /// only to generated classes for C++. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool CcEnableArenas { - get { return ccEnableArenas_; } + get { if ((_hasBits0 & 256) != 0) { return ccEnableArenas_; } else { return CcEnableArenasDefaultValue; } } set { + _hasBits0 |= 256; ccEnableArenas_ = value; } } + /// Gets whether the "cc_enable_arenas" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasCcEnableArenas { + get { return (_hasBits0 & 256) != 0; } + } + /// Clears the value of the "cc_enable_arenas" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearCcEnableArenas() { + _hasBits0 &= ~256; + } /// Field number for the "objc_class_prefix" field. public const int ObjcClassPrefixFieldNumber = 36; - private string objcClassPrefix_ = ""; + private readonly static string ObjcClassPrefixDefaultValue = ""; + + private string objcClassPrefix_; /// - /// Sets the objective c class prefix which is prepended to all objective c - /// generated classes from this .proto. There is no default. + /// Sets the objective c class prefix which is prepended to all objective c + /// generated classes from this .proto. There is no default. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string ObjcClassPrefix { - get { return objcClassPrefix_; } + get { return objcClassPrefix_ ?? ObjcClassPrefixDefaultValue; } set { objcClassPrefix_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "objc_class_prefix" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasObjcClassPrefix { + get { return objcClassPrefix_ != null; } + } + /// Clears the value of the "objc_class_prefix" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearObjcClassPrefix() { + objcClassPrefix_ = null; + } /// Field number for the "csharp_namespace" field. public const int CsharpNamespaceFieldNumber = 37; - private string csharpNamespace_ = ""; + private readonly static string CsharpNamespaceDefaultValue = ""; + + private string csharpNamespace_; /// - /// Namespace for generated classes; defaults to the package. + /// Namespace for generated classes; defaults to the package. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string CsharpNamespace { - get { return csharpNamespace_; } + get { return csharpNamespace_ ?? CsharpNamespaceDefaultValue; } set { csharpNamespace_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "csharp_namespace" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasCsharpNamespace { + get { return csharpNamespace_ != null; } + } + /// Clears the value of the "csharp_namespace" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearCsharpNamespace() { + csharpNamespace_ = null; + } + + /// Field number for the "swift_prefix" field. + public const int SwiftPrefixFieldNumber = 39; + private readonly static string SwiftPrefixDefaultValue = ""; + + private string swiftPrefix_; + /// + /// By default Swift generators will take the proto package and CamelCase it + /// replacing '.' with underscore and use that to prefix the types/symbols + /// defined. When this options is provided, they will use this value instead + /// to prefix the types/symbols defined. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string SwiftPrefix { + get { return swiftPrefix_ ?? SwiftPrefixDefaultValue; } + set { + swiftPrefix_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + /// Gets whether the "swift_prefix" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasSwiftPrefix { + get { return swiftPrefix_ != null; } + } + /// Clears the value of the "swift_prefix" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearSwiftPrefix() { + swiftPrefix_ = null; + } + + /// Field number for the "php_class_prefix" field. + public const int PhpClassPrefixFieldNumber = 40; + private readonly static string PhpClassPrefixDefaultValue = ""; + + private string phpClassPrefix_; + /// + /// Sets the php class prefix which is prepended to all php generated classes + /// from this .proto. Default is empty. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string PhpClassPrefix { + get { return phpClassPrefix_ ?? PhpClassPrefixDefaultValue; } + set { + phpClassPrefix_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + /// Gets whether the "php_class_prefix" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasPhpClassPrefix { + get { return phpClassPrefix_ != null; } + } + /// Clears the value of the "php_class_prefix" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearPhpClassPrefix() { + phpClassPrefix_ = null; + } + + /// Field number for the "php_namespace" field. + public const int PhpNamespaceFieldNumber = 41; + private readonly static string PhpNamespaceDefaultValue = ""; + + private string phpNamespace_; + /// + /// Use this option to change the namespace of php generated classes. Default + /// is empty. When this option is empty, the package name will be used for + /// determining the namespace. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string PhpNamespace { + get { return phpNamespace_ ?? PhpNamespaceDefaultValue; } + set { + phpNamespace_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + /// Gets whether the "php_namespace" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasPhpNamespace { + get { return phpNamespace_ != null; } + } + /// Clears the value of the "php_namespace" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearPhpNamespace() { + phpNamespace_ = null; + } + + /// Field number for the "php_metadata_namespace" field. + public const int PhpMetadataNamespaceFieldNumber = 44; + private readonly static string PhpMetadataNamespaceDefaultValue = ""; + + private string phpMetadataNamespace_; + /// + /// Use this option to change the namespace of php generated metadata classes. + /// Default is empty. When this option is empty, the proto file name will be + /// used for determining the namespace. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string PhpMetadataNamespace { + get { return phpMetadataNamespace_ ?? PhpMetadataNamespaceDefaultValue; } + set { + phpMetadataNamespace_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + /// Gets whether the "php_metadata_namespace" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasPhpMetadataNamespace { + get { return phpMetadataNamespace_ != null; } + } + /// Clears the value of the "php_metadata_namespace" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearPhpMetadataNamespace() { + phpMetadataNamespace_ = null; + } + + /// Field number for the "ruby_package" field. + public const int RubyPackageFieldNumber = 45; + private readonly static string RubyPackageDefaultValue = ""; + + private string rubyPackage_; + /// + /// Use this option to change the package of ruby generated classes. Default + /// is empty. When this option is not set, the package name will be used for + /// determining the ruby package. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string RubyPackage { + get { return rubyPackage_ ?? RubyPackageDefaultValue; } + set { + rubyPackage_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + /// Gets whether the "ruby_package" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasRubyPackage { + get { return rubyPackage_ != null; } + } + /// Clears the value of the "ruby_package" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearRubyPackage() { + rubyPackage_ = null; + } /// Field number for the "uninterpreted_option" field. public const int UninterpretedOptionFieldNumber = 999; @@ -2794,16 +4445,20 @@ public string CsharpNamespace { = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); /// - /// The parser stores options it doesn't recognize here. See above. + /// The parser stores options it doesn't recognize here. + /// See the documentation for the "Options" section above. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as FileOptions); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(FileOptions other) { if (ReferenceEquals(other, null)) { return false; @@ -2821,201 +4476,304 @@ public bool Equals(FileOptions other) { if (CcGenericServices != other.CcGenericServices) return false; if (JavaGenericServices != other.JavaGenericServices) return false; if (PyGenericServices != other.PyGenericServices) return false; + if (PhpGenericServices != other.PhpGenericServices) return false; if (Deprecated != other.Deprecated) return false; if (CcEnableArenas != other.CcEnableArenas) return false; if (ObjcClassPrefix != other.ObjcClassPrefix) return false; if (CsharpNamespace != other.CsharpNamespace) return false; + if (SwiftPrefix != other.SwiftPrefix) return false; + if (PhpClassPrefix != other.PhpClassPrefix) return false; + if (PhpNamespace != other.PhpNamespace) return false; + if (PhpMetadataNamespace != other.PhpMetadataNamespace) return false; + if (RubyPackage != other.RubyPackage) return false; if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; - return true; + if (!Equals(_extensions, other._extensions)) { + return false; + } + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (JavaPackage.Length != 0) hash ^= JavaPackage.GetHashCode(); - if (JavaOuterClassname.Length != 0) hash ^= JavaOuterClassname.GetHashCode(); - if (JavaMultipleFiles != false) hash ^= JavaMultipleFiles.GetHashCode(); - if (JavaGenerateEqualsAndHash != false) hash ^= JavaGenerateEqualsAndHash.GetHashCode(); - if (JavaStringCheckUtf8 != false) hash ^= JavaStringCheckUtf8.GetHashCode(); - if (OptimizeFor != 0) hash ^= OptimizeFor.GetHashCode(); - if (GoPackage.Length != 0) hash ^= GoPackage.GetHashCode(); - if (CcGenericServices != false) hash ^= CcGenericServices.GetHashCode(); - if (JavaGenericServices != false) hash ^= JavaGenericServices.GetHashCode(); - if (PyGenericServices != false) hash ^= PyGenericServices.GetHashCode(); - if (Deprecated != false) hash ^= Deprecated.GetHashCode(); - if (CcEnableArenas != false) hash ^= CcEnableArenas.GetHashCode(); - if (ObjcClassPrefix.Length != 0) hash ^= ObjcClassPrefix.GetHashCode(); - if (CsharpNamespace.Length != 0) hash ^= CsharpNamespace.GetHashCode(); + if (HasJavaPackage) hash ^= JavaPackage.GetHashCode(); + if (HasJavaOuterClassname) hash ^= JavaOuterClassname.GetHashCode(); + if (HasJavaMultipleFiles) hash ^= JavaMultipleFiles.GetHashCode(); + if (HasJavaGenerateEqualsAndHash) hash ^= JavaGenerateEqualsAndHash.GetHashCode(); + if (HasJavaStringCheckUtf8) hash ^= JavaStringCheckUtf8.GetHashCode(); + if (HasOptimizeFor) hash ^= OptimizeFor.GetHashCode(); + if (HasGoPackage) hash ^= GoPackage.GetHashCode(); + if (HasCcGenericServices) hash ^= CcGenericServices.GetHashCode(); + if (HasJavaGenericServices) hash ^= JavaGenericServices.GetHashCode(); + if (HasPyGenericServices) hash ^= PyGenericServices.GetHashCode(); + if (HasPhpGenericServices) hash ^= PhpGenericServices.GetHashCode(); + if (HasDeprecated) hash ^= Deprecated.GetHashCode(); + if (HasCcEnableArenas) hash ^= CcEnableArenas.GetHashCode(); + if (HasObjcClassPrefix) hash ^= ObjcClassPrefix.GetHashCode(); + if (HasCsharpNamespace) hash ^= CsharpNamespace.GetHashCode(); + if (HasSwiftPrefix) hash ^= SwiftPrefix.GetHashCode(); + if (HasPhpClassPrefix) hash ^= PhpClassPrefix.GetHashCode(); + if (HasPhpNamespace) hash ^= PhpNamespace.GetHashCode(); + if (HasPhpMetadataNamespace) hash ^= PhpMetadataNamespace.GetHashCode(); + if (HasRubyPackage) hash ^= RubyPackage.GetHashCode(); hash ^= uninterpretedOption_.GetHashCode(); + if (_extensions != null) { + hash ^= _extensions.GetHashCode(); + } + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (JavaPackage.Length != 0) { + if (HasJavaPackage) { output.WriteRawTag(10); output.WriteString(JavaPackage); } - if (JavaOuterClassname.Length != 0) { + if (HasJavaOuterClassname) { output.WriteRawTag(66); output.WriteString(JavaOuterClassname); } - if (OptimizeFor != 0) { + if (HasOptimizeFor) { output.WriteRawTag(72); output.WriteEnum((int) OptimizeFor); } - if (JavaMultipleFiles != false) { + if (HasJavaMultipleFiles) { output.WriteRawTag(80); output.WriteBool(JavaMultipleFiles); } - if (GoPackage.Length != 0) { + if (HasGoPackage) { output.WriteRawTag(90); output.WriteString(GoPackage); } - if (CcGenericServices != false) { + if (HasCcGenericServices) { output.WriteRawTag(128, 1); output.WriteBool(CcGenericServices); } - if (JavaGenericServices != false) { + if (HasJavaGenericServices) { output.WriteRawTag(136, 1); output.WriteBool(JavaGenericServices); } - if (PyGenericServices != false) { + if (HasPyGenericServices) { output.WriteRawTag(144, 1); output.WriteBool(PyGenericServices); } - if (JavaGenerateEqualsAndHash != false) { + if (HasJavaGenerateEqualsAndHash) { output.WriteRawTag(160, 1); output.WriteBool(JavaGenerateEqualsAndHash); } - if (Deprecated != false) { + if (HasDeprecated) { output.WriteRawTag(184, 1); output.WriteBool(Deprecated); } - if (JavaStringCheckUtf8 != false) { + if (HasJavaStringCheckUtf8) { output.WriteRawTag(216, 1); output.WriteBool(JavaStringCheckUtf8); } - if (CcEnableArenas != false) { + if (HasCcEnableArenas) { output.WriteRawTag(248, 1); output.WriteBool(CcEnableArenas); } - if (ObjcClassPrefix.Length != 0) { + if (HasObjcClassPrefix) { output.WriteRawTag(162, 2); output.WriteString(ObjcClassPrefix); } - if (CsharpNamespace.Length != 0) { + if (HasCsharpNamespace) { output.WriteRawTag(170, 2); output.WriteString(CsharpNamespace); } + if (HasSwiftPrefix) { + output.WriteRawTag(186, 2); + output.WriteString(SwiftPrefix); + } + if (HasPhpClassPrefix) { + output.WriteRawTag(194, 2); + output.WriteString(PhpClassPrefix); + } + if (HasPhpNamespace) { + output.WriteRawTag(202, 2); + output.WriteString(PhpNamespace); + } + if (HasPhpGenericServices) { + output.WriteRawTag(208, 2); + output.WriteBool(PhpGenericServices); + } + if (HasPhpMetadataNamespace) { + output.WriteRawTag(226, 2); + output.WriteString(PhpMetadataNamespace); + } + if (HasRubyPackage) { + output.WriteRawTag(234, 2); + output.WriteString(RubyPackage); + } uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); + if (_extensions != null) { + _extensions.WriteTo(output); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (JavaPackage.Length != 0) { + if (HasJavaPackage) { size += 1 + pb::CodedOutputStream.ComputeStringSize(JavaPackage); } - if (JavaOuterClassname.Length != 0) { + if (HasJavaOuterClassname) { size += 1 + pb::CodedOutputStream.ComputeStringSize(JavaOuterClassname); } - if (JavaMultipleFiles != false) { + if (HasJavaMultipleFiles) { size += 1 + 1; } - if (JavaGenerateEqualsAndHash != false) { + if (HasJavaGenerateEqualsAndHash) { size += 2 + 1; } - if (JavaStringCheckUtf8 != false) { + if (HasJavaStringCheckUtf8) { size += 2 + 1; } - if (OptimizeFor != 0) { + if (HasOptimizeFor) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) OptimizeFor); } - if (GoPackage.Length != 0) { + if (HasGoPackage) { size += 1 + pb::CodedOutputStream.ComputeStringSize(GoPackage); } - if (CcGenericServices != false) { + if (HasCcGenericServices) { size += 2 + 1; } - if (JavaGenericServices != false) { + if (HasJavaGenericServices) { size += 2 + 1; } - if (PyGenericServices != false) { + if (HasPyGenericServices) { size += 2 + 1; } - if (Deprecated != false) { + if (HasPhpGenericServices) { size += 2 + 1; } - if (CcEnableArenas != false) { + if (HasDeprecated) { size += 2 + 1; } - if (ObjcClassPrefix.Length != 0) { + if (HasCcEnableArenas) { + size += 2 + 1; + } + if (HasObjcClassPrefix) { size += 2 + pb::CodedOutputStream.ComputeStringSize(ObjcClassPrefix); } - if (CsharpNamespace.Length != 0) { + if (HasCsharpNamespace) { size += 2 + pb::CodedOutputStream.ComputeStringSize(CsharpNamespace); } + if (HasSwiftPrefix) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(SwiftPrefix); + } + if (HasPhpClassPrefix) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(PhpClassPrefix); + } + if (HasPhpNamespace) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(PhpNamespace); + } + if (HasPhpMetadataNamespace) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(PhpMetadataNamespace); + } + if (HasRubyPackage) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(RubyPackage); + } size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); + if (_extensions != null) { + size += _extensions.CalculateSize(); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(FileOptions other) { if (other == null) { return; } - if (other.JavaPackage.Length != 0) { + if (other.HasJavaPackage) { JavaPackage = other.JavaPackage; } - if (other.JavaOuterClassname.Length != 0) { + if (other.HasJavaOuterClassname) { JavaOuterClassname = other.JavaOuterClassname; } - if (other.JavaMultipleFiles != false) { + if (other.HasJavaMultipleFiles) { JavaMultipleFiles = other.JavaMultipleFiles; } - if (other.JavaGenerateEqualsAndHash != false) { + if (other.HasJavaGenerateEqualsAndHash) { JavaGenerateEqualsAndHash = other.JavaGenerateEqualsAndHash; } - if (other.JavaStringCheckUtf8 != false) { + if (other.HasJavaStringCheckUtf8) { JavaStringCheckUtf8 = other.JavaStringCheckUtf8; } - if (other.OptimizeFor != 0) { + if (other.HasOptimizeFor) { OptimizeFor = other.OptimizeFor; } - if (other.GoPackage.Length != 0) { + if (other.HasGoPackage) { GoPackage = other.GoPackage; } - if (other.CcGenericServices != false) { + if (other.HasCcGenericServices) { CcGenericServices = other.CcGenericServices; } - if (other.JavaGenericServices != false) { + if (other.HasJavaGenericServices) { JavaGenericServices = other.JavaGenericServices; } - if (other.PyGenericServices != false) { + if (other.HasPyGenericServices) { PyGenericServices = other.PyGenericServices; } - if (other.Deprecated != false) { + if (other.HasPhpGenericServices) { + PhpGenericServices = other.PhpGenericServices; + } + if (other.HasDeprecated) { Deprecated = other.Deprecated; } - if (other.CcEnableArenas != false) { + if (other.HasCcEnableArenas) { CcEnableArenas = other.CcEnableArenas; } - if (other.ObjcClassPrefix.Length != 0) { + if (other.HasObjcClassPrefix) { ObjcClassPrefix = other.ObjcClassPrefix; } - if (other.CsharpNamespace.Length != 0) { + if (other.HasCsharpNamespace) { CsharpNamespace = other.CsharpNamespace; } + if (other.HasSwiftPrefix) { + SwiftPrefix = other.SwiftPrefix; + } + if (other.HasPhpClassPrefix) { + PhpClassPrefix = other.PhpClassPrefix; + } + if (other.HasPhpNamespace) { + PhpNamespace = other.PhpNamespace; + } + if (other.HasPhpMetadataNamespace) { + PhpMetadataNamespace = other.PhpMetadataNamespace; + } + if (other.HasRubyPackage) { + RubyPackage = other.RubyPackage; + } uninterpretedOption_.Add(other.uninterpretedOption_); + pb::ExtensionSet.MergeFrom(ref _extensions, other._extensions); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + } break; case 10: { JavaPackage = input.ReadString(); @@ -3026,7 +4784,7 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 72: { - optimizeFor_ = (global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) input.ReadEnum(); + OptimizeFor = (global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) input.ReadEnum(); break; } case 80: { @@ -3073,6 +4831,30 @@ public void MergeFrom(pb::CodedInputStream input) { CsharpNamespace = input.ReadString(); break; } + case 314: { + SwiftPrefix = input.ReadString(); + break; + } + case 322: { + PhpClassPrefix = input.ReadString(); + break; + } + case 330: { + PhpNamespace = input.ReadString(); + break; + } + case 336: { + PhpGenericServices = input.ReadBool(); + break; + } + case 354: { + PhpMetadataNamespace = input.ReadString(); + break; + } + case 362: { + RubyPackage = input.ReadString(); + break; + } case 7994: { uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); break; @@ -3081,24 +4863,46 @@ public void MergeFrom(pb::CodedInputStream input) { } } + public TValue GetExtension(pb::Extension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetOrRegisterExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.GetOrRegister(ref _extensions, extension); + } + public void SetExtension(pb::Extension extension, TValue value) { + pb::ExtensionSet.Set(ref _extensions, extension, value); + } + public bool HasExtension(pb::Extension extension) { + return pb::ExtensionSet.Has(ref _extensions, extension); + } + public void ClearExtension(pb::Extension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); + } + public void ClearExtension(pb::RepeatedExtension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); + } + #region Nested types /// Container for nested types declared in the FileOptions message type. - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { /// - /// Generated classes can be optimized for speed or code size. + /// Generated classes can be optimized for speed or code size. /// internal enum OptimizeMode { /// - /// Generate complete code for parsing, serialization, + /// Generate complete code for parsing, serialization, /// [pbr::OriginalName("SPEED")] Speed = 1, /// - /// etc. + /// etc. /// [pbr::OriginalName("CODE_SIZE")] CodeSize = 2, /// - /// Generate code using MessageLite and the lite runtime. + /// Generate code using MessageLite and the lite runtime. /// [pbr::OriginalName("LITE_RUNTIME")] LiteRuntime = 3, } @@ -3108,130 +4912,197 @@ internal enum OptimizeMode { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - internal sealed partial class MessageOptions : pb::IMessage { + internal sealed partial class MessageOptions : pb::IExtendableMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageOptions()); + private pb::UnknownFieldSet _unknownFields; + internal pb::ExtensionSet _extensions; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[10]; } + get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[11]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MessageOptions() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MessageOptions(MessageOptions other) : this() { + _hasBits0 = other._hasBits0; messageSetWireFormat_ = other.messageSetWireFormat_; noStandardDescriptorAccessor_ = other.noStandardDescriptorAccessor_; deprecated_ = other.deprecated_; mapEntry_ = other.mapEntry_; uninterpretedOption_ = other.uninterpretedOption_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + _extensions = pb::ExtensionSet.Clone(other._extensions); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MessageOptions Clone() { return new MessageOptions(this); } /// Field number for the "message_set_wire_format" field. public const int MessageSetWireFormatFieldNumber = 1; + private readonly static bool MessageSetWireFormatDefaultValue = false; + private bool messageSetWireFormat_; /// - /// Set true to use the old proto1 MessageSet wire format for extensions. - /// This is provided for backwards-compatibility with the MessageSet wire - /// format. You should not use this for any other reason: It's less - /// efficient, has fewer features, and is more complicated. + /// Set true to use the old proto1 MessageSet wire format for extensions. + /// This is provided for backwards-compatibility with the MessageSet wire + /// format. You should not use this for any other reason: It's less + /// efficient, has fewer features, and is more complicated. /// - /// The message must be defined exactly as follows: - /// message Foo { - /// option message_set_wire_format = true; - /// extensions 4 to max; - /// } - /// Note that the message cannot have any defined fields; MessageSets only - /// have extensions. + /// The message must be defined exactly as follows: + /// message Foo { + /// option message_set_wire_format = true; + /// extensions 4 to max; + /// } + /// Note that the message cannot have any defined fields; MessageSets only + /// have extensions. /// - /// All extensions of your type must be singular messages; e.g. they cannot - /// be int32s, enums, or repeated messages. + /// All extensions of your type must be singular messages; e.g. they cannot + /// be int32s, enums, or repeated messages. /// - /// Because this is an option, the above two restrictions are not enforced by - /// the protocol compiler. + /// Because this is an option, the above two restrictions are not enforced by + /// the protocol compiler. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool MessageSetWireFormat { - get { return messageSetWireFormat_; } + get { if ((_hasBits0 & 1) != 0) { return messageSetWireFormat_; } else { return MessageSetWireFormatDefaultValue; } } set { + _hasBits0 |= 1; messageSetWireFormat_ = value; } } + /// Gets whether the "message_set_wire_format" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasMessageSetWireFormat { + get { return (_hasBits0 & 1) != 0; } + } + /// Clears the value of the "message_set_wire_format" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearMessageSetWireFormat() { + _hasBits0 &= ~1; + } /// Field number for the "no_standard_descriptor_accessor" field. public const int NoStandardDescriptorAccessorFieldNumber = 2; + private readonly static bool NoStandardDescriptorAccessorDefaultValue = false; + private bool noStandardDescriptorAccessor_; /// - /// Disables the generation of the standard "descriptor()" accessor, which can - /// conflict with a field of the same name. This is meant to make migration - /// from proto1 easier; new code should avoid fields named "descriptor". + /// Disables the generation of the standard "descriptor()" accessor, which can + /// conflict with a field of the same name. This is meant to make migration + /// from proto1 easier; new code should avoid fields named "descriptor". /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool NoStandardDescriptorAccessor { - get { return noStandardDescriptorAccessor_; } + get { if ((_hasBits0 & 2) != 0) { return noStandardDescriptorAccessor_; } else { return NoStandardDescriptorAccessorDefaultValue; } } set { + _hasBits0 |= 2; noStandardDescriptorAccessor_ = value; } } + /// Gets whether the "no_standard_descriptor_accessor" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasNoStandardDescriptorAccessor { + get { return (_hasBits0 & 2) != 0; } + } + /// Clears the value of the "no_standard_descriptor_accessor" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearNoStandardDescriptorAccessor() { + _hasBits0 &= ~2; + } /// Field number for the "deprecated" field. public const int DeprecatedFieldNumber = 3; + private readonly static bool DeprecatedDefaultValue = false; + private bool deprecated_; /// - /// Is this message deprecated? - /// Depending on the target platform, this can emit Deprecated annotations - /// for the message, or it will be completely ignored; in the very least, - /// this is a formalization for deprecating messages. + /// Is this message deprecated? + /// Depending on the target platform, this can emit Deprecated annotations + /// for the message, or it will be completely ignored; in the very least, + /// this is a formalization for deprecating messages. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Deprecated { - get { return deprecated_; } + get { if ((_hasBits0 & 4) != 0) { return deprecated_; } else { return DeprecatedDefaultValue; } } set { + _hasBits0 |= 4; deprecated_ = value; } } + /// Gets whether the "deprecated" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasDeprecated { + get { return (_hasBits0 & 4) != 0; } + } + /// Clears the value of the "deprecated" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearDeprecated() { + _hasBits0 &= ~4; + } /// Field number for the "map_entry" field. public const int MapEntryFieldNumber = 7; + private readonly static bool MapEntryDefaultValue = false; + private bool mapEntry_; /// - /// Whether the message is an automatically generated map entry type for the - /// maps field. + /// Whether the message is an automatically generated map entry type for the + /// maps field. /// - /// For maps fields: - /// map<KeyType, ValueType> map_field = 1; - /// The parsed descriptor looks like: - /// message MapFieldEntry { - /// option map_entry = true; - /// optional KeyType key = 1; - /// optional ValueType value = 2; - /// } - /// repeated MapFieldEntry map_field = 1; + /// For maps fields: + /// map<KeyType, ValueType> map_field = 1; + /// The parsed descriptor looks like: + /// message MapFieldEntry { + /// option map_entry = true; + /// optional KeyType key = 1; + /// optional ValueType value = 2; + /// } + /// repeated MapFieldEntry map_field = 1; /// - /// Implementations may choose not to generate the map_entry=true message, but - /// use a native map in the target language to hold the keys and values. - /// The reflection APIs in such implementions still need to work as - /// if the field is a repeated message field. + /// Implementations may choose not to generate the map_entry=true message, but + /// use a native map in the target language to hold the keys and values. + /// The reflection APIs in such implementations still need to work as + /// if the field is a repeated message field. /// - /// NOTE: Do not set the option in .proto files. Always use the maps syntax - /// instead. The option should only be implicitly set by the proto compiler - /// parser. + /// NOTE: Do not set the option in .proto files. Always use the maps syntax + /// instead. The option should only be implicitly set by the proto compiler + /// parser. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool MapEntry { - get { return mapEntry_; } + get { if ((_hasBits0 & 8) != 0) { return mapEntry_; } else { return MapEntryDefaultValue; } } set { + _hasBits0 |= 8; mapEntry_ = value; } } + /// Gets whether the "map_entry" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasMapEntry { + get { return (_hasBits0 & 8) != 0; } + } + /// Clears the value of the "map_entry" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearMapEntry() { + _hasBits0 &= ~8; + } /// Field number for the "uninterpreted_option" field. public const int UninterpretedOptionFieldNumber = 999; @@ -3239,16 +5110,19 @@ public bool MapEntry { = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); /// - /// The parser stores options it doesn't recognize here. See above. + /// The parser stores options it doesn't recognize here. See above. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as MessageOptions); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(MessageOptions other) { if (ReferenceEquals(other, null)) { return false; @@ -3261,86 +5135,117 @@ public bool Equals(MessageOptions other) { if (Deprecated != other.Deprecated) return false; if (MapEntry != other.MapEntry) return false; if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; - return true; + if (!Equals(_extensions, other._extensions)) { + return false; + } + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (MessageSetWireFormat != false) hash ^= MessageSetWireFormat.GetHashCode(); - if (NoStandardDescriptorAccessor != false) hash ^= NoStandardDescriptorAccessor.GetHashCode(); - if (Deprecated != false) hash ^= Deprecated.GetHashCode(); - if (MapEntry != false) hash ^= MapEntry.GetHashCode(); + if (HasMessageSetWireFormat) hash ^= MessageSetWireFormat.GetHashCode(); + if (HasNoStandardDescriptorAccessor) hash ^= NoStandardDescriptorAccessor.GetHashCode(); + if (HasDeprecated) hash ^= Deprecated.GetHashCode(); + if (HasMapEntry) hash ^= MapEntry.GetHashCode(); hash ^= uninterpretedOption_.GetHashCode(); + if (_extensions != null) { + hash ^= _extensions.GetHashCode(); + } + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (MessageSetWireFormat != false) { + if (HasMessageSetWireFormat) { output.WriteRawTag(8); output.WriteBool(MessageSetWireFormat); } - if (NoStandardDescriptorAccessor != false) { + if (HasNoStandardDescriptorAccessor) { output.WriteRawTag(16); output.WriteBool(NoStandardDescriptorAccessor); } - if (Deprecated != false) { + if (HasDeprecated) { output.WriteRawTag(24); output.WriteBool(Deprecated); } - if (MapEntry != false) { + if (HasMapEntry) { output.WriteRawTag(56); output.WriteBool(MapEntry); } uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); + if (_extensions != null) { + _extensions.WriteTo(output); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (MessageSetWireFormat != false) { + if (HasMessageSetWireFormat) { size += 1 + 1; } - if (NoStandardDescriptorAccessor != false) { + if (HasNoStandardDescriptorAccessor) { size += 1 + 1; } - if (Deprecated != false) { + if (HasDeprecated) { size += 1 + 1; } - if (MapEntry != false) { + if (HasMapEntry) { size += 1 + 1; } size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); + if (_extensions != null) { + size += _extensions.CalculateSize(); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(MessageOptions other) { if (other == null) { return; } - if (other.MessageSetWireFormat != false) { + if (other.HasMessageSetWireFormat) { MessageSetWireFormat = other.MessageSetWireFormat; } - if (other.NoStandardDescriptorAccessor != false) { + if (other.HasNoStandardDescriptorAccessor) { NoStandardDescriptorAccessor = other.NoStandardDescriptorAccessor; } - if (other.Deprecated != false) { + if (other.HasDeprecated) { Deprecated = other.Deprecated; } - if (other.MapEntry != false) { + if (other.HasMapEntry) { MapEntry = other.MapEntry; } uninterpretedOption_.Add(other.uninterpretedOption_); + pb::ExtensionSet.MergeFrom(ref _extensions, other._extensions); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + } break; case 8: { MessageSetWireFormat = input.ReadBool(); @@ -3366,28 +5271,58 @@ public void MergeFrom(pb::CodedInputStream input) { } } + public TValue GetExtension(pb::Extension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetOrRegisterExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.GetOrRegister(ref _extensions, extension); + } + public void SetExtension(pb::Extension extension, TValue value) { + pb::ExtensionSet.Set(ref _extensions, extension, value); + } + public bool HasExtension(pb::Extension extension) { + return pb::ExtensionSet.Has(ref _extensions, extension); + } + public void ClearExtension(pb::Extension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); + } + public void ClearExtension(pb::RepeatedExtension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); + } + } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - internal sealed partial class FieldOptions : pb::IMessage { + internal sealed partial class FieldOptions : pb::IExtendableMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FieldOptions()); + private pb::UnknownFieldSet _unknownFields; + internal pb::ExtensionSet _extensions; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[11]; } + get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[12]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FieldOptions() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FieldOptions(FieldOptions other) : this() { + _hasBits0 = other._hasBits0; ctype_ = other.ctype_; packed_ = other.packed_; jstype_ = other.jstype_; @@ -3395,133 +5330,222 @@ public FieldOptions(FieldOptions other) : this() { deprecated_ = other.deprecated_; weak_ = other.weak_; uninterpretedOption_ = other.uninterpretedOption_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + _extensions = pb::ExtensionSet.Clone(other._extensions); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FieldOptions Clone() { return new FieldOptions(this); } /// Field number for the "ctype" field. public const int CtypeFieldNumber = 1; - private global::Google.Protobuf.Reflection.FieldOptions.Types.CType ctype_ = 0; + private readonly static global::Google.Protobuf.Reflection.FieldOptions.Types.CType CtypeDefaultValue = global::Google.Protobuf.Reflection.FieldOptions.Types.CType.String; + + private global::Google.Protobuf.Reflection.FieldOptions.Types.CType ctype_; /// - /// The ctype option instructs the C++ code generator to use a different - /// representation of the field than it normally would. See the specific - /// options below. This option is not yet implemented in the open source - /// release -- sorry, we'll try to include it in a future version! + /// The ctype option instructs the C++ code generator to use a different + /// representation of the field than it normally would. See the specific + /// options below. This option is not yet implemented in the open source + /// release -- sorry, we'll try to include it in a future version! /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.Reflection.FieldOptions.Types.CType Ctype { - get { return ctype_; } + get { if ((_hasBits0 & 1) != 0) { return ctype_; } else { return CtypeDefaultValue; } } set { + _hasBits0 |= 1; ctype_ = value; } } + /// Gets whether the "ctype" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasCtype { + get { return (_hasBits0 & 1) != 0; } + } + /// Clears the value of the "ctype" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearCtype() { + _hasBits0 &= ~1; + } /// Field number for the "packed" field. public const int PackedFieldNumber = 2; + private readonly static bool PackedDefaultValue = false; + private bool packed_; /// - /// The packed option can be enabled for repeated primitive fields to enable - /// a more efficient representation on the wire. Rather than repeatedly - /// writing the tag and type for each element, the entire array is encoded as - /// a single length-delimited blob. In proto3, only explicit setting it to - /// false will avoid using packed encoding. + /// The packed option can be enabled for repeated primitive fields to enable + /// a more efficient representation on the wire. Rather than repeatedly + /// writing the tag and type for each element, the entire array is encoded as + /// a single length-delimited blob. In proto3, only explicit setting it to + /// false will avoid using packed encoding. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Packed { - get { return packed_; } + get { if ((_hasBits0 & 2) != 0) { return packed_; } else { return PackedDefaultValue; } } set { + _hasBits0 |= 2; packed_ = value; } } + /// Gets whether the "packed" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasPacked { + get { return (_hasBits0 & 2) != 0; } + } + /// Clears the value of the "packed" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearPacked() { + _hasBits0 &= ~2; + } /// Field number for the "jstype" field. public const int JstypeFieldNumber = 6; - private global::Google.Protobuf.Reflection.FieldOptions.Types.JSType jstype_ = 0; + private readonly static global::Google.Protobuf.Reflection.FieldOptions.Types.JSType JstypeDefaultValue = global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JsNormal; + + private global::Google.Protobuf.Reflection.FieldOptions.Types.JSType jstype_; /// - /// The jstype option determines the JavaScript type used for values of the - /// field. The option is permitted only for 64 bit integral and fixed types - /// (int64, uint64, sint64, fixed64, sfixed64). By default these types are - /// represented as JavaScript strings. This avoids loss of precision that can - /// happen when a large value is converted to a floating point JavaScript - /// numbers. Specifying JS_NUMBER for the jstype causes the generated - /// JavaScript code to use the JavaScript "number" type instead of strings. - /// This option is an enum to permit additional types to be added, - /// e.g. goog.math.Integer. + /// The jstype option determines the JavaScript type used for values of the + /// field. The option is permitted only for 64 bit integral and fixed types + /// (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + /// is represented as JavaScript string, which avoids loss of precision that + /// can happen when a large value is converted to a floating point JavaScript. + /// Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + /// use the JavaScript "number" type. The behavior of the default option + /// JS_NORMAL is implementation dependent. + /// + /// This option is an enum to permit additional types to be added, e.g. + /// goog.math.Integer. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.Reflection.FieldOptions.Types.JSType Jstype { - get { return jstype_; } + get { if ((_hasBits0 & 16) != 0) { return jstype_; } else { return JstypeDefaultValue; } } set { + _hasBits0 |= 16; jstype_ = value; } } + /// Gets whether the "jstype" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasJstype { + get { return (_hasBits0 & 16) != 0; } + } + /// Clears the value of the "jstype" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearJstype() { + _hasBits0 &= ~16; + } /// Field number for the "lazy" field. public const int LazyFieldNumber = 5; + private readonly static bool LazyDefaultValue = false; + private bool lazy_; /// - /// Should this field be parsed lazily? Lazy applies only to message-type - /// fields. It means that when the outer message is initially parsed, the - /// inner message's contents will not be parsed but instead stored in encoded - /// form. The inner message will actually be parsed when it is first accessed. + /// Should this field be parsed lazily? Lazy applies only to message-type + /// fields. It means that when the outer message is initially parsed, the + /// inner message's contents will not be parsed but instead stored in encoded + /// form. The inner message will actually be parsed when it is first accessed. /// - /// This is only a hint. Implementations are free to choose whether to use - /// eager or lazy parsing regardless of the value of this option. However, - /// setting this option true suggests that the protocol author believes that - /// using lazy parsing on this field is worth the additional bookkeeping - /// overhead typically needed to implement it. + /// This is only a hint. Implementations are free to choose whether to use + /// eager or lazy parsing regardless of the value of this option. However, + /// setting this option true suggests that the protocol author believes that + /// using lazy parsing on this field is worth the additional bookkeeping + /// overhead typically needed to implement it. /// - /// This option does not affect the public interface of any generated code; - /// all method signatures remain the same. Furthermore, thread-safety of the - /// interface is not affected by this option; const methods remain safe to - /// call from multiple threads concurrently, while non-const methods continue - /// to require exclusive access. + /// This option does not affect the public interface of any generated code; + /// all method signatures remain the same. Furthermore, thread-safety of the + /// interface is not affected by this option; const methods remain safe to + /// call from multiple threads concurrently, while non-const methods continue + /// to require exclusive access. /// - /// Note that implementations may choose not to check required fields within - /// a lazy sub-message. That is, calling IsInitialized() on the outher message - /// may return true even if the inner message has missing required fields. - /// This is necessary because otherwise the inner message would have to be - /// parsed in order to perform the check, defeating the purpose of lazy - /// parsing. An implementation which chooses not to check required fields - /// must be consistent about it. That is, for any particular sub-message, the - /// implementation must either *always* check its required fields, or *never* - /// check its required fields, regardless of whether or not the message has - /// been parsed. + /// Note that implementations may choose not to check required fields within + /// a lazy sub-message. That is, calling IsInitialized() on the outer message + /// may return true even if the inner message has missing required fields. + /// This is necessary because otherwise the inner message would have to be + /// parsed in order to perform the check, defeating the purpose of lazy + /// parsing. An implementation which chooses not to check required fields + /// must be consistent about it. That is, for any particular sub-message, the + /// implementation must either *always* check its required fields, or *never* + /// check its required fields, regardless of whether or not the message has + /// been parsed. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Lazy { - get { return lazy_; } + get { if ((_hasBits0 & 8) != 0) { return lazy_; } else { return LazyDefaultValue; } } set { + _hasBits0 |= 8; lazy_ = value; } } + /// Gets whether the "lazy" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasLazy { + get { return (_hasBits0 & 8) != 0; } + } + /// Clears the value of the "lazy" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearLazy() { + _hasBits0 &= ~8; + } /// Field number for the "deprecated" field. public const int DeprecatedFieldNumber = 3; + private readonly static bool DeprecatedDefaultValue = false; + private bool deprecated_; /// - /// Is this field deprecated? - /// Depending on the target platform, this can emit Deprecated annotations - /// for accessors, or it will be completely ignored; in the very least, this - /// is a formalization for deprecating fields. + /// Is this field deprecated? + /// Depending on the target platform, this can emit Deprecated annotations + /// for accessors, or it will be completely ignored; in the very least, this + /// is a formalization for deprecating fields. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Deprecated { - get { return deprecated_; } + get { if ((_hasBits0 & 4) != 0) { return deprecated_; } else { return DeprecatedDefaultValue; } } set { + _hasBits0 |= 4; deprecated_ = value; } } + /// Gets whether the "deprecated" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasDeprecated { + get { return (_hasBits0 & 4) != 0; } + } + /// Clears the value of the "deprecated" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearDeprecated() { + _hasBits0 &= ~4; + } /// Field number for the "weak" field. public const int WeakFieldNumber = 10; + private readonly static bool WeakDefaultValue = false; + private bool weak_; /// - /// For Google-internal migration only. Do not use. + /// For Google-internal migration only. Do not use. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Weak { - get { return weak_; } + get { if ((_hasBits0 & 32) != 0) { return weak_; } else { return WeakDefaultValue; } } set { + _hasBits0 |= 32; weak_ = value; } } + /// Gets whether the "weak" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasWeak { + get { return (_hasBits0 & 32) != 0; } + } + /// Clears the value of the "weak" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearWeak() { + _hasBits0 &= ~32; + } /// Field number for the "uninterpreted_option" field. public const int UninterpretedOptionFieldNumber = 999; @@ -3529,16 +5553,19 @@ public bool Weak { = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); /// - /// The parser stores options it doesn't recognize here. See above. + /// The parser stores options it doesn't recognize here. See above. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as FieldOptions); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(FieldOptions other) { if (ReferenceEquals(other, null)) { return false; @@ -3553,133 +5580,358 @@ public bool Equals(FieldOptions other) { if (Deprecated != other.Deprecated) return false; if (Weak != other.Weak) return false; if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; - return true; + if (!Equals(_extensions, other._extensions)) { + return false; + } + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (Ctype != 0) hash ^= Ctype.GetHashCode(); - if (Packed != false) hash ^= Packed.GetHashCode(); - if (Jstype != 0) hash ^= Jstype.GetHashCode(); - if (Lazy != false) hash ^= Lazy.GetHashCode(); - if (Deprecated != false) hash ^= Deprecated.GetHashCode(); - if (Weak != false) hash ^= Weak.GetHashCode(); + if (HasCtype) hash ^= Ctype.GetHashCode(); + if (HasPacked) hash ^= Packed.GetHashCode(); + if (HasJstype) hash ^= Jstype.GetHashCode(); + if (HasLazy) hash ^= Lazy.GetHashCode(); + if (HasDeprecated) hash ^= Deprecated.GetHashCode(); + if (HasWeak) hash ^= Weak.GetHashCode(); hash ^= uninterpretedOption_.GetHashCode(); + if (_extensions != null) { + hash ^= _extensions.GetHashCode(); + } + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (Ctype != 0) { + if (HasCtype) { output.WriteRawTag(8); output.WriteEnum((int) Ctype); } - if (Packed != false) { + if (HasPacked) { output.WriteRawTag(16); output.WriteBool(Packed); } - if (Deprecated != false) { + if (HasDeprecated) { output.WriteRawTag(24); output.WriteBool(Deprecated); } - if (Lazy != false) { + if (HasLazy) { output.WriteRawTag(40); output.WriteBool(Lazy); } - if (Jstype != 0) { + if (HasJstype) { output.WriteRawTag(48); output.WriteEnum((int) Jstype); } - if (Weak != false) { + if (HasWeak) { output.WriteRawTag(80); output.WriteBool(Weak); } - uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); + uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); + if (_extensions != null) { + _extensions.WriteTo(output); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (HasCtype) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Ctype); + } + if (HasPacked) { + size += 1 + 1; + } + if (HasJstype) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Jstype); + } + if (HasLazy) { + size += 1 + 1; + } + if (HasDeprecated) { + size += 1 + 1; + } + if (HasWeak) { + size += 1 + 1; + } + size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); + if (_extensions != null) { + size += _extensions.CalculateSize(); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(FieldOptions other) { + if (other == null) { + return; + } + if (other.HasCtype) { + Ctype = other.Ctype; + } + if (other.HasPacked) { + Packed = other.Packed; + } + if (other.HasJstype) { + Jstype = other.Jstype; + } + if (other.HasLazy) { + Lazy = other.Lazy; + } + if (other.HasDeprecated) { + Deprecated = other.Deprecated; + } + if (other.HasWeak) { + Weak = other.Weak; + } + uninterpretedOption_.Add(other.uninterpretedOption_); + pb::ExtensionSet.MergeFrom(ref _extensions, other._extensions); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + } + break; + case 8: { + Ctype = (global::Google.Protobuf.Reflection.FieldOptions.Types.CType) input.ReadEnum(); + break; + } + case 16: { + Packed = input.ReadBool(); + break; + } + case 24: { + Deprecated = input.ReadBool(); + break; + } + case 40: { + Lazy = input.ReadBool(); + break; + } + case 48: { + Jstype = (global::Google.Protobuf.Reflection.FieldOptions.Types.JSType) input.ReadEnum(); + break; + } + case 80: { + Weak = input.ReadBool(); + break; + } + case 7994: { + uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); + break; + } + } + } + } + + public TValue GetExtension(pb::Extension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetOrRegisterExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.GetOrRegister(ref _extensions, extension); + } + public void SetExtension(pb::Extension extension, TValue value) { + pb::ExtensionSet.Set(ref _extensions, extension, value); + } + public bool HasExtension(pb::Extension extension) { + return pb::ExtensionSet.Has(ref _extensions, extension); + } + public void ClearExtension(pb::Extension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); + } + public void ClearExtension(pb::RepeatedExtension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); + } + + #region Nested types + /// Container for nested types declared in the FieldOptions message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + internal enum CType { + /// + /// Default mode. + /// + [pbr::OriginalName("STRING")] String = 0, + [pbr::OriginalName("CORD")] Cord = 1, + [pbr::OriginalName("STRING_PIECE")] StringPiece = 2, + } + + internal enum JSType { + /// + /// Use the default type. + /// + [pbr::OriginalName("JS_NORMAL")] JsNormal = 0, + /// + /// Use JavaScript strings. + /// + [pbr::OriginalName("JS_STRING")] JsString = 1, + /// + /// Use JavaScript numbers. + /// + [pbr::OriginalName("JS_NUMBER")] JsNumber = 2, + } + + } + #endregion + + } + + internal sealed partial class OneofOptions : pb::IExtendableMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneofOptions()); + private pb::UnknownFieldSet _unknownFields; + internal pb::ExtensionSet _extensions; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[13]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public OneofOptions() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public OneofOptions(OneofOptions other) : this() { + uninterpretedOption_ = other.uninterpretedOption_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + _extensions = pb::ExtensionSet.Clone(other._extensions); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public OneofOptions Clone() { + return new OneofOptions(this); + } + + /// Field number for the "uninterpreted_option" field. + public const int UninterpretedOptionFieldNumber = 999; + private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); + private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); + /// + /// The parser stores options it doesn't recognize here. See above. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField UninterpretedOption { + get { return uninterpretedOption_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as OneofOptions); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(OneofOptions other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; + if (!Equals(_extensions, other._extensions)) { + return false; + } + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + hash ^= uninterpretedOption_.GetHashCode(); + if (_extensions != null) { + hash ^= _extensions.GetHashCode(); + } + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); + if (_extensions != null) { + _extensions.WriteTo(output); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (Ctype != 0) { - size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Ctype); - } - if (Packed != false) { - size += 1 + 1; - } - if (Jstype != 0) { - size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Jstype); - } - if (Lazy != false) { - size += 1 + 1; - } - if (Deprecated != false) { - size += 1 + 1; + size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); + if (_extensions != null) { + size += _extensions.CalculateSize(); } - if (Weak != false) { - size += 1 + 1; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); } - size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); return size; } - public void MergeFrom(FieldOptions other) { + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(OneofOptions other) { if (other == null) { return; } - if (other.Ctype != 0) { - Ctype = other.Ctype; - } - if (other.Packed != false) { - Packed = other.Packed; - } - if (other.Jstype != 0) { - Jstype = other.Jstype; - } - if (other.Lazy != false) { - Lazy = other.Lazy; - } - if (other.Deprecated != false) { - Deprecated = other.Deprecated; - } - if (other.Weak != false) { - Weak = other.Weak; - } uninterpretedOption_.Add(other.uninterpretedOption_); + pb::ExtensionSet.MergeFrom(ref _extensions, other._extensions); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); - break; - case 8: { - ctype_ = (global::Google.Protobuf.Reflection.FieldOptions.Types.CType) input.ReadEnum(); - break; - } - case 16: { - Packed = input.ReadBool(); - break; - } - case 24: { - Deprecated = input.ReadBool(); - break; - } - case 40: { - Lazy = input.ReadBool(); - break; - } - case 48: { - jstype_ = (global::Google.Protobuf.Reflection.FieldOptions.Types.JSType) input.ReadEnum(); - break; - } - case 80: { - Weak = input.ReadBool(); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + } break; - } case 7994: { uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); break; @@ -3688,97 +5940,127 @@ public void MergeFrom(pb::CodedInputStream input) { } } - #region Nested types - /// Container for nested types declared in the FieldOptions message type. - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - internal enum CType { - /// - /// Default mode. - /// - [pbr::OriginalName("STRING")] String = 0, - [pbr::OriginalName("CORD")] Cord = 1, - [pbr::OriginalName("STRING_PIECE")] StringPiece = 2, - } - - internal enum JSType { - /// - /// Use the default type. - /// - [pbr::OriginalName("JS_NORMAL")] JsNormal = 0, - /// - /// Use JavaScript strings. - /// - [pbr::OriginalName("JS_STRING")] JsString = 1, - /// - /// Use JavaScript numbers. - /// - [pbr::OriginalName("JS_NUMBER")] JsNumber = 2, - } - + public TValue GetExtension(pb::Extension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetOrRegisterExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.GetOrRegister(ref _extensions, extension); + } + public void SetExtension(pb::Extension extension, TValue value) { + pb::ExtensionSet.Set(ref _extensions, extension, value); + } + public bool HasExtension(pb::Extension extension) { + return pb::ExtensionSet.Has(ref _extensions, extension); + } + public void ClearExtension(pb::Extension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); + } + public void ClearExtension(pb::RepeatedExtension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); } - #endregion } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - internal sealed partial class EnumOptions : pb::IMessage { + internal sealed partial class EnumOptions : pb::IExtendableMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumOptions()); + private pb::UnknownFieldSet _unknownFields; + internal pb::ExtensionSet _extensions; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[12]; } + get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[14]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public EnumOptions() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public EnumOptions(EnumOptions other) : this() { + _hasBits0 = other._hasBits0; allowAlias_ = other.allowAlias_; deprecated_ = other.deprecated_; uninterpretedOption_ = other.uninterpretedOption_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + _extensions = pb::ExtensionSet.Clone(other._extensions); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public EnumOptions Clone() { return new EnumOptions(this); } /// Field number for the "allow_alias" field. public const int AllowAliasFieldNumber = 2; + private readonly static bool AllowAliasDefaultValue = false; + private bool allowAlias_; /// - /// Set this option to true to allow mapping different tag names to the same - /// value. + /// Set this option to true to allow mapping different tag names to the same + /// value. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool AllowAlias { - get { return allowAlias_; } + get { if ((_hasBits0 & 1) != 0) { return allowAlias_; } else { return AllowAliasDefaultValue; } } set { + _hasBits0 |= 1; allowAlias_ = value; } } + /// Gets whether the "allow_alias" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasAllowAlias { + get { return (_hasBits0 & 1) != 0; } + } + /// Clears the value of the "allow_alias" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearAllowAlias() { + _hasBits0 &= ~1; + } /// Field number for the "deprecated" field. public const int DeprecatedFieldNumber = 3; + private readonly static bool DeprecatedDefaultValue = false; + private bool deprecated_; /// - /// Is this enum deprecated? - /// Depending on the target platform, this can emit Deprecated annotations - /// for the enum, or it will be completely ignored; in the very least, this - /// is a formalization for deprecating enums. + /// Is this enum deprecated? + /// Depending on the target platform, this can emit Deprecated annotations + /// for the enum, or it will be completely ignored; in the very least, this + /// is a formalization for deprecating enums. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Deprecated { - get { return deprecated_; } + get { if ((_hasBits0 & 2) != 0) { return deprecated_; } else { return DeprecatedDefaultValue; } } set { + _hasBits0 |= 2; deprecated_ = value; } } + /// Gets whether the "deprecated" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasDeprecated { + get { return (_hasBits0 & 2) != 0; } + } + /// Clears the value of the "deprecated" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearDeprecated() { + _hasBits0 &= ~2; + } /// Field number for the "uninterpreted_option" field. public const int UninterpretedOptionFieldNumber = 999; @@ -3786,16 +6068,19 @@ public bool Deprecated { = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); /// - /// The parser stores options it doesn't recognize here. See above. + /// The parser stores options it doesn't recognize here. See above. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as EnumOptions); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(EnumOptions other) { if (ReferenceEquals(other, null)) { return false; @@ -3806,64 +6091,95 @@ public bool Equals(EnumOptions other) { if (AllowAlias != other.AllowAlias) return false; if (Deprecated != other.Deprecated) return false; if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; - return true; + if (!Equals(_extensions, other._extensions)) { + return false; + } + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (AllowAlias != false) hash ^= AllowAlias.GetHashCode(); - if (Deprecated != false) hash ^= Deprecated.GetHashCode(); + if (HasAllowAlias) hash ^= AllowAlias.GetHashCode(); + if (HasDeprecated) hash ^= Deprecated.GetHashCode(); hash ^= uninterpretedOption_.GetHashCode(); + if (_extensions != null) { + hash ^= _extensions.GetHashCode(); + } + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (AllowAlias != false) { + if (HasAllowAlias) { output.WriteRawTag(16); output.WriteBool(AllowAlias); } - if (Deprecated != false) { + if (HasDeprecated) { output.WriteRawTag(24); output.WriteBool(Deprecated); } uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); + if (_extensions != null) { + _extensions.WriteTo(output); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (AllowAlias != false) { + if (HasAllowAlias) { size += 1 + 1; } - if (Deprecated != false) { + if (HasDeprecated) { size += 1 + 1; } size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); + if (_extensions != null) { + size += _extensions.CalculateSize(); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(EnumOptions other) { if (other == null) { return; } - if (other.AllowAlias != false) { + if (other.HasAllowAlias) { AllowAlias = other.AllowAlias; } - if (other.Deprecated != false) { + if (other.HasDeprecated) { Deprecated = other.Deprecated; } uninterpretedOption_.Add(other.uninterpretedOption_); + pb::ExtensionSet.MergeFrom(ref _extensions, other._extensions); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + } break; case 16: { AllowAlias = input.ReadBool(); @@ -3881,51 +6197,98 @@ public void MergeFrom(pb::CodedInputStream input) { } } + public TValue GetExtension(pb::Extension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetOrRegisterExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.GetOrRegister(ref _extensions, extension); + } + public void SetExtension(pb::Extension extension, TValue value) { + pb::ExtensionSet.Set(ref _extensions, extension, value); + } + public bool HasExtension(pb::Extension extension) { + return pb::ExtensionSet.Has(ref _extensions, extension); + } + public void ClearExtension(pb::Extension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); + } + public void ClearExtension(pb::RepeatedExtension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); + } + } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - internal sealed partial class EnumValueOptions : pb::IMessage { + internal sealed partial class EnumValueOptions : pb::IExtendableMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumValueOptions()); + private pb::UnknownFieldSet _unknownFields; + internal pb::ExtensionSet _extensions; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[13]; } + get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[15]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public EnumValueOptions() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public EnumValueOptions(EnumValueOptions other) : this() { + _hasBits0 = other._hasBits0; deprecated_ = other.deprecated_; uninterpretedOption_ = other.uninterpretedOption_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + _extensions = pb::ExtensionSet.Clone(other._extensions); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public EnumValueOptions Clone() { return new EnumValueOptions(this); } /// Field number for the "deprecated" field. public const int DeprecatedFieldNumber = 1; + private readonly static bool DeprecatedDefaultValue = false; + private bool deprecated_; /// - /// Is this enum value deprecated? - /// Depending on the target platform, this can emit Deprecated annotations - /// for the enum value, or it will be completely ignored; in the very least, - /// this is a formalization for deprecating enum values. + /// Is this enum value deprecated? + /// Depending on the target platform, this can emit Deprecated annotations + /// for the enum value, or it will be completely ignored; in the very least, + /// this is a formalization for deprecating enum values. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Deprecated { - get { return deprecated_; } + get { if ((_hasBits0 & 1) != 0) { return deprecated_; } else { return DeprecatedDefaultValue; } } set { + _hasBits0 |= 1; deprecated_ = value; } } + /// Gets whether the "deprecated" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasDeprecated { + get { return (_hasBits0 & 1) != 0; } + } + /// Clears the value of the "deprecated" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearDeprecated() { + _hasBits0 &= ~1; + } /// Field number for the "uninterpreted_option" field. public const int UninterpretedOptionFieldNumber = 999; @@ -3933,16 +6296,19 @@ public bool Deprecated { = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); /// - /// The parser stores options it doesn't recognize here. See above. + /// The parser stores options it doesn't recognize here. See above. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as EnumValueOptions); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(EnumValueOptions other) { if (ReferenceEquals(other, null)) { return false; @@ -3952,53 +6318,84 @@ public bool Equals(EnumValueOptions other) { } if (Deprecated != other.Deprecated) return false; if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; - return true; + if (!Equals(_extensions, other._extensions)) { + return false; + } + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (Deprecated != false) hash ^= Deprecated.GetHashCode(); + if (HasDeprecated) hash ^= Deprecated.GetHashCode(); hash ^= uninterpretedOption_.GetHashCode(); + if (_extensions != null) { + hash ^= _extensions.GetHashCode(); + } + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (Deprecated != false) { + if (HasDeprecated) { output.WriteRawTag(8); output.WriteBool(Deprecated); } uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); + if (_extensions != null) { + _extensions.WriteTo(output); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (Deprecated != false) { + if (HasDeprecated) { size += 1 + 1; } size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); + if (_extensions != null) { + size += _extensions.CalculateSize(); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(EnumValueOptions other) { if (other == null) { return; } - if (other.Deprecated != false) { + if (other.HasDeprecated) { Deprecated = other.Deprecated; } uninterpretedOption_.Add(other.uninterpretedOption_); + pb::ExtensionSet.MergeFrom(ref _extensions, other._extensions); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + } break; case 8: { Deprecated = input.ReadBool(); @@ -4012,51 +6409,98 @@ public void MergeFrom(pb::CodedInputStream input) { } } + public TValue GetExtension(pb::Extension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetOrRegisterExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.GetOrRegister(ref _extensions, extension); + } + public void SetExtension(pb::Extension extension, TValue value) { + pb::ExtensionSet.Set(ref _extensions, extension, value); + } + public bool HasExtension(pb::Extension extension) { + return pb::ExtensionSet.Has(ref _extensions, extension); + } + public void ClearExtension(pb::Extension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); + } + public void ClearExtension(pb::RepeatedExtension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); + } + } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - internal sealed partial class ServiceOptions : pb::IMessage { + internal sealed partial class ServiceOptions : pb::IExtendableMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServiceOptions()); + private pb::UnknownFieldSet _unknownFields; + internal pb::ExtensionSet _extensions; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[14]; } + get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[16]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ServiceOptions() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ServiceOptions(ServiceOptions other) : this() { + _hasBits0 = other._hasBits0; deprecated_ = other.deprecated_; uninterpretedOption_ = other.uninterpretedOption_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + _extensions = pb::ExtensionSet.Clone(other._extensions); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ServiceOptions Clone() { return new ServiceOptions(this); } /// Field number for the "deprecated" field. public const int DeprecatedFieldNumber = 33; + private readonly static bool DeprecatedDefaultValue = false; + private bool deprecated_; /// - /// Is this service deprecated? - /// Depending on the target platform, this can emit Deprecated annotations - /// for the service, or it will be completely ignored; in the very least, - /// this is a formalization for deprecating services. + /// Is this service deprecated? + /// Depending on the target platform, this can emit Deprecated annotations + /// for the service, or it will be completely ignored; in the very least, + /// this is a formalization for deprecating services. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Deprecated { - get { return deprecated_; } + get { if ((_hasBits0 & 1) != 0) { return deprecated_; } else { return DeprecatedDefaultValue; } } set { + _hasBits0 |= 1; deprecated_ = value; } } + /// Gets whether the "deprecated" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasDeprecated { + get { return (_hasBits0 & 1) != 0; } + } + /// Clears the value of the "deprecated" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearDeprecated() { + _hasBits0 &= ~1; + } /// Field number for the "uninterpreted_option" field. public const int UninterpretedOptionFieldNumber = 999; @@ -4064,16 +6508,19 @@ public bool Deprecated { = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); /// - /// The parser stores options it doesn't recognize here. See above. + /// The parser stores options it doesn't recognize here. See above. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ServiceOptions); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(ServiceOptions other) { if (ReferenceEquals(other, null)) { return false; @@ -4083,53 +6530,84 @@ public bool Equals(ServiceOptions other) { } if (Deprecated != other.Deprecated) return false; if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; - return true; + if (!Equals(_extensions, other._extensions)) { + return false; + } + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (Deprecated != false) hash ^= Deprecated.GetHashCode(); + if (HasDeprecated) hash ^= Deprecated.GetHashCode(); hash ^= uninterpretedOption_.GetHashCode(); + if (_extensions != null) { + hash ^= _extensions.GetHashCode(); + } + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (Deprecated != false) { + if (HasDeprecated) { output.WriteRawTag(136, 2); output.WriteBool(Deprecated); } uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); + if (_extensions != null) { + _extensions.WriteTo(output); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (Deprecated != false) { + if (HasDeprecated) { size += 2 + 1; } size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); + if (_extensions != null) { + size += _extensions.CalculateSize(); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(ServiceOptions other) { if (other == null) { return; } - if (other.Deprecated != false) { + if (other.HasDeprecated) { Deprecated = other.Deprecated; } uninterpretedOption_.Add(other.uninterpretedOption_); + pb::ExtensionSet.MergeFrom(ref _extensions, other._extensions); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + } break; case 264: { Deprecated = input.ReadBool(); @@ -4143,51 +6621,123 @@ public void MergeFrom(pb::CodedInputStream input) { } } + public TValue GetExtension(pb::Extension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetOrRegisterExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.GetOrRegister(ref _extensions, extension); + } + public void SetExtension(pb::Extension extension, TValue value) { + pb::ExtensionSet.Set(ref _extensions, extension, value); + } + public bool HasExtension(pb::Extension extension) { + return pb::ExtensionSet.Has(ref _extensions, extension); + } + public void ClearExtension(pb::Extension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); + } + public void ClearExtension(pb::RepeatedExtension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); + } + } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - internal sealed partial class MethodOptions : pb::IMessage { + internal sealed partial class MethodOptions : pb::IExtendableMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MethodOptions()); + private pb::UnknownFieldSet _unknownFields; + internal pb::ExtensionSet _extensions; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[15]; } + get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[17]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MethodOptions() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MethodOptions(MethodOptions other) : this() { + _hasBits0 = other._hasBits0; deprecated_ = other.deprecated_; + idempotencyLevel_ = other.idempotencyLevel_; uninterpretedOption_ = other.uninterpretedOption_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + _extensions = pb::ExtensionSet.Clone(other._extensions); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MethodOptions Clone() { return new MethodOptions(this); } /// Field number for the "deprecated" field. public const int DeprecatedFieldNumber = 33; + private readonly static bool DeprecatedDefaultValue = false; + private bool deprecated_; /// - /// Is this method deprecated? - /// Depending on the target platform, this can emit Deprecated annotations - /// for the method, or it will be completely ignored; in the very least, - /// this is a formalization for deprecating methods. + /// Is this method deprecated? + /// Depending on the target platform, this can emit Deprecated annotations + /// for the method, or it will be completely ignored; in the very least, + /// this is a formalization for deprecating methods. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Deprecated { - get { return deprecated_; } + get { if ((_hasBits0 & 1) != 0) { return deprecated_; } else { return DeprecatedDefaultValue; } } set { + _hasBits0 |= 1; deprecated_ = value; } } + /// Gets whether the "deprecated" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasDeprecated { + get { return (_hasBits0 & 1) != 0; } + } + /// Clears the value of the "deprecated" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearDeprecated() { + _hasBits0 &= ~1; + } + + /// Field number for the "idempotency_level" field. + public const int IdempotencyLevelFieldNumber = 34; + private readonly static global::Google.Protobuf.Reflection.MethodOptions.Types.IdempotencyLevel IdempotencyLevelDefaultValue = global::Google.Protobuf.Reflection.MethodOptions.Types.IdempotencyLevel.IdempotencyUnknown; + + private global::Google.Protobuf.Reflection.MethodOptions.Types.IdempotencyLevel idempotencyLevel_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.Reflection.MethodOptions.Types.IdempotencyLevel IdempotencyLevel { + get { if ((_hasBits0 & 2) != 0) { return idempotencyLevel_; } else { return IdempotencyLevelDefaultValue; } } + set { + _hasBits0 |= 2; + idempotencyLevel_ = value; + } + } + /// Gets whether the "idempotency_level" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasIdempotencyLevel { + get { return (_hasBits0 & 2) != 0; } + } + /// Clears the value of the "idempotency_level" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearIdempotencyLevel() { + _hasBits0 &= ~2; + } /// Field number for the "uninterpreted_option" field. public const int UninterpretedOptionFieldNumber = 999; @@ -4195,16 +6745,19 @@ public bool Deprecated { = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); /// - /// The parser stores options it doesn't recognize here. See above. + /// The parser stores options it doesn't recognize here. See above. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as MethodOptions); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(MethodOptions other) { if (ReferenceEquals(other, null)) { return false; @@ -4213,59 +6766,106 @@ public bool Equals(MethodOptions other) { return true; } if (Deprecated != other.Deprecated) return false; + if (IdempotencyLevel != other.IdempotencyLevel) return false; if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; - return true; + if (!Equals(_extensions, other._extensions)) { + return false; + } + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (Deprecated != false) hash ^= Deprecated.GetHashCode(); + if (HasDeprecated) hash ^= Deprecated.GetHashCode(); + if (HasIdempotencyLevel) hash ^= IdempotencyLevel.GetHashCode(); hash ^= uninterpretedOption_.GetHashCode(); + if (_extensions != null) { + hash ^= _extensions.GetHashCode(); + } + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (Deprecated != false) { + if (HasDeprecated) { output.WriteRawTag(136, 2); output.WriteBool(Deprecated); } + if (HasIdempotencyLevel) { + output.WriteRawTag(144, 2); + output.WriteEnum((int) IdempotencyLevel); + } uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); + if (_extensions != null) { + _extensions.WriteTo(output); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (Deprecated != false) { + if (HasDeprecated) { size += 2 + 1; } + if (HasIdempotencyLevel) { + size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) IdempotencyLevel); + } size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); + if (_extensions != null) { + size += _extensions.CalculateSize(); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(MethodOptions other) { if (other == null) { return; } - if (other.Deprecated != false) { + if (other.HasDeprecated) { Deprecated = other.Deprecated; } + if (other.HasIdempotencyLevel) { + IdempotencyLevel = other.IdempotencyLevel; + } uninterpretedOption_.Add(other.uninterpretedOption_); + pb::ExtensionSet.MergeFrom(ref _extensions, other._extensions); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + } break; case 264: { Deprecated = input.ReadBool(); break; } + case 272: { + IdempotencyLevel = (global::Google.Protobuf.Reflection.MethodOptions.Types.IdempotencyLevel) input.ReadEnum(); + break; + } case 7994: { uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); break; @@ -4274,36 +6874,89 @@ public void MergeFrom(pb::CodedInputStream input) { } } + public TValue GetExtension(pb::Extension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetOrRegisterExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.GetOrRegister(ref _extensions, extension); + } + public void SetExtension(pb::Extension extension, TValue value) { + pb::ExtensionSet.Set(ref _extensions, extension, value); + } + public bool HasExtension(pb::Extension extension) { + return pb::ExtensionSet.Has(ref _extensions, extension); + } + public void ClearExtension(pb::Extension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); + } + public void ClearExtension(pb::RepeatedExtension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); + } + + #region Nested types + /// Container for nested types declared in the MethodOptions message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + /// + /// Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + /// or neither? HTTP based RPC implementation may choose GET verb for safe + /// methods, and PUT verb for idempotent methods instead of the default POST. + /// + internal enum IdempotencyLevel { + [pbr::OriginalName("IDEMPOTENCY_UNKNOWN")] IdempotencyUnknown = 0, + /// + /// implies idempotent + /// + [pbr::OriginalName("NO_SIDE_EFFECTS")] NoSideEffects = 1, + /// + /// idempotent, but may have side effects + /// + [pbr::OriginalName("IDEMPOTENT")] Idempotent = 2, + } + + } + #endregion + } /// - /// A message representing a option the parser does not recognize. This only - /// appears in options protos created by the compiler::Parser class. - /// DescriptorPool resolves these when building Descriptor objects. Therefore, - /// options protos in descriptor objects (e.g. returned by Descriptor::options(), - /// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions - /// in them. + /// A message representing a option the parser does not recognize. This only + /// appears in options protos created by the compiler::Parser class. + /// DescriptorPool resolves these when building Descriptor objects. Therefore, + /// options protos in descriptor objects (e.g. returned by Descriptor::options(), + /// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + /// in them. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal sealed partial class UninterpretedOption : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new UninterpretedOption()); + private pb::UnknownFieldSet _unknownFields; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[16]; } + get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[18]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public UninterpretedOption() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public UninterpretedOption(UninterpretedOption other) : this() { + _hasBits0 = other._hasBits0; name_ = other.name_.Clone(); identifierValue_ = other.identifierValue_; positiveIntValue_ = other.positiveIntValue_; @@ -4311,8 +6964,10 @@ public UninterpretedOption(UninterpretedOption other) : this() { doubleValue_ = other.doubleValue_; stringValue_ = other.stringValue_; aggregateValue_ = other.aggregateValue_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public UninterpretedOption Clone() { return new UninterpretedOption(this); } @@ -4322,78 +6977,162 @@ public UninterpretedOption Clone() { private static readonly pb::FieldCodec _repeated_name_codec = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.Reflection.UninterpretedOption.Types.NamePart.Parser); private readonly pbc::RepeatedField name_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Name { get { return name_; } } /// Field number for the "identifier_value" field. public const int IdentifierValueFieldNumber = 3; - private string identifierValue_ = ""; + private readonly static string IdentifierValueDefaultValue = ""; + + private string identifierValue_; /// - /// The value of the uninterpreted option, in whatever type the tokenizer - /// identified it as during parsing. Exactly one of these should be set. + /// The value of the uninterpreted option, in whatever type the tokenizer + /// identified it as during parsing. Exactly one of these should be set. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string IdentifierValue { - get { return identifierValue_; } + get { return identifierValue_ ?? IdentifierValueDefaultValue; } set { identifierValue_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "identifier_value" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasIdentifierValue { + get { return identifierValue_ != null; } + } + /// Clears the value of the "identifier_value" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearIdentifierValue() { + identifierValue_ = null; + } /// Field number for the "positive_int_value" field. public const int PositiveIntValueFieldNumber = 4; + private readonly static ulong PositiveIntValueDefaultValue = 0UL; + private ulong positiveIntValue_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ulong PositiveIntValue { - get { return positiveIntValue_; } + get { if ((_hasBits0 & 1) != 0) { return positiveIntValue_; } else { return PositiveIntValueDefaultValue; } } set { + _hasBits0 |= 1; positiveIntValue_ = value; } } + /// Gets whether the "positive_int_value" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasPositiveIntValue { + get { return (_hasBits0 & 1) != 0; } + } + /// Clears the value of the "positive_int_value" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearPositiveIntValue() { + _hasBits0 &= ~1; + } /// Field number for the "negative_int_value" field. public const int NegativeIntValueFieldNumber = 5; + private readonly static long NegativeIntValueDefaultValue = 0L; + private long negativeIntValue_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public long NegativeIntValue { - get { return negativeIntValue_; } + get { if ((_hasBits0 & 2) != 0) { return negativeIntValue_; } else { return NegativeIntValueDefaultValue; } } set { + _hasBits0 |= 2; negativeIntValue_ = value; } } + /// Gets whether the "negative_int_value" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasNegativeIntValue { + get { return (_hasBits0 & 2) != 0; } + } + /// Clears the value of the "negative_int_value" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearNegativeIntValue() { + _hasBits0 &= ~2; + } /// Field number for the "double_value" field. public const int DoubleValueFieldNumber = 6; + private readonly static double DoubleValueDefaultValue = 0D; + private double doubleValue_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public double DoubleValue { - get { return doubleValue_; } + get { if ((_hasBits0 & 4) != 0) { return doubleValue_; } else { return DoubleValueDefaultValue; } } set { + _hasBits0 |= 4; doubleValue_ = value; } } + /// Gets whether the "double_value" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasDoubleValue { + get { return (_hasBits0 & 4) != 0; } + } + /// Clears the value of the "double_value" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearDoubleValue() { + _hasBits0 &= ~4; + } /// Field number for the "string_value" field. public const int StringValueFieldNumber = 7; - private pb::ByteString stringValue_ = pb::ByteString.Empty; + private readonly static pb::ByteString StringValueDefaultValue = pb::ByteString.Empty; + + private pb::ByteString stringValue_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pb::ByteString StringValue { - get { return stringValue_; } + get { return stringValue_ ?? StringValueDefaultValue; } set { stringValue_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "string_value" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasStringValue { + get { return stringValue_ != null; } + } + /// Clears the value of the "string_value" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearStringValue() { + stringValue_ = null; + } /// Field number for the "aggregate_value" field. public const int AggregateValueFieldNumber = 8; - private string aggregateValue_ = ""; + private readonly static string AggregateValueDefaultValue = ""; + + private string aggregateValue_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string AggregateValue { - get { return aggregateValue_; } + get { return aggregateValue_ ?? AggregateValueDefaultValue; } set { aggregateValue_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "aggregate_value" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasAggregateValue { + get { return aggregateValue_ != null; } + } + /// Clears the value of the "aggregate_value" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearAggregateValue() { + aggregateValue_ = null; + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as UninterpretedOption); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(UninterpretedOption other) { if (ReferenceEquals(other, null)) { return false; @@ -4405,111 +7144,127 @@ public bool Equals(UninterpretedOption other) { if (IdentifierValue != other.IdentifierValue) return false; if (PositiveIntValue != other.PositiveIntValue) return false; if (NegativeIntValue != other.NegativeIntValue) return false; - if (DoubleValue != other.DoubleValue) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleValue, other.DoubleValue)) return false; if (StringValue != other.StringValue) return false; if (AggregateValue != other.AggregateValue) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= name_.GetHashCode(); - if (IdentifierValue.Length != 0) hash ^= IdentifierValue.GetHashCode(); - if (PositiveIntValue != 0UL) hash ^= PositiveIntValue.GetHashCode(); - if (NegativeIntValue != 0L) hash ^= NegativeIntValue.GetHashCode(); - if (DoubleValue != 0D) hash ^= DoubleValue.GetHashCode(); - if (StringValue.Length != 0) hash ^= StringValue.GetHashCode(); - if (AggregateValue.Length != 0) hash ^= AggregateValue.GetHashCode(); + if (HasIdentifierValue) hash ^= IdentifierValue.GetHashCode(); + if (HasPositiveIntValue) hash ^= PositiveIntValue.GetHashCode(); + if (HasNegativeIntValue) hash ^= NegativeIntValue.GetHashCode(); + if (HasDoubleValue) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleValue); + if (HasStringValue) hash ^= StringValue.GetHashCode(); + if (HasAggregateValue) hash ^= AggregateValue.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { name_.WriteTo(output, _repeated_name_codec); - if (IdentifierValue.Length != 0) { + if (HasIdentifierValue) { output.WriteRawTag(26); output.WriteString(IdentifierValue); } - if (PositiveIntValue != 0UL) { + if (HasPositiveIntValue) { output.WriteRawTag(32); output.WriteUInt64(PositiveIntValue); } - if (NegativeIntValue != 0L) { + if (HasNegativeIntValue) { output.WriteRawTag(40); output.WriteInt64(NegativeIntValue); } - if (DoubleValue != 0D) { + if (HasDoubleValue) { output.WriteRawTag(49); output.WriteDouble(DoubleValue); } - if (StringValue.Length != 0) { + if (HasStringValue) { output.WriteRawTag(58); output.WriteBytes(StringValue); } - if (AggregateValue.Length != 0) { + if (HasAggregateValue) { output.WriteRawTag(66); output.WriteString(AggregateValue); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += name_.CalculateSize(_repeated_name_codec); - if (IdentifierValue.Length != 0) { + if (HasIdentifierValue) { size += 1 + pb::CodedOutputStream.ComputeStringSize(IdentifierValue); } - if (PositiveIntValue != 0UL) { + if (HasPositiveIntValue) { size += 1 + pb::CodedOutputStream.ComputeUInt64Size(PositiveIntValue); } - if (NegativeIntValue != 0L) { + if (HasNegativeIntValue) { size += 1 + pb::CodedOutputStream.ComputeInt64Size(NegativeIntValue); } - if (DoubleValue != 0D) { + if (HasDoubleValue) { size += 1 + 8; } - if (StringValue.Length != 0) { + if (HasStringValue) { size += 1 + pb::CodedOutputStream.ComputeBytesSize(StringValue); } - if (AggregateValue.Length != 0) { + if (HasAggregateValue) { size += 1 + pb::CodedOutputStream.ComputeStringSize(AggregateValue); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(UninterpretedOption other) { if (other == null) { return; } name_.Add(other.name_); - if (other.IdentifierValue.Length != 0) { + if (other.HasIdentifierValue) { IdentifierValue = other.IdentifierValue; } - if (other.PositiveIntValue != 0UL) { + if (other.HasPositiveIntValue) { PositiveIntValue = other.PositiveIntValue; } - if (other.NegativeIntValue != 0L) { + if (other.HasNegativeIntValue) { NegativeIntValue = other.NegativeIntValue; } - if (other.DoubleValue != 0D) { + if (other.HasDoubleValue) { DoubleValue = other.DoubleValue; } - if (other.StringValue.Length != 0) { + if (other.HasStringValue) { StringValue = other.StringValue; } - if (other.AggregateValue.Length != 0) { + if (other.HasAggregateValue) { AggregateValue = other.AggregateValue; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 18: { name_.AddEntriesFrom(input, _repeated_name_codec); @@ -4545,67 +7300,105 @@ public void MergeFrom(pb::CodedInputStream input) { #region Nested types /// Container for nested types declared in the UninterpretedOption message type. - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { /// - /// The name of the uninterpreted option. Each string represents a segment in - /// a dot-separated name. is_extension is true iff a segment represents an - /// extension (denoted with parentheses in options specs in .proto files). - /// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents - /// "foo.(bar.baz).qux". + /// The name of the uninterpreted option. Each string represents a segment in + /// a dot-separated name. is_extension is true iff a segment represents an + /// extension (denoted with parentheses in options specs in .proto files). + /// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + /// "foo.(bar.baz).qux". /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal sealed partial class NamePart : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NamePart()); + private pb::UnknownFieldSet _unknownFields; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.Reflection.UninterpretedOption.Descriptor.NestedTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NamePart() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NamePart(NamePart other) : this() { + _hasBits0 = other._hasBits0; namePart_ = other.namePart_; isExtension_ = other.isExtension_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NamePart Clone() { return new NamePart(this); } /// Field number for the "name_part" field. public const int NamePart_FieldNumber = 1; - private string namePart_ = ""; + private readonly static string NamePart_DefaultValue = ""; + + private string namePart_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string NamePart_ { - get { return namePart_; } + get { return namePart_ ?? NamePart_DefaultValue; } set { namePart_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "name_part" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasNamePart_ { + get { return namePart_ != null; } + } + /// Clears the value of the "name_part" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearNamePart_() { + namePart_ = null; + } /// Field number for the "is_extension" field. public const int IsExtensionFieldNumber = 2; + private readonly static bool IsExtensionDefaultValue = false; + private bool isExtension_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool IsExtension { - get { return isExtension_; } + get { if ((_hasBits0 & 1) != 0) { return isExtension_; } else { return IsExtensionDefaultValue; } } set { + _hasBits0 |= 1; isExtension_ = value; } } + /// Gets whether the "is_extension" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasIsExtension { + get { return (_hasBits0 & 1) != 0; } + } + /// Clears the value of the "is_extension" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearIsExtension() { + _hasBits0 &= ~1; + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as NamePart); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(NamePart other) { if (ReferenceEquals(other, null)) { return false; @@ -4615,60 +7408,76 @@ public bool Equals(NamePart other) { } if (NamePart_ != other.NamePart_) return false; if (IsExtension != other.IsExtension) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (NamePart_.Length != 0) hash ^= NamePart_.GetHashCode(); - if (IsExtension != false) hash ^= IsExtension.GetHashCode(); + if (HasNamePart_) hash ^= NamePart_.GetHashCode(); + if (HasIsExtension) hash ^= IsExtension.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (NamePart_.Length != 0) { + if (HasNamePart_) { output.WriteRawTag(10); output.WriteString(NamePart_); } - if (IsExtension != false) { + if (HasIsExtension) { output.WriteRawTag(16); output.WriteBool(IsExtension); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (NamePart_.Length != 0) { + if (HasNamePart_) { size += 1 + pb::CodedOutputStream.ComputeStringSize(NamePart_); } - if (IsExtension != false) { + if (HasIsExtension) { size += 1 + 1; } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(NamePart other) { if (other == null) { return; } - if (other.NamePart_.Length != 0) { + if (other.HasNamePart_) { NamePart_ = other.NamePart_; } - if (other.IsExtension != false) { + if (other.HasIsExtension) { IsExtension = other.IsExtension; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { NamePart_ = input.ReadString(); @@ -4690,32 +7499,39 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Encapsulates information about the original source file from which a - /// FileDescriptorProto was generated. + /// Encapsulates information about the original source file from which a + /// FileDescriptorProto was generated. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal sealed partial class SourceCodeInfo : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SourceCodeInfo()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[17]; } + get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[19]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public SourceCodeInfo() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public SourceCodeInfo(SourceCodeInfo other) : this() { location_ = other.location_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public SourceCodeInfo Clone() { return new SourceCodeInfo(this); } @@ -4726,58 +7542,61 @@ public SourceCodeInfo Clone() { = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location.Parser); private readonly pbc::RepeatedField location_ = new pbc::RepeatedField(); /// - /// A Location identifies a piece of source code in a .proto file which - /// corresponds to a particular definition. This information is intended - /// to be useful to IDEs, code indexers, documentation generators, and similar - /// tools. + /// A Location identifies a piece of source code in a .proto file which + /// corresponds to a particular definition. This information is intended + /// to be useful to IDEs, code indexers, documentation generators, and similar + /// tools. /// - /// For example, say we have a file like: - /// message Foo { - /// optional string foo = 1; - /// } - /// Let's look at just the field definition: - /// optional string foo = 1; - /// ^ ^^ ^^ ^ ^^^ - /// a bc de f ghi - /// We have the following locations: - /// span path represents - /// [a,i) [ 4, 0, 2, 0 ] The whole field definition. - /// [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). - /// [c,d) [ 4, 0, 2, 0, 5 ] The type (string). - /// [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). - /// [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + /// For example, say we have a file like: + /// message Foo { + /// optional string foo = 1; + /// } + /// Let's look at just the field definition: + /// optional string foo = 1; + /// ^ ^^ ^^ ^ ^^^ + /// a bc de f ghi + /// We have the following locations: + /// span path represents + /// [a,i) [ 4, 0, 2, 0 ] The whole field definition. + /// [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + /// [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + /// [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + /// [g,h) [ 4, 0, 2, 0, 3 ] The number (1). /// - /// Notes: - /// - A location may refer to a repeated field itself (i.e. not to any - /// particular index within it). This is used whenever a set of elements are - /// logically enclosed in a single code segment. For example, an entire - /// extend block (possibly containing multiple extension definitions) will - /// have an outer location whose path refers to the "extensions" repeated - /// field without an index. - /// - Multiple locations may have the same path. This happens when a single - /// logical declaration is spread out across multiple places. The most - /// obvious example is the "extend" block again -- there may be multiple - /// extend blocks in the same scope, each of which will have the same path. - /// - A location's span is not always a subset of its parent's span. For - /// example, the "extendee" of an extension declaration appears at the - /// beginning of the "extend" block and is shared by all extensions within - /// the block. - /// - Just because a location's span is a subset of some other location's span - /// does not mean that it is a descendent. For example, a "group" defines - /// both a type and a field in a single declaration. Thus, the locations - /// corresponding to the type and field and their components will overlap. - /// - Code which tries to interpret locations should probably be designed to - /// ignore those that it doesn't understand, as more types of locations could - /// be recorded in the future. + /// Notes: + /// - A location may refer to a repeated field itself (i.e. not to any + /// particular index within it). This is used whenever a set of elements are + /// logically enclosed in a single code segment. For example, an entire + /// extend block (possibly containing multiple extension definitions) will + /// have an outer location whose path refers to the "extensions" repeated + /// field without an index. + /// - Multiple locations may have the same path. This happens when a single + /// logical declaration is spread out across multiple places. The most + /// obvious example is the "extend" block again -- there may be multiple + /// extend blocks in the same scope, each of which will have the same path. + /// - A location's span is not always a subset of its parent's span. For + /// example, the "extendee" of an extension declaration appears at the + /// beginning of the "extend" block and is shared by all extensions within + /// the block. + /// - Just because a location's span is a subset of some other location's span + /// does not mean that it is a descendant. For example, a "group" defines + /// both a type and a field in a single declaration. Thus, the locations + /// corresponding to the type and field and their components will overlap. + /// - Code which tries to interpret locations should probably be designed to + /// ignore those that it doesn't understand, as more types of locations could + /// be recorded in the future. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Location { get { return location_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as SourceCodeInfo); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(SourceCodeInfo other) { if (ReferenceEquals(other, null)) { return false; @@ -4786,42 +7605,58 @@ public bool Equals(SourceCodeInfo other) { return true; } if(!location_.Equals(other.location_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= location_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { location_.WriteTo(output, _repeated_location_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += location_.CalculateSize(_repeated_location_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(SourceCodeInfo other) { if (other == null) { return; } location_.Add(other.location_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { location_.AddEntriesFrom(input, _repeated_location_codec); @@ -4833,35 +7668,42 @@ public void MergeFrom(pb::CodedInputStream input) { #region Nested types /// Container for nested types declared in the SourceCodeInfo message type. - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal sealed partial class Location : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Location()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.Reflection.SourceCodeInfo.Descriptor.NestedTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Location() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Location(Location other) : this() { path_ = other.path_.Clone(); span_ = other.span_.Clone(); leadingComments_ = other.leadingComments_; trailingComments_ = other.trailingComments_; leadingDetachedComments_ = other.leadingDetachedComments_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Location Clone() { return new Location(this); } @@ -4872,30 +7714,31 @@ public Location Clone() { = pb::FieldCodec.ForInt32(10); private readonly pbc::RepeatedField path_ = new pbc::RepeatedField(); /// - /// Identifies which part of the FileDescriptorProto was defined at this - /// location. + /// Identifies which part of the FileDescriptorProto was defined at this + /// location. /// - /// Each element is a field number or an index. They form a path from - /// the root FileDescriptorProto to the place where the definition. For - /// example, this path: - /// [ 4, 3, 2, 7, 1 ] - /// refers to: - /// file.message_type(3) // 4, 3 - /// .field(7) // 2, 7 - /// .name() // 1 - /// This is because FileDescriptorProto.message_type has field number 4: - /// repeated DescriptorProto message_type = 4; - /// and DescriptorProto.field has field number 2: - /// repeated FieldDescriptorProto field = 2; - /// and FieldDescriptorProto.name has field number 1: - /// optional string name = 1; + /// Each element is a field number or an index. They form a path from + /// the root FileDescriptorProto to the place where the definition. For + /// example, this path: + /// [ 4, 3, 2, 7, 1 ] + /// refers to: + /// file.message_type(3) // 4, 3 + /// .field(7) // 2, 7 + /// .name() // 1 + /// This is because FileDescriptorProto.message_type has field number 4: + /// repeated DescriptorProto message_type = 4; + /// and DescriptorProto.field has field number 2: + /// repeated FieldDescriptorProto field = 2; + /// and FieldDescriptorProto.name has field number 1: + /// optional string name = 1; /// - /// Thus, the above path gives the location of a field name. If we removed - /// the last element: - /// [ 4, 3, 2, 7 ] - /// this path refers to the whole field declaration (from the beginning - /// of the label to the terminating semicolon). + /// Thus, the above path gives the location of a field name. If we removed + /// the last element: + /// [ 4, 3, 2, 7 ] + /// this path refers to the whole field declaration (from the beginning + /// of the label to the terminating semicolon). /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Path { get { return path_; } } @@ -4906,98 +7749,128 @@ public Location Clone() { = pb::FieldCodec.ForInt32(18); private readonly pbc::RepeatedField span_ = new pbc::RepeatedField(); /// - /// Always has exactly three or four elements: start line, start column, - /// end line (optional, otherwise assumed same as start line), end column. - /// These are packed into a single field for efficiency. Note that line - /// and column numbers are zero-based -- typically you will want to add - /// 1 to each before displaying to a user. + /// Always has exactly three or four elements: start line, start column, + /// end line (optional, otherwise assumed same as start line), end column. + /// These are packed into a single field for efficiency. Note that line + /// and column numbers are zero-based -- typically you will want to add + /// 1 to each before displaying to a user. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Span { get { return span_; } } /// Field number for the "leading_comments" field. public const int LeadingCommentsFieldNumber = 3; - private string leadingComments_ = ""; + private readonly static string LeadingCommentsDefaultValue = ""; + + private string leadingComments_; /// - /// If this SourceCodeInfo represents a complete declaration, these are any - /// comments appearing before and after the declaration which appear to be - /// attached to the declaration. + /// If this SourceCodeInfo represents a complete declaration, these are any + /// comments appearing before and after the declaration which appear to be + /// attached to the declaration. /// - /// A series of line comments appearing on consecutive lines, with no other - /// tokens appearing on those lines, will be treated as a single comment. + /// A series of line comments appearing on consecutive lines, with no other + /// tokens appearing on those lines, will be treated as a single comment. /// - /// leading_detached_comments will keep paragraphs of comments that appear - /// before (but not connected to) the current element. Each paragraph, - /// separated by empty lines, will be one comment element in the repeated - /// field. + /// leading_detached_comments will keep paragraphs of comments that appear + /// before (but not connected to) the current element. Each paragraph, + /// separated by empty lines, will be one comment element in the repeated + /// field. /// - /// Only the comment content is provided; comment markers (e.g. //) are - /// stripped out. For block comments, leading whitespace and an asterisk - /// will be stripped from the beginning of each line other than the first. - /// Newlines are included in the output. + /// Only the comment content is provided; comment markers (e.g. //) are + /// stripped out. For block comments, leading whitespace and an asterisk + /// will be stripped from the beginning of each line other than the first. + /// Newlines are included in the output. /// - /// Examples: + /// Examples: /// - /// optional int32 foo = 1; // Comment attached to foo. - /// // Comment attached to bar. - /// optional int32 bar = 2; + /// optional int32 foo = 1; // Comment attached to foo. + /// // Comment attached to bar. + /// optional int32 bar = 2; /// - /// optional string baz = 3; - /// // Comment attached to baz. - /// // Another line attached to baz. + /// optional string baz = 3; + /// // Comment attached to baz. + /// // Another line attached to baz. /// - /// // Comment attached to qux. - /// // - /// // Another line attached to qux. - /// optional double qux = 4; + /// // Comment attached to qux. + /// // + /// // Another line attached to qux. + /// optional double qux = 4; /// - /// // Detached comment for corge. This is not leading or trailing comments - /// // to qux or corge because there are blank lines separating it from - /// // both. + /// // Detached comment for corge. This is not leading or trailing comments + /// // to qux or corge because there are blank lines separating it from + /// // both. /// - /// // Detached comment for corge paragraph 2. + /// // Detached comment for corge paragraph 2. /// - /// optional string corge = 5; - /// /* Block comment attached - /// * to corge. Leading asterisks - /// * will be removed. */ - /// /* Block comment attached to - /// * grault. */ - /// optional int32 grault = 6; + /// optional string corge = 5; + /// /* Block comment attached + /// * to corge. Leading asterisks + /// * will be removed. */ + /// /* Block comment attached to + /// * grault. */ + /// optional int32 grault = 6; /// - /// // ignored detached comments. + /// // ignored detached comments. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string LeadingComments { - get { return leadingComments_; } + get { return leadingComments_ ?? LeadingCommentsDefaultValue; } set { leadingComments_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "leading_comments" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasLeadingComments { + get { return leadingComments_ != null; } + } + /// Clears the value of the "leading_comments" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearLeadingComments() { + leadingComments_ = null; + } /// Field number for the "trailing_comments" field. public const int TrailingCommentsFieldNumber = 4; - private string trailingComments_ = ""; + private readonly static string TrailingCommentsDefaultValue = ""; + + private string trailingComments_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string TrailingComments { - get { return trailingComments_; } + get { return trailingComments_ ?? TrailingCommentsDefaultValue; } set { trailingComments_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "trailing_comments" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasTrailingComments { + get { return trailingComments_ != null; } + } + /// Clears the value of the "trailing_comments" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearTrailingComments() { + trailingComments_ = null; + } /// Field number for the "leading_detached_comments" field. public const int LeadingDetachedCommentsFieldNumber = 6; private static readonly pb::FieldCodec _repeated_leadingDetachedComments_codec = pb::FieldCodec.ForString(50); private readonly pbc::RepeatedField leadingDetachedComments_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField LeadingDetachedComments { get { return leadingDetachedComments_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Location); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Location other) { if (ReferenceEquals(other, null)) { return false; @@ -5010,72 +7883,88 @@ public bool Equals(Location other) { if (LeadingComments != other.LeadingComments) return false; if (TrailingComments != other.TrailingComments) return false; if(!leadingDetachedComments_.Equals(other.leadingDetachedComments_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= path_.GetHashCode(); hash ^= span_.GetHashCode(); - if (LeadingComments.Length != 0) hash ^= LeadingComments.GetHashCode(); - if (TrailingComments.Length != 0) hash ^= TrailingComments.GetHashCode(); + if (HasLeadingComments) hash ^= LeadingComments.GetHashCode(); + if (HasTrailingComments) hash ^= TrailingComments.GetHashCode(); hash ^= leadingDetachedComments_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { path_.WriteTo(output, _repeated_path_codec); span_.WriteTo(output, _repeated_span_codec); - if (LeadingComments.Length != 0) { + if (HasLeadingComments) { output.WriteRawTag(26); output.WriteString(LeadingComments); } - if (TrailingComments.Length != 0) { + if (HasTrailingComments) { output.WriteRawTag(34); output.WriteString(TrailingComments); } leadingDetachedComments_.WriteTo(output, _repeated_leadingDetachedComments_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += path_.CalculateSize(_repeated_path_codec); size += span_.CalculateSize(_repeated_span_codec); - if (LeadingComments.Length != 0) { + if (HasLeadingComments) { size += 1 + pb::CodedOutputStream.ComputeStringSize(LeadingComments); } - if (TrailingComments.Length != 0) { + if (HasTrailingComments) { size += 1 + pb::CodedOutputStream.ComputeStringSize(TrailingComments); } size += leadingDetachedComments_.CalculateSize(_repeated_leadingDetachedComments_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Location other) { if (other == null) { return; } path_.Add(other.path_); span_.Add(other.span_); - if (other.LeadingComments.Length != 0) { + if (other.HasLeadingComments) { LeadingComments = other.LeadingComments; } - if (other.TrailingComments.Length != 0) { + if (other.HasTrailingComments) { TrailingComments = other.TrailingComments; } leadingDetachedComments_.Add(other.leadingDetachedComments_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: case 8: { @@ -5111,33 +8000,40 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Describes the relationship between generated code and its original source - /// file. A GeneratedCodeInfo message is associated with only one generated - /// source file, but may contain references to different source .proto files. + /// Describes the relationship between generated code and its original source + /// file. A GeneratedCodeInfo message is associated with only one generated + /// source file, but may contain references to different source .proto files. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal sealed partial class GeneratedCodeInfo : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new GeneratedCodeInfo()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[18]; } + get { return global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor.MessageTypes[20]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public GeneratedCodeInfo() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public GeneratedCodeInfo(GeneratedCodeInfo other) : this() { annotation_ = other.annotation_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public GeneratedCodeInfo Clone() { return new GeneratedCodeInfo(this); } @@ -5148,17 +8044,20 @@ public GeneratedCodeInfo Clone() { = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.Reflection.GeneratedCodeInfo.Types.Annotation.Parser); private readonly pbc::RepeatedField annotation_ = new pbc::RepeatedField(); /// - /// An Annotation connects some span of text in generated code to an element - /// of its generating .proto file. + /// An Annotation connects some span of text in generated code to an element + /// of its generating .proto file. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Annotation { get { return annotation_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as GeneratedCodeInfo); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(GeneratedCodeInfo other) { if (ReferenceEquals(other, null)) { return false; @@ -5167,42 +8066,58 @@ public bool Equals(GeneratedCodeInfo other) { return true; } if(!annotation_.Equals(other.annotation_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= annotation_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { annotation_.WriteTo(output, _repeated_annotation_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += annotation_.CalculateSize(_repeated_annotation_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(GeneratedCodeInfo other) { if (other == null) { return; } annotation_.Add(other.annotation_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { annotation_.AddEntriesFrom(input, _repeated_annotation_codec); @@ -5214,34 +8129,43 @@ public void MergeFrom(pb::CodedInputStream input) { #region Nested types /// Container for nested types declared in the GeneratedCodeInfo message type. - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] internal sealed partial class Annotation : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Annotation()); + private pb::UnknownFieldSet _unknownFields; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.Reflection.GeneratedCodeInfo.Descriptor.NestedTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Annotation() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Annotation(Annotation other) : this() { + _hasBits0 = other._hasBits0; path_ = other.path_.Clone(); sourceFile_ = other.sourceFile_; begin_ = other.begin_; end_ = other.end_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Annotation Clone() { return new Annotation(this); } @@ -5252,59 +8176,103 @@ public Annotation Clone() { = pb::FieldCodec.ForInt32(10); private readonly pbc::RepeatedField path_ = new pbc::RepeatedField(); /// - /// Identifies the element in the original source .proto file. This field - /// is formatted the same as SourceCodeInfo.Location.path. + /// Identifies the element in the original source .proto file. This field + /// is formatted the same as SourceCodeInfo.Location.path. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Path { get { return path_; } } /// Field number for the "source_file" field. public const int SourceFileFieldNumber = 2; - private string sourceFile_ = ""; + private readonly static string SourceFileDefaultValue = ""; + + private string sourceFile_; /// - /// Identifies the filesystem path to the original source .proto. + /// Identifies the filesystem path to the original source .proto. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string SourceFile { - get { return sourceFile_; } + get { return sourceFile_ ?? SourceFileDefaultValue; } set { sourceFile_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } + /// Gets whether the "source_file" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasSourceFile { + get { return sourceFile_ != null; } + } + /// Clears the value of the "source_file" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearSourceFile() { + sourceFile_ = null; + } /// Field number for the "begin" field. public const int BeginFieldNumber = 3; + private readonly static int BeginDefaultValue = 0; + private int begin_; /// - /// Identifies the starting offset in bytes in the generated code - /// that relates to the identified object. + /// Identifies the starting offset in bytes in the generated code + /// that relates to the identified object. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Begin { - get { return begin_; } + get { if ((_hasBits0 & 1) != 0) { return begin_; } else { return BeginDefaultValue; } } set { + _hasBits0 |= 1; begin_ = value; } } + /// Gets whether the "begin" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasBegin { + get { return (_hasBits0 & 1) != 0; } + } + /// Clears the value of the "begin" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearBegin() { + _hasBits0 &= ~1; + } /// Field number for the "end" field. public const int EndFieldNumber = 4; + private readonly static int EndDefaultValue = 0; + private int end_; /// - /// Identifies the ending offset in bytes in the generated code that - /// relates to the identified offset. The end offset should be one past - /// the last relevant byte (so the length of the text = end - begin). + /// Identifies the ending offset in bytes in the generated code that + /// relates to the identified offset. The end offset should be one past + /// the last relevant byte (so the length of the text = end - begin). /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int End { - get { return end_; } + get { if ((_hasBits0 & 2) != 0) { return end_; } else { return EndDefaultValue; } } set { + _hasBits0 |= 2; end_ = value; } } + /// Gets whether the "end" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasEnd { + get { return (_hasBits0 & 2) != 0; } + } + /// Clears the value of the "end" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearEnd() { + _hasBits0 &= ~2; + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Annotation); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Annotation other) { if (ReferenceEquals(other, null)) { return false; @@ -5316,75 +8284,91 @@ public bool Equals(Annotation other) { if (SourceFile != other.SourceFile) return false; if (Begin != other.Begin) return false; if (End != other.End) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= path_.GetHashCode(); - if (SourceFile.Length != 0) hash ^= SourceFile.GetHashCode(); - if (Begin != 0) hash ^= Begin.GetHashCode(); - if (End != 0) hash ^= End.GetHashCode(); + if (HasSourceFile) hash ^= SourceFile.GetHashCode(); + if (HasBegin) hash ^= Begin.GetHashCode(); + if (HasEnd) hash ^= End.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { path_.WriteTo(output, _repeated_path_codec); - if (SourceFile.Length != 0) { + if (HasSourceFile) { output.WriteRawTag(18); output.WriteString(SourceFile); } - if (Begin != 0) { + if (HasBegin) { output.WriteRawTag(24); output.WriteInt32(Begin); } - if (End != 0) { + if (HasEnd) { output.WriteRawTag(32); output.WriteInt32(End); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += path_.CalculateSize(_repeated_path_codec); - if (SourceFile.Length != 0) { + if (HasSourceFile) { size += 1 + pb::CodedOutputStream.ComputeStringSize(SourceFile); } - if (Begin != 0) { + if (HasBegin) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(Begin); } - if (End != 0) { + if (HasEnd) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(End); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Annotation other) { if (other == null) { return; } path_.Add(other.path_); - if (other.SourceFile.Length != 0) { + if (other.HasSourceFile) { SourceFile = other.SourceFile; } - if (other.Begin != 0) { + if (other.HasBegin) { Begin = other.Begin; } - if (other.End != 0) { + if (other.HasEnd) { End = other.End; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: case 8: { diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/DescriptorBase.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/DescriptorBase.cs index 194041a88942..6befbf1c2b0e 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/DescriptorBase.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/DescriptorBase.cs @@ -30,6 +30,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion +using System.Collections.Generic; + namespace Google.Protobuf.Reflection { /// @@ -37,29 +39,22 @@ namespace Google.Protobuf.Reflection /// public abstract class DescriptorBase : IDescriptor { - private readonly FileDescriptor file; - private readonly string fullName; - private readonly int index; - internal DescriptorBase(FileDescriptor file, string fullName, int index) { - this.file = file; - this.fullName = fullName; - this.index = index; + File = file; + FullName = fullName; + Index = index; } /// - /// The index of this descriptor within its parent descriptor. + /// The index of this descriptor within its parent descriptor. /// /// /// This returns the index of this descriptor within its parent, for /// this descriptor's type. (There can be duplicate values for different /// types, e.g. one enum type with index 0 and one message type with index 0.) /// - public int Index - { - get { return index; } - } + public int Index { get; } /// /// Returns the name of the entity (field, message etc) being described. @@ -69,17 +64,29 @@ public int Index /// /// The fully qualified name of the descriptor's target. /// - public string FullName - { - get { return fullName; } - } + public string FullName { get; } /// /// The file this descriptor was declared in. /// - public FileDescriptor File - { - get { return file; } - } + public FileDescriptor File { get; } + + /// + /// The declaration information about the descriptor, or null if no declaration information + /// is available for this descriptor. + /// + /// + /// This information is typically only available for dynamically loaded descriptors, + /// for example within a protoc plugin where the full descriptors, including source info, + /// are passed to the code by protoc. + /// + public DescriptorDeclaration Declaration => File.GetDeclaration(this); + + /// + /// Retrieves the list of nested descriptors corresponding to the given field number, if any. + /// If the field is unknown or not a nested descriptor list, return null to terminate the search. + /// The default implementation returns null. + /// + internal virtual IReadOnlyList GetNestedDescriptorListForField(int fieldNumber) => null; } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/DescriptorDeclaration.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/DescriptorDeclaration.cs new file mode 100644 index 000000000000..b22048f0a8cb --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/DescriptorDeclaration.cs @@ -0,0 +1,112 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2018 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using static Google.Protobuf.Reflection.SourceCodeInfo.Types; + +namespace Google.Protobuf.Reflection +{ + /// + /// Provides additional information about the declaration of a descriptor, + /// such as source location and comments. + /// + public sealed class DescriptorDeclaration + { + /// + /// The descriptor this declaration relates to. + /// + public IDescriptor Descriptor { get; } + + /// + /// The start line of the declaration within the source file. This value is 1-based. + /// + public int StartLine { get; } + /// + /// The start column of the declaration within the source file. This value is 1-based. + /// + public int StartColumn { get; } + + /// + /// // The end line of the declaration within the source file. This value is 1-based. + /// + public int EndLine { get; } + /// + /// The end column of the declaration within the source file. This value is 1-based, and + /// exclusive. (The final character of the declaration is on the column before this value.) + /// + public int EndColumn { get; } + + /// + /// Comments appearing before the declaration. Never null, but may be empty. Multi-line comments + /// are represented as a newline-separated string. Leading whitespace and the comment marker ("//") + /// are removed from each line. + /// + public string LeadingComments { get; } + + /// + /// Comments appearing after the declaration. Never null, but may be empty. Multi-line comments + /// are represented as a newline-separated string. Leading whitespace and the comment marker ("//") + /// are removed from each line. + /// + public string TrailingComments { get; } + + /// + /// Comments appearing before the declaration, but separated from it by blank + /// lines. Each string represents a newline-separated paragraph of comments. + /// Leading whitespace and the comment marker ("//") are removed from each line. + /// The list is never null, but may be empty. Likewise each element is never null, but may be empty. + /// + public IReadOnlyList LeadingDetachedComments { get; } + + private DescriptorDeclaration(IDescriptor descriptor, Location location) + { + // TODO: Validation + Descriptor = descriptor; + bool hasEndLine = location.Span.Count == 4; + // Lines and columns are 0-based in the proto. + StartLine = location.Span[0] + 1; + StartColumn = location.Span[1] + 1; + EndLine = hasEndLine ? location.Span[2] + 1 : StartLine; + EndColumn = location.Span[hasEndLine ? 3 : 2] + 1; + LeadingComments = location.LeadingComments; + TrailingComments = location.TrailingComments; + LeadingDetachedComments = new ReadOnlyCollection(location.LeadingDetachedComments.ToList()); + } + + internal static DescriptorDeclaration FromProto(IDescriptor descriptor, Location location) => + new DescriptorDeclaration(descriptor, location); + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/DescriptorPool.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/DescriptorPool.cs index 99ca4bf34f14..93f2fa9a4aef 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/DescriptorPool.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/DescriptorPool.cs @@ -45,21 +45,21 @@ internal sealed class DescriptorPool private readonly IDictionary descriptorsByName = new Dictionary(); - private readonly IDictionary fieldsByNumber = - new Dictionary(); + private readonly IDictionary, FieldDescriptor> fieldsByNumber = + new Dictionary, FieldDescriptor>(); - private readonly IDictionary enumValuesByNumber = - new Dictionary(); + private readonly IDictionary, EnumValueDescriptor> enumValuesByNumber = + new Dictionary, EnumValueDescriptor>(); private readonly HashSet dependencies; - internal DescriptorPool(FileDescriptor[] dependencyFiles) + internal DescriptorPool(IEnumerable dependencyFiles) { dependencies = new HashSet(); - for (int i = 0; i < dependencyFiles.Length; i++) + foreach (var dependencyFile in dependencyFiles) { - dependencies.Add(dependencyFiles[i]); - ImportPublicDependencies(dependencyFiles[i]); + dependencies.Add(dependencyFile); + ImportPublicDependencies(dependencyFile); } foreach (FileDescriptor dependency in dependencyFiles) @@ -209,14 +209,14 @@ private static void ValidateSymbolName(IDescriptor descriptor) internal FieldDescriptor FindFieldByNumber(MessageDescriptor messageDescriptor, int number) { FieldDescriptor ret; - fieldsByNumber.TryGetValue(new DescriptorIntPair(messageDescriptor, number), out ret); + fieldsByNumber.TryGetValue(new ObjectIntPair(messageDescriptor, number), out ret); return ret; } internal EnumValueDescriptor FindEnumValueByNumber(EnumDescriptor enumDescriptor, int number) { EnumValueDescriptor ret; - enumValuesByNumber.TryGetValue(new DescriptorIntPair(enumDescriptor, number), out ret); + enumValuesByNumber.TryGetValue(new ObjectIntPair(enumDescriptor, number), out ret); return ret; } @@ -227,7 +227,8 @@ internal EnumValueDescriptor FindEnumValueByNumber(EnumDescriptor enumDescriptor /// containing type and number already exists. internal void AddFieldByNumber(FieldDescriptor field) { - DescriptorIntPair key = new DescriptorIntPair(field.ContainingType, field.FieldNumber); + // for extensions, we use the extended type, otherwise we use the containing type + ObjectIntPair key = new ObjectIntPair(field.Proto.HasExtendee ? field.ExtendeeType : field.ContainingType, field.FieldNumber); FieldDescriptor old; if (fieldsByNumber.TryGetValue(key, out old)) { @@ -246,7 +247,7 @@ internal void AddFieldByNumber(FieldDescriptor field) /// internal void AddEnumValueByNumber(EnumValueDescriptor enumValue) { - DescriptorIntPair key = new DescriptorIntPair(enumValue.EnumDescriptor, enumValue.Number); + ObjectIntPair key = new ObjectIntPair(enumValue.EnumDescriptor, enumValue.Number); if (!enumValuesByNumber.ContainsKey(key)) { enumValuesByNumber[key] = enumValue; @@ -329,40 +330,5 @@ internal IDescriptor LookupSymbol(string name, IDescriptor relativeTo) return result; } } - - /// - /// Struct used to hold the keys for the fieldByNumber table. - /// - private struct DescriptorIntPair : IEquatable - { - private readonly int number; - private readonly IDescriptor descriptor; - - internal DescriptorIntPair(IDescriptor descriptor, int number) - { - this.number = number; - this.descriptor = descriptor; - } - - public bool Equals(DescriptorIntPair other) - { - return descriptor == other.descriptor - && number == other.number; - } - - public override bool Equals(object obj) - { - if (obj is DescriptorIntPair) - { - return Equals((DescriptorIntPair) obj); - } - return false; - } - - public override int GetHashCode() - { - return descriptor.GetHashCode()*((1 << 16) - 1) + number; - } - } } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs index c732c93a0659..36a1d0a5ecd9 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs @@ -30,6 +30,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion +using Google.Protobuf.Collections; using System; using System.Collections.Generic; @@ -72,6 +73,17 @@ internal EnumDescriptor(EnumDescriptorProto proto, FileDescriptor file, MessageD /// public override string Name { get { return proto.Name; } } + internal override IReadOnlyList GetNestedDescriptorListForField(int fieldNumber) + { + switch (fieldNumber) + { + case EnumDescriptorProto.ValueFieldNumber: + return (IReadOnlyList) Values; + default: + return null; + } + } + /// /// The CLR type for this enum. For generated code, this will be a CLR enum type. /// @@ -112,5 +124,30 @@ public EnumValueDescriptor FindValueByName(string name) { return File.DescriptorPool.FindSymbol(FullName + "." + name); } + + /// + /// The (possibly empty) set of custom options for this enum. + /// + //[Obsolete("CustomOptions are obsolete. Use GetOption")] + public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber); + + /* // uncomment this in the full proto2 support PR + /// + /// Gets a single value enum option for this descriptor + /// + public T GetOption(Extension extension) + { + var value = Proto.Options.GetExtension(extension); + return value is IDeepCloneable clonable ? clonable.Clone() : value; + } + + /// + /// Gets a repeated value enum option for this descriptor + /// + public RepeatedField GetOption(RepeatedExtension extension) + { + return Proto.Options.GetExtension(extension).Clone(); + } + */ } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs index b212ce961854..99c989130c8e 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs @@ -30,12 +30,15 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion +using Google.Protobuf.Collections; +using System; + namespace Google.Protobuf.Reflection { /// /// Descriptor for a single enum value within an enum in a .proto file. /// - public sealed class EnumValueDescriptor : DescriptorBase + public sealed class EnumValueDescriptor : DescriptorBase { private readonly EnumDescriptor enumDescriptor; private readonly EnumValueDescriptorProto proto; @@ -66,5 +69,31 @@ internal EnumValueDescriptor(EnumValueDescriptorProto proto, FileDescriptor file /// Returns the enum descriptor that this value is part of. /// public EnumDescriptor EnumDescriptor { get { return enumDescriptor; } } + + /// + /// The (possibly empty) set of custom options for this enum value. + /// + //[Obsolete("CustomOptions are obsolete. Use GetOption")] + public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber); + + /* // uncomment this in the full proto2 support PR + /// + /// Gets a single value enum option for this descriptor + /// + public T GetOption(Extension extension) + { + var value = Proto.Options.GetExtension(extension); + return value is IDeepCloneable clonable ? clonable.Clone() : value; + } + + /// + /// Gets a repeated value enum option for this descriptor + /// + public RepeatedField GetOption(RepeatedExtension extension) + { + return Proto.Options.GetExtension(extension).Clone(); + } + */ } -} \ No newline at end of file +} + \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/PartialClasses.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/ExtensionAccessor.cs similarity index 63% rename from third_party/protobuf/csharp/src/Google.Protobuf/Reflection/PartialClasses.cs rename to third_party/protobuf/csharp/src/Google.Protobuf/Reflection/ExtensionAccessor.cs index 6c285410d4b4..81d6e35f0132 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/PartialClasses.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/ExtensionAccessor.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. // https://developers.google.com/protocol-buffers/ @@ -30,30 +30,40 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion -// This file just contains partial classes for any autogenerated classes that need additional support. namespace Google.Protobuf.Reflection { - internal partial class FieldDescriptorProto + internal sealed class ExtensionAccessor : IFieldAccessor { - // We can't tell the difference between "explicitly set to 0" and "not set" - // in proto3, but we need to tell the difference for OneofIndex. descriptor.proto - // is really a proto2 file, but the runtime doesn't know about proto2 semantics... - // We fake it by defaulting to -1. - partial void OnConstruction() + private readonly Extension extension; + private readonly ReflectionUtil.IExtensionReflectionHelper helper; + + internal ExtensionAccessor(FieldDescriptor descriptor) { - OneofIndex = -1; + Descriptor = descriptor; + extension = descriptor.Extension; + helper = ReflectionUtil.CreateExtensionHelper(extension); } - } - internal partial class FieldOptions - { - // We can't tell the difference between "explicitly set to false" and "not set" - // in proto3, but we need to tell the difference for FieldDescriptor.IsPacked. - // This won't work if we ever need to support proto2, but at that point we'll be - // able to remove this hack and use field presence instead. - partial void OnConstruction() + public FieldDescriptor Descriptor { get; } + + public void Clear(IMessage message) + { + helper.ClearExtension(message); + } + + public bool HasValue(IMessage message) + { + return helper.HasExtension(message); + } + + public object GetValue(IMessage message) + { + return helper.GetExtension(message); + } + + public void SetValue(IMessage message, object value) { - Packed = true; + helper.SetExtension(message, value); } } -} \ No newline at end of file +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/ExtensionCollection.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/ExtensionCollection.cs new file mode 100644 index 000000000000..9cb6abaf9a7d --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/ExtensionCollection.cs @@ -0,0 +1,105 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; + +namespace Google.Protobuf.Reflection +{ + /// + /// A collection to simplify retrieving the descriptors of extensions in a descriptor for a message + /// + public class ExtensionCollection + { + private IDictionary> extensionsByTypeInDeclarationOrder; + private IDictionary> extensionsByTypeInNumberOrder; + + internal ExtensionCollection(FileDescriptor file, Extension[] extensions) + { + UnorderedExtensions = DescriptorUtil.ConvertAndMakeReadOnly( + file.Proto.Extension, + (extension, i) => new FieldDescriptor(extension, file, null, i, null, extensions?[i])); + } + + internal ExtensionCollection(MessageDescriptor message, Extension[] extensions) + { + UnorderedExtensions = DescriptorUtil.ConvertAndMakeReadOnly( + message.Proto.Extension, + (extension, i) => new FieldDescriptor(extension, message.File, message, i, null, extensions?[i])); + } + + /// + /// Returns a readonly list of all the extensions defined in this type in + /// the order they were defined in the source .proto file + /// + public IList UnorderedExtensions { get; } + + /// + /// Returns a readonly list of all the extensions define in this type that extend + /// the provided descriptor type in the order they were defined in the source .proto file + /// + public IList GetExtensionsInDeclarationOrder(MessageDescriptor descriptor) + { + return extensionsByTypeInDeclarationOrder[descriptor]; + } + + /// + /// Returns a readonly list of all the extensions define in this type that extend + /// the provided descriptor type in accending field order + /// + public IList GetExtensionsInNumberOrder(MessageDescriptor descriptor) + { + return extensionsByTypeInNumberOrder[descriptor]; + } + + internal void CrossLink() + { + Dictionary> declarationOrder = new Dictionary>(); + foreach (FieldDescriptor descriptor in UnorderedExtensions) + { + descriptor.CrossLink(); + + IList _; + if (!declarationOrder.TryGetValue(descriptor.ExtendeeType, out _)) + declarationOrder.Add(descriptor.ExtendeeType, new List()); + + declarationOrder[descriptor.ExtendeeType].Add(descriptor); + } + + extensionsByTypeInDeclarationOrder = declarationOrder + .ToDictionary(kvp => kvp.Key, kvp => (IList)new ReadOnlyCollection(kvp.Value)); + extensionsByTypeInNumberOrder = declarationOrder + .ToDictionary(kvp => kvp.Key, kvp => (IList)new ReadOnlyCollection(kvp.Value.OrderBy(field => field.FieldNumber).ToArray())); + } + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs index 82ce50518d8e..85b7d39a8337 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs @@ -57,6 +57,7 @@ public object GetValue(IMessage message) return getValueDelegate(message); } + public abstract bool HasValue(IMessage message); public abstract void Clear(IMessage message); public abstract void SetValue(IMessage message, object value); } diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs index 6c6f6ee05ff0..5a2f7f3d8e1f 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs @@ -30,6 +30,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion +using Google.Protobuf.Collections; using Google.Protobuf.Compatibility; using System; @@ -41,13 +42,14 @@ namespace Google.Protobuf.Reflection public sealed class FieldDescriptor : DescriptorBase, IComparable { private EnumDescriptor enumType; + private MessageDescriptor extendeeType; private MessageDescriptor messageType; private FieldType fieldType; private readonly string propertyName; // Annoyingly, needed in Crosslink. private IFieldAccessor accessor; /// - /// Get the field's containing message type. + /// Get the field's containing message type, or null if it is a field defined at the top level of a file as an extension. /// public MessageDescriptor ContainingType { get; } @@ -64,8 +66,10 @@ public sealed class FieldDescriptor : DescriptorBase, IComparable= parent.Proto.OneofDecl.Count) { @@ -97,9 +100,10 @@ internal FieldDescriptor(FieldDescriptorProto proto, FileDescriptor file, // We could trust the generated code and check whether the type of the property is // a MapField, but that feels a tad nasty. this.propertyName = propertyName; - JsonName = Proto.JsonName == "" ? JsonFormatter.ToCamelCase(Proto.Name) : Proto.JsonName; + Extension = extension; + JsonName = Proto.JsonName == "" ? JsonFormatter.ToJsonName(Proto.Name) : Proto.JsonName; } - + /// /// The brief name of the descriptor's target. @@ -116,16 +120,21 @@ internal FieldDescriptor(FieldDescriptorProto proto, FileDescriptor file, /// that is the responsibility of the accessor. /// /// - /// The value returned by this property will be non-null for all regular fields. However, - /// if a message containing a map field is introspected, the list of nested messages will include + /// In descriptors for generated code, the value returned by this property will be non-null for all + /// regular fields. However, if a message containing a map field is introspected, the list of nested messages will include /// an auto-generated nested key/value pair message for the field. This is not represented in any /// generated type, and the value of the map field itself is represented by a dictionary in the /// reflection API. There are never instances of those "hidden" messages, so no accessor is provided /// and this property will return null. /// + /// + /// In dynamically loaded descriptors, the value returned by this property will current be null; + /// if and when dynamic messages are supported, it will return a suitable accessor to work with + /// them. + /// /// public IFieldAccessor Accessor => accessor; - + /// /// Maps a field type as included in the .proto file to a FieldType. /// @@ -179,6 +188,11 @@ private static FieldType GetFieldTypeFromProtoType(FieldDescriptorProto.Types.Ty /// public bool IsRepeated => Proto.Label == FieldDescriptorProto.Types.Label.Repeated; + /// + /// Returns true if this field is a required field; false otherwise. + /// + public bool IsRequired => Proto.Label == FieldDescriptorProto.Types.Label.Required; + /// /// Returns true if this field is a map field; false otherwise. /// @@ -187,13 +201,8 @@ private static FieldType GetFieldTypeFromProtoType(FieldDescriptorProto.Types.Ty /// /// Returns true if this field is a packed, repeated field; false otherwise. /// - public bool IsPacked => - // Note the || rather than && here - we're effectively defaulting to packed, because that *is* - // the default in proto3, which is all we support. We may give the wrong result for the protos - // within descriptor.proto, but that's okay, as they're never exposed and we don't use IsPacked - // within the runtime. - Proto.Options == null || Proto.Options.Packed; - + public bool IsPacked => File.Proto.Syntax == "proto2" ? Proto.Options?.Packed ?? false : !Proto.Options.HasPacked || Proto.Options.Packed; + /// /// Returns the type of the field. /// @@ -242,25 +251,65 @@ public MessageDescriptor MessageType { get { - if (fieldType != FieldType.Message) + if (fieldType != FieldType.Message && fieldType != FieldType.Group) { - throw new InvalidOperationException("MessageType is only valid for message fields."); + throw new InvalidOperationException("MessageType is only valid for message or group fields."); } return messageType; } } + /// + /// For extension fields, returns the extended type + /// + public MessageDescriptor ExtendeeType + { + get + { + if (!Proto.HasExtendee) + { + throw new InvalidOperationException("ExtendeeType is only valid for extension fields."); + } + return extendeeType; + } + } + + /// + /// The (possibly empty) set of custom options for this field. + /// + //[Obsolete("CustomOptions are obsolete. Use GetOption")] + public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber); + + /* // uncomment this in the full proto2 support PR + /// + /// Gets a single value enum option for this descriptor + /// + public T GetOption(Extension extension) + { + var value = Proto.Options.GetExtension(extension); + return value is IDeepCloneable clonable ? clonable.Clone() : value; + } + + /// + /// Gets a repeated value enum option for this descriptor + /// + public RepeatedField GetOption(RepeatedExtension extension) + { + return Proto.Options.GetExtension(extension).Clone(); + } + */ + /// /// Look up and cross-link all field types etc. /// internal void CrossLink() { - if (Proto.TypeName != "") + if (Proto.HasTypeName) { IDescriptor typeDescriptor = File.DescriptorPool.LookupSymbol(Proto.TypeName, this); - if (Proto.Type != 0) + if (Proto.HasType) { // Choose field type based on symbol. if (typeDescriptor is MessageDescriptor) @@ -277,7 +326,7 @@ internal void CrossLink() } } - if (fieldType == FieldType.Message) + if (fieldType == FieldType.Message || fieldType == FieldType.Group) { if (!(typeDescriptor is MessageDescriptor)) { @@ -285,7 +334,7 @@ internal void CrossLink() } messageType = (MessageDescriptor) typeDescriptor; - if (Proto.DefaultValue != "") + if (Proto.HasDefaultValue) { throw new DescriptorValidationException(this, "Messages can't have default values."); } @@ -311,11 +360,16 @@ internal void CrossLink() } } + if (Proto.HasExtendee) + { + extendeeType = File.DescriptorPool.LookupSymbol(Proto.Extendee, this) as MessageDescriptor; + } + // Note: no attempt to perform any default value parsing File.DescriptorPool.AddFieldByNumber(this); - if (ContainingType != null && ContainingType.Proto.Options != null && ContainingType.Proto.Options.MessageSetWireFormat) + if (ContainingType != null && ContainingType.Proto.HasOptions && ContainingType.Proto.Options.MessageSetWireFormat) { throw new DescriptorValidationException(this, "MessageSet format is not supported."); } @@ -325,11 +379,17 @@ internal void CrossLink() private IFieldAccessor CreateAccessor() { // If we're given no property name, that's because we really don't want an accessor. - // (At the moment, that means it's a map entry message...) + // This could be because it's a map message, or it could be that we're loading a FileDescriptor dynamically. + // TODO: Support dynamic messages. if (propertyName == null) { return null; } + + if (Extension != null) + { + return new ExtensionAccessor(this); + } var property = ContainingType.ClrType.GetProperty(propertyName); if (property == null) { @@ -340,4 +400,5 @@ private IFieldAccessor CreateAccessor() : (IFieldAccessor) new SingleFieldAccessor(property, this); } } -} \ No newline at end of file +} + \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FieldType.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FieldType.cs index 1658e34cd1e1..37af17915ee7 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FieldType.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FieldType.cs @@ -74,7 +74,7 @@ public enum FieldType /// String, /// - /// The field type used for groups (not supported in this implementation). + /// The field type used for groups. /// Group, /// diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs index ab7cd92216e0..4c2fe54d560b 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs @@ -30,9 +30,15 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion +using Google.Protobuf.Collections; +using Google.Protobuf.WellKnownTypes; using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Threading; +using static Google.Protobuf.Reflection.SourceCodeInfo.Types; namespace Google.Protobuf.Reflection { @@ -43,12 +49,24 @@ namespace Google.Protobuf.Reflection /// public sealed class FileDescriptor : IDescriptor { - private FileDescriptor(ByteString descriptorData, FileDescriptorProto proto, FileDescriptor[] dependencies, DescriptorPool pool, bool allowUnknownDependencies, GeneratedClrTypeInfo generatedCodeInfo) + // Prevent linker failures when using IL2CPP with the well-known types. + static FileDescriptor() + { + ForceReflectionInitialization(); + ForceReflectionInitialization(); + ForceReflectionInitialization(); + ForceReflectionInitialization(); + ForceReflectionInitialization(); + } + + private readonly Lazy> declarations; + + private FileDescriptor(ByteString descriptorData, FileDescriptorProto proto, IEnumerable dependencies, DescriptorPool pool, bool allowUnknownDependencies, GeneratedClrTypeInfo generatedCodeInfo) { SerializedData = descriptorData; DescriptorPool = pool; Proto = proto; - Dependencies = new ReadOnlyCollection((FileDescriptor[]) dependencies.Clone()); + Dependencies = new ReadOnlyCollection(dependencies.ToList()); PublicDependencies = DeterminePublicDependencies(this, proto, dependencies, allowUnknownDependencies); @@ -56,15 +74,93 @@ private FileDescriptor(ByteString descriptorData, FileDescriptorProto proto, Fil MessageTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.MessageType, (message, index) => - new MessageDescriptor(message, this, null, index, generatedCodeInfo.NestedTypes[index])); + new MessageDescriptor(message, this, null, index, generatedCodeInfo?.NestedTypes[index])); EnumTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.EnumType, (enumType, index) => - new EnumDescriptor(enumType, this, null, index, generatedCodeInfo.NestedEnums[index])); + new EnumDescriptor(enumType, this, null, index, generatedCodeInfo?.NestedEnums[index])); Services = DescriptorUtil.ConvertAndMakeReadOnly(proto.Service, (service, index) => new ServiceDescriptor(service, this, index)); + + Extensions = new ExtensionCollection(this, generatedCodeInfo?.Extensions); + + declarations = new Lazy>(CreateDeclarationMap, LazyThreadSafetyMode.ExecutionAndPublication); + } + + private Dictionary CreateDeclarationMap() + { + var dictionary = new Dictionary(); + foreach (var location in Proto.SourceCodeInfo?.Location ?? Enumerable.Empty()) + { + var descriptor = FindDescriptorForPath(location.Path); + if (descriptor != null) + { + dictionary[descriptor] = DescriptorDeclaration.FromProto(descriptor, location); + } + } + return dictionary; + } + + private IDescriptor FindDescriptorForPath(IList path) + { + // All complete declarations have an even, non-empty path length + // (There can be an empty path for a descriptor declaration, but that can't have any comments, + // so we currently ignore it.) + if (path.Count == 0 || (path.Count & 1) != 0) + { + return null; + } + IReadOnlyList topLevelList = GetNestedDescriptorListForField(path[0]); + DescriptorBase current = GetDescriptorFromList(topLevelList, path[1]); + + for (int i = 2; current != null && i < path.Count; i += 2) + { + var list = current.GetNestedDescriptorListForField(path[i]); + current = GetDescriptorFromList(list, path[i + 1]); + } + return current; + } + + private DescriptorBase GetDescriptorFromList(IReadOnlyList list, int index) + { + // This is fine: it may be a newer version of protobuf than we understand, with a new descriptor + // field. + if (list == null) + { + return null; + } + // We *could* return null to silently continue, but this is basically data corruption. + if (index < 0 || index >= list.Count) + { + // We don't have much extra information to give at this point unfortunately. If this becomes a problem, + // we can pass in the complete path and report that and the file name. + throw new InvalidProtocolBufferException($"Invalid descriptor location path: index out of range"); + } + return list[index]; + } + + private IReadOnlyList GetNestedDescriptorListForField(int fieldNumber) + { + switch (fieldNumber) + { + case FileDescriptorProto.ServiceFieldNumber: + return (IReadOnlyList) Services; + case FileDescriptorProto.MessageTypeFieldNumber: + return (IReadOnlyList) MessageTypes; + case FileDescriptorProto.EnumTypeFieldNumber: + return (IReadOnlyList) EnumTypes; + default: + return null; + } + } + + internal DescriptorDeclaration GetDeclaration(IDescriptor descriptor) + { + DescriptorDeclaration declaration; + declarations.Value.TryGetValue(descriptor, out declaration); + return declaration; } /// @@ -87,13 +183,9 @@ internal string ComputeFullName(MessageDescriptor parent, string name) /// Extracts public dependencies from direct dependencies. This is a static method despite its /// first parameter, as the value we're in the middle of constructing is only used for exceptions. /// - private static IList DeterminePublicDependencies(FileDescriptor @this, FileDescriptorProto proto, FileDescriptor[] dependencies, bool allowUnknownDependencies) + private static IList DeterminePublicDependencies(FileDescriptor @this, FileDescriptorProto proto, IEnumerable dependencies, bool allowUnknownDependencies) { - var nameToFileMap = new Dictionary(); - foreach (var file in dependencies) - { - nameToFileMap[file.Name] = file; - } + var nameToFileMap = dependencies.ToDictionary(file => file.Name); var publicDependencies = new List(); for (int i = 0; i < proto.PublicDependency.Count; i++) { @@ -103,8 +195,8 @@ private static IList DeterminePublicDependencies(FileDescriptor throw new DescriptorValidationException(@this, "Invalid public dependency index."); } string name = proto.Dependency[index]; - FileDescriptor file = nameToFileMap[name]; - if (file == null) + FileDescriptor file; + if (!nameToFileMap.TryGetValue(name, out file)) { if (!allowUnknownDependencies) { @@ -151,6 +243,11 @@ private static IList DeterminePublicDependencies(FileDescriptor /// public IList Services { get; } + /// + /// Unmodifiable list of top-level extensions declared in this file. + /// + public ExtensionCollection Extensions { get; } + /// /// Unmodifiable list of this file's dependencies (imports). /// @@ -251,17 +348,6 @@ private static FileDescriptor BuildFrom(ByteString descriptorData, FileDescripto "Dependencies passed to FileDescriptor.BuildFrom() don't match " + "those listed in the FileDescriptorProto."); } - for (int i = 0; i < proto.Dependency.Count; i++) - { - if (dependencies[i].Name != proto.Dependency[i]) - { - throw new DescriptorValidationException( - result, - "Dependencies passed to FileDescriptor.BuildFrom() don't match " + - "those listed in the FileDescriptorProto. Expected: " + - proto.Dependency[i] + " but was: " + dependencies[i].Name); - } - } result.CrossLink(); return result; @@ -278,6 +364,8 @@ private void CrossLink() { service.CrossLink(); } + + Extensions.CrossLink(); } /// @@ -293,10 +381,12 @@ public static FileDescriptor FromGeneratedCode( FileDescriptor[] dependencies, GeneratedClrTypeInfo generatedCodeInfo) { + ExtensionRegistry registry = new ExtensionRegistry(); + AddAllExtensions(dependencies, generatedCodeInfo, registry); FileDescriptorProto proto; try { - proto = FileDescriptorProto.Parser.ParseFrom(descriptorData); + proto = FileDescriptorProto.Parser.WithExtensionRegistry(registry).ParseFrom(descriptorData); } catch (InvalidProtocolBufferException e) { @@ -315,6 +405,76 @@ public static FileDescriptor FromGeneratedCode( } } + private static void AddAllExtensions(FileDescriptor[] dependencies, GeneratedClrTypeInfo generatedInfo, ExtensionRegistry registry) + { + registry.Add(dependencies.SelectMany(GetAllDependedExtensions).Concat(GetAllGeneratedExtensions(generatedInfo)).ToArray()); + } + + private static IEnumerable GetAllGeneratedExtensions(GeneratedClrTypeInfo generated) + { + return generated.Extensions.Concat(generated.NestedTypes.Where(t => t != null).SelectMany(GetAllGeneratedExtensions)); + } + + private static IEnumerable GetAllDependedExtensions(FileDescriptor descriptor) + { + return descriptor.Extensions.UnorderedExtensions + .Select(s => s.Extension) + .Concat(descriptor.Dependencies.Concat(descriptor.PublicDependencies).SelectMany(GetAllDependedExtensions)) + .Concat(descriptor.MessageTypes.SelectMany(GetAllDependedExtensionsFromMessage)); + } + + private static IEnumerable GetAllDependedExtensionsFromMessage(MessageDescriptor descriptor) + { + return descriptor.Extensions.UnorderedExtensions + .Select(s => s.Extension) + .Concat(descriptor.NestedTypes.SelectMany(GetAllDependedExtensionsFromMessage)); + } + + /// + /// Converts the given descriptor binary data into FileDescriptor objects. + /// Note: reflection using the returned FileDescriptors is not currently supported. + /// + /// The binary file descriptor proto data. Must not be null, and any + /// dependencies must come before the descriptor which depends on them. (If A depends on B, and B + /// depends on C, then the descriptors must be presented in the order C, B, A.) This is compatible + /// with the order in which protoc provides descriptors to plugins. + /// The file descriptors corresponding to . + public static IReadOnlyList BuildFromByteStrings(IEnumerable descriptorData) + { + ProtoPreconditions.CheckNotNull(descriptorData, nameof(descriptorData)); + + // TODO: See if we can build a single DescriptorPool instead of building lots of them. + // This will all behave correctly, but it's less efficient than we'd like. + var descriptors = new List(); + var descriptorsByName = new Dictionary(); + foreach (var data in descriptorData) + { + var proto = FileDescriptorProto.Parser.ParseFrom(data); + var dependencies = new List(); + foreach (var dependencyName in proto.Dependency) + { + FileDescriptor dependency; + if (!descriptorsByName.TryGetValue(dependencyName, out dependency)) + { + throw new ArgumentException($"Dependency missing: {dependencyName}"); + } + dependencies.Add(dependency); + } + var pool = new DescriptorPool(dependencies); + FileDescriptor descriptor = new FileDescriptor( + data, proto, dependencies, pool, + allowUnknownDependencies: false, generatedCodeInfo: null); + descriptor.CrossLink(); + descriptors.Add(descriptor); + if (descriptorsByName.ContainsKey(descriptor.Name)) + { + throw new ArgumentException($"Duplicate descriptor name: {descriptor.Name}"); + } + descriptorsByName.Add(descriptor.Name, descriptor); + } + return new ReadOnlyCollection(descriptors); + } + /// /// Returns a that represents this instance. /// @@ -340,5 +500,43 @@ public override string ToString() /// The file descriptor for descriptor.proto. /// public static FileDescriptor DescriptorProtoFileDescriptor { get { return DescriptorReflection.Descriptor; } } + + /// + /// The (possibly empty) set of custom options for this file. + /// + //[Obsolete("CustomOptions are obsolete. Use GetOption")] + public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber); + + /* // uncomment this in the full proto2 support PR + /// + /// Gets a single value enum option for this descriptor + /// + public T GetOption(Extension extension) + { + var value = Proto.Options.GetExtension(extension); + return value is IDeepCloneable clonable ? clonable.Clone() : value; + } + + /// + /// Gets a repeated value enum option for this descriptor + /// + public RepeatedField GetOption(RepeatedExtension extension) + { + return Proto.Options.GetExtension(extension).Clone(); + } + */ + + /// + /// Performs initialization for the given generic type argument. + /// + /// + /// This method is present for the sake of AOT compilers. It allows code (whether handwritten or generated) + /// to make calls into the reflection machinery of this library to express an intention to use that type + /// reflectively (e.g. for JSON parsing and formatting). The call itself does almost nothing, but AOT compilers + /// attempting to determine which generic type arguments need to be handled will spot the code path and act + /// accordingly. + /// + /// The type to force initialization for. + public static void ForceReflectionInitialization() => ReflectionUtil.ForceInitialize(); } -} \ No newline at end of file +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/GeneratedClrTypeInfo.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/GeneratedClrTypeInfo.cs index fe5db65656ff..479e177130fc 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/GeneratedClrTypeInfo.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/GeneratedClrTypeInfo.cs @@ -42,6 +42,7 @@ public sealed class GeneratedClrTypeInfo { private static readonly string[] EmptyNames = new string[0]; private static readonly GeneratedClrTypeInfo[] EmptyCodeInfo = new GeneratedClrTypeInfo[0]; + private static readonly Extension[] EmptyExtensions = new Extension[0]; /// /// Irrelevant for file descriptors; the CLR type for the message for message descriptors. @@ -59,6 +60,11 @@ public sealed class GeneratedClrTypeInfo /// public string[] PropertyNames { get; } + /// + /// The extensions defined within this file/message descriptor + /// + public Extension[] Extensions { get; } + /// /// Irrelevant for file descriptors; the CLR property "base" names (in message descriptor oneof order) /// for oneofs in the message for message descriptors. It is expected that for a oneof name of "Foo", @@ -82,16 +88,35 @@ public sealed class GeneratedClrTypeInfo /// Each array parameter may be null, to indicate a lack of values. /// The parameter order is designed to make it feasible to format the generated code readably. /// - public GeneratedClrTypeInfo(Type clrType, MessageParser parser, string[] propertyNames, string[] oneofNames, Type[] nestedEnums, GeneratedClrTypeInfo[] nestedTypes) + public GeneratedClrTypeInfo(Type clrType, MessageParser parser, string[] propertyNames, string[] oneofNames, Type[] nestedEnums, Extension[] extensions, GeneratedClrTypeInfo[] nestedTypes) { NestedTypes = nestedTypes ?? EmptyCodeInfo; NestedEnums = nestedEnums ?? ReflectionUtil.EmptyTypes; ClrType = clrType; + Extensions = extensions ?? EmptyExtensions; Parser = parser; PropertyNames = propertyNames ?? EmptyNames; OneofNames = oneofNames ?? EmptyNames; } + /// + /// Creates a GeneratedClrTypeInfo for a message descriptor, with nested types, nested enums, the CLR type, property names and oneof names. + /// Each array parameter may be null, to indicate a lack of values. + /// The parameter order is designed to make it feasible to format the generated code readably. + /// + public GeneratedClrTypeInfo(Type clrType, MessageParser parser, string[] propertyNames, string[] oneofNames, Type[] nestedEnums, GeneratedClrTypeInfo[] nestedTypes) + : this(clrType, parser, propertyNames, oneofNames, nestedEnums, null, nestedTypes) + { + } + + /// + /// Creates a GeneratedClrTypeInfo for a file descriptor, with only types, enums, and extensions. + /// + public GeneratedClrTypeInfo(Type[] nestedEnums, Extension[] extensions, GeneratedClrTypeInfo[] nestedTypes) + : this(null, null, null, null, nestedEnums, extensions, nestedTypes) + { + } + /// /// Creates a GeneratedClrTypeInfo for a file descriptor, with only types and enums. /// diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/IDescriptor.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/IDescriptor.cs index 318d58c968a5..1c1ef387da03 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/IDescriptor.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/IDescriptor.cs @@ -51,5 +51,5 @@ public interface IDescriptor /// Returns the descriptor for the .proto file that this entity is part of. /// FileDescriptor File { get; } - } + } } \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/IFieldAccessor.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/IFieldAccessor.cs index cfe56fde671e..8f7ef3c67c92 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/IFieldAccessor.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/IFieldAccessor.cs @@ -51,6 +51,11 @@ public interface IFieldAccessor /// void Clear(IMessage message); + /// + /// Indicates whether the field in the specified message is set. For proto3 fields, this throws an + /// + bool HasValue(IMessage message); + /// /// Fetches the field value. For repeated values, this will be an /// implementation. For map values, this will be an diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/MapFieldAccessor.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/MapFieldAccessor.cs index 9ed7f8c4df4c..56e3dddc947b 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/MapFieldAccessor.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/MapFieldAccessor.cs @@ -51,6 +51,11 @@ public override void Clear(IMessage message) list.Clear(); } + public override bool HasValue(IMessage message) + { + throw new InvalidOperationException("HasValue is not implemented for map fields"); + } + public override void SetValue(IMessage message, object value) { throw new InvalidOperationException("SetValue is not implemented for map fields"); diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs index f5a835e5ccb5..15bfbfadd04e 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs @@ -34,6 +34,10 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; +#if NET35 +// Needed for ReadOnlyDictionary, which does not exist in .NET 3.5 +using Google.Protobuf.Collections; +#endif namespace Google.Protobuf.Reflection { @@ -59,7 +63,7 @@ public sealed class MessageDescriptor : DescriptorBase private readonly IList fieldsInDeclarationOrder; private readonly IList fieldsInNumberOrder; private readonly IDictionary jsonFieldMap; - + internal MessageDescriptor(DescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int typeIndex, GeneratedClrTypeInfo generatedCodeInfo) : base(file, file.ComputeFullName(parent, proto.Name), typeIndex) { @@ -68,28 +72,28 @@ internal MessageDescriptor(DescriptorProto proto, FileDescriptor file, MessageDe ClrType = generatedCodeInfo?.ClrType; ContainingType = parent; - // Note use of generatedCodeInfo. rather than generatedCodeInfo?. here... we don't expect - // to see any nested oneofs, types or enums in "not actually generated" code... we do - // expect fields though (for map entry messages). + // If generatedCodeInfo is null, we just won't generate an accessor for any fields. Oneofs = DescriptorUtil.ConvertAndMakeReadOnly( proto.OneofDecl, (oneof, index) => - new OneofDescriptor(oneof, file, this, index, generatedCodeInfo.OneofNames[index])); + new OneofDescriptor(oneof, file, this, index, generatedCodeInfo?.OneofNames[index])); NestedTypes = DescriptorUtil.ConvertAndMakeReadOnly( proto.NestedType, (type, index) => - new MessageDescriptor(type, file, this, index, generatedCodeInfo.NestedTypes[index])); + new MessageDescriptor(type, file, this, index, generatedCodeInfo?.NestedTypes[index])); EnumTypes = DescriptorUtil.ConvertAndMakeReadOnly( proto.EnumType, (type, index) => - new EnumDescriptor(type, file, this, index, generatedCodeInfo.NestedEnums[index])); + new EnumDescriptor(type, file, this, index, generatedCodeInfo?.NestedEnums[index])); + + Extensions = new ExtensionCollection(this, generatedCodeInfo?.Extensions); fieldsInDeclarationOrder = DescriptorUtil.ConvertAndMakeReadOnly( proto.Field, (field, index) => - new FieldDescriptor(field, file, this, index, generatedCodeInfo?.PropertyNames[index])); + new FieldDescriptor(field, file, this, index, generatedCodeInfo?.PropertyNames[index], null)); fieldsInNumberOrder = new ReadOnlyCollection(fieldsInDeclarationOrder.OrderBy(field => field.FieldNumber).ToArray()); // TODO: Use field => field.Proto.JsonName when we're confident it's appropriate. (And then use it in the formatter, too.) jsonFieldMap = CreateJsonFieldMap(fieldsInNumberOrder); @@ -113,6 +117,21 @@ private static ReadOnlyDictionary CreateJsonFieldMap(IL /// public override string Name => Proto.Name; + internal override IReadOnlyList GetNestedDescriptorListForField(int fieldNumber) + { + switch (fieldNumber) + { + case DescriptorProto.FieldFieldNumber: + return (IReadOnlyList) fieldsInDeclarationOrder; + case DescriptorProto.NestedTypeFieldNumber: + return (IReadOnlyList) NestedTypes; + case DescriptorProto.EnumTypeFieldNumber: + return (IReadOnlyList) EnumTypes; + default: + return null; + } + } + internal DescriptorProto Proto { get; } /// @@ -178,6 +197,11 @@ private static ReadOnlyDictionary CreateJsonFieldMap(IL /// public FieldCollection Fields { get; } + /// + /// An unmodifiable list of extensions defined in this message's scrope + /// + public ExtensionCollection Extensions { get; } + /// /// An unmodifiable list of this message type's nested types. /// @@ -216,6 +240,31 @@ private static ReadOnlyDictionary CreateJsonFieldMap(IL public T FindDescriptor(string name) where T : class, IDescriptor => File.DescriptorPool.FindSymbol(FullName + "." + name); + /// + /// The (possibly empty) set of custom options for this message. + /// + //[Obsolete("CustomOptions are obsolete. Use GetOption")] + public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber); + + /* // uncomment this in the full proto2 support PR + /// + /// Gets a single value enum option for this descriptor + /// + public T GetOption(Extension extension) + { + var value = Proto.Options.GetExtension(extension); + return value is IDeepCloneable clonable ? clonable.Clone() : value; + } + + /// + /// Gets a repeated value enum option for this descriptor + /// + public Collections.RepeatedField GetOption(RepeatedExtension extension) + { + return Proto.Options.GetExtension(extension).Clone(); + } + */ + /// /// Looks up and cross-links all fields and nested types. /// @@ -235,6 +284,8 @@ internal void CrossLink() { oneof.CrossLink(); } + + Extensions.CrossLink(); } /// diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs index f9539f6cbdc2..1b37d9b17226 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs @@ -30,6 +30,9 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion +using Google.Protobuf.Collections; +using System; + namespace Google.Protobuf.Reflection { /// @@ -67,6 +70,31 @@ public sealed class MethodDescriptor : DescriptorBase /// public bool IsServerStreaming { get { return proto.ServerStreaming; } } + /// + /// The (possibly empty) set of custom options for this method. + /// + //[Obsolete("CustomOptions are obsolete. Use GetOption")] + public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber); + + /* // uncomment this in the full proto2 support PR + /// + /// Gets a single value enum option for this descriptor + /// + public T GetOption(Extension extension) + { + var value = Proto.Options.GetExtension(extension); + return value is IDeepCloneable clonable ? clonable.Clone() : value; + } + + /// + /// Gets a repeated value enum option for this descriptor + /// + public RepeatedField GetOption(RepeatedExtension extension) + { + return Proto.Options.GetExtension(extension).Clone(); + } + */ + internal MethodDescriptor(MethodDescriptorProto proto, FileDescriptor file, ServiceDescriptor parent, int index) : base(file, parent.FullName + "." + proto.Name, index) @@ -100,4 +128,5 @@ internal void CrossLink() outputType = (MessageDescriptor) lookup; } } -} \ No newline at end of file +} + \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs index 8714ab18efe7..f4bf628a6f56 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs @@ -45,14 +45,14 @@ public sealed class OneofAccessor private readonly Action clearDelegate; private OneofDescriptor descriptor; - internal OneofAccessor(PropertyInfo caseProperty, MethodInfo clearMethod, OneofDescriptor descriptor) + internal OneofAccessor(PropertyInfo caseProperty, MethodInfo clearMethod, OneofDescriptor descriptor) { if (!caseProperty.CanRead) { throw new ArgumentException("Cannot read from property"); } this.descriptor = descriptor; - caseDelegate = ReflectionUtil.CreateFuncIMessageT(caseProperty.GetGetMethod()); + caseDelegate = ReflectionUtil.CreateFuncIMessageInt32(caseProperty.GetGetMethod()); this.descriptor = descriptor; clearDelegate = ReflectionUtil.CreateActionIMessage(clearMethod); diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs index 22020acf0660..9f3d805d05bd 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs @@ -30,8 +30,10 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion +using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using Google.Protobuf.Collections; using Google.Protobuf.Compatibility; namespace Google.Protobuf.Reflection @@ -85,11 +87,46 @@ public MessageDescriptor ContainingType /// Gets an accessor for reflective access to the values associated with the oneof /// in a particular message. /// + /// + /// + /// In descriptors for generated code, the value returned by this property will always be non-null. + /// + /// + /// In dynamically loaded descriptors, the value returned by this property will current be null; + /// if and when dynamic messages are supported, it will return a suitable accessor to work with + /// them. + /// + /// /// /// The accessor used for reflective access. /// public OneofAccessor Accessor { get { return accessor; } } + /// + /// The (possibly empty) set of custom options for this oneof. + /// + //[Obsolete("CustomOptions are obsolete. Use GetOption")] + public CustomOptions CustomOptions => new CustomOptions(proto.Options._extensions?.ValuesByNumber); + + /* // uncomment this in the full proto2 support PR + /// + /// Gets a single value enum option for this descriptor + /// + public T GetOption(Extension extension) + { + var value = proto.Options.GetExtension(extension); + return value is IDeepCloneable clonable ? clonable.Clone() : value; + } + + /// + /// Gets a repeated value enum option for this descriptor + /// + public RepeatedField GetOption(RepeatedExtension extension) + { + return proto.Options.GetExtension(extension).Clone(); + } + */ + internal void CrossLink() { List fieldCollection = new List(); @@ -105,6 +142,12 @@ internal void CrossLink() private OneofAccessor CreateAccessor(string clrName) { + // We won't have a CLR name if this is from a dynamically-loaded FileDescriptor. + // TODO: Support dynamic messages. + if (clrName == null) + { + return null; + } var caseProperty = containingType.ClrType.GetProperty(clrName + "Case"); if (caseProperty == null) { diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/OriginalNameAttribute.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/OriginalNameAttribute.cs index 27f9ab98c324..63f5228f3d62 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/OriginalNameAttribute.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/OriginalNameAttribute.cs @@ -46,6 +46,11 @@ public class OriginalNameAttribute : Attribute /// public string Name { get; set; } + /// + /// If the name is preferred in the .proto file. + /// + public bool PreferredAlias { get; set; } + /// /// Constructs a new attribute instance for the given name. /// @@ -53,6 +58,8 @@ public class OriginalNameAttribute : Attribute public OriginalNameAttribute(string name) { Name = ProtoPreconditions.CheckNotNull(name, nameof(name)); + PreferredAlias = true; } + } -} \ No newline at end of file +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs index df820ca36bd8..ca9c808343b9 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs @@ -30,9 +30,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion +using Google.Protobuf.Compatibility; using System; -using System.Collections.Generic; -using System.Linq.Expressions; using System.Reflection; namespace Google.Protobuf.Reflection @@ -47,61 +46,288 @@ namespace Google.Protobuf.Reflection /// internal static class ReflectionUtil { + static ReflectionUtil() + { + ForceInitialize(); // Handles all reference types + ForceInitialize(); + ForceInitialize(); + ForceInitialize(); + ForceInitialize(); + ForceInitialize(); + ForceInitialize(); + ForceInitialize(); + ForceInitialize(); + ForceInitialize(); + ForceInitialize(); + ForceInitialize(); + ForceInitialize(); + ForceInitialize(); + ForceInitialize(); + ForceInitialize(); + SampleEnumMethod(); + } + + internal static void ForceInitialize() => new ReflectionHelper(); + /// /// Empty Type[] used when calling GetProperty to force property instead of indexer fetching. /// internal static readonly Type[] EmptyTypes = new Type[0]; /// - /// Creates a delegate which will cast the argument to the appropriate method target type, + /// Creates a delegate which will cast the argument to the type that declares the method, /// call the method on it, then convert the result to object. /// - internal static Func CreateFuncIMessageObject(MethodInfo method) - { - ParameterExpression parameter = Expression.Parameter(typeof(IMessage), "p"); - Expression downcast = Expression.Convert(parameter, method.DeclaringType); - Expression call = Expression.Call(downcast, method); - Expression upcast = Expression.Convert(call, typeof(object)); - return Expression.Lambda>(upcast, parameter).Compile(); - } + /// The method to create a delegate for, which must be declared in an IMessage + /// implementation. + internal static Func CreateFuncIMessageObject(MethodInfo method) => + GetReflectionHelper(method.DeclaringType, method.ReturnType).CreateFuncIMessageObject(method); /// - /// Creates a delegate which will cast the argument to the appropriate method target type, - /// call the method on it, then convert the result to the specified type. + /// Creates a delegate which will cast the argument to the type that declares the method, + /// call the method on it, then convert the result to the specified type. The method is expected + /// to actually return an enum (because of where we're calling it - for oneof cases). Sometimes that + /// means we need some extra work to perform conversions. /// - internal static Func CreateFuncIMessageT(MethodInfo method) - { - ParameterExpression parameter = Expression.Parameter(typeof(IMessage), "p"); - Expression downcast = Expression.Convert(parameter, method.DeclaringType); - Expression call = Expression.Call(downcast, method); - Expression upcast = Expression.Convert(call, typeof(T)); - return Expression.Lambda>(upcast, parameter).Compile(); - } + /// The method to create a delegate for, which must be declared in an IMessage + /// implementation. + internal static Func CreateFuncIMessageInt32(MethodInfo method) => + GetReflectionHelper(method.DeclaringType, method.ReturnType).CreateFuncIMessageInt32(method); /// /// Creates a delegate which will execute the given method after casting the first argument to - /// the target type of the method, and the second argument to the first parameter type of the method. + /// the type that declares the method, and the second argument to the first parameter type of the method. /// - internal static Action CreateActionIMessageObject(MethodInfo method) - { - ParameterExpression targetParameter = Expression.Parameter(typeof(IMessage), "target"); - ParameterExpression argParameter = Expression.Parameter(typeof(object), "arg"); - Expression castTarget = Expression.Convert(targetParameter, method.DeclaringType); - Expression castArgument = Expression.Convert(argParameter, method.GetParameters()[0].ParameterType); - Expression call = Expression.Call(castTarget, method, castArgument); - return Expression.Lambda>(call, targetParameter, argParameter).Compile(); - } + /// The method to create a delegate for, which must be declared in an IMessage + /// implementation. + internal static Action CreateActionIMessageObject(MethodInfo method) => + GetReflectionHelper(method.DeclaringType, method.GetParameters()[0].ParameterType).CreateActionIMessageObject(method); + + /// + /// Creates a delegate which will execute the given method after casting the first argument to + /// type that declares the method. + /// + /// The method to create a delegate for, which must be declared in an IMessage + /// implementation. + internal static Action CreateActionIMessage(MethodInfo method) => + GetReflectionHelper(method.DeclaringType, typeof(object)).CreateActionIMessage(method); + + internal static Func CreateFuncIMessageBool(MethodInfo method) => + GetReflectionHelper(method.DeclaringType, method.ReturnType).CreateFuncIMessageBool(method); /// /// Creates a delegate which will execute the given method after casting the first argument to - /// the target type of the method. + /// the type that declares the method, and the second argument to the first parameter type of the method. + /// + internal static IExtensionReflectionHelper CreateExtensionHelper(Extension extension) => + (IExtensionReflectionHelper)Activator.CreateInstance(typeof(ExtensionReflectionHelper<,>).MakeGenericType(extension.TargetType, extension.GetType().GenericTypeArguments[1])); + + /// + /// Creates a reflection helper for the given type arguments. Currently these are created on demand + /// rather than cached; this will be "busy" when initially loading a message's descriptor, but after that + /// they can be garbage collected. We could cache them by type if that proves to be important, but creating + /// an object is pretty cheap. /// - internal static Action CreateActionIMessage(MethodInfo method) + private static IReflectionHelper GetReflectionHelper(Type t1, Type t2) => + (IReflectionHelper) Activator.CreateInstance(typeof(ReflectionHelper<,>).MakeGenericType(t1, t2)); + + // Non-generic interface allowing us to use an instance of ReflectionHelper without statically + // knowing the types involved. + private interface IReflectionHelper + { + Func CreateFuncIMessageInt32(MethodInfo method); + Action CreateActionIMessage(MethodInfo method); + Func CreateFuncIMessageObject(MethodInfo method); + Action CreateActionIMessageObject(MethodInfo method); + Func CreateFuncIMessageBool(MethodInfo method); + } + + internal interface IExtensionReflectionHelper + { + object GetExtension(IMessage message); + void SetExtension(IMessage message, object value); + bool HasExtension(IMessage message); + void ClearExtension(IMessage message); + } + + private class ReflectionHelper : IReflectionHelper + { + + public Func CreateFuncIMessageInt32(MethodInfo method) + { + // On pleasant runtimes, we can create a Func from a method returning + // an enum based on an int. That's the fast path. + if (CanConvertEnumFuncToInt32Func) + { + var del = (Func) method.CreateDelegate(typeof(Func)); + return message => del((T1) message); + } + else + { + // On some runtimes (e.g. old Mono) the return type has to be exactly correct, + // so we go via boxing. Reflection is already fairly inefficient, and this is + // only used for one-of case checking, fortunately. + var del = (Func) method.CreateDelegate(typeof(Func)); + return message => (int) (object) del((T1) message); + } + } + + public Action CreateActionIMessage(MethodInfo method) + { + var del = (Action) method.CreateDelegate(typeof(Action)); + return message => del((T1) message); + } + + public Func CreateFuncIMessageObject(MethodInfo method) + { + var del = (Func) method.CreateDelegate(typeof(Func)); + return message => del((T1) message); + } + + public Action CreateActionIMessageObject(MethodInfo method) + { + var del = (Action) method.CreateDelegate(typeof(Action)); + return (message, arg) => del((T1) message, (T2) arg); + } + + public Func CreateFuncIMessageBool(MethodInfo method) + { + var del = (Func)method.CreateDelegate(typeof(Func)); + return message => del((T1)message); + } + } + + private class ExtensionReflectionHelper : IExtensionReflectionHelper + where T1 : IExtendableMessage + { + private readonly Extension extension; + + public ExtensionReflectionHelper(Extension extension) + { + this.extension = extension; + } + + public object GetExtension(IMessage message) + { + if (!(message is T1)) + { + throw new InvalidCastException("Cannot access extension on message that isn't IExtensionMessage"); + } + + T1 extensionMessage = (T1)message; + + if (extension is Extension) + { + return extensionMessage.GetExtension(extension as Extension); + } + else if (extension is RepeatedExtension) + { + return extensionMessage.GetExtension(extension as RepeatedExtension); + } + else + { + throw new InvalidCastException("The provided extension is not a valid extension identifier type"); + } + } + + public bool HasExtension(IMessage message) + { + if (!(message is T1)) + { + throw new InvalidCastException("Cannot access extension on message that isn't IExtensionMessage"); + } + + T1 extensionMessage = (T1)message; + + if (extension is Extension) + { + return extensionMessage.HasExtension(extension as Extension); + } + else if (extension is RepeatedExtension) + { + throw new InvalidOperationException("HasValue is not implemented for repeated extensions"); + } + else + { + throw new InvalidCastException("The provided extension is not a valid extension identifier type"); + } + } + + public void SetExtension(IMessage message, object value) + { + if (!(message is T1)) + { + throw new InvalidCastException("Cannot access extension on message that isn't IExtensionMessage"); + } + + T1 extensionMessage = (T1)message; + + if (extension is Extension) + { + extensionMessage.SetExtension(extension as Extension, (T3)value); + } + else if (extension is RepeatedExtension) + { + throw new InvalidOperationException("SetValue is not implemented for repeated extensions"); + } + else + { + throw new InvalidCastException("The provided extension is not a valid extension identifier type"); + } + } + + public void ClearExtension(IMessage message) + { + if (!(message is T1)) + { + throw new InvalidCastException("Cannot access extension on message that isn't IExtensionMessage"); + } + + T1 extensionMessage = (T1)message; + + if (extension is Extension) + { + extensionMessage.ClearExtension(extension as Extension); + } + else if (extension is RepeatedExtension) + { + extensionMessage.GetExtension(extension as RepeatedExtension).Clear(); + } + else + { + throw new InvalidCastException("The provided extension is not a valid extension identifier type"); + } + } + } + + // Runtime compatibility checking code - see ReflectionHelper.CreateFuncIMessageInt32 for + // details about why we're doing this. + + // Deliberately not inside the generic type. We only want to check this once. + private static bool CanConvertEnumFuncToInt32Func { get; } = CheckCanConvertEnumFuncToInt32Func(); + + private static bool CheckCanConvertEnumFuncToInt32Func() { - ParameterExpression targetParameter = Expression.Parameter(typeof(IMessage), "target"); - Expression castTarget = Expression.Convert(targetParameter, method.DeclaringType); - Expression call = Expression.Call(castTarget, method); - return Expression.Lambda>(call, targetParameter).Compile(); - } + try + { + // Try to do the conversion using reflection, so we can see whether it's supported. + MethodInfo method = typeof(ReflectionUtil).GetMethod(nameof(SampleEnumMethod)); + // If this passes, we're in a reasonable runtime. + method.CreateDelegate(typeof(Func)); + return true; + } + catch (ArgumentException) + { + return false; + } + } + + public enum SampleEnum + { + X + } + + // Public to make the reflection simpler. + public static SampleEnum SampleEnumMethod() => SampleEnum.X; } -} \ No newline at end of file +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs index bd408470929b..afb4a693fcef 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs @@ -51,6 +51,11 @@ public override void Clear(IMessage message) list.Clear(); } + public override bool HasValue(IMessage message) + { + throw new InvalidOperationException("HasValue is not implemented for repeated fields"); + } + public override void SetValue(IMessage message, object value) { throw new InvalidOperationException("SetValue is not implemented for repeated fields"); diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs index cc0a50104241..54f4df7298a0 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs @@ -30,8 +30,10 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion +using Google.Protobuf.Collections; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; namespace Google.Protobuf.Reflection { @@ -58,6 +60,17 @@ internal ServiceDescriptor(ServiceDescriptorProto proto, FileDescriptor file, in /// public override string Name { get { return proto.Name; } } + internal override IReadOnlyList GetNestedDescriptorListForField(int fieldNumber) + { + switch (fieldNumber) + { + case ServiceDescriptorProto.MethodFieldNumber: + return (IReadOnlyList) methods; + default: + return null; + } + } + internal ServiceDescriptorProto Proto { get { return proto; } } /// @@ -78,6 +91,31 @@ public MethodDescriptor FindMethodByName(String name) return File.DescriptorPool.FindSymbol(FullName + "." + name); } + /// + /// The (possibly empty) set of custom options for this service. + /// + //[Obsolete("CustomOptions are obsolete. Use GetOption")] + public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber); + + /* // uncomment this in the full proto2 support PR + /// + /// Gets a single value enum option for this descriptor + /// + public T GetOption(Extension extension) + { + var value = Proto.Options.GetExtension(extension); + return value is IDeepCloneable clonable ? clonable.Clone() : value; + } + + /// + /// Gets a repeated value enum option for this descriptor + /// + public RepeatedField GetOption(RepeatedExtension extension) + { + return Proto.Options.GetExtension(extension).Clone(); + } + */ + internal void CrossLink() { foreach (MethodDescriptor method in methods) @@ -86,4 +124,5 @@ internal void CrossLink() } } } -} \ No newline at end of file +} + \ No newline at end of file diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs index bbac2173d4d3..dfc5b6263c60 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs @@ -48,6 +48,7 @@ internal sealed class SingleFieldAccessor : FieldAccessorBase private readonly Action setValueDelegate; private readonly Action clearDelegate; + private readonly Func hasDelegate; internal SingleFieldAccessor(PropertyInfo property, FieldDescriptor descriptor) : base(property, descriptor) { @@ -56,16 +57,34 @@ internal SingleFieldAccessor(PropertyInfo property, FieldDescriptor descriptor) throw new ArgumentException("Not all required properties/methods available"); } setValueDelegate = ReflectionUtil.CreateActionIMessageObject(property.GetSetMethod()); + if (descriptor.File.Proto.Syntax == "proto2") + { + MethodInfo hasMethod = property.DeclaringType.GetRuntimeProperty("Has" + property.Name).GetMethod; + if (hasMethod == null) { + throw new ArgumentException("Not all required properties/methods are available"); + } + hasDelegate = ReflectionUtil.CreateFuncIMessageBool(hasMethod); + MethodInfo clearMethod = property.DeclaringType.GetRuntimeMethod("Clear" + property.Name, ReflectionUtil.EmptyTypes); + if (clearMethod == null) { + throw new ArgumentException("Not all required properties/methods are available"); + } + clearDelegate = ReflectionUtil.CreateActionIMessage(clearMethod); + } + else + { + hasDelegate = message => { + throw new InvalidOperationException("HasValue is not implemented for proto3 fields"); + }; + var clrType = property.PropertyType; - var clrType = property.PropertyType; - - // TODO: Validate that this is a reasonable single field? (Should be a value type, a message type, or string/ByteString.) - object defaultValue = - descriptor.FieldType == FieldType.Message ? null - : clrType == typeof(string) ? "" - : clrType == typeof(ByteString) ? ByteString.Empty - : Activator.CreateInstance(clrType); - clearDelegate = message => SetValue(message, defaultValue); + // TODO: Validate that this is a reasonable single field? (Should be a value type, a message type, or string/ByteString.) + object defaultValue = + descriptor.FieldType == FieldType.Message ? null + : clrType == typeof(string) ? "" + : clrType == typeof(ByteString) ? ByteString.Empty + : Activator.CreateInstance(clrType); + clearDelegate = message => SetValue(message, defaultValue); + } } public override void Clear(IMessage message) @@ -73,6 +92,11 @@ public override void Clear(IMessage message) clearDelegate(message); } + public override bool HasValue(IMessage message) + { + return hasDelegate(message); + } + public override void SetValue(IMessage message, object value) { setValueDelegate(message, value); diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/UnknownField.cs b/third_party/protobuf/csharp/src/Google.Protobuf/UnknownField.cs new file mode 100644 index 000000000000..e3ce0e86efce --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf/UnknownField.cs @@ -0,0 +1,290 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2017 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using Google.Protobuf.Collections; + +namespace Google.Protobuf +{ + /// + /// Represents a single field in an UnknownFieldSet. + /// + /// An UnknownField consists of four lists of values. The lists correspond + /// to the four "wire types" used in the protocol buffer binary format. + /// Normally, only one of the four lists will contain any values, since it + /// is impossible to define a valid message type that declares two different + /// types for the same field number. However, the code is designed to allow + /// for the case where the same unknown field number is encountered using + /// multiple different wire types. + /// + /// + internal sealed class UnknownField + { + private List varintList; + private List fixed32List; + private List fixed64List; + private List lengthDelimitedList; + private List groupList; + + /// + /// Creates a new UnknownField. + /// + public UnknownField() + { + } + + /// + /// Checks if two unknown field are equal. + /// + public override bool Equals(object other) + { + if (ReferenceEquals(this, other)) + { + return true; + } + UnknownField otherField = other as UnknownField; + return otherField != null + && Lists.Equals(varintList, otherField.varintList) + && Lists.Equals(fixed32List, otherField.fixed32List) + && Lists.Equals(fixed64List, otherField.fixed64List) + && Lists.Equals(lengthDelimitedList, otherField.lengthDelimitedList) + && Lists.Equals(groupList, otherField.groupList); + } + + /// + /// Get the hash code of the unknown field. + /// + public override int GetHashCode() + { + int hash = 43; + hash = hash * 47 + Lists.GetHashCode(varintList); + hash = hash * 47 + Lists.GetHashCode(fixed32List); + hash = hash * 47 + Lists.GetHashCode(fixed64List); + hash = hash * 47 + Lists.GetHashCode(lengthDelimitedList); + hash = hash * 47 + Lists.GetHashCode(groupList); + return hash; + } + + /// + /// Serializes the field, including the field number, and writes it to + /// + /// + /// The unknown field number. + /// The CodedOutputStream to write to. + internal void WriteTo(int fieldNumber, CodedOutputStream output) + { + if (varintList != null) + { + foreach (ulong value in varintList) + { + output.WriteTag(fieldNumber, WireFormat.WireType.Varint); + output.WriteUInt64(value); + } + } + if (fixed32List != null) + { + foreach (uint value in fixed32List) + { + output.WriteTag(fieldNumber, WireFormat.WireType.Fixed32); + output.WriteFixed32(value); + } + } + if (fixed64List != null) + { + foreach (ulong value in fixed64List) + { + output.WriteTag(fieldNumber, WireFormat.WireType.Fixed64); + output.WriteFixed64(value); + } + } + if (lengthDelimitedList != null) + { + foreach (ByteString value in lengthDelimitedList) + { + output.WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteBytes(value); + } + } + if (groupList != null) + { + foreach (UnknownFieldSet value in groupList) + { + output.WriteTag(fieldNumber, WireFormat.WireType.StartGroup); + value.WriteTo(output); + output.WriteTag(fieldNumber, WireFormat.WireType.EndGroup); + } + } + } + + /// + /// Computes the number of bytes required to encode this field, including field + /// number. + /// + internal int GetSerializedSize(int fieldNumber) + { + int result = 0; + if (varintList != null) + { + result += CodedOutputStream.ComputeTagSize(fieldNumber) * varintList.Count; + foreach (ulong value in varintList) + { + result += CodedOutputStream.ComputeUInt64Size(value); + } + } + if (fixed32List != null) + { + result += CodedOutputStream.ComputeTagSize(fieldNumber) * fixed32List.Count; + result += CodedOutputStream.ComputeFixed32Size(1) * fixed32List.Count; + } + if (fixed64List != null) + { + result += CodedOutputStream.ComputeTagSize(fieldNumber) * fixed64List.Count; + result += CodedOutputStream.ComputeFixed64Size(1) * fixed64List.Count; + } + if (lengthDelimitedList != null) + { + result += CodedOutputStream.ComputeTagSize(fieldNumber) * lengthDelimitedList.Count; + foreach (ByteString value in lengthDelimitedList) + { + result += CodedOutputStream.ComputeBytesSize(value); + } + } + if (groupList != null) + { + result += CodedOutputStream.ComputeTagSize(fieldNumber) * 2 * groupList.Count; + foreach (UnknownFieldSet value in groupList) + { + result += value.CalculateSize(); + } + } + return result; + } + + /// + /// Merge the values in into this field. For each list + /// of values, 's values are append to the ones in this + /// field. + /// + internal UnknownField MergeFrom(UnknownField other) + { + varintList = AddAll(varintList, other.varintList); + fixed32List = AddAll(fixed32List, other.fixed32List); + fixed64List = AddAll(fixed64List, other.fixed64List); + lengthDelimitedList = AddAll(lengthDelimitedList, other.lengthDelimitedList); + groupList = AddAll(groupList, other.groupList); + return this; + } + + /// + /// Returns a new list containing all of the given specified values from + /// both the and lists. + /// If is null and is empty, + /// null is returned. Otherwise, either a new list is created (if + /// is null) or the elements of are added to . + /// + private static List AddAll(List current, IList extras) + { + if (extras.Count == 0) + { + return current; + } + if (current == null) + { + current = new List(extras); + } + else + { + current.AddRange(extras); + } + return current; + } + + /// + /// Adds a varint value. + /// + internal UnknownField AddVarint(ulong value) + { + varintList = Add(varintList, value); + return this; + } + + /// + /// Adds a fixed32 value. + /// + internal UnknownField AddFixed32(uint value) + { + fixed32List = Add(fixed32List, value); + return this; + } + + /// + /// Adds a fixed64 value. + /// + internal UnknownField AddFixed64(ulong value) + { + fixed64List = Add(fixed64List, value); + return this; + } + + /// + /// Adds a length-delimited value. + /// + internal UnknownField AddLengthDelimited(ByteString value) + { + lengthDelimitedList = Add(lengthDelimitedList, value); + return this; + } + + internal UnknownField AddGroup(UnknownFieldSet value) + { + groupList = Add(groupList, value); + return this; + } + + /// + /// Adds to the , creating + /// a new list if is null. The list is returned - either + /// the original reference or the new list. + /// + private static List Add(List list, T value) + { + if (list == null) + { + list = new List(); + } + list.Add(value); + return list; + } + } +} diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/UnknownFieldSet.cs b/third_party/protobuf/csharp/src/Google.Protobuf/UnknownFieldSet.cs new file mode 100644 index 000000000000..d136cf1e6572 --- /dev/null +++ b/third_party/protobuf/csharp/src/Google.Protobuf/UnknownFieldSet.cs @@ -0,0 +1,339 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections.Generic; +using System.IO; +using Google.Protobuf.Reflection; + +namespace Google.Protobuf +{ + /// + /// Used to keep track of fields which were seen when parsing a protocol message + /// but whose field numbers or types are unrecognized. This most frequently + /// occurs when new fields are added to a message type and then messages containing + /// those fields are read by old software that was built before the new types were + /// added. + /// + /// Most users will never need to use this class directly. + /// + public sealed partial class UnknownFieldSet + { + private readonly IDictionary fields; + + /// + /// Creates a new UnknownFieldSet. + /// + internal UnknownFieldSet() + { + this.fields = new Dictionary(); + } + + /// + /// Checks whether or not the given field number is present in the set. + /// + internal bool HasField(int field) + { + return fields.ContainsKey(field); + } + + /// + /// Serializes the set and writes it to . + /// + public void WriteTo(CodedOutputStream output) + { + foreach (KeyValuePair entry in fields) + { + entry.Value.WriteTo(entry.Key, output); + } + } + + /// + /// Gets the number of bytes required to encode this set. + /// + public int CalculateSize() + { + int result = 0; + foreach (KeyValuePair entry in fields) + { + result += entry.Value.GetSerializedSize(entry.Key); + } + return result; + } + + /// + /// Checks if two unknown field sets are equal. + /// + public override bool Equals(object other) + { + if (ReferenceEquals(this, other)) + { + return true; + } + UnknownFieldSet otherSet = other as UnknownFieldSet; + IDictionary otherFields = otherSet.fields; + if (fields.Count != otherFields.Count) + { + return false; + } + foreach (KeyValuePair leftEntry in fields) + { + UnknownField rightValue; + if (!otherFields.TryGetValue(leftEntry.Key, out rightValue)) + { + return false; + } + if (!leftEntry.Value.Equals(rightValue)) + { + return false; + } + } + return true; + } + + /// + /// Gets the unknown field set's hash code. + /// + public override int GetHashCode() + { + int ret = 1; + foreach (KeyValuePair field in fields) + { + // Use ^ here to make the field order irrelevant. + int hash = field.Key.GetHashCode() ^ field.Value.GetHashCode(); + ret ^= hash; + } + return ret; + } + + // Optimization: We keep around the last field that was + // modified so that we can efficiently add to it multiple times in a + // row (important when parsing an unknown repeated field). + private int lastFieldNumber; + private UnknownField lastField; + + private UnknownField GetOrAddField(int number) + { + if (lastField != null && number == lastFieldNumber) + { + return lastField; + } + if (number == 0) + { + return null; + } + + UnknownField existing; + if (fields.TryGetValue(number, out existing)) + { + return existing; + } + lastField = new UnknownField(); + AddOrReplaceField(number, lastField); + lastFieldNumber = number; + return lastField; + } + + /// + /// Adds a field to the set. If a field with the same number already exists, it + /// is replaced. + /// + internal UnknownFieldSet AddOrReplaceField(int number, UnknownField field) + { + if (number == 0) + { + throw new ArgumentOutOfRangeException("number", "Zero is not a valid field number."); + } + fields[number] = field; + return this; + } + + /// + /// Parse a single field from and merge it + /// into this set. + /// + /// The coded input stream containing the field + /// false if the tag is an "end group" tag, true otherwise + private bool MergeFieldFrom(CodedInputStream input) + { + uint tag = input.LastTag; + int number = WireFormat.GetTagFieldNumber(tag); + switch (WireFormat.GetTagWireType(tag)) + { + case WireFormat.WireType.Varint: + { + ulong uint64 = input.ReadUInt64(); + GetOrAddField(number).AddVarint(uint64); + return true; + } + case WireFormat.WireType.Fixed32: + { + uint uint32 = input.ReadFixed32(); + GetOrAddField(number).AddFixed32(uint32); + return true; + } + case WireFormat.WireType.Fixed64: + { + ulong uint64 = input.ReadFixed64(); + GetOrAddField(number).AddFixed64(uint64); + return true; + } + case WireFormat.WireType.LengthDelimited: + { + ByteString bytes = input.ReadBytes(); + GetOrAddField(number).AddLengthDelimited(bytes); + return true; + } + case WireFormat.WireType.StartGroup: + { + uint endTag = WireFormat.MakeTag(number, WireFormat.WireType.EndGroup); + UnknownFieldSet set = new UnknownFieldSet(); + while (input.ReadTag() != endTag) + { + set.MergeFieldFrom(input); + } + GetOrAddField(number).AddGroup(set); + return true; + } + case WireFormat.WireType.EndGroup: + { + return false; + } + default: + throw InvalidProtocolBufferException.InvalidWireType(); + } + } + + /// + /// Create a new UnknownFieldSet if unknownFields is null. + /// Parse a single field from and merge it + /// into unknownFields. If is configured to discard unknown fields, + /// will be returned as-is and the field will be skipped. + /// + /// The UnknownFieldSet which need to be merged + /// The coded input stream containing the field + /// The merged UnknownFieldSet + public static UnknownFieldSet MergeFieldFrom(UnknownFieldSet unknownFields, + CodedInputStream input) + { + if (input.DiscardUnknownFields) + { + input.SkipLastField(); + return unknownFields; + } + if (unknownFields == null) + { + unknownFields = new UnknownFieldSet(); + } + if (!unknownFields.MergeFieldFrom(input)) + { + throw new InvalidProtocolBufferException("Merge an unknown field of end-group tag, indicating that the corresponding start-group was missing."); // match the old code-gen + } + return unknownFields; + } + + /// + /// Merges the fields from into this set. + /// If a field number exists in both sets, the values in + /// will be appended to the values in this set. + /// + private UnknownFieldSet MergeFrom(UnknownFieldSet other) + { + if (other != null) + { + foreach (KeyValuePair entry in other.fields) + { + MergeField(entry.Key, entry.Value); + } + } + return this; + } + + /// + /// Created a new UnknownFieldSet to if + /// needed and merges the fields from into the first set. + /// If a field number exists in both sets, the values in + /// will be appended to the values in this set. + /// + public static UnknownFieldSet MergeFrom(UnknownFieldSet unknownFields, + UnknownFieldSet other) + { + if (other == null) + { + return unknownFields; + } + if (unknownFields == null) + { + unknownFields = new UnknownFieldSet(); + } + unknownFields.MergeFrom(other); + return unknownFields; + } + + + /// + /// Adds a field to the unknown field set. If a field with the same + /// number already exists, the two are merged. + /// + private UnknownFieldSet MergeField(int number, UnknownField field) + { + if (number == 0) + { + throw new ArgumentOutOfRangeException("number", "Zero is not a valid field number."); + } + if (HasField(number)) + { + GetOrAddField(number).MergeFrom(field); + } + else + { + AddOrReplaceField(number, field); + } + return this; + } + + /// + /// Clone an unknown field set from . + /// + public static UnknownFieldSet Clone(UnknownFieldSet other) + { + if (other == null) + { + return null; + } + UnknownFieldSet unknownFields = new UnknownFieldSet(); + unknownFields.MergeFrom(other); + return unknownFields; + } + } +} + diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs index 871a383f0d7d..09e0e29f0de9 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs @@ -1,5 +1,7 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/any.proto +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/any.proto +// #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -10,7 +12,6 @@ namespace Google.Protobuf.WellKnownTypes { /// Holder for reflection information generated from google/protobuf/any.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class AnyReflection { #region Descriptor @@ -24,14 +25,14 @@ static AnyReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "Chlnb29nbGUvcHJvdG9idWYvYW55LnByb3RvEg9nb29nbGUucHJvdG9idWYi", - "JgoDQW55EhAKCHR5cGVfdXJsGAEgASgJEg0KBXZhbHVlGAIgASgMQnIKE2Nv", + "JgoDQW55EhAKCHR5cGVfdXJsGAEgASgJEg0KBXZhbHVlGAIgASgMQm8KE2Nv", "bS5nb29nbGUucHJvdG9idWZCCEFueVByb3RvUAFaJWdpdGh1Yi5jb20vZ29s", - "YW5nL3Byb3RvYnVmL3B0eXBlcy9hbnmgAQGiAgNHUEKqAh5Hb29nbGUuUHJv", - "dG9idWYuV2VsbEtub3duVHlwZXNiBnByb3RvMw==")); + "YW5nL3Byb3RvYnVmL3B0eXBlcy9hbnmiAgNHUEKqAh5Hb29nbGUuUHJvdG9i", + "dWYuV2VsbEtub3duVHlwZXNiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Any), global::Google.Protobuf.WellKnownTypes.Any.Parser, new[]{ "TypeUrl", "Value" }, null, null, null) + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Any), global::Google.Protobuf.WellKnownTypes.Any.Parser, new[]{ "TypeUrl", "Value" }, null, null, null, null) })); } #endregion @@ -39,89 +40,116 @@ static AnyReflection() { } #region Messages /// - /// `Any` contains an arbitrary serialized protocol buffer message along with a - /// URL that describes the type of the serialized message. + /// `Any` contains an arbitrary serialized protocol buffer message along with a + /// URL that describes the type of the serialized message. /// - /// Protobuf library provides support to pack/unpack Any values in the form - /// of utility functions or additional generated methods of the Any type. + /// Protobuf library provides support to pack/unpack Any values in the form + /// of utility functions or additional generated methods of the Any type. /// - /// Example 1: Pack and unpack a message in C++. + /// Example 1: Pack and unpack a message in C++. /// - /// Foo foo = ...; - /// Any any; - /// any.PackFrom(foo); - /// ... - /// if (any.UnpackTo(&foo)) { - /// ... - /// } + /// Foo foo = ...; + /// Any any; + /// any.PackFrom(foo); + /// ... + /// if (any.UnpackTo(&foo)) { + /// ... + /// } + /// + /// Example 2: Pack and unpack a message in Java. /// - /// Example 2: Pack and unpack a message in Java. + /// Foo foo = ...; + /// Any any = Any.pack(foo); + /// ... + /// if (any.is(Foo.class)) { + /// foo = any.unpack(Foo.class); + /// } /// - /// Foo foo = ...; - /// Any any = Any.pack(foo); + /// Example 3: Pack and unpack a message in Python. + /// + /// foo = Foo(...) + /// any = Any() + /// any.Pack(foo) + /// ... + /// if any.Is(Foo.DESCRIPTOR): + /// any.Unpack(foo) + /// ... + /// + /// Example 4: Pack and unpack a message in Go + /// + /// foo := &pb.Foo{...} + /// any, err := ptypes.MarshalAny(foo) /// ... - /// if (any.is(Foo.class)) { - /// foo = any.unpack(Foo.class); + /// foo := &pb.Foo{} + /// if err := ptypes.UnmarshalAny(any, foo); err != nil { + /// ... /// } /// - /// The pack methods provided by protobuf library will by default use - /// 'type.googleapis.com/full.type.name' as the type URL and the unpack - /// methods only use the fully qualified type name after the last '/' - /// in the type URL, for example "foo.bar.com/x/y.z" will yield type - /// name "y.z". + /// The pack methods provided by protobuf library will by default use + /// 'type.googleapis.com/full.type.name' as the type URL and the unpack + /// methods only use the fully qualified type name after the last '/' + /// in the type URL, for example "foo.bar.com/x/y.z" will yield type + /// name "y.z". /// - /// JSON - /// ==== - /// The JSON representation of an `Any` value uses the regular - /// representation of the deserialized, embedded message, with an - /// additional field `@type` which contains the type URL. Example: + /// JSON + /// ==== + /// The JSON representation of an `Any` value uses the regular + /// representation of the deserialized, embedded message, with an + /// additional field `@type` which contains the type URL. Example: /// - /// package google.profile; - /// message Person { - /// string first_name = 1; - /// string last_name = 2; - /// } + /// package google.profile; + /// message Person { + /// string first_name = 1; + /// string last_name = 2; + /// } /// - /// { - /// "@type": "type.googleapis.com/google.profile.Person", - /// "firstName": <string>, - /// "lastName": <string> - /// } + /// { + /// "@type": "type.googleapis.com/google.profile.Person", + /// "firstName": <string>, + /// "lastName": <string> + /// } /// - /// If the embedded message type is well-known and has a custom JSON - /// representation, that representation will be embedded adding a field - /// `value` which holds the custom JSON in addition to the `@type` - /// field. Example (for message [google.protobuf.Duration][]): + /// If the embedded message type is well-known and has a custom JSON + /// representation, that representation will be embedded adding a field + /// `value` which holds the custom JSON in addition to the `@type` + /// field. Example (for message [google.protobuf.Duration][]): /// - /// { - /// "@type": "type.googleapis.com/google.protobuf.Duration", - /// "value": "1.212s" - /// } + /// { + /// "@type": "type.googleapis.com/google.protobuf.Duration", + /// "value": "1.212s" + /// } /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Any : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Any()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Any() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Any(Any other) : this() { typeUrl_ = other.typeUrl_; value_ = other.value_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Any Clone() { return new Any(this); } @@ -130,28 +158,35 @@ public Any Clone() { public const int TypeUrlFieldNumber = 1; private string typeUrl_ = ""; /// - /// A URL/resource name whose content describes the type of the - /// serialized protocol buffer message. + /// A URL/resource name that uniquely identifies the type of the serialized + /// protocol buffer message. This string must contain at least + /// one "/" character. The last segment of the URL's path must represent + /// the fully qualified name of the type (as in + /// `path/google.protobuf.Duration`). The name should be in a canonical form + /// (e.g., leading "." is not accepted). + /// + /// In practice, teams usually precompile into the binary all types that they + /// expect it to use in the context of Any. However, for URLs which use the + /// scheme `http`, `https`, or no scheme, one can optionally set up a type + /// server that maps type URLs to message definitions as follows: /// - /// For URLs which use the schema `http`, `https`, or no schema, the - /// following restrictions and interpretations apply: + /// * If no scheme is provided, `https` is assumed. + /// * An HTTP GET on the URL must yield a [google.protobuf.Type][] + /// value in binary format, or produce an error. + /// * Applications are allowed to cache lookup results based on the + /// URL, or have them precompiled into a binary to avoid any + /// lookup. Therefore, binary compatibility needs to be preserved + /// on changes to types. (Use versioned type names to manage + /// breaking changes.) /// - /// * If no schema is provided, `https` is assumed. - /// * The last segment of the URL's path must represent the fully - /// qualified name of the type (as in `path/google.protobuf.Duration`). - /// The name should be in a canonical form (e.g., leading "." is - /// not accepted). - /// * An HTTP GET on the URL must yield a [google.protobuf.Type][] - /// value in binary format, or produce an error. - /// * Applications are allowed to cache lookup results based on the - /// URL, or have them precompiled into a binary to avoid any - /// lookup. Therefore, binary compatibility needs to be preserved - /// on changes to types. (Use versioned type names to manage - /// breaking changes.) + /// Note: this functionality is not currently available in the official + /// protobuf release, and it is not used for type URLs beginning with + /// type.googleapis.com. /// - /// Schemas other than `http`, `https` (or the empty schema) might be - /// used with implementation specific semantics. + /// Schemes other than `http`, `https` (or the empty scheme) might be + /// used with implementation specific semantics. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string TypeUrl { get { return typeUrl_; } set { @@ -163,8 +198,9 @@ public string TypeUrl { public const int ValueFieldNumber = 2; private pb::ByteString value_ = pb::ByteString.Empty; /// - /// Must be a valid serialized protocol buffer of the above specified type. + /// Must be a valid serialized protocol buffer of the above specified type. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pb::ByteString Value { get { return value_; } set { @@ -172,10 +208,12 @@ public string TypeUrl { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Any); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Any other) { if (ReferenceEquals(other, null)) { return false; @@ -185,20 +223,26 @@ public bool Equals(Any other) { } if (TypeUrl != other.TypeUrl) return false; if (Value != other.Value) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (TypeUrl.Length != 0) hash ^= TypeUrl.GetHashCode(); if (Value.Length != 0) hash ^= Value.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (TypeUrl.Length != 0) { output.WriteRawTag(10); @@ -208,8 +252,12 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(18); output.WriteBytes(Value); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (TypeUrl.Length != 0) { @@ -218,9 +266,13 @@ public int CalculateSize() { if (Value.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeBytesSize(Value); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Any other) { if (other == null) { return; @@ -231,14 +283,16 @@ public void MergeFrom(Any other) { if (other.Value.Length != 0) { Value = other.Value; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { TypeUrl = input.ReadString(); diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs index f4fac73865c1..49f259982acb 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs @@ -44,21 +44,40 @@ private static string GetTypeUrl(MessageDescriptor descriptor, string prefix) => prefix.EndsWith("/") ? prefix + descriptor.FullName : prefix + "/" + descriptor.FullName; /// - /// Retrieves the type name for a type URL. This is always just the last part of the URL, - /// after the trailing slash. No validation of anything before the trailing slash is performed. - /// If the type URL does not include a slash, an empty string is returned rather than an exception - /// being thrown; this won't match any types, and the calling code is probably in a better position - /// to give a meaningful error. - /// There is no handling of fragments or queries at the moment. + /// Retrieves the type name for a type URL, matching the + /// of the packed message type. /// + /// + /// + /// This is always just the last part of the URL, after the final slash. No validation of + /// anything before the trailing slash is performed. If the type URL does not include a slash, + /// an empty string is returned rather than an exception being thrown; this won't match any types, + /// and the calling code is probably in a better position to give a meaningful error. + /// + /// + /// There is no handling of fragments or queries at the moment. + /// + /// /// The URL to extract the type name from /// The type name - internal static string GetTypeName(string typeUrl) + public static string GetTypeName(string typeUrl) { + ProtoPreconditions.CheckNotNull(typeUrl, nameof(typeUrl)); int lastSlash = typeUrl.LastIndexOf('/'); return lastSlash == -1 ? "" : typeUrl.Substring(lastSlash + 1); } + /// + /// Returns a bool indictating whether this Any message is of the target message type + /// + /// The descriptor of the message type + /// true if the type name matches the descriptor's full name or false otherwise + public bool Is(MessageDescriptor descriptor) + { + ProtoPreconditions.CheckNotNull(descriptor, nameof(descriptor)); + return GetTypeName(TypeUrl) == descriptor.FullName; + } + /// /// Unpacks the content of this Any message into the target message type, /// which must match the type URL within this Any message. @@ -80,6 +99,27 @@ internal static string GetTypeName(string typeUrl) return target; } + /// + /// Attempts to unpack the content of this Any message into the target message type, + /// if it matches the type URL within this Any message. + /// + /// The type of message to attempt to unpack the content into. + /// true if the message was successfully unpacked; false if the type name didn't match + public bool TryUnpack(out T result) where T : IMessage, new() + { + // Note: deliberately avoid writing anything to result until the end, in case it's being + // monitored by other threads. (That would be a bug in the calling code, but let's not make it worse.) + T target = new T(); + if (GetTypeName(TypeUrl) != target.Descriptor.FullName) + { + result = default(T); // Can't use null as there's no class constraint, but this always *will* be null in real usage. + return false; + } + target.MergeFrom(Value); + result = target; + return true; + } + /// /// Packs the specified message into an Any message using a type URL prefix of "type.googleapis.com". /// diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs index e568a2c981a6..06a990591940 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs @@ -1,5 +1,7 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/api.proto +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/api.proto +// #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -10,7 +12,6 @@ namespace Google.Protobuf.WellKnownTypes { /// Holder for reflection information generated from google/protobuf/api.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class ApiReflection { #region Descriptor @@ -36,15 +37,16 @@ static ApiReflection() { "ChFyZXNwb25zZV90eXBlX3VybBgEIAEoCRIaChJyZXNwb25zZV9zdHJlYW1p", "bmcYBSABKAgSKAoHb3B0aW9ucxgGIAMoCzIXLmdvb2dsZS5wcm90b2J1Zi5P", "cHRpb24SJwoGc3ludGF4GAcgASgOMhcuZ29vZ2xlLnByb3RvYnVmLlN5bnRh", - "eCIjCgVNaXhpbhIMCgRuYW1lGAEgASgJEgwKBHJvb3QYAiABKAlCSwoTY29t", - "Lmdvb2dsZS5wcm90b2J1ZkIIQXBpUHJvdG9QAaABAaICA0dQQqoCHkdvb2ds", - "ZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJvdG8z")); + "eCIjCgVNaXhpbhIMCgRuYW1lGAEgASgJEgwKBHJvb3QYAiABKAlCdQoTY29t", + "Lmdvb2dsZS5wcm90b2J1ZkIIQXBpUHJvdG9QAVorZ29vZ2xlLmdvbGFuZy5v", + "cmcvZ2VucHJvdG8vcHJvdG9idWYvYXBpO2FwaaICA0dQQqoCHkdvb2dsZS5Q", + "cm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.SourceContextReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TypeReflection.Descriptor, }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Api), global::Google.Protobuf.WellKnownTypes.Api.Parser, new[]{ "Name", "Methods", "Options", "Version", "SourceContext", "Mixins", "Syntax" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Method), global::Google.Protobuf.WellKnownTypes.Method.Parser, new[]{ "Name", "RequestTypeUrl", "RequestStreaming", "ResponseTypeUrl", "ResponseStreaming", "Options", "Syntax" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Mixin), global::Google.Protobuf.WellKnownTypes.Mixin.Parser, new[]{ "Name", "Root" }, null, null, null) + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Api), global::Google.Protobuf.WellKnownTypes.Api.Parser, new[]{ "Name", "Methods", "Options", "Version", "SourceContext", "Mixins", "Syntax" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Method), global::Google.Protobuf.WellKnownTypes.Method.Parser, new[]{ "Name", "RequestTypeUrl", "RequestStreaming", "ResponseTypeUrl", "ResponseStreaming", "Options", "Syntax" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Mixin), global::Google.Protobuf.WellKnownTypes.Mixin.Parser, new[]{ "Name", "Root" }, null, null, null, null) })); } #endregion @@ -52,37 +54,52 @@ static ApiReflection() { } #region Messages /// - /// Api is a light-weight descriptor for a protocol buffer service. + /// Api is a light-weight descriptor for an API Interface. + /// + /// Interfaces are also described as "protocol buffer services" in some contexts, + /// such as by the "service" keyword in a .proto file, but they are different + /// from API Services, which represent a concrete implementation of an interface + /// as opposed to simply a description of methods and bindings. They are also + /// sometimes simply referred to as "APIs" in other contexts, such as the name of + /// this message itself. See https://cloud.google.com/apis/design/glossary for + /// detailed terminology. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Api : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Api()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.WellKnownTypes.ApiReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Api() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Api(Api other) : this() { name_ = other.name_; methods_ = other.methods_.Clone(); options_ = other.options_.Clone(); version_ = other.version_; - SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null; + sourceContext_ = other.sourceContext_ != null ? other.sourceContext_.Clone() : null; mixins_ = other.mixins_.Clone(); syntax_ = other.syntax_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Api Clone() { return new Api(this); } @@ -91,9 +108,10 @@ public Api Clone() { public const int NameFieldNumber = 1; private string name_ = ""; /// - /// The fully qualified name of this api, including package name - /// followed by the api's simple name. + /// The fully qualified name of this interface, including package name + /// followed by the interface's simple name. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -107,8 +125,9 @@ public string Name { = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Method.Parser); private readonly pbc::RepeatedField methods_ = new pbc::RepeatedField(); /// - /// The methods of this api, in unspecified order. + /// The methods of this interface, in unspecified order. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Methods { get { return methods_; } } @@ -119,8 +138,9 @@ public string Name { = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.WellKnownTypes.Option.Parser); private readonly pbc::RepeatedField options_ = new pbc::RepeatedField(); /// - /// Any metadata attached to the API. + /// Any metadata attached to the interface. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Options { get { return options_; } } @@ -129,27 +149,27 @@ public string Name { public const int VersionFieldNumber = 4; private string version_ = ""; /// - /// A version string for this api. If specified, must have the form - /// `major-version.minor-version`, as in `1.10`. If the minor version - /// is omitted, it defaults to zero. If the entire version field is - /// empty, the major version is derived from the package name, as - /// outlined below. If the field is not empty, the version in the - /// package name will be verified to be consistent with what is - /// provided here. + /// A version string for this interface. If specified, must have the form + /// `major-version.minor-version`, as in `1.10`. If the minor version is + /// omitted, it defaults to zero. If the entire version field is empty, the + /// major version is derived from the package name, as outlined below. If the + /// field is not empty, the version in the package name will be verified to be + /// consistent with what is provided here. /// - /// The versioning schema uses [semantic - /// versioning](http://semver.org) where the major version number - /// indicates a breaking change and the minor version an additive, - /// non-breaking change. Both version numbers are signals to users - /// what to expect from different versions, and should be carefully - /// chosen based on the product plan. + /// The versioning schema uses [semantic + /// versioning](http://semver.org) where the major version number + /// indicates a breaking change and the minor version an additive, + /// non-breaking change. Both version numbers are signals to users + /// what to expect from different versions, and should be carefully + /// chosen based on the product plan. /// - /// The major version is also reflected in the package name of the - /// API, which must end in `v<major-version>`, as in - /// `google.feature.v1`. For major versions 0 and 1, the suffix can - /// be omitted. Zero major versions must only be used for - /// experimental, none-GA apis. + /// The major version is also reflected in the package name of the + /// interface, which must end in `v<major-version>`, as in + /// `google.feature.v1`. For major versions 0 and 1, the suffix can + /// be omitted. Zero major versions must only be used for + /// experimental, non-GA interfaces. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Version { get { return version_; } set { @@ -161,9 +181,10 @@ public string Version { public const int SourceContextFieldNumber = 5; private global::Google.Protobuf.WellKnownTypes.SourceContext sourceContext_; /// - /// Source context for the protocol buffer service represented by this - /// message. + /// Source context for the protocol buffer service represented by this + /// message. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.SourceContext SourceContext { get { return sourceContext_; } set { @@ -177,18 +198,20 @@ public string Version { = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.WellKnownTypes.Mixin.Parser); private readonly pbc::RepeatedField mixins_ = new pbc::RepeatedField(); /// - /// Included APIs. See [Mixin][]. + /// Included interfaces. See [Mixin][]. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Mixins { get { return mixins_; } } /// Field number for the "syntax" field. public const int SyntaxFieldNumber = 7; - private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = 0; + private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = global::Google.Protobuf.WellKnownTypes.Syntax.Proto2; /// - /// The source syntax of the service. + /// The source syntax of the service. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Syntax Syntax { get { return syntax_; } set { @@ -196,10 +219,12 @@ public string Version { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Api); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Api other) { if (ReferenceEquals(other, null)) { return false; @@ -214,9 +239,10 @@ public bool Equals(Api other) { if (!object.Equals(SourceContext, other.SourceContext)) return false; if(!mixins_.Equals(other.mixins_)) return false; if (Syntax != other.Syntax) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); @@ -225,14 +251,19 @@ public override int GetHashCode() { if (Version.Length != 0) hash ^= Version.GetHashCode(); if (sourceContext_ != null) hash ^= SourceContext.GetHashCode(); hash ^= mixins_.GetHashCode(); - if (Syntax != 0) hash ^= Syntax.GetHashCode(); + if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) hash ^= Syntax.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -249,12 +280,16 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteMessage(SourceContext); } mixins_.WriteTo(output, _repeated_mixins_codec); - if (Syntax != 0) { + if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) { output.WriteRawTag(56); output.WriteEnum((int) Syntax); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -269,12 +304,16 @@ public int CalculateSize() { size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceContext); } size += mixins_.CalculateSize(_repeated_mixins_codec); - if (Syntax != 0) { + if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Api other) { if (other == null) { return; @@ -289,22 +328,24 @@ public void MergeFrom(Api other) { } if (other.sourceContext_ != null) { if (sourceContext_ == null) { - sourceContext_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + SourceContext = new global::Google.Protobuf.WellKnownTypes.SourceContext(); } SourceContext.MergeFrom(other.SourceContext); } mixins_.Add(other.mixins_); - if (other.Syntax != 0) { + if (other.Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) { Syntax = other.Syntax; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Name = input.ReadString(); @@ -324,9 +365,9 @@ public void MergeFrom(pb::CodedInputStream input) { } case 42: { if (sourceContext_ == null) { - sourceContext_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + SourceContext = new global::Google.Protobuf.WellKnownTypes.SourceContext(); } - input.ReadMessage(sourceContext_); + input.ReadMessage(SourceContext); break; } case 50: { @@ -334,7 +375,7 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 56: { - syntax_ = (global::Google.Protobuf.WellKnownTypes.Syntax) input.ReadEnum(); + Syntax = (global::Google.Protobuf.WellKnownTypes.Syntax) input.ReadEnum(); break; } } @@ -344,27 +385,32 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Method represents a method of an api. + /// Method represents a method of an API interface. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Method : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Method()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.WellKnownTypes.ApiReflection.Descriptor.MessageTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Method() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Method(Method other) : this() { name_ = other.name_; requestTypeUrl_ = other.requestTypeUrl_; @@ -373,8 +419,10 @@ public Method(Method other) : this() { responseStreaming_ = other.responseStreaming_; options_ = other.options_.Clone(); syntax_ = other.syntax_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Method Clone() { return new Method(this); } @@ -383,8 +431,9 @@ public Method Clone() { public const int NameFieldNumber = 1; private string name_ = ""; /// - /// The simple name of this method. + /// The simple name of this method. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -396,8 +445,9 @@ public string Name { public const int RequestTypeUrlFieldNumber = 2; private string requestTypeUrl_ = ""; /// - /// A URL of the input message type. + /// A URL of the input message type. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string RequestTypeUrl { get { return requestTypeUrl_; } set { @@ -409,8 +459,9 @@ public string RequestTypeUrl { public const int RequestStreamingFieldNumber = 3; private bool requestStreaming_; /// - /// If true, the request is streamed. + /// If true, the request is streamed. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool RequestStreaming { get { return requestStreaming_; } set { @@ -422,8 +473,9 @@ public bool RequestStreaming { public const int ResponseTypeUrlFieldNumber = 4; private string responseTypeUrl_ = ""; /// - /// The URL of the output message type. + /// The URL of the output message type. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string ResponseTypeUrl { get { return responseTypeUrl_; } set { @@ -435,8 +487,9 @@ public string ResponseTypeUrl { public const int ResponseStreamingFieldNumber = 5; private bool responseStreaming_; /// - /// If true, the response is streamed. + /// If true, the response is streamed. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool ResponseStreaming { get { return responseStreaming_; } set { @@ -450,18 +503,20 @@ public bool ResponseStreaming { = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.WellKnownTypes.Option.Parser); private readonly pbc::RepeatedField options_ = new pbc::RepeatedField(); /// - /// Any metadata attached to the method. + /// Any metadata attached to the method. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Options { get { return options_; } } /// Field number for the "syntax" field. public const int SyntaxFieldNumber = 7; - private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = 0; + private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = global::Google.Protobuf.WellKnownTypes.Syntax.Proto2; /// - /// The source syntax of this method. + /// The source syntax of this method. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Syntax Syntax { get { return syntax_; } set { @@ -469,10 +524,12 @@ public bool ResponseStreaming { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Method); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Method other) { if (ReferenceEquals(other, null)) { return false; @@ -487,9 +544,10 @@ public bool Equals(Method other) { if (ResponseStreaming != other.ResponseStreaming) return false; if(!options_.Equals(other.options_)) return false; if (Syntax != other.Syntax) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); @@ -498,14 +556,19 @@ public override int GetHashCode() { if (ResponseTypeUrl.Length != 0) hash ^= ResponseTypeUrl.GetHashCode(); if (ResponseStreaming != false) hash ^= ResponseStreaming.GetHashCode(); hash ^= options_.GetHashCode(); - if (Syntax != 0) hash ^= Syntax.GetHashCode(); + if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) hash ^= Syntax.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -528,12 +591,16 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteBool(ResponseStreaming); } options_.WriteTo(output, _repeated_options_codec); - if (Syntax != 0) { + if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) { output.WriteRawTag(56); output.WriteEnum((int) Syntax); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -552,12 +619,16 @@ public int CalculateSize() { size += 1 + 1; } size += options_.CalculateSize(_repeated_options_codec); - if (Syntax != 0) { + if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Method other) { if (other == null) { return; @@ -578,17 +649,19 @@ public void MergeFrom(Method other) { ResponseStreaming = other.ResponseStreaming; } options_.Add(other.options_); - if (other.Syntax != 0) { + if (other.Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) { Syntax = other.Syntax; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Name = input.ReadString(); @@ -615,7 +688,7 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 56: { - syntax_ = (global::Google.Protobuf.WellKnownTypes.Syntax) input.ReadEnum(); + Syntax = (global::Google.Protobuf.WellKnownTypes.Syntax) input.ReadEnum(); break; } } @@ -625,108 +698,116 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Declares an API to be included in this API. The including API must - /// redeclare all the methods from the included API, but documentation - /// and options are inherited as follows: + /// Declares an API Interface to be included in this interface. The including + /// interface must redeclare all the methods from the included interface, but + /// documentation and options are inherited as follows: /// - /// - If after comment and whitespace stripping, the documentation - /// string of the redeclared method is empty, it will be inherited - /// from the original method. + /// - If after comment and whitespace stripping, the documentation + /// string of the redeclared method is empty, it will be inherited + /// from the original method. /// - /// - Each annotation belonging to the service config (http, - /// visibility) which is not set in the redeclared method will be - /// inherited. + /// - Each annotation belonging to the service config (http, + /// visibility) which is not set in the redeclared method will be + /// inherited. /// - /// - If an http annotation is inherited, the path pattern will be - /// modified as follows. Any version prefix will be replaced by the - /// version of the including API plus the [root][] path if specified. + /// - If an http annotation is inherited, the path pattern will be + /// modified as follows. Any version prefix will be replaced by the + /// version of the including interface plus the [root][] path if + /// specified. /// - /// Example of a simple mixin: + /// Example of a simple mixin: /// - /// package google.acl.v1; - /// service AccessControl { - /// // Get the underlying ACL object. - /// rpc GetAcl(GetAclRequest) returns (Acl) { - /// option (google.api.http).get = "/v1/{resource=**}:getAcl"; - /// } - /// } + /// package google.acl.v1; + /// service AccessControl { + /// // Get the underlying ACL object. + /// rpc GetAcl(GetAclRequest) returns (Acl) { + /// option (google.api.http).get = "/v1/{resource=**}:getAcl"; + /// } + /// } /// - /// package google.storage.v2; - /// service Storage { - /// rpc GetAcl(GetAclRequest) returns (Acl); + /// package google.storage.v2; + /// service Storage { + /// rpc GetAcl(GetAclRequest) returns (Acl); /// - /// // Get a data record. - /// rpc GetData(GetDataRequest) returns (Data) { - /// option (google.api.http).get = "/v2/{resource=**}"; - /// } - /// } + /// // Get a data record. + /// rpc GetData(GetDataRequest) returns (Data) { + /// option (google.api.http).get = "/v2/{resource=**}"; + /// } + /// } /// - /// Example of a mixin configuration: + /// Example of a mixin configuration: /// - /// apis: - /// - name: google.storage.v2.Storage - /// mixins: - /// - name: google.acl.v1.AccessControl + /// apis: + /// - name: google.storage.v2.Storage + /// mixins: + /// - name: google.acl.v1.AccessControl /// - /// The mixin construct implies that all methods in `AccessControl` are - /// also declared with same name and request/response types in - /// `Storage`. A documentation generator or annotation processor will - /// see the effective `Storage.GetAcl` method after inherting - /// documentation and annotations as follows: + /// The mixin construct implies that all methods in `AccessControl` are + /// also declared with same name and request/response types in + /// `Storage`. A documentation generator or annotation processor will + /// see the effective `Storage.GetAcl` method after inherting + /// documentation and annotations as follows: /// - /// service Storage { - /// // Get the underlying ACL object. - /// rpc GetAcl(GetAclRequest) returns (Acl) { - /// option (google.api.http).get = "/v2/{resource=**}:getAcl"; - /// } - /// ... - /// } + /// service Storage { + /// // Get the underlying ACL object. + /// rpc GetAcl(GetAclRequest) returns (Acl) { + /// option (google.api.http).get = "/v2/{resource=**}:getAcl"; + /// } + /// ... + /// } /// - /// Note how the version in the path pattern changed from `v1` to `v2`. + /// Note how the version in the path pattern changed from `v1` to `v2`. /// - /// If the `root` field in the mixin is specified, it should be a - /// relative path under which inherited HTTP paths are placed. Example: + /// If the `root` field in the mixin is specified, it should be a + /// relative path under which inherited HTTP paths are placed. Example: /// - /// apis: - /// - name: google.storage.v2.Storage - /// mixins: - /// - name: google.acl.v1.AccessControl - /// root: acls + /// apis: + /// - name: google.storage.v2.Storage + /// mixins: + /// - name: google.acl.v1.AccessControl + /// root: acls /// - /// This implies the following inherited HTTP annotation: + /// This implies the following inherited HTTP annotation: /// - /// service Storage { - /// // Get the underlying ACL object. - /// rpc GetAcl(GetAclRequest) returns (Acl) { - /// option (google.api.http).get = "/v2/acls/{resource=**}:getAcl"; - /// } - /// ... - /// } + /// service Storage { + /// // Get the underlying ACL object. + /// rpc GetAcl(GetAclRequest) returns (Acl) { + /// option (google.api.http).get = "/v2/acls/{resource=**}:getAcl"; + /// } + /// ... + /// } /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Mixin : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Mixin()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.WellKnownTypes.ApiReflection.Descriptor.MessageTypes[2]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Mixin() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Mixin(Mixin other) : this() { name_ = other.name_; root_ = other.root_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Mixin Clone() { return new Mixin(this); } @@ -735,8 +816,9 @@ public Mixin Clone() { public const int NameFieldNumber = 1; private string name_ = ""; /// - /// The fully qualified name of the API which is included. + /// The fully qualified name of the interface which is included. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -748,9 +830,10 @@ public string Name { public const int RootFieldNumber = 2; private string root_ = ""; /// - /// If non-empty specifies a path under which inherited HTTP paths - /// are rooted. + /// If non-empty specifies a path under which inherited HTTP paths + /// are rooted. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Root { get { return root_; } set { @@ -758,10 +841,12 @@ public string Root { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Mixin); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Mixin other) { if (ReferenceEquals(other, null)) { return false; @@ -771,20 +856,26 @@ public bool Equals(Mixin other) { } if (Name != other.Name) return false; if (Root != other.Root) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); if (Root.Length != 0) hash ^= Root.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -794,8 +885,12 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(18); output.WriteString(Root); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -804,9 +899,13 @@ public int CalculateSize() { if (Root.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Root); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Mixin other) { if (other == null) { return; @@ -817,14 +916,16 @@ public void MergeFrom(Mixin other) { if (other.Root.Length != 0) { Root = other.Root; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Name = input.ReadString(); diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs index f17358f4b383..7a6f50190e1a 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs @@ -1,5 +1,7 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/duration.proto +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/duration.proto +// #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -10,7 +12,6 @@ namespace Google.Protobuf.WellKnownTypes { /// Holder for reflection information generated from google/protobuf/duration.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class DurationReflection { #region Descriptor @@ -26,13 +27,13 @@ static DurationReflection() { "Ch5nb29nbGUvcHJvdG9idWYvZHVyYXRpb24ucHJvdG8SD2dvb2dsZS5wcm90", "b2J1ZiIqCghEdXJhdGlvbhIPCgdzZWNvbmRzGAEgASgDEg0KBW5hbm9zGAIg", "ASgFQnwKE2NvbS5nb29nbGUucHJvdG9idWZCDUR1cmF0aW9uUHJvdG9QAVoq", - "Z2l0aHViLmNvbS9nb2xhbmcvcHJvdG9idWYvcHR5cGVzL2R1cmF0aW9uoAEB", + "Z2l0aHViLmNvbS9nb2xhbmcvcHJvdG9idWYvcHR5cGVzL2R1cmF0aW9u+AEB", "ogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90", "bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Duration), global::Google.Protobuf.WellKnownTypes.Duration.Parser, new[]{ "Seconds", "Nanos" }, null, null, null) + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Duration), global::Google.Protobuf.WellKnownTypes.Duration.Parser, new[]{ "Seconds", "Nanos" }, null, null, null, null) })); } #endregion @@ -40,71 +41,96 @@ static DurationReflection() { } #region Messages /// - /// A Duration represents a signed, fixed-length span of time represented - /// as a count of seconds and fractions of seconds at nanosecond - /// resolution. It is independent of any calendar and concepts like "day" - /// or "month". It is related to Timestamp in that the difference between - /// two Timestamp values is a Duration and it can be added or subtracted - /// from a Timestamp. Range is approximately +-10,000 years. + /// A Duration represents a signed, fixed-length span of time represented + /// as a count of seconds and fractions of seconds at nanosecond + /// resolution. It is independent of any calendar and concepts like "day" + /// or "month". It is related to Timestamp in that the difference between + /// two Timestamp values is a Duration and it can be added or subtracted + /// from a Timestamp. Range is approximately +-10,000 years. /// - /// Example 1: Compute Duration from two Timestamps in pseudo code. + /// # Examples /// - /// Timestamp start = ...; - /// Timestamp end = ...; - /// Duration duration = ...; + /// Example 1: Compute Duration from two Timestamps in pseudo code. /// - /// duration.seconds = end.seconds - start.seconds; - /// duration.nanos = end.nanos - start.nanos; + /// Timestamp start = ...; + /// Timestamp end = ...; + /// Duration duration = ...; /// - /// if (duration.seconds < 0 && duration.nanos > 0) { - /// duration.seconds += 1; - /// duration.nanos -= 1000000000; - /// } else if (durations.seconds > 0 && duration.nanos < 0) { - /// duration.seconds -= 1; - /// duration.nanos += 1000000000; - /// } + /// duration.seconds = end.seconds - start.seconds; + /// duration.nanos = end.nanos - start.nanos; /// - /// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. + /// if (duration.seconds < 0 && duration.nanos > 0) { + /// duration.seconds += 1; + /// duration.nanos -= 1000000000; + /// } else if (durations.seconds > 0 && duration.nanos < 0) { + /// duration.seconds -= 1; + /// duration.nanos += 1000000000; + /// } /// - /// Timestamp start = ...; - /// Duration duration = ...; - /// Timestamp end = ...; + /// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. /// - /// end.seconds = start.seconds + duration.seconds; - /// end.nanos = start.nanos + duration.nanos; + /// Timestamp start = ...; + /// Duration duration = ...; + /// Timestamp end = ...; /// - /// if (end.nanos < 0) { - /// end.seconds -= 1; - /// end.nanos += 1000000000; - /// } else if (end.nanos >= 1000000000) { - /// end.seconds += 1; - /// end.nanos -= 1000000000; - /// } + /// end.seconds = start.seconds + duration.seconds; + /// end.nanos = start.nanos + duration.nanos; + /// + /// if (end.nanos < 0) { + /// end.seconds -= 1; + /// end.nanos += 1000000000; + /// } else if (end.nanos >= 1000000000) { + /// end.seconds += 1; + /// end.nanos -= 1000000000; + /// } + /// + /// Example 3: Compute Duration from datetime.timedelta in Python. + /// + /// td = datetime.timedelta(days=3, minutes=10) + /// duration = Duration() + /// duration.FromTimedelta(td) + /// + /// # JSON Mapping + /// + /// In JSON format, the Duration type is encoded as a string rather than an + /// object, where the string ends in the suffix "s" (indicating seconds) and + /// is preceded by the number of seconds, with nanoseconds expressed as + /// fractional seconds. For example, 3 seconds with 0 nanoseconds should be + /// encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should + /// be expressed in JSON format as "3.000000001s", and 3 seconds and 1 + /// microsecond should be expressed in JSON format as "3.000001s". /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Duration : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Duration()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.WellKnownTypes.DurationReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Duration() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Duration(Duration other) : this() { seconds_ = other.seconds_; nanos_ = other.nanos_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Duration Clone() { return new Duration(this); } @@ -113,9 +139,11 @@ public Duration Clone() { public const int SecondsFieldNumber = 1; private long seconds_; /// - /// Signed seconds of the span of time. Must be from -315,576,000,000 - /// to +315,576,000,000 inclusive. + /// Signed seconds of the span of time. Must be from -315,576,000,000 + /// to +315,576,000,000 inclusive. Note: these bounds are computed from: + /// 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public long Seconds { get { return seconds_; } set { @@ -127,13 +155,14 @@ public long Seconds { public const int NanosFieldNumber = 2; private int nanos_; /// - /// Signed fractions of a second at nanosecond resolution of the span - /// of time. Durations less than one second are represented with a 0 - /// `seconds` field and a positive or negative `nanos` field. For durations - /// of one second or more, a non-zero value for the `nanos` field must be - /// of the same sign as the `seconds` field. Must be from -999,999,999 - /// to +999,999,999 inclusive. + /// Signed fractions of a second at nanosecond resolution of the span + /// of time. Durations less than one second are represented with a 0 + /// `seconds` field and a positive or negative `nanos` field. For durations + /// of one second or more, a non-zero value for the `nanos` field must be + /// of the same sign as the `seconds` field. Must be from -999,999,999 + /// to +999,999,999 inclusive. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Nanos { get { return nanos_; } set { @@ -141,10 +170,12 @@ public int Nanos { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Duration); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Duration other) { if (ReferenceEquals(other, null)) { return false; @@ -154,20 +185,26 @@ public bool Equals(Duration other) { } if (Seconds != other.Seconds) return false; if (Nanos != other.Nanos) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Seconds != 0L) hash ^= Seconds.GetHashCode(); if (Nanos != 0) hash ^= Nanos.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Seconds != 0L) { output.WriteRawTag(8); @@ -177,8 +214,12 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(16); output.WriteInt32(Nanos); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Seconds != 0L) { @@ -187,9 +228,13 @@ public int CalculateSize() { if (Nanos != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(Nanos); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Duration other) { if (other == null) { return; @@ -200,14 +245,16 @@ public void MergeFrom(Duration other) { if (other.Nanos != 0) { Nanos = other.Nanos; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { Seconds = input.ReadInt64(); diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs index f164bfd19d2e..9a468fc1988c 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs @@ -156,7 +156,7 @@ public static Duration FromTimeSpan(TimeSpan timeSpan) return Normalize(lhs.Seconds - rhs.Seconds, lhs.Nanos - rhs.Nanos); } } - + /// /// Creates a duration with the normalized values from the given number of seconds and /// nanoseconds, conforming with the description in the proto file. diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs index e08ea2400b9d..fa435cd23edf 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs @@ -1,5 +1,7 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/empty.proto +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/empty.proto +// #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -10,7 +12,6 @@ namespace Google.Protobuf.WellKnownTypes { /// Holder for reflection information generated from google/protobuf/empty.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class EmptyReflection { #region Descriptor @@ -24,14 +25,14 @@ static EmptyReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "Chtnb29nbGUvcHJvdG9idWYvZW1wdHkucHJvdG8SD2dvb2dsZS5wcm90b2J1", - "ZiIHCgVFbXB0eUJ5ChNjb20uZ29vZ2xlLnByb3RvYnVmQgpFbXB0eVByb3Rv", - "UAFaJ2dpdGh1Yi5jb20vZ29sYW5nL3Byb3RvYnVmL3B0eXBlcy9lbXB0eaAB", - "AfgBAaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IG", - "cHJvdG8z")); + "ZiIHCgVFbXB0eUJ2ChNjb20uZ29vZ2xlLnByb3RvYnVmQgpFbXB0eVByb3Rv", + "UAFaJ2dpdGh1Yi5jb20vZ29sYW5nL3Byb3RvYnVmL3B0eXBlcy9lbXB0efgB", + "AaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJv", + "dG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Empty), global::Google.Protobuf.WellKnownTypes.Empty.Parser, null, null, null, null) + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Empty), global::Google.Protobuf.WellKnownTypes.Empty.Parser, null, null, null, null, null) })); } #endregion @@ -39,46 +40,55 @@ static EmptyReflection() { } #region Messages /// - /// A generic empty message that you can re-use to avoid defining duplicated - /// empty messages in your APIs. A typical example is to use it as the request - /// or the response type of an API method. For instance: + /// A generic empty message that you can re-use to avoid defining duplicated + /// empty messages in your APIs. A typical example is to use it as the request + /// or the response type of an API method. For instance: /// - /// service Foo { - /// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); - /// } + /// service Foo { + /// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); + /// } /// - /// The JSON representation for `Empty` is empty JSON object `{}`. + /// The JSON representation for `Empty` is empty JSON object `{}`. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Empty : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Empty()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.WellKnownTypes.EmptyReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Empty() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Empty(Empty other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Empty Clone() { return new Empty(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Empty); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Empty other) { if (ReferenceEquals(other, null)) { return false; @@ -86,38 +96,54 @@ public bool Equals(Empty other) { if (ReferenceEquals(other, this)) { return true; } - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Empty other) { if (other == null) { return; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; } } diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs index 6f0a64d6aee6..0bbf31397162 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs @@ -1,5 +1,7 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/field_mask.proto +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/field_mask.proto +// #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -10,7 +12,6 @@ namespace Google.Protobuf.WellKnownTypes { /// Holder for reflection information generated from google/protobuf/field_mask.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class FieldMaskReflection { #region Descriptor @@ -24,13 +25,15 @@ static FieldMaskReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "CiBnb29nbGUvcHJvdG9idWYvZmllbGRfbWFzay5wcm90bxIPZ29vZ2xlLnBy", - "b3RvYnVmIhoKCUZpZWxkTWFzaxINCgVwYXRocxgBIAMoCUJRChNjb20uZ29v", - "Z2xlLnByb3RvYnVmQg5GaWVsZE1hc2tQcm90b1ABoAEBogIDR1BCqgIeR29v", - "Z2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM=")); + "b3RvYnVmIhoKCUZpZWxkTWFzaxINCgVwYXRocxgBIAMoCUKMAQoTY29tLmdv", + "b2dsZS5wcm90b2J1ZkIORmllbGRNYXNrUHJvdG9QAVo5Z29vZ2xlLmdvbGFu", + "Zy5vcmcvZ2VucHJvdG8vcHJvdG9idWYvZmllbGRfbWFzaztmaWVsZF9tYXNr", + "+AEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZw", + "cm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.FieldMask), global::Google.Protobuf.WellKnownTypes.FieldMask.Parser, new[]{ "Paths" }, null, null, null) + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.FieldMask), global::Google.Protobuf.WellKnownTypes.FieldMask.Parser, new[]{ "Paths" }, null, null, null, null) })); } #endregion @@ -38,178 +41,235 @@ static FieldMaskReflection() { } #region Messages /// - /// `FieldMask` represents a set of symbolic field paths, for example: - /// - /// paths: "f.a" - /// paths: "f.b.d" - /// - /// Here `f` represents a field in some root message, `a` and `b` - /// fields in the message found in `f`, and `d` a field found in the - /// message in `f.b`. - /// - /// Field masks are used to specify a subset of fields that should be - /// returned by a get operation or modified by an update operation. - /// Field masks also have a custom JSON encoding (see below). - /// - /// # Field Masks in Projections - /// - /// When used in the context of a projection, a response message or - /// sub-message is filtered by the API to only contain those fields as - /// specified in the mask. For example, if the mask in the previous - /// example is applied to a response message as follows: - /// - /// f { - /// a : 22 - /// b { - /// d : 1 - /// x : 2 - /// } - /// y : 13 - /// } - /// z: 8 - /// - /// The result will not contain specific values for fields x,y and z - /// (their value will be set to the default, and omitted in proto text - /// output): - /// - /// f { - /// a : 22 - /// b { - /// d : 1 - /// } - /// } - /// - /// A repeated field is not allowed except at the last position of a - /// field mask. - /// - /// If a FieldMask object is not present in a get operation, the - /// operation applies to all fields (as if a FieldMask of all fields - /// had been specified). - /// - /// Note that a field mask does not necessarily apply to the - /// top-level response message. In case of a REST get operation, the - /// field mask applies directly to the response, but in case of a REST - /// list operation, the mask instead applies to each individual message - /// in the returned resource list. In case of a REST custom method, - /// other definitions may be used. Where the mask applies will be - /// clearly documented together with its declaration in the API. In - /// any case, the effect on the returned resource/resources is required - /// behavior for APIs. - /// - /// # Field Masks in Update Operations - /// - /// A field mask in update operations specifies which fields of the - /// targeted resource are going to be updated. The API is required - /// to only change the values of the fields as specified in the mask - /// and leave the others untouched. If a resource is passed in to - /// describe the updated values, the API ignores the values of all - /// fields not covered by the mask. - /// - /// In order to reset a field's value to the default, the field must - /// be in the mask and set to the default value in the provided resource. - /// Hence, in order to reset all fields of a resource, provide a default - /// instance of the resource and set all fields in the mask, or do - /// not provide a mask as described below. - /// - /// If a field mask is not present on update, the operation applies to - /// all fields (as if a field mask of all fields has been specified). - /// Note that in the presence of schema evolution, this may mean that - /// fields the client does not know and has therefore not filled into - /// the request will be reset to their default. If this is unwanted - /// behavior, a specific service may require a client to always specify - /// a field mask, producing an error if not. - /// - /// As with get operations, the location of the resource which - /// describes the updated values in the request message depends on the - /// operation kind. In any case, the effect of the field mask is - /// required to be honored by the API. - /// - /// ## Considerations for HTTP REST - /// - /// The HTTP kind of an update operation which uses a field mask must - /// be set to PATCH instead of PUT in order to satisfy HTTP semantics - /// (PUT must only be used for full updates). - /// - /// # JSON Encoding of Field Masks - /// - /// In JSON, a field mask is encoded as a single string where paths are - /// separated by a comma. Fields name in each path are converted - /// to/from lower-camel naming conventions. - /// - /// As an example, consider the following message declarations: - /// - /// message Profile { - /// User user = 1; - /// Photo photo = 2; - /// } - /// message User { - /// string display_name = 1; - /// string address = 2; - /// } - /// - /// In proto a field mask for `Profile` may look as such: - /// - /// mask { - /// paths: "user.display_name" - /// paths: "photo" - /// } - /// - /// In JSON, the same mask is represented as below: - /// - /// { - /// mask: "user.displayName,photo" - /// } - /// - /// # Field Masks and Oneof Fields - /// - /// Field masks treat fields in oneofs just as regular fields. Consider the - /// following message: - /// - /// message SampleMessage { - /// oneof test_oneof { - /// string name = 4; - /// SubMessage sub_message = 9; - /// } - /// } - /// - /// The field mask can be: - /// - /// mask { - /// paths: "name" - /// } - /// - /// Or: - /// - /// mask { - /// paths: "sub_message" - /// } - /// - /// Note that oneof type names ("test_oneof" in this case) cannot be used in - /// paths. + /// `FieldMask` represents a set of symbolic field paths, for example: + /// + /// paths: "f.a" + /// paths: "f.b.d" + /// + /// Here `f` represents a field in some root message, `a` and `b` + /// fields in the message found in `f`, and `d` a field found in the + /// message in `f.b`. + /// + /// Field masks are used to specify a subset of fields that should be + /// returned by a get operation or modified by an update operation. + /// Field masks also have a custom JSON encoding (see below). + /// + /// # Field Masks in Projections + /// + /// When used in the context of a projection, a response message or + /// sub-message is filtered by the API to only contain those fields as + /// specified in the mask. For example, if the mask in the previous + /// example is applied to a response message as follows: + /// + /// f { + /// a : 22 + /// b { + /// d : 1 + /// x : 2 + /// } + /// y : 13 + /// } + /// z: 8 + /// + /// The result will not contain specific values for fields x,y and z + /// (their value will be set to the default, and omitted in proto text + /// output): + /// + /// f { + /// a : 22 + /// b { + /// d : 1 + /// } + /// } + /// + /// A repeated field is not allowed except at the last position of a + /// paths string. + /// + /// If a FieldMask object is not present in a get operation, the + /// operation applies to all fields (as if a FieldMask of all fields + /// had been specified). + /// + /// Note that a field mask does not necessarily apply to the + /// top-level response message. In case of a REST get operation, the + /// field mask applies directly to the response, but in case of a REST + /// list operation, the mask instead applies to each individual message + /// in the returned resource list. In case of a REST custom method, + /// other definitions may be used. Where the mask applies will be + /// clearly documented together with its declaration in the API. In + /// any case, the effect on the returned resource/resources is required + /// behavior for APIs. + /// + /// # Field Masks in Update Operations + /// + /// A field mask in update operations specifies which fields of the + /// targeted resource are going to be updated. The API is required + /// to only change the values of the fields as specified in the mask + /// and leave the others untouched. If a resource is passed in to + /// describe the updated values, the API ignores the values of all + /// fields not covered by the mask. + /// + /// If a repeated field is specified for an update operation, new values will + /// be appended to the existing repeated field in the target resource. Note that + /// a repeated field is only allowed in the last position of a `paths` string. + /// + /// If a sub-message is specified in the last position of the field mask for an + /// update operation, then new value will be merged into the existing sub-message + /// in the target resource. + /// + /// For example, given the target message: + /// + /// f { + /// b { + /// d: 1 + /// x: 2 + /// } + /// c: [1] + /// } + /// + /// And an update message: + /// + /// f { + /// b { + /// d: 10 + /// } + /// c: [2] + /// } + /// + /// then if the field mask is: + /// + /// paths: ["f.b", "f.c"] + /// + /// then the result will be: + /// + /// f { + /// b { + /// d: 10 + /// x: 2 + /// } + /// c: [1, 2] + /// } + /// + /// An implementation may provide options to override this default behavior for + /// repeated and message fields. + /// + /// In order to reset a field's value to the default, the field must + /// be in the mask and set to the default value in the provided resource. + /// Hence, in order to reset all fields of a resource, provide a default + /// instance of the resource and set all fields in the mask, or do + /// not provide a mask as described below. + /// + /// If a field mask is not present on update, the operation applies to + /// all fields (as if a field mask of all fields has been specified). + /// Note that in the presence of schema evolution, this may mean that + /// fields the client does not know and has therefore not filled into + /// the request will be reset to their default. If this is unwanted + /// behavior, a specific service may require a client to always specify + /// a field mask, producing an error if not. + /// + /// As with get operations, the location of the resource which + /// describes the updated values in the request message depends on the + /// operation kind. In any case, the effect of the field mask is + /// required to be honored by the API. + /// + /// ## Considerations for HTTP REST + /// + /// The HTTP kind of an update operation which uses a field mask must + /// be set to PATCH instead of PUT in order to satisfy HTTP semantics + /// (PUT must only be used for full updates). + /// + /// # JSON Encoding of Field Masks + /// + /// In JSON, a field mask is encoded as a single string where paths are + /// separated by a comma. Fields name in each path are converted + /// to/from lower-camel naming conventions. + /// + /// As an example, consider the following message declarations: + /// + /// message Profile { + /// User user = 1; + /// Photo photo = 2; + /// } + /// message User { + /// string display_name = 1; + /// string address = 2; + /// } + /// + /// In proto a field mask for `Profile` may look as such: + /// + /// mask { + /// paths: "user.display_name" + /// paths: "photo" + /// } + /// + /// In JSON, the same mask is represented as below: + /// + /// { + /// mask: "user.displayName,photo" + /// } + /// + /// # Field Masks and Oneof Fields + /// + /// Field masks treat fields in oneofs just as regular fields. Consider the + /// following message: + /// + /// message SampleMessage { + /// oneof test_oneof { + /// string name = 4; + /// SubMessage sub_message = 9; + /// } + /// } + /// + /// The field mask can be: + /// + /// mask { + /// paths: "name" + /// } + /// + /// Or: + /// + /// mask { + /// paths: "sub_message" + /// } + /// + /// Note that oneof type names ("test_oneof" in this case) cannot be used in + /// paths. + /// + /// ## Field Mask Verification + /// + /// The implementation of any API method which has a FieldMask type field in the + /// request should verify the included field paths, and return an + /// `INVALID_ARGUMENT` error if any path is duplicated or unmappable. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class FieldMask : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FieldMask()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.WellKnownTypes.FieldMaskReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FieldMask() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FieldMask(FieldMask other) : this() { paths_ = other.paths_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FieldMask Clone() { return new FieldMask(this); } @@ -220,16 +280,19 @@ public FieldMask Clone() { = pb::FieldCodec.ForString(10); private readonly pbc::RepeatedField paths_ = new pbc::RepeatedField(); /// - /// The set of field mask paths. + /// The set of field mask paths. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Paths { get { return paths_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as FieldMask); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(FieldMask other) { if (ReferenceEquals(other, null)) { return false; @@ -238,42 +301,58 @@ public bool Equals(FieldMask other) { return true; } if(!paths_.Equals(other.paths_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= paths_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { paths_.WriteTo(output, _repeated_paths_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += paths_.CalculateSize(_repeated_paths_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(FieldMask other) { if (other == null) { return; } paths_.Add(other.paths_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { paths_.AddEntriesFrom(input, _repeated_paths_codec); diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs index 4bd62cf3d436..91d2ee9094ab 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs @@ -35,15 +35,18 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; +using Google.Protobuf.Reflection; namespace Google.Protobuf.WellKnownTypes { // Manually-written partial class for the FieldMask well-known type. public partial class FieldMask : ICustomDiagnosticMessage { + private const char FIELD_PATH_SEPARATOR = ','; + private const char FIELD_SEPARATOR_REGEX = '.'; + /// - /// Converts a timestamp specified in seconds/nanoseconds to a string. + /// Converts a field mask specified by paths to a string. /// /// /// If the value is a normalized duration in the range described in field_mask.proto, @@ -52,14 +55,19 @@ public partial class FieldMask : ICustomDiagnosticMessage /// /// Paths in the field mask /// Determines the handling of non-normalized values - /// The represented duration is invalid, and is false. + /// The represented field mask is invalid, and is false. internal static string ToJson(IList paths, bool diagnosticOnly) { - var firstInvalid = paths.FirstOrDefault(p => !ValidatePath(p)); + var firstInvalid = paths.FirstOrDefault(p => !IsPathValid(p)); if (firstInvalid == null) { var writer = new StringWriter(); - JsonFormatter.WriteString(writer, string.Join(",", paths.Select(JsonFormatter.ToCamelCase))); +#if NET35 + var query = paths.Select(JsonFormatter.ToJsonName); + JsonFormatter.WriteString(writer, string.Join(",", query.ToArray())); +#else + JsonFormatter.WriteString(writer, string.Join(",", paths.Select(JsonFormatter.ToJsonName))); +#endif return writer.ToString(); } else @@ -80,10 +88,102 @@ internal static string ToJson(IList paths, bool diagnosticOnly) } /// - /// Camel-case converter with added strictness for field mask formatting. + /// Returns a string representation of this for diagnostic purposes. + /// + /// + /// Normally the returned value will be a JSON string value (including leading and trailing quotes) but + /// when the value is non-normalized or out of range, a JSON object representation will be returned + /// instead, including a warning. This is to avoid exceptions being thrown when trying to + /// diagnose problems - the regular JSON formatter will still throw an exception for non-normalized + /// values. + /// + /// A string representation of this value. + public string ToDiagnosticString() + { + return ToJson(Paths, true); + } + + /// + /// Parses from a string to a FieldMask. + /// + public static FieldMask FromString(string value) + { + return FromStringEnumerable(new List(value.Split(FIELD_PATH_SEPARATOR))); + } + + /// + /// Parses from a string to a FieldMask and validates all field paths. + /// + /// The type to validate the field paths against. + public static FieldMask FromString(string value) where T : IMessage + { + return FromStringEnumerable(new List(value.Split(FIELD_PATH_SEPARATOR))); + } + + /// + /// Constructs a FieldMask for a list of field paths in a certain type. + /// + /// The type to validate the field paths against. + public static FieldMask FromStringEnumerable(IEnumerable paths) where T : IMessage + { + var mask = new FieldMask(); + foreach (var path in paths) + { + if (path.Length == 0) + { + // Ignore empty field paths. + continue; + } + + if (typeof(T) != typeof(Empty) + && !IsValid(path)) + { + throw new InvalidProtocolBufferException(path + " is not a valid path for " + typeof(T)); + } + + mask.Paths.Add(path); + } + + return mask; + } + + /// + /// Constructs a FieldMask from the passed field numbers. + /// + /// The type to validate the field paths against. + public static FieldMask FromFieldNumbers(params int[] fieldNumbers) where T : IMessage + { + return FromFieldNumbers((IEnumerable)fieldNumbers); + } + + /// + /// Constructs a FieldMask from the passed field numbers. /// - /// The field mask is invalid for JSON representation - private static bool ValidatePath(string input) + /// The type to validate the field paths against. + public static FieldMask FromFieldNumbers(IEnumerable fieldNumbers) where T : IMessage + { + var descriptor = Activator.CreateInstance().Descriptor; + + var mask = new FieldMask(); + foreach (var fieldNumber in fieldNumbers) + { + var field = descriptor.FindFieldByNumber(fieldNumber); + if (field == null) + { + throw new ArgumentNullException($"{fieldNumber} is not a valid field number for {descriptor.Name}"); + } + + mask.Paths.Add(field.Name); + } + + return mask; + } + + /// + /// Checks whether the given path is valid for a field mask. + /// + /// true if the path is valid; false otherwise + private static bool IsPathValid(string input) { for (int i = 0; i < input.Length; i++) { @@ -105,19 +205,166 @@ private static bool ValidatePath(string input) } /// - /// Returns a string representation of this for diagnostic purposes. + /// Checks whether paths in a given fields mask are valid. /// - /// - /// Normally the returned value will be a JSON string value (including leading and trailing quotes) but - /// when the value is non-normalized or out of range, a JSON object representation will be returned - /// instead, including a warning. This is to avoid exceptions being thrown when trying to - /// diagnose problems - the regular JSON formatter will still throw an exception for non-normalized - /// values. - /// - /// A string representation of this value. - public string ToDiagnosticString() + /// The type to validate the field paths against. + public static bool IsValid(FieldMask fieldMask) where T : IMessage { - return ToJson(Paths, true); + var descriptor = Activator.CreateInstance().Descriptor; + + return IsValid(descriptor, fieldMask); + } + + /// + /// Checks whether paths in a given fields mask are valid. + /// + public static bool IsValid(MessageDescriptor descriptor, FieldMask fieldMask) + { + foreach (var path in fieldMask.Paths) + { + if (!IsValid(descriptor, path)) + { + return false; + } + } + + return true; + } + + /// + /// Checks whether a given field path is valid. + /// + /// The type to validate the field paths against. + public static bool IsValid(string path) where T : IMessage + { + var descriptor = Activator.CreateInstance().Descriptor; + + return IsValid(descriptor, path); + } + + /// + /// Checks whether paths in a given fields mask are valid. + /// + public static bool IsValid(MessageDescriptor descriptor, string path) + { + var parts = path.Split(FIELD_SEPARATOR_REGEX); + if (parts.Length == 0) + { + return false; + } + + foreach (var name in parts) + { + var field = descriptor?.FindFieldByName(name); + if (field == null) + { + return false; + } + + if (!field.IsRepeated + && field.FieldType == FieldType.Message) + { + descriptor = field.MessageType; + } + else + { + descriptor = null; + } + } + + return true; + } + + /// + /// Converts this FieldMask to its canonical form. In the canonical form of a + /// FieldMask, all field paths are sorted alphabetically and redundant field + /// paths are removed. + /// + public FieldMask Normalize() + { + return new FieldMaskTree(this).ToFieldMask(); + } + + /// + /// Creates a union of two or more FieldMasks. + /// + public FieldMask Union(params FieldMask[] otherMasks) + { + var maskTree = new FieldMaskTree(this); + foreach (var mask in otherMasks) + { + maskTree.MergeFromFieldMask(mask); + } + + return maskTree.ToFieldMask(); + } + + /// + /// Calculates the intersection of two FieldMasks. + /// + public FieldMask Intersection(FieldMask additionalMask) + { + var tree = new FieldMaskTree(this); + var result = new FieldMaskTree(); + foreach (var path in additionalMask.Paths) + { + tree.IntersectFieldPath(path, result); + } + + return result.ToFieldMask(); + } + + /// + /// Merges fields specified by this FieldMask from one message to another with the + /// specified merge options. + /// + public void Merge(IMessage source, IMessage destination, MergeOptions options) + { + new FieldMaskTree(this).Merge(source, destination, options); + } + + /// + /// Merges fields specified by this FieldMask from one message to another. + /// + public void Merge(IMessage source, IMessage destination) + { + Merge(source, destination, new MergeOptions()); + } + + /// + /// Options to customize merging behavior. + /// + public sealed class MergeOptions + { + /// + /// Whether to replace message fields(i.e., discard existing content in + /// destination message fields) when merging. + /// Default behavior is to merge the source message field into the + /// destination message field. + /// + public bool ReplaceMessageFields { get; set; } = false; + + /// + /// Whether to replace repeated fields (i.e., discard existing content in + /// destination repeated fields) when merging. + /// Default behavior is to append elements from source repeated field to the + /// destination repeated field. + /// + public bool ReplaceRepeatedFields { get; set; } = false; + + /// + /// Whether to replace primitive (non-repeated and non-message) fields in + /// destination message fields with the source primitive fields (i.e., if the + /// field is set in the source, the value is copied to the + /// destination; if the field is unset in the source, the field is cleared + /// from the destination) when merging. + /// + /// Default behavior is to always set the value of the source primitive + /// field to the destination primitive field, and if the source field is + /// unset, the default value of the source field is copied to the + /// destination. + /// + public bool ReplacePrimitiveFields { get; set; } = false; } } } diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs index a235ecefa6f4..d7076196e0fd 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs @@ -1,5 +1,7 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/source_context.proto +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/source_context.proto +// #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -10,7 +12,6 @@ namespace Google.Protobuf.WellKnownTypes { /// Holder for reflection information generated from google/protobuf/source_context.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class SourceContextReflection { #region Descriptor @@ -25,13 +26,14 @@ static SourceContextReflection() { string.Concat( "CiRnb29nbGUvcHJvdG9idWYvc291cmNlX2NvbnRleHQucHJvdG8SD2dvb2ds", "ZS5wcm90b2J1ZiIiCg1Tb3VyY2VDb250ZXh0EhEKCWZpbGVfbmFtZRgBIAEo", - "CUJVChNjb20uZ29vZ2xlLnByb3RvYnVmQhJTb3VyY2VDb250ZXh0UHJvdG9Q", - "AaABAaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IG", - "cHJvdG8z")); + "CUKVAQoTY29tLmdvb2dsZS5wcm90b2J1ZkISU291cmNlQ29udGV4dFByb3Rv", + "UAFaQWdvb2dsZS5nb2xhbmcub3JnL2dlbnByb3RvL3Byb3RvYnVmL3NvdXJj", + "ZV9jb250ZXh0O3NvdXJjZV9jb250ZXh0ogIDR1BCqgIeR29vZ2xlLlByb3Rv", + "YnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.SourceContext), global::Google.Protobuf.WellKnownTypes.SourceContext.Parser, new[]{ "FileName" }, null, null, null) + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.SourceContext), global::Google.Protobuf.WellKnownTypes.SourceContext.Parser, new[]{ "FileName" }, null, null, null, null) })); } #endregion @@ -39,32 +41,39 @@ static SourceContextReflection() { } #region Messages /// - /// `SourceContext` represents information about the source of a - /// protobuf element, like the file in which it is defined. + /// `SourceContext` represents information about the source of a + /// protobuf element, like the file in which it is defined. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class SourceContext : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SourceContext()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.WellKnownTypes.SourceContextReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public SourceContext() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public SourceContext(SourceContext other) : this() { fileName_ = other.fileName_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public SourceContext Clone() { return new SourceContext(this); } @@ -73,9 +82,10 @@ public SourceContext Clone() { public const int FileNameFieldNumber = 1; private string fileName_ = ""; /// - /// The path-qualified name of the .proto file that contained the associated - /// protobuf element. For example: `"google/protobuf/source.proto"`. + /// The path-qualified name of the .proto file that contained the associated + /// protobuf element. For example: `"google/protobuf/source_context.proto"`. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string FileName { get { return fileName_; } set { @@ -83,10 +93,12 @@ public string FileName { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as SourceContext); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(SourceContext other) { if (ReferenceEquals(other, null)) { return false; @@ -95,34 +107,48 @@ public bool Equals(SourceContext other) { return true; } if (FileName != other.FileName) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (FileName.Length != 0) hash ^= FileName.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (FileName.Length != 0) { output.WriteRawTag(10); output.WriteString(FileName); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (FileName.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(FileName); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(SourceContext other) { if (other == null) { return; @@ -130,14 +156,16 @@ public void MergeFrom(SourceContext other) { if (other.FileName.Length != 0) { FileName = other.FileName; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { FileName = input.ReadString(); diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs index edc8940db3fb..b1dbe239cc9c 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs @@ -1,5 +1,7 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/struct.proto +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/struct.proto +// #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -10,7 +12,6 @@ namespace Google.Protobuf.WellKnownTypes { /// Holder for reflection information generated from google/protobuf/struct.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class StructReflection { #region Descriptor @@ -36,14 +37,14 @@ static StructReflection() { "Lmdvb2dsZS5wcm90b2J1Zi5WYWx1ZSobCglOdWxsVmFsdWUSDgoKTlVMTF9W", "QUxVRRAAQoEBChNjb20uZ29vZ2xlLnByb3RvYnVmQgtTdHJ1Y3RQcm90b1AB", "WjFnaXRodWIuY29tL2dvbGFuZy9wcm90b2J1Zi9wdHlwZXMvc3RydWN0O3N0", - "cnVjdHBioAEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5", + "cnVjdHBi+AEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5", "cGVzYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.WellKnownTypes.NullValue), }, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Struct), global::Google.Protobuf.WellKnownTypes.Struct.Parser, new[]{ "Fields" }, null, null, new pbr::GeneratedClrTypeInfo[] { null, }), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Value), global::Google.Protobuf.WellKnownTypes.Value.Parser, new[]{ "NullValue", "NumberValue", "StringValue", "BoolValue", "StructValue", "ListValue" }, new[]{ "Kind" }, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.ListValue), global::Google.Protobuf.WellKnownTypes.ListValue.Parser, new[]{ "Values" }, null, null, null) + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.WellKnownTypes.NullValue), }, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Struct), global::Google.Protobuf.WellKnownTypes.Struct.Parser, new[]{ "Fields" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { null, }), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Value), global::Google.Protobuf.WellKnownTypes.Value.Parser, new[]{ "NullValue", "NumberValue", "StringValue", "BoolValue", "StructValue", "ListValue" }, new[]{ "Kind" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.ListValue), global::Google.Protobuf.WellKnownTypes.ListValue.Parser, new[]{ "Values" }, null, null, null, null) })); } #endregion @@ -51,14 +52,14 @@ static StructReflection() { } #region Enums /// - /// `NullValue` is a singleton enumeration to represent the null value for the - /// `Value` type union. + /// `NullValue` is a singleton enumeration to represent the null value for the + /// `Value` type union. /// - /// The JSON representation for `NullValue` is JSON `null`. + /// The JSON representation for `NullValue` is JSON `null`. /// public enum NullValue { /// - /// Null value. + /// Null value. /// [pbr::OriginalName("NULL_VALUE")] NullValue = 0, } @@ -67,38 +68,45 @@ public enum NullValue { #region Messages /// - /// `Struct` represents a structured data value, consisting of fields - /// which map to dynamically typed values. In some languages, `Struct` - /// might be supported by a native representation. For example, in - /// scripting languages like JS a struct is represented as an - /// object. The details of that representation are described together - /// with the proto support for the language. + /// `Struct` represents a structured data value, consisting of fields + /// which map to dynamically typed values. In some languages, `Struct` + /// might be supported by a native representation. For example, in + /// scripting languages like JS a struct is represented as an + /// object. The details of that representation are described together + /// with the proto support for the language. /// - /// The JSON representation for `Struct` is JSON object. + /// The JSON representation for `Struct` is JSON object. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Struct : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Struct()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.WellKnownTypes.StructReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Struct() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Struct(Struct other) : this() { fields_ = other.fields_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Struct Clone() { return new Struct(this); } @@ -106,19 +114,22 @@ public Struct Clone() { /// Field number for the "fields" field. public const int FieldsFieldNumber = 1; private static readonly pbc::MapField.Codec _map_fields_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Value.Parser), 10); + = new pbc::MapField.Codec(pb::FieldCodec.ForString(10, ""), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Value.Parser), 10); private readonly pbc::MapField fields_ = new pbc::MapField(); /// - /// Unordered map of dynamically typed values. + /// Unordered map of dynamically typed values. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::MapField Fields { get { return fields_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Struct); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Struct other) { if (ReferenceEquals(other, null)) { return false; @@ -127,42 +138,58 @@ public bool Equals(Struct other) { return true; } if (!Fields.Equals(other.Fields)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= Fields.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { fields_.WriteTo(output, _map_fields_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += fields_.CalculateSize(_map_fields_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Struct other) { if (other == null) { return; } fields_.Add(other.fields_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { fields_.AddEntriesFrom(input, _map_fields_codec); @@ -175,32 +202,37 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// `Value` represents a dynamically typed value which can be either - /// null, a number, a string, a boolean, a recursive struct value, or a - /// list of values. A producer of value is expected to set one of that - /// variants, absence of any variant indicates an error. + /// `Value` represents a dynamically typed value which can be either + /// null, a number, a string, a boolean, a recursive struct value, or a + /// list of values. A producer of value is expected to set one of that + /// variants, absence of any variant indicates an error. /// - /// The JSON representation for `Value` is JSON value. + /// The JSON representation for `Value` is JSON value. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Value : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Value()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.WellKnownTypes.StructReflection.Descriptor.MessageTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Value() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Value(Value other) : this() { switch (other.KindCase) { case KindOneofCase.NullValue: @@ -223,8 +255,10 @@ public Value(Value other) : this() { break; } + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Value Clone() { return new Value(this); } @@ -232,10 +266,11 @@ public Value Clone() { /// Field number for the "null_value" field. public const int NullValueFieldNumber = 1; /// - /// Represents a null value. + /// Represents a null value. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.NullValue NullValue { - get { return kindCase_ == KindOneofCase.NullValue ? (global::Google.Protobuf.WellKnownTypes.NullValue) kind_ : 0; } + get { return kindCase_ == KindOneofCase.NullValue ? (global::Google.Protobuf.WellKnownTypes.NullValue) kind_ : global::Google.Protobuf.WellKnownTypes.NullValue.NullValue; } set { kind_ = value; kindCase_ = KindOneofCase.NullValue; @@ -245,8 +280,9 @@ public Value Clone() { /// Field number for the "number_value" field. public const int NumberValueFieldNumber = 2; /// - /// Represents a double value. + /// Represents a double value. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public double NumberValue { get { return kindCase_ == KindOneofCase.NumberValue ? (double) kind_ : 0D; } set { @@ -258,8 +294,9 @@ public double NumberValue { /// Field number for the "string_value" field. public const int StringValueFieldNumber = 3; /// - /// Represents a string value. + /// Represents a string value. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string StringValue { get { return kindCase_ == KindOneofCase.StringValue ? (string) kind_ : ""; } set { @@ -271,8 +308,9 @@ public string StringValue { /// Field number for the "bool_value" field. public const int BoolValueFieldNumber = 4; /// - /// Represents a boolean value. + /// Represents a boolean value. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool BoolValue { get { return kindCase_ == KindOneofCase.BoolValue ? (bool) kind_ : false; } set { @@ -284,8 +322,9 @@ public bool BoolValue { /// Field number for the "struct_value" field. public const int StructValueFieldNumber = 5; /// - /// Represents a structured value. + /// Represents a structured value. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Struct StructValue { get { return kindCase_ == KindOneofCase.StructValue ? (global::Google.Protobuf.WellKnownTypes.Struct) kind_ : null; } set { @@ -297,8 +336,9 @@ public bool BoolValue { /// Field number for the "list_value" field. public const int ListValueFieldNumber = 6; /// - /// Represents a repeated `Value`. + /// Represents a repeated `Value`. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.ListValue ListValue { get { return kindCase_ == KindOneofCase.ListValue ? (global::Google.Protobuf.WellKnownTypes.ListValue) kind_ : null; } set { @@ -319,19 +359,23 @@ public enum KindOneofCase { ListValue = 6, } private KindOneofCase kindCase_ = KindOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public KindOneofCase KindCase { get { return kindCase_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void ClearKind() { kindCase_ = KindOneofCase.None; kind_ = null; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Value); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Value other) { if (ReferenceEquals(other, null)) { return false; @@ -340,31 +384,37 @@ public bool Equals(Value other) { return true; } if (NullValue != other.NullValue) return false; - if (NumberValue != other.NumberValue) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(NumberValue, other.NumberValue)) return false; if (StringValue != other.StringValue) return false; if (BoolValue != other.BoolValue) return false; if (!object.Equals(StructValue, other.StructValue)) return false; if (!object.Equals(ListValue, other.ListValue)) return false; if (KindCase != other.KindCase) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (kindCase_ == KindOneofCase.NullValue) hash ^= NullValue.GetHashCode(); - if (kindCase_ == KindOneofCase.NumberValue) hash ^= NumberValue.GetHashCode(); + if (kindCase_ == KindOneofCase.NumberValue) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(NumberValue); if (kindCase_ == KindOneofCase.StringValue) hash ^= StringValue.GetHashCode(); if (kindCase_ == KindOneofCase.BoolValue) hash ^= BoolValue.GetHashCode(); if (kindCase_ == KindOneofCase.StructValue) hash ^= StructValue.GetHashCode(); if (kindCase_ == KindOneofCase.ListValue) hash ^= ListValue.GetHashCode(); hash ^= (int) kindCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (kindCase_ == KindOneofCase.NullValue) { output.WriteRawTag(8); @@ -390,8 +440,12 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(50); output.WriteMessage(ListValue); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (kindCase_ == KindOneofCase.NullValue) { @@ -412,9 +466,13 @@ public int CalculateSize() { if (kindCase_ == KindOneofCase.ListValue) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(ListValue); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Value other) { if (other == null) { return; @@ -433,21 +491,29 @@ public void MergeFrom(Value other) { BoolValue = other.BoolValue; break; case KindOneofCase.StructValue: - StructValue = other.StructValue; + if (StructValue == null) { + StructValue = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + StructValue.MergeFrom(other.StructValue); break; case KindOneofCase.ListValue: - ListValue = other.ListValue; + if (ListValue == null) { + ListValue = new global::Google.Protobuf.WellKnownTypes.ListValue(); + } + ListValue.MergeFrom(other.ListValue); break; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { kind_ = input.ReadEnum(); @@ -491,33 +557,40 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// `ListValue` is a wrapper around a repeated field of values. + /// `ListValue` is a wrapper around a repeated field of values. /// - /// The JSON representation for `ListValue` is JSON array. + /// The JSON representation for `ListValue` is JSON array. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class ListValue : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ListValue()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.WellKnownTypes.StructReflection.Descriptor.MessageTypes[2]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ListValue() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ListValue(ListValue other) : this() { values_ = other.values_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ListValue Clone() { return new ListValue(this); } @@ -528,16 +601,19 @@ public ListValue Clone() { = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.WellKnownTypes.Value.Parser); private readonly pbc::RepeatedField values_ = new pbc::RepeatedField(); /// - /// Repeated field of dynamically typed values. + /// Repeated field of dynamically typed values. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Values { get { return values_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ListValue); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(ListValue other) { if (ReferenceEquals(other, null)) { return false; @@ -546,42 +622,58 @@ public bool Equals(ListValue other) { return true; } if(!values_.Equals(other.values_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= values_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { values_.WriteTo(output, _repeated_values_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += values_.CalculateSize(_repeated_values_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(ListValue other) { if (other == null) { return; } values_.Add(other.values_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { values_.AddEntriesFrom(input, _repeated_values_codec); diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/TimeExtensions.cs b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/TimeExtensions.cs index dd485d324aa1..8b63d63035b1 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/TimeExtensions.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/TimeExtensions.cs @@ -31,10 +31,6 @@ #endregion using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Google.Protobuf.WellKnownTypes { diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs index 053b88bd33c9..12f4812af37f 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs @@ -1,5 +1,7 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/timestamp.proto +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/timestamp.proto +// #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -10,7 +12,6 @@ namespace Google.Protobuf.WellKnownTypes { /// Holder for reflection information generated from google/protobuf/timestamp.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class TimestampReflection { #region Descriptor @@ -25,14 +26,14 @@ static TimestampReflection() { string.Concat( "Ch9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1wLnByb3RvEg9nb29nbGUucHJv", "dG9idWYiKwoJVGltZXN0YW1wEg8KB3NlY29uZHMYASABKAMSDQoFbmFub3MY", - "AiABKAVCgQEKE2NvbS5nb29nbGUucHJvdG9idWZCDlRpbWVzdGFtcFByb3Rv", - "UAFaK2dpdGh1Yi5jb20vZ29sYW5nL3Byb3RvYnVmL3B0eXBlcy90aW1lc3Rh", - "bXCgAQH4AQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlw", - "ZXNiBnByb3RvMw==")); + "AiABKAVCfgoTY29tLmdvb2dsZS5wcm90b2J1ZkIOVGltZXN0YW1wUHJvdG9Q", + "AVorZ2l0aHViLmNvbS9nb2xhbmcvcHJvdG9idWYvcHR5cGVzL3RpbWVzdGFt", + "cPgBAaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IG", + "cHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Timestamp), global::Google.Protobuf.WellKnownTypes.Timestamp.Parser, new[]{ "Seconds", "Nanos" }, null, null, null) + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Timestamp), global::Google.Protobuf.WellKnownTypes.Timestamp.Parser, new[]{ "Seconds", "Nanos" }, null, null, null, null) })); } #endregion @@ -40,83 +41,119 @@ static TimestampReflection() { } #region Messages /// - /// A Timestamp represents a point in time independent of any time zone - /// or calendar, represented as seconds and fractions of seconds at - /// nanosecond resolution in UTC Epoch time. It is encoded using the - /// Proleptic Gregorian Calendar which extends the Gregorian calendar - /// backwards to year one. It is encoded assuming all minutes are 60 - /// seconds long, i.e. leap seconds are "smeared" so that no leap second - /// table is needed for interpretation. Range is from - /// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. - /// By restricting to that range, we ensure that we can convert to - /// and from RFC 3339 date strings. - /// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). + /// A Timestamp represents a point in time independent of any time zone or local + /// calendar, encoded as a count of seconds and fractions of seconds at + /// nanosecond resolution. The count is relative to an epoch at UTC midnight on + /// January 1, 1970, in the proleptic Gregorian calendar which extends the + /// Gregorian calendar backwards to year one. /// - /// Example 1: Compute Timestamp from POSIX `time()`. + /// All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + /// second table is needed for interpretation, using a [24-hour linear + /// smear](https://developers.google.com/time/smear). /// - /// Timestamp timestamp; - /// timestamp.set_seconds(time(NULL)); - /// timestamp.set_nanos(0); + /// The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + /// restricting to that range, we ensure that we can convert to and from [RFC + /// 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. /// - /// Example 2: Compute Timestamp from POSIX `gettimeofday()`. + /// # Examples /// - /// struct timeval tv; - /// gettimeofday(&tv, NULL); + /// Example 1: Compute Timestamp from POSIX `time()`. /// - /// Timestamp timestamp; - /// timestamp.set_seconds(tv.tv_sec); - /// timestamp.set_nanos(tv.tv_usec * 1000); + /// Timestamp timestamp; + /// timestamp.set_seconds(time(NULL)); + /// timestamp.set_nanos(0); /// - /// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + /// Example 2: Compute Timestamp from POSIX `gettimeofday()`. /// - /// FILETIME ft; - /// GetSystemTimeAsFileTime(&ft); - /// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + /// struct timeval tv; + /// gettimeofday(&tv, NULL); /// - /// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z - /// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. - /// Timestamp timestamp; - /// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); - /// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + /// Timestamp timestamp; + /// timestamp.set_seconds(tv.tv_sec); + /// timestamp.set_nanos(tv.tv_usec * 1000); /// - /// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + /// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. /// - /// long millis = System.currentTimeMillis(); + /// FILETIME ft; + /// GetSystemTimeAsFileTime(&ft); + /// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; /// - /// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) - /// .setNanos((int) ((millis % 1000) * 1000000)).build(); + /// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + /// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + /// Timestamp timestamp; + /// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + /// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); /// - /// Example 5: Compute Timestamp from current time in Python. + /// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. /// - /// now = time.time() - /// seconds = int(now) - /// nanos = int((now - seconds) * 10**9) - /// timestamp = Timestamp(seconds=seconds, nanos=nanos) + /// long millis = System.currentTimeMillis(); + /// + /// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + /// .setNanos((int) ((millis % 1000) * 1000000)).build(); + /// + /// Example 5: Compute Timestamp from current time in Python. + /// + /// timestamp = Timestamp() + /// timestamp.GetCurrentTime() + /// + /// # JSON Mapping + /// + /// In JSON format, the Timestamp type is encoded as a string in the + /// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + /// format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + /// where {year} is always expressed using four digits while {month}, {day}, + /// {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + /// seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + /// are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + /// is required. A proto3 JSON serializer should always use UTC (as indicated by + /// "Z") when printing the Timestamp type and a proto3 JSON parser should be + /// able to accept both UTC and other timezones (as indicated by an offset). + /// + /// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + /// 01:30 UTC on January 15, 2017. + /// + /// In JavaScript, one can convert a Date object to this format using the + /// standard + /// [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + /// method. In Python, a standard `datetime.datetime` object can be converted + /// to this format using + /// [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + /// the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + /// the Joda Time's [`ISODateTimeFormat.dateTime()`]( + /// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + /// ) to obtain a formatter capable of generating timestamps in this format. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Timestamp : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Timestamp()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Timestamp() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Timestamp(Timestamp other) : this() { seconds_ = other.seconds_; nanos_ = other.nanos_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Timestamp Clone() { return new Timestamp(this); } @@ -125,10 +162,11 @@ public Timestamp Clone() { public const int SecondsFieldNumber = 1; private long seconds_; /// - /// Represents seconds of UTC time since Unix epoch - /// 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to - /// 9999-12-31T23:59:59Z inclusive. + /// Represents seconds of UTC time since Unix epoch + /// 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + /// 9999-12-31T23:59:59Z inclusive. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public long Seconds { get { return seconds_; } set { @@ -140,11 +178,12 @@ public long Seconds { public const int NanosFieldNumber = 2; private int nanos_; /// - /// Non-negative fractions of a second at nanosecond resolution. Negative - /// second values with fractions must still have non-negative nanos values - /// that count forward in time. Must be from 0 to 999,999,999 - /// inclusive. + /// Non-negative fractions of a second at nanosecond resolution. Negative + /// second values with fractions must still have non-negative nanos values + /// that count forward in time. Must be from 0 to 999,999,999 + /// inclusive. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Nanos { get { return nanos_; } set { @@ -152,10 +191,12 @@ public int Nanos { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Timestamp); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Timestamp other) { if (ReferenceEquals(other, null)) { return false; @@ -165,20 +206,26 @@ public bool Equals(Timestamp other) { } if (Seconds != other.Seconds) return false; if (Nanos != other.Nanos) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Seconds != 0L) hash ^= Seconds.GetHashCode(); if (Nanos != 0) hash ^= Nanos.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Seconds != 0L) { output.WriteRawTag(8); @@ -188,8 +235,12 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(16); output.WriteInt32(Nanos); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Seconds != 0L) { @@ -198,9 +249,13 @@ public int CalculateSize() { if (Nanos != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(Nanos); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Timestamp other) { if (other == null) { return; @@ -211,14 +266,16 @@ public void MergeFrom(Timestamp other) { if (other.Nanos != 0) { Nanos = other.Nanos; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { Seconds = input.ReadInt64(); diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs index aa40347342f5..2f5172f1ca7c 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs @@ -36,7 +36,7 @@ namespace Google.Protobuf.WellKnownTypes { - public partial class Timestamp : ICustomDiagnosticMessage + public partial class Timestamp : ICustomDiagnosticMessage, IComparable { private static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); // Constants determined programmatically, but then hard-coded so they can be constant expressions. @@ -222,6 +222,109 @@ internal static string ToJson(long seconds, int nanoseconds, bool diagnosticOnly } } + /// + /// Given another timestamp, returns 0 if the timestamps are equivalent, -1 if this timestamp precedes the other, and 1 otherwise + /// + /// + /// Make sure the timestamps are normalized. Comparing non-normalized timestamps is not specified and may give unexpected results. + /// + /// Timestamp to compare + /// an integer indicating whether this timestamp precedes or follows the other + public int CompareTo(Timestamp other) + { + return other == null ? 1 + : Seconds < other.Seconds ? -1 + : Seconds > other.Seconds ? 1 + : Nanos < other.Nanos ? -1 + : Nanos > other.Nanos ? 1 + : 0; + } + + /// + /// Compares two timestamps and returns whether the first is less than (chronologically precedes) the second + /// + /// + /// Make sure the timestamps are normalized. Comparing non-normalized timestamps is not specified and may give unexpected results. + /// + /// + /// + /// true if a precedes b + public static bool operator <(Timestamp a, Timestamp b) + { + return a.CompareTo(b) < 0; + } + + /// + /// Compares two timestamps and returns whether the first is greater than (chronologically follows) the second + /// + /// + /// Make sure the timestamps are normalized. Comparing non-normalized timestamps is not specified and may give unexpected results. + /// + /// + /// + /// true if a follows b + public static bool operator >(Timestamp a, Timestamp b) + { + return a.CompareTo(b) > 0; + } + + /// + /// Compares two timestamps and returns whether the first is less than (chronologically precedes) the second + /// + /// + /// Make sure the timestamps are normalized. Comparing non-normalized timestamps is not specified and may give unexpected results. + /// + /// + /// + /// true if a precedes b + public static bool operator <=(Timestamp a, Timestamp b) + { + return a.CompareTo(b) <= 0; + } + + /// + /// Compares two timestamps and returns whether the first is greater than (chronologically follows) the second + /// + /// + /// Make sure the timestamps are normalized. Comparing non-normalized timestamps is not specified and may give unexpected results. + /// + /// + /// + /// true if a follows b + public static bool operator >=(Timestamp a, Timestamp b) + { + return a.CompareTo(b) >= 0; + } + + + /// + /// Returns whether two timestamps are equivalent + /// + /// + /// Make sure the timestamps are normalized. Comparing non-normalized timestamps is not specified and may give unexpected results. + /// + /// + /// + /// true if the two timestamps refer to the same nanosecond + public static bool operator ==(Timestamp a, Timestamp b) + { + return ReferenceEquals(a, b) || (ReferenceEquals(a, null) ? (ReferenceEquals(b, null) ? true : false) : a.Equals(b)); + } + + /// + /// Returns whether two timestamps differ + /// + /// + /// Make sure the timestamps are normalized. Comparing non-normalized timestamps is not specified and may give unexpected results. + /// + /// + /// + /// true if the two timestamps differ + public static bool operator !=(Timestamp a, Timestamp b) + { + return !(a == b); + } + /// /// Returns a string representation of this for diagnostic purposes. /// diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs index 657c24645b37..bfd4b8ec8221 100644 --- a/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs +++ b/third_party/protobuf/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs @@ -1,5 +1,7 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/type.proto +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/type.proto +// #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -10,7 +12,6 @@ namespace Google.Protobuf.WellKnownTypes { /// Holder for reflection information generated from google/protobuf/type.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class TypeReflection { #region Descriptor @@ -55,17 +56,18 @@ static TypeReflection() { "ASgFEigKB29wdGlvbnMYAyADKAsyFy5nb29nbGUucHJvdG9idWYuT3B0aW9u", "IjsKBk9wdGlvbhIMCgRuYW1lGAEgASgJEiMKBXZhbHVlGAIgASgLMhQuZ29v", "Z2xlLnByb3RvYnVmLkFueSouCgZTeW50YXgSEQoNU1lOVEFYX1BST1RPMhAA", - "EhEKDVNZTlRBWF9QUk9UTzMQAUJMChNjb20uZ29vZ2xlLnByb3RvYnVmQglU", - "eXBlUHJvdG9QAaABAaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25v", - "d25UeXBlc2IGcHJvdG8z")); + "EhEKDVNZTlRBWF9QUk9UTzMQAUJ9ChNjb20uZ29vZ2xlLnByb3RvYnVmQglU", + "eXBlUHJvdG9QAVovZ29vZ2xlLmdvbGFuZy5vcmcvZ2VucHJvdG8vcHJvdG9i", + "dWYvcHR5cGU7cHR5cGX4AQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2Vs", + "bEtub3duVHlwZXNiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.SourceContextReflection.Descriptor, }, - new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.WellKnownTypes.Syntax), }, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Type), global::Google.Protobuf.WellKnownTypes.Type.Parser, new[]{ "Name", "Fields", "Oneofs", "Options", "SourceContext", "Syntax" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Field), global::Google.Protobuf.WellKnownTypes.Field.Parser, new[]{ "Kind", "Cardinality", "Number", "Name", "TypeUrl", "OneofIndex", "Packed", "Options", "JsonName", "DefaultValue" }, null, new[]{ typeof(global::Google.Protobuf.WellKnownTypes.Field.Types.Kind), typeof(global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality) }, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Enum), global::Google.Protobuf.WellKnownTypes.Enum.Parser, new[]{ "Name", "Enumvalue", "Options", "SourceContext", "Syntax" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.EnumValue), global::Google.Protobuf.WellKnownTypes.EnumValue.Parser, new[]{ "Name", "Number", "Options" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Option), global::Google.Protobuf.WellKnownTypes.Option.Parser, new[]{ "Name", "Value" }, null, null, null) + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.WellKnownTypes.Syntax), }, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Type), global::Google.Protobuf.WellKnownTypes.Type.Parser, new[]{ "Name", "Fields", "Oneofs", "Options", "SourceContext", "Syntax" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Field), global::Google.Protobuf.WellKnownTypes.Field.Parser, new[]{ "Kind", "Cardinality", "Number", "Name", "TypeUrl", "OneofIndex", "Packed", "Options", "JsonName", "DefaultValue" }, null, new[]{ typeof(global::Google.Protobuf.WellKnownTypes.Field.Types.Kind), typeof(global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality) }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Enum), global::Google.Protobuf.WellKnownTypes.Enum.Parser, new[]{ "Name", "Enumvalue", "Options", "SourceContext", "Syntax" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.EnumValue), global::Google.Protobuf.WellKnownTypes.EnumValue.Parser, new[]{ "Name", "Number", "Options" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Option), global::Google.Protobuf.WellKnownTypes.Option.Parser, new[]{ "Name", "Value" }, null, null, null, null) })); } #endregion @@ -73,15 +75,15 @@ static TypeReflection() { } #region Enums /// - /// The syntax in which a protocol buffer element is defined. + /// The syntax in which a protocol buffer element is defined. /// public enum Syntax { /// - /// Syntax `proto2`. + /// Syntax `proto2`. /// [pbr::OriginalName("SYNTAX_PROTO2")] Proto2 = 0, /// - /// Syntax `proto3`. + /// Syntax `proto3`. /// [pbr::OriginalName("SYNTAX_PROTO3")] Proto3 = 1, } @@ -90,36 +92,43 @@ public enum Syntax { #region Messages /// - /// A protocol buffer message type. + /// A protocol buffer message type. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Type : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Type()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.WellKnownTypes.TypeReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Type() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Type(Type other) : this() { name_ = other.name_; fields_ = other.fields_.Clone(); oneofs_ = other.oneofs_.Clone(); options_ = other.options_.Clone(); - SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null; + sourceContext_ = other.sourceContext_ != null ? other.sourceContext_.Clone() : null; syntax_ = other.syntax_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Type Clone() { return new Type(this); } @@ -128,8 +137,9 @@ public Type Clone() { public const int NameFieldNumber = 1; private string name_ = ""; /// - /// The fully qualified message name. + /// The fully qualified message name. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -143,8 +153,9 @@ public string Name { = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Field.Parser); private readonly pbc::RepeatedField fields_ = new pbc::RepeatedField(); /// - /// The list of fields. + /// The list of fields. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Fields { get { return fields_; } } @@ -155,8 +166,9 @@ public string Name { = pb::FieldCodec.ForString(26); private readonly pbc::RepeatedField oneofs_ = new pbc::RepeatedField(); /// - /// The list of types appearing in `oneof` definitions in this type. + /// The list of types appearing in `oneof` definitions in this type. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Oneofs { get { return oneofs_; } } @@ -167,8 +179,9 @@ public string Name { = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.WellKnownTypes.Option.Parser); private readonly pbc::RepeatedField options_ = new pbc::RepeatedField(); /// - /// The protocol buffer options. + /// The protocol buffer options. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Options { get { return options_; } } @@ -177,8 +190,9 @@ public string Name { public const int SourceContextFieldNumber = 5; private global::Google.Protobuf.WellKnownTypes.SourceContext sourceContext_; /// - /// The source context. + /// The source context. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.SourceContext SourceContext { get { return sourceContext_; } set { @@ -188,10 +202,11 @@ public string Name { /// Field number for the "syntax" field. public const int SyntaxFieldNumber = 6; - private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = 0; + private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = global::Google.Protobuf.WellKnownTypes.Syntax.Proto2; /// - /// The source syntax. + /// The source syntax. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Syntax Syntax { get { return syntax_; } set { @@ -199,10 +214,12 @@ public string Name { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Type); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Type other) { if (ReferenceEquals(other, null)) { return false; @@ -216,9 +233,10 @@ public bool Equals(Type other) { if(!options_.Equals(other.options_)) return false; if (!object.Equals(SourceContext, other.SourceContext)) return false; if (Syntax != other.Syntax) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); @@ -226,14 +244,19 @@ public override int GetHashCode() { hash ^= oneofs_.GetHashCode(); hash ^= options_.GetHashCode(); if (sourceContext_ != null) hash ^= SourceContext.GetHashCode(); - if (Syntax != 0) hash ^= Syntax.GetHashCode(); + if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) hash ^= Syntax.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -246,12 +269,16 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(42); output.WriteMessage(SourceContext); } - if (Syntax != 0) { + if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) { output.WriteRawTag(48); output.WriteEnum((int) Syntax); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -263,12 +290,16 @@ public int CalculateSize() { if (sourceContext_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceContext); } - if (Syntax != 0) { + if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Type other) { if (other == null) { return; @@ -281,21 +312,23 @@ public void MergeFrom(Type other) { options_.Add(other.options_); if (other.sourceContext_ != null) { if (sourceContext_ == null) { - sourceContext_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + SourceContext = new global::Google.Protobuf.WellKnownTypes.SourceContext(); } SourceContext.MergeFrom(other.SourceContext); } - if (other.Syntax != 0) { + if (other.Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) { Syntax = other.Syntax; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Name = input.ReadString(); @@ -315,13 +348,13 @@ public void MergeFrom(pb::CodedInputStream input) { } case 42: { if (sourceContext_ == null) { - sourceContext_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + SourceContext = new global::Google.Protobuf.WellKnownTypes.SourceContext(); } - input.ReadMessage(sourceContext_); + input.ReadMessage(SourceContext); break; } case 48: { - syntax_ = (global::Google.Protobuf.WellKnownTypes.Syntax) input.ReadEnum(); + Syntax = (global::Google.Protobuf.WellKnownTypes.Syntax) input.ReadEnum(); break; } } @@ -331,27 +364,32 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// A single field of a message type. + /// A single field of a message type. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Field : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Field()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.WellKnownTypes.TypeReflection.Descriptor.MessageTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Field() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Field(Field other) : this() { kind_ = other.kind_; cardinality_ = other.cardinality_; @@ -363,18 +401,21 @@ public Field(Field other) : this() { options_ = other.options_.Clone(); jsonName_ = other.jsonName_; defaultValue_ = other.defaultValue_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Field Clone() { return new Field(this); } /// Field number for the "kind" field. public const int KindFieldNumber = 1; - private global::Google.Protobuf.WellKnownTypes.Field.Types.Kind kind_ = 0; + private global::Google.Protobuf.WellKnownTypes.Field.Types.Kind kind_ = global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TypeUnknown; /// - /// The field type. + /// The field type. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Field.Types.Kind Kind { get { return kind_; } set { @@ -384,10 +425,11 @@ public Field Clone() { /// Field number for the "cardinality" field. public const int CardinalityFieldNumber = 2; - private global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality cardinality_ = 0; + private global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality cardinality_ = global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.Unknown; /// - /// The field cardinality. + /// The field cardinality. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality Cardinality { get { return cardinality_; } set { @@ -399,8 +441,9 @@ public Field Clone() { public const int NumberFieldNumber = 3; private int number_; /// - /// The field number. + /// The field number. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Number { get { return number_; } set { @@ -412,8 +455,9 @@ public int Number { public const int NameFieldNumber = 4; private string name_ = ""; /// - /// The field name. + /// The field name. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -425,9 +469,10 @@ public string Name { public const int TypeUrlFieldNumber = 6; private string typeUrl_ = ""; /// - /// The field type URL, without the scheme, for message or enumeration - /// types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`. + /// The field type URL, without the scheme, for message or enumeration + /// types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string TypeUrl { get { return typeUrl_; } set { @@ -439,9 +484,10 @@ public string TypeUrl { public const int OneofIndexFieldNumber = 7; private int oneofIndex_; /// - /// The index of the field type in `Type.oneofs`, for message or enumeration - /// types. The first type has index 1; zero means the type is not in the list. + /// The index of the field type in `Type.oneofs`, for message or enumeration + /// types. The first type has index 1; zero means the type is not in the list. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int OneofIndex { get { return oneofIndex_; } set { @@ -453,8 +499,9 @@ public int OneofIndex { public const int PackedFieldNumber = 8; private bool packed_; /// - /// Whether to use alternative packed wire representation. + /// Whether to use alternative packed wire representation. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Packed { get { return packed_; } set { @@ -468,8 +515,9 @@ public bool Packed { = pb::FieldCodec.ForMessage(74, global::Google.Protobuf.WellKnownTypes.Option.Parser); private readonly pbc::RepeatedField options_ = new pbc::RepeatedField(); /// - /// The protocol buffer options. + /// The protocol buffer options. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Options { get { return options_; } } @@ -478,8 +526,9 @@ public bool Packed { public const int JsonNameFieldNumber = 10; private string jsonName_ = ""; /// - /// The field JSON name. + /// The field JSON name. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string JsonName { get { return jsonName_; } set { @@ -491,8 +540,9 @@ public string JsonName { public const int DefaultValueFieldNumber = 11; private string defaultValue_ = ""; /// - /// The string value of the default value of this field. Proto2 syntax only. + /// The string value of the default value of this field. Proto2 syntax only. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string DefaultValue { get { return defaultValue_; } set { @@ -500,10 +550,12 @@ public string DefaultValue { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Field); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Field other) { if (ReferenceEquals(other, null)) { return false; @@ -521,13 +573,14 @@ public bool Equals(Field other) { if(!options_.Equals(other.options_)) return false; if (JsonName != other.JsonName) return false; if (DefaultValue != other.DefaultValue) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (Kind != 0) hash ^= Kind.GetHashCode(); - if (Cardinality != 0) hash ^= Cardinality.GetHashCode(); + if (Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TypeUnknown) hash ^= Kind.GetHashCode(); + if (Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.Unknown) hash ^= Cardinality.GetHashCode(); if (Number != 0) hash ^= Number.GetHashCode(); if (Name.Length != 0) hash ^= Name.GetHashCode(); if (TypeUrl.Length != 0) hash ^= TypeUrl.GetHashCode(); @@ -536,19 +589,24 @@ public override int GetHashCode() { hash ^= options_.GetHashCode(); if (JsonName.Length != 0) hash ^= JsonName.GetHashCode(); if (DefaultValue.Length != 0) hash ^= DefaultValue.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (Kind != 0) { + if (Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TypeUnknown) { output.WriteRawTag(8); output.WriteEnum((int) Kind); } - if (Cardinality != 0) { + if (Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.Unknown) { output.WriteRawTag(16); output.WriteEnum((int) Cardinality); } @@ -581,14 +639,18 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(90); output.WriteString(DefaultValue); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (Kind != 0) { + if (Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TypeUnknown) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Kind); } - if (Cardinality != 0) { + if (Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.Unknown) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Cardinality); } if (Number != 0) { @@ -613,17 +675,21 @@ public int CalculateSize() { if (DefaultValue.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(DefaultValue); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Field other) { if (other == null) { return; } - if (other.Kind != 0) { + if (other.Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TypeUnknown) { Kind = other.Kind; } - if (other.Cardinality != 0) { + if (other.Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.Unknown) { Cardinality = other.Cardinality; } if (other.Number != 0) { @@ -648,21 +714,23 @@ public void MergeFrom(Field other) { if (other.DefaultValue.Length != 0) { DefaultValue = other.DefaultValue; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { - kind_ = (global::Google.Protobuf.WellKnownTypes.Field.Types.Kind) input.ReadEnum(); + Kind = (global::Google.Protobuf.WellKnownTypes.Field.Types.Kind) input.ReadEnum(); break; } case 16: { - cardinality_ = (global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality) input.ReadEnum(); + Cardinality = (global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality) input.ReadEnum(); break; } case 24: { @@ -703,108 +771,108 @@ public void MergeFrom(pb::CodedInputStream input) { #region Nested types /// Container for nested types declared in the Field message type. - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { /// - /// Basic field types. + /// Basic field types. /// public enum Kind { /// - /// Field type unknown. + /// Field type unknown. /// [pbr::OriginalName("TYPE_UNKNOWN")] TypeUnknown = 0, /// - /// Field type double. + /// Field type double. /// [pbr::OriginalName("TYPE_DOUBLE")] TypeDouble = 1, /// - /// Field type float. + /// Field type float. /// [pbr::OriginalName("TYPE_FLOAT")] TypeFloat = 2, /// - /// Field type int64. + /// Field type int64. /// [pbr::OriginalName("TYPE_INT64")] TypeInt64 = 3, /// - /// Field type uint64. + /// Field type uint64. /// [pbr::OriginalName("TYPE_UINT64")] TypeUint64 = 4, /// - /// Field type int32. + /// Field type int32. /// [pbr::OriginalName("TYPE_INT32")] TypeInt32 = 5, /// - /// Field type fixed64. + /// Field type fixed64. /// [pbr::OriginalName("TYPE_FIXED64")] TypeFixed64 = 6, /// - /// Field type fixed32. + /// Field type fixed32. /// [pbr::OriginalName("TYPE_FIXED32")] TypeFixed32 = 7, /// - /// Field type bool. + /// Field type bool. /// [pbr::OriginalName("TYPE_BOOL")] TypeBool = 8, /// - /// Field type string. + /// Field type string. /// [pbr::OriginalName("TYPE_STRING")] TypeString = 9, /// - /// Field type group. Proto2 syntax only, and deprecated. + /// Field type group. Proto2 syntax only, and deprecated. /// [pbr::OriginalName("TYPE_GROUP")] TypeGroup = 10, /// - /// Field type message. + /// Field type message. /// [pbr::OriginalName("TYPE_MESSAGE")] TypeMessage = 11, /// - /// Field type bytes. + /// Field type bytes. /// [pbr::OriginalName("TYPE_BYTES")] TypeBytes = 12, /// - /// Field type uint32. + /// Field type uint32. /// [pbr::OriginalName("TYPE_UINT32")] TypeUint32 = 13, /// - /// Field type enum. + /// Field type enum. /// [pbr::OriginalName("TYPE_ENUM")] TypeEnum = 14, /// - /// Field type sfixed32. + /// Field type sfixed32. /// [pbr::OriginalName("TYPE_SFIXED32")] TypeSfixed32 = 15, /// - /// Field type sfixed64. + /// Field type sfixed64. /// [pbr::OriginalName("TYPE_SFIXED64")] TypeSfixed64 = 16, /// - /// Field type sint32. + /// Field type sint32. /// [pbr::OriginalName("TYPE_SINT32")] TypeSint32 = 17, /// - /// Field type sint64. + /// Field type sint64. /// [pbr::OriginalName("TYPE_SINT64")] TypeSint64 = 18, } /// - /// Whether a field is optional, required, or repeated. + /// Whether a field is optional, required, or repeated. /// public enum Cardinality { /// - /// For fields with unknown cardinality. + /// For fields with unknown cardinality. /// [pbr::OriginalName("CARDINALITY_UNKNOWN")] Unknown = 0, /// - /// For optional fields. + /// For optional fields. /// [pbr::OriginalName("CARDINALITY_OPTIONAL")] Optional = 1, /// - /// For required fields. Proto2 syntax only. + /// For required fields. Proto2 syntax only. /// [pbr::OriginalName("CARDINALITY_REQUIRED")] Required = 2, /// - /// For repeated fields. + /// For repeated fields. /// [pbr::OriginalName("CARDINALITY_REPEATED")] Repeated = 3, } @@ -815,35 +883,42 @@ public enum Cardinality { } /// - /// Enum type definition. + /// Enum type definition. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Enum : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Enum()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.WellKnownTypes.TypeReflection.Descriptor.MessageTypes[2]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Enum() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Enum(Enum other) : this() { name_ = other.name_; enumvalue_ = other.enumvalue_.Clone(); options_ = other.options_.Clone(); - SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null; + sourceContext_ = other.sourceContext_ != null ? other.sourceContext_.Clone() : null; syntax_ = other.syntax_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Enum Clone() { return new Enum(this); } @@ -852,8 +927,9 @@ public Enum Clone() { public const int NameFieldNumber = 1; private string name_ = ""; /// - /// Enum type name. + /// Enum type name. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -867,8 +943,9 @@ public string Name { = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.EnumValue.Parser); private readonly pbc::RepeatedField enumvalue_ = new pbc::RepeatedField(); /// - /// Enum value definitions. + /// Enum value definitions. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Enumvalue { get { return enumvalue_; } } @@ -879,8 +956,9 @@ public string Name { = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.WellKnownTypes.Option.Parser); private readonly pbc::RepeatedField options_ = new pbc::RepeatedField(); /// - /// Protocol buffer options. + /// Protocol buffer options. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Options { get { return options_; } } @@ -889,8 +967,9 @@ public string Name { public const int SourceContextFieldNumber = 4; private global::Google.Protobuf.WellKnownTypes.SourceContext sourceContext_; /// - /// The source context. + /// The source context. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.SourceContext SourceContext { get { return sourceContext_; } set { @@ -900,10 +979,11 @@ public string Name { /// Field number for the "syntax" field. public const int SyntaxFieldNumber = 5; - private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = 0; + private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = global::Google.Protobuf.WellKnownTypes.Syntax.Proto2; /// - /// The source syntax. + /// The source syntax. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Google.Protobuf.WellKnownTypes.Syntax Syntax { get { return syntax_; } set { @@ -911,10 +991,12 @@ public string Name { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Enum); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Enum other) { if (ReferenceEquals(other, null)) { return false; @@ -927,23 +1009,29 @@ public bool Equals(Enum other) { if(!options_.Equals(other.options_)) return false; if (!object.Equals(SourceContext, other.SourceContext)) return false; if (Syntax != other.Syntax) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); hash ^= enumvalue_.GetHashCode(); hash ^= options_.GetHashCode(); if (sourceContext_ != null) hash ^= SourceContext.GetHashCode(); - if (Syntax != 0) hash ^= Syntax.GetHashCode(); + if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) hash ^= Syntax.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -955,12 +1043,16 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(34); output.WriteMessage(SourceContext); } - if (Syntax != 0) { + if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) { output.WriteRawTag(40); output.WriteEnum((int) Syntax); } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -971,12 +1063,16 @@ public int CalculateSize() { if (sourceContext_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceContext); } - if (Syntax != 0) { + if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax); } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Enum other) { if (other == null) { return; @@ -988,21 +1084,23 @@ public void MergeFrom(Enum other) { options_.Add(other.options_); if (other.sourceContext_ != null) { if (sourceContext_ == null) { - sourceContext_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + SourceContext = new global::Google.Protobuf.WellKnownTypes.SourceContext(); } SourceContext.MergeFrom(other.SourceContext); } - if (other.Syntax != 0) { + if (other.Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) { Syntax = other.Syntax; } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Name = input.ReadString(); @@ -1018,13 +1116,13 @@ public void MergeFrom(pb::CodedInputStream input) { } case 34: { if (sourceContext_ == null) { - sourceContext_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + SourceContext = new global::Google.Protobuf.WellKnownTypes.SourceContext(); } - input.ReadMessage(sourceContext_); + input.ReadMessage(SourceContext); break; } case 40: { - syntax_ = (global::Google.Protobuf.WellKnownTypes.Syntax) input.ReadEnum(); + Syntax = (global::Google.Protobuf.WellKnownTypes.Syntax) input.ReadEnum(); break; } } @@ -1034,33 +1132,40 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// Enum value definition. + /// Enum value definition. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class EnumValue : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumValue()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Google.Protobuf.WellKnownTypes.TypeReflection.Descriptor.MessageTypes[3]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public EnumValue() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public EnumValue(EnumValue other) : this() { name_ = other.name_; number_ = other.number_; options_ = other.options_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public EnumValue Clone() { return new EnumValue(this); } @@ -1069,8 +1174,9 @@ public EnumValue Clone() { public const int NameFieldNumber = 1; private string name_ = ""; /// - /// Enum value name. + /// Enum value name. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -1082,8 +1188,9 @@ public string Name { public const int NumberFieldNumber = 2; private int number_; /// - /// Enum value number. + /// Enum value number. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Number { get { return number_; } set { @@ -1097,16 +1204,19 @@ public int Number { = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.WellKnownTypes.Option.Parser); private readonly pbc::RepeatedField options_ = new pbc::RepeatedField(); /// - /// Protocol buffer options. + /// Protocol buffer options. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField Options { get { return options_; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as EnumValue); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(EnumValue other) { if (ReferenceEquals(other, null)) { return false; @@ -1117,21 +1227,27 @@ public bool Equals(EnumValue other) { if (Name != other.Name) return false; if (Number != other.Number) return false; if(!options_.Equals(other.options_)) return false; - return true; + return Equals(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); if (Number != 0) hash ^= Number.GetHashCode(); hash ^= options_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -1142,8 +1258,12 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteInt32(Number); } options_.WriteTo(output, _repeated_options_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -1153,9 +1273,13 @@ public int CalculateSize() { size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number); } size += options_.CalculateSize(_repeated_options_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(EnumValue other) { if (other == null) { return; @@ -1167,14 +1291,16 @@ public void MergeFrom(EnumValue other) { Number = other.Number; } options_.Add(other.options_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 10: { Name = input.ReadString(); @@ -1195,33 +1321,40 @@ public void MergeFrom(pb::CodedInputStream input) { } /// - /// A protocol buffer option, which can be attached to a message, field, - /// enumeration, etc. + /// A protocol buffer option, which can be attached to a message, field, + /// enumeration, etc. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Option : pb::IMessage