Merge pull request #1 from protocolbuffers/master

merge
pull/6811/head
Elliotte Rusty Harold 5 years ago committed by GitHub
commit 939a6f5de6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      .github/ISSUE_TEMPLATE/bug_report.md
  2. 10
      .github/ISSUE_TEMPLATE/feature_request.md
  3. 7
      .github/ISSUE_TEMPLATE/question.md
  4. 1
      .gitignore
  5. 94
      BUILD
  6. 124
      CHANGES.txt
  7. 14
      Makefile.am
  8. 42
      Protobuf-C++.podspec
  9. 3
      Protobuf.podspec
  10. 33
      WORKSPACE
  11. 6
      benchmarks/Makefile.am
  12. 62
      build_files_updated_unittest.sh
  13. 2
      cmake/CMakeLists.txt
  14. 12
      cmake/README.md
  15. 3
      cmake/extract_includes.bat.in
  16. 2
      cmake/libprotobuf-lite.cmake
  17. 14
      cmake/tests.cmake
  18. 2
      configure.ac
  19. 3
      conformance/Makefile.am
  20. 917
      conformance/binary_json_conformance_suite.cc
  21. 11
      conformance/binary_json_conformance_suite.h
  22. 26
      conformance/conformance_cpp.cc
  23. 11
      conformance/conformance_objc.m
  24. 44
      conformance/conformance_test.cc
  25. 28
      conformance/conformance_test.h
  26. 23
      conformance/conformance_test_runner.cc
  27. 127
      conformance/failure_list_js.txt
  28. 71
      conformance/failure_list_php.txt
  29. 76
      conformance/failure_list_php_c.txt
  30. 26
      conformance/failure_list_python.txt
  31. 80
      conformance/failure_list_ruby.txt
  32. 66
      conformance/failure_list_ruby_mac.txt
  33. 2
      csharp/Google.Protobuf.Tools.nuspec
  34. 12
      csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
  35. 20
      csharp/compatibility_tests/v3.0.0/test.sh
  36. 6
      csharp/generate_protos.sh
  37. 1113
      csharp/protos/unittest.proto
  38. 69
      csharp/protos/unittest_import.proto
  39. 41
      csharp/protos/unittest_import_public.proto
  40. 14
      csharp/src/Google.Protobuf.Conformance/Program.cs
  41. 48
      csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs
  42. 102
      csharp/src/Google.Protobuf.Test/ExtensionSetTest.cs
  43. 368
      csharp/src/Google.Protobuf.Test/GeneratedMessageTest.Proto2.cs
  44. 3
      csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs
  45. 12
      csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
  46. 173
      csharp/src/Google.Protobuf.Test/Reflection/CustomOptionsTest.cs
  47. 208
      csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs
  48. 112
      csharp/src/Google.Protobuf.Test/SampleMessages.cs
  49. 5403
      csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto2.cs
  50. 895
      csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs
  51. 23941
      csharp/src/Google.Protobuf.Test/TestProtos/Unittest.cs
  52. 4
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs
  53. 210
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestImport.cs
  54. 188
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublic.cs
  55. 40
      csharp/src/Google.Protobuf.Test/UnknownFieldSetTest.cs
  56. BIN
      csharp/src/Google.Protobuf.Test/testprotos.pb
  57. 6
      csharp/src/Google.Protobuf/ByteString.cs
  58. 40
      csharp/src/Google.Protobuf/Collections/RepeatedField.cs
  59. 16
      csharp/src/Google.Protobuf/Extension.cs
  60. 32
      csharp/src/Google.Protobuf/ExtensionRegistry.cs
  61. 28
      csharp/src/Google.Protobuf/ExtensionSet.cs
  62. 63
      csharp/src/Google.Protobuf/ExtensionValue.cs
  63. 264
      csharp/src/Google.Protobuf/FieldCodec.cs
  64. 18
      csharp/src/Google.Protobuf/Google.Protobuf.csproj
  65. 19
      csharp/src/Google.Protobuf/IExtendableMessage.cs
  66. 19
      csharp/src/Google.Protobuf/MessageExtensions.cs
  67. 14
      csharp/src/Google.Protobuf/Reflection/CustomOptions.cs
  68. 113
      csharp/src/Google.Protobuf/Reflection/Descriptor.cs
  69. 6
      csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs
  70. 10
      csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs
  71. 24
      csharp/src/Google.Protobuf/Reflection/ExtensionCollection.cs
  72. 44
      csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs
  73. 49
      csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs
  74. 10
      csharp/src/Google.Protobuf/Reflection/IFieldAccessor.cs
  75. 27
      csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs
  76. 10
      csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs
  77. 10
      csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs
  78. 34
      csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs
  79. 10
      csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs
  80. 28
      csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs
  81. 2
      csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs
  82. 184
      docs/csharp/proto2.md
  83. 7
      docs/options.md
  84. 5
      docs/third_party.md
  85. 4
      examples/BUILD
  86. 46
      examples/WORKSPACE
  87. 27
      examples/add_person.dart
  88. 16
      examples/list_people.dart
  89. 1
      examples/third_party/zlib.BUILD
  90. 6
      java/README.md
  91. 6
      java/bom/pom.xml
  92. 34
      java/compatibility_tests/v2.5.0/test.sh
  93. 8
      java/core/pom.xml
  94. 2
      java/core/src/main/java/com/google/protobuf/AbstractMessage.java
  95. 9
      java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java
  96. 17
      java/core/src/main/java/com/google/protobuf/ByteString.java
  97. 38
      java/core/src/main/java/com/google/protobuf/ExtensionRegistryFactory.java
  98. 24
      java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java
  99. 573
      java/core/src/main/java/com/google/protobuf/FieldSet.java
  100. 29
      java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1,9 +1,18 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
<!--
NOTE: this form is for bug reports only. For questions or troubleshooting, please see the protobuf mailing list: https://groups.google.com/forum/#!forum/protobuf
-->
**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

@ -1,9 +1,19 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
<!--
NOTE: this form is for feature requests (including cleanup requests) only. For questions or troubleshooting, please see the protobuf mailing list: https://groups.google.com/forum/#!forum/protobuf
-->
**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?

@ -1,7 +0,0 @@
---
name: Question
about: Questions and troubleshooting
---

1
.gitignore vendored

@ -117,6 +117,7 @@ conformance/Conformance.pbobjc.h
conformance/Conformance.pbobjc.m
conformance/conformance_pb.js
conformance/conformance_pb.rb
conformance/core
conformance/failing_tests.txt
conformance/google/
conformance/google-protobuf/

94
BUILD

@ -1,5 +1,10 @@
# Bazel (https://bazel.build/) BUILD file for Protobuf.
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test", "objc_library")
load("@rules_java//java:defs.bzl", "java_library")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library")
load("@rules_python//python:defs.bzl", "py_library")
licenses(["notice"])
exports_files(["LICENSE"])
@ -54,6 +59,7 @@ COPTS = select({
"-Wno-unused-function",
# Prevents ISO C++ const string assignment warnings for pyext sources.
"-Wno-write-strings",
"-Wno-deprecated-declarations",
],
})
@ -103,10 +109,10 @@ LINK_OPTS = select({
load(
":protobuf.bzl",
"cc_proto_library",
"py_proto_library",
"internal_copied_filegroup",
"internal_gen_well_known_protos_java",
"internal_protobuf_py_tests",
"py_proto_library",
)
cc_library(
@ -242,38 +248,36 @@ cc_library(
# Map of all well known protos.
# name => (include path, imports)
WELL_KNOWN_PROTO_MAP = {
"any": ("google/protobuf/any.proto", []),
"any": ("src/google/protobuf/any.proto", []),
"api": (
"google/protobuf/api.proto",
"src/google/protobuf/api.proto",
[
"source_context",
"type",
],
),
"compiler_plugin": (
"google/protobuf/compiler/plugin.proto",
"src/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", []),
"descriptor": ("src/google/protobuf/descriptor.proto", []),
"duration": ("src/google/protobuf/duration.proto", []),
"empty": ("src/google/protobuf/empty.proto", []),
"field_mask": ("src/google/protobuf/field_mask.proto", []),
"source_context": ("src/google/protobuf/source_context.proto", []),
"struct": ("src/google/protobuf/struct.proto", []),
"timestamp": ("src/google/protobuf/timestamp.proto", []),
"type": (
"google/protobuf/type.proto",
"src/google/protobuf/type.proto",
[
"any",
"source_context",
],
),
"wrappers": ("google/protobuf/wrappers.proto", []),
"wrappers": ("src/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]
WELL_KNOWN_PROTOS = [value[0] for value in WELL_KNOWN_PROTO_MAP.values()]
filegroup(
name = "well_known_protos",
@ -303,17 +307,10 @@ cc_proto_library(
# )
################################################################################
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]],
strip_import_prefix = "src",
visibility = ["//visibility:public"],
deps = [dep + "_proto" for dep in proto[1][1]],
) for proto in WELL_KNOWN_PROTO_MAP.items()]
@ -410,25 +407,7 @@ cc_library(
],
copts = COPTS,
includes = ["src/"],
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": [],
}),
linkopts = LINK_OPTS,
visibility = ["//visibility:public"],
deps = [":protobuf"],
)
@ -520,6 +499,7 @@ cc_proto_library(
COMMON_TEST_SRCS = [
# AUTOGEN(common_test_srcs)
"src/google/protobuf/arena_test_util.cc",
"src/google/protobuf/map_test_util.inc",
"src/google/protobuf/test_util.cc",
"src/google/protobuf/test_util.inc",
"src/google/protobuf/testing/file.cc",
@ -632,7 +612,7 @@ cc_test(
"src/google/protobuf/wire_format_unittest.cc",
] + select({
"//conditions:default": [
# Doesn't pass on Windows with MSVC
# AUTOGEN(non_msvc_test_srcs)
"src/google/protobuf/compiler/command_line_interface_unittest.cc",
],
":msvc": [],
@ -809,12 +789,9 @@ py_library(
name = "python_srcs",
srcs = glob(
[
"python/google/__init__.py",
"python/google/protobuf/*.py",
"python/google/protobuf/**/*.py",
"python/google/**/*.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",
@ -893,7 +870,7 @@ internal_copied_filegroup(
# 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]
COPIED_WELL_KNOWN_PROTOS = ["python/" + s[4:] for s in WELL_KNOWN_PROTOS]
py_proto_library(
name = "protobuf_python",
@ -911,7 +888,7 @@ py_proto_library(
py_extra_srcs = glob(["python/**/__init__.py"]),
py_libs = [
":python_srcs",
"//external:six",
"@six//:six",
],
srcs_version = "PY2AND3",
visibility = ["//visibility:public"],
@ -1243,3 +1220,20 @@ cc_binary(
":text_format_conformance_suite",
],
)
sh_test(
name = "build_files_updated_unittest",
srcs = [
"build_files_updated_unittest.sh",
],
data = [
"BUILD",
"cmake/extract_includes.bat.in",
"cmake/libprotobuf.cmake",
"cmake/libprotobuf-lite.cmake",
"cmake/libprotoc.cmake",
"cmake/tests.cmake",
"src/Makefile.am",
"update_file_lists.sh",
],
)

@ -1,3 +1,127 @@
2019-09-03 version 3.10.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
C++
* Switch the proto parser to the faster MOMI parser.
* Properly escape Struct keys in the proto3 JSON serializer.
* Fix crash on uninitialized map entries.
* Informed the compiler of has-bit invariant to produce better code
* Unused imports of files defining descriptor extensions will now be reported
* Add proto2::util::RemoveSubranges to remove multiple subranges in linear time.
* Added BaseTextGenerator::GetCurrentIndentationSize()
* Made implicit weak fields compatible with the Apple linker
* Support 32 bit values for ProtoStreamObjectWriter to Struct.
* Removed the internal-only header coded_stream_inl.h and the internal-only methods defined there.
* Enforced no SWIG wrapping of descriptor_database.h (other headers already had this restriction).
* Implementation of the equivalent of the MOMI parser for serialization. This removes one of the two serialization routines, by making the fast array serialization routine completely general. SerializeToCodedStream can now be implemented in terms of the much much faster array serialization. The array serialization regresses slightly, but when array serialization is not possible this wins big.
* Do not convert unknown field name to snake case to accurately report error.
* Fix a UBSAN warnings. (#6333)
* Add podspec for C++ (#6404)
* protoc: fix source code info location for missing label (#6436)
* C++ Add move constructor for Reflection's SetString (#6477)
Java
* Call loadDescriptor outside of synchronized block to remove one possible source of deadlock.
* Have oneof enums implement a separate interface (other than EnumLite) for clarity.
* Opensource Android Memory Accessors
* Update TextFormat to make use of the new TypeRegistry.
* Support getFieldBuilder and getRepeatedFieldBuilder in ExtendableBuilder
* Update JsonFormat to make use of the new TypeRegistry.
* Add proguard config generator for GmmBenchmarkSuiteLite.
* Change ProtobufArrayList to use Object[] instead of ArrayList for 5-10% faster parsing
* Implement ProtobufArrayList.add(E) for 20% (5%-40%) faster overall protolite2 parsing
* Make a copy of JsonFormat.TypeRegistry at the protobuf top level package. This will eventually replace JsonFormat.TypeRegistry.
* Fix javadoc warnings in generated files (#6231)
* Java: Add Automatic-Module-Name entries to the Manifest (#6568)
Python
* Add descriptor methods in descriptor_pool are deprecated.
* Uses explicit imports to prevent multithread test failures in py3.
* Added __delitem__ for Python extension dict
* Update six version to 1.12.0 and fix legacy_create_init issue (#6391)
JavaScript
* Remove deprecated boolean option to getResultBase64String().
* Fix sint64 zig-zag encoding.
* Simplify hash64 string conversion to avoid DIGIT array. Should reduce overhead if these functions aren't used, and be more efficient by avoiding linear array searches.
* Change the parameter types of binaryReaderFn in ExtensionFieldBinaryInfo to (number, ?, ?).
* Create dates.ts and time_of_days.ts to mirror Java versions. This is a near-identical conversion of c.g.type.util.{Dates,TimeOfDays} respectively.
* Migrate moneys to TypeScript.
PHP
* Fix incorrect leap day for Timestamp (#6696)
* Initialize well known type values (#6713)
Ruby
* Fix scope resolution for Google namespace (#5878)
* Support hashes for struct initializers (#5716)
* Optimized away the creation of empty string objects. (#6502)
* Roll forward Ruby upb changes now that protobuf Ruby build is fixed (#5866)
* Optimized layout_mark() for Ruby (#6521)
* Optimization for layout_init() (#6547)
* Fix for GC of Ruby map frames. (#6533)
* Fixed leap year handling by reworking upb_mktime() -> upb_timegm(). (#6695)
Objective C
* Remove OSReadLittle* due to alignment requirements (#6678)
* Don't use unions and instead use memcpy for the type swaps. (#6672)
Other
* Override CocoaPods module to lowercase (#6464)
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++

@ -68,9 +68,12 @@ csharp_EXTRA_DIST= \
csharp/protos/map_unittest_proto3.proto \
csharp/protos/unittest_custom_options_proto3.proto \
csharp/protos/unittest_import_public_proto3.proto \
csharp/protos/unittest_import_public.proto \
csharp/protos/unittest_import_proto3.proto \
csharp/protos/unittest_import.proto \
csharp/protos/unittest_issues.proto \
csharp/protos/unittest_proto3.proto \
csharp/protos/unittest.proto \
csharp/src/AddressBook/AddPerson.cs \
csharp/src/AddressBook/Addressbook.cs \
csharp/src/AddressBook/AddressBook.csproj \
@ -100,9 +103,11 @@ csharp_EXTRA_DIST= \
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/ExtensionSetTest.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/GeneratedMessageTest.Proto2.cs \
csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj \
csharp/src/Google.Protobuf.Test/IssuesTest.cs \
csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs \
@ -119,13 +124,17 @@ csharp_EXTRA_DIST= \
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/TestMessagesProto2.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/UnittestImportPublic.cs \
csharp/src/Google.Protobuf.Test/TestProtos/UnittestImport.cs \
csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs \
csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs \
csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs \
csharp/src/Google.Protobuf.Test/TestProtos/Unittest.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 \
@ -339,6 +348,7 @@ java_EXTRA_DIST=
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/TypeRegistry.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 \
@ -435,6 +445,7 @@ java_EXTRA_DIST=
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/TypeRegistryTest.java \
java/core/src/test/java/com/google/protobuf/UnknownEnumValueTest.java \
java/core/src/test/java/com/google/protobuf/UnknownFieldSetTest.java \
java/core/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java \
@ -1228,14 +1239,13 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
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/six.BUILD \
third_party/zlib.BUILD \
util/python/BUILD

@ -0,0 +1,42 @@
Pod::Spec.new do |s|
s.name = 'Protobuf-C++'
s.version = '3.11.0-rc0'
s.summary = 'Protocol Buffers v3 runtime library for C++.'
s.homepage = 'https://github.com/google/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',
:tag => "v#{s.version}" }
s.source_files = 'src/google/protobuf/*.{h,cc,inc}',
'src/google/protobuf/stubs/*.{h,cc}',
'src/google/protobuf/io/*.{h,cc}',
'src/google/protobuf/util/*.{h,cc}',
'src/google/protobuf/util/internal/*.{h,cc}'
# Excluding all the tests in the directories above
s.exclude_files = 'src/google/**/*_test.{h,cc,inc}',
'src/google/**/*_unittest.{h,cc}',
'src/google/protobuf/test_util*.{h,cc}',
'src/google/protobuf/map_lite_test_util.{h,cc}',
'src/google/protobuf/map_test_util*.{h,cc,inc}'
s.header_mappings_dir = 'src'
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.pod_target_xcconfig = {
# Do not let src/google/protobuf/stubs/time.h override system API
'USE_HEADERMAP' => 'NO',
'ALWAYS_SEARCH_USER_PATHS' => 'NO',
# Configure tool is not being used for Xcode. When building, assume pthread is supported.
'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "HAVE_PTHREAD=1"',
}
end

@ -5,13 +5,14 @@
# dependent projects use the :git notation to refer to the library.
Pod::Spec.new do |s|
s.name = 'Protobuf'
s.version = '3.9.0-rc1'
s.version = '3.11.0-rc0'
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
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.module_name = 'protobuf'
s.source = { :git => 'https://github.com/protocolbuffers/protobuf.git',
:tag => "v#{s.version}" }

@ -1,30 +1,20 @@
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()
local_repository(
name = "com_google_protobuf_examples",
path = "examples",
)
new_local_repository(
local_repository(
name = "submodule_gmock",
build_file = "@//:third_party/googletest/BUILD.bazel",
path = "third_party/googletest",
)
http_archive(
name = "six_archive",
build_file = "@//:six.BUILD",
sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a",
urls = ["https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55"],
)
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//:protobuf_deps.bzl", "protobuf_deps")
http_archive(
name = "bazel_skylib",
sha256 = "bbccf674aa441c266df9894182d80de104cabd19be98be002f6d478aaa31574d",
strip_prefix = "bazel-skylib-2169ae1c374aab4a09aa90e65efe1a3aad4e279b",
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/2169ae1c374aab4a09aa90e65efe1a3aad4e279b.tar.gz"],
)
# Load common dependencies.
protobuf_deps()
bind(
name = "python_headers",
@ -41,11 +31,6 @@ bind(
actual = "@submodule_gmock//:gtest_main",
)
bind(
name = "six",
actual = "@six_archive//:six",
)
maven_jar(
name = "guava_maven",
artifact = "com.google.guava:guava:18.0",

@ -598,6 +598,12 @@ js: js-benchmark
############ JS RULE END #############
EXTRA_DIST = \
$(benchmarks_protoc_inputs_benchmark_wrapper) \
$(benchmarks_protoc_inputs) \
$(benchmarks_protoc_inputs_proto2) \
google_size.proto
MAINTAINERCLEANFILES = \
Makefile.in

@ -0,0 +1,62 @@
#!/bin/bash
# This script verifies that BUILD files and cmake files are in sync with src/Makefile.am
set -eo pipefail
if [ "$(uname)" != "Linux" ]; then
echo "build_files_updated_unittest only supported on Linux. Skipping..."
exit 0
fi
# Keep in sync with files needed by update_file_lists.sh
generated_files=(
"BUILD"
"cmake/extract_includes.bat.in"
"cmake/libprotobuf-lite.cmake"
"cmake/libprotobuf.cmake"
"cmake/libprotoc.cmake"
"cmake/tests.cmake"
"src/Makefile.am"
)
# If we're running in Bazel, use the Bazel-provided temp-dir.
if [ -n "${TEST_TMPDIR}" ]; then
# Env-var TEST_TMPDIR is set, assume that this is Bazel.
# Bazel may have opinions whether we are allowed to delete TEST_TMPDIR.
test_root="${TEST_TMPDIR}/build_files_updated_unittest"
mkdir "${test_root}"
else
# Seems like we're not executed by Bazel.
test_root=$(mktemp -d)
fi
# From now on, fail if there are any unbound variables.
set -u
# Remove artifacts after test is finished.
function cleanup {
rm -rf "${test_root}"
}
trap cleanup EXIT
# Create golden dir and add snapshot of current state.
golden_dir="${test_root}/golden"
mkdir -p "${golden_dir}/cmake" "${golden_dir}/src"
for file in ${generated_files[@]}; do
cp "${file}" "${golden_dir}/${file}"
done
# Create test dir, copy current state into it, and execute update script.
test_dir="${test_root}/test"
cp -R "${golden_dir}" "${test_dir}"
cp "update_file_lists.sh" "${test_dir}/update_file_lists.sh"
chmod +x "${test_dir}/update_file_lists.sh"
cd "${test_root}/test"
bash "${test_dir}/update_file_lists.sh"
# Test whether there are any differences
for file in ${generated_files[@]}; do
diff "${golden_dir}/${file}" "${test_dir}/${file}"
done

@ -199,7 +199,7 @@ if (MSVC)
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)
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221")
# Configure Resource Compiler
enable_language(RC)

@ -13,13 +13,13 @@ Environment Setup
Open the appropriate *Command Prompt* from the *Start* menu.
For example *VS2013 x64 Native Tools Command Prompt*:
For example *x86 Native Tools Command Prompt for VS 2019*:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64>
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional>
Change to your working directory:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64>cd C:\Path\to
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional>cd C:\Path\to
C:\Path\to>
Where *C:\Path\to* is path to your real working directory.
@ -121,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 14 2015 Win64" ^
C:\Path\to\protobuf\cmake\build\solution>cmake -G "Visual Studio 16 2019" ^
-DCMAKE_INSTALL_PREFIX=../../../../install ^
../..
@ -130,8 +130,8 @@ 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.
To make a *Visual Studio* file for Visual Studio 16 2019, create the *Visual Studio*
solution file above and edit the CMakeCache file.
C:Path\to\protobuf\cmake\build\solution\CMakeCache

@ -56,6 +56,7 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\implicit_weak_message
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
@ -89,9 +90,9 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\casts.h" includ
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\io_win32.h" include\google\protobuf\stubs\io_win32.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\map_util.h" include\google\protobuf\stubs\map_util.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

@ -10,7 +10,7 @@ set(libprotobuf_lite_files
${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.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

@ -132,7 +132,6 @@ set(tests_files
${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
@ -203,12 +202,21 @@ set(tests_files
${protobuf_source_dir}/src/google/protobuf/wire_format_unittest.cc
)
set(non_msvc_tests_files
${protobuf_source_dir}/src/google/protobuf/compiler/command_line_interface_unittest.cc
)
set(all_tests_files
${tests_files}
${non_msvc_tests_files}
)
if(protobuf_ABSOLUTE_TEST_PLUGIN_PATH)
add_compile_options(-DGOOGLE_PROTOBUF_TEST_PLUGIN_PATH="$<TARGET_FILE:test_plugin>")
endif()
if(MINGW)
set_source_files_properties(${tests_files} PROPERTIES COMPILE_FLAGS "-Wno-narrowing")
set_source_files_properties(${all_tests_files} PROPERTIES COMPILE_FLAGS "-Wno-narrowing")
# required for tests on MinGW Win64
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
@ -218,7 +226,7 @@ if(MINGW)
endif()
add_executable(tests ${tests_files} ${common_test_files} ${tests_proto_files} ${lite_test_proto_files})
add_executable(tests ${all_tests_files} ${common_test_files} ${tests_proto_files} ${lite_test_proto_files})
target_link_libraries(tests libprotoc libprotobuf gmock_main)
set(test_plugin_files

@ -17,7 +17,7 @@ AC_PREREQ(2.59)
# 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.9.0-rc-1],[protobuf@googlegroups.com],[protobuf])
AC_INIT([Protocol Buffers],[3.11.0-rc-0],[protobuf@googlegroups.com],[protobuf])
AM_MAINTAINER_MODE([enable])

@ -347,9 +347,6 @@ test_csharp: protoc_middleman conformance-test-runner conformance-csharp
test_ruby: protoc_middleman conformance-test-runner $(other_language_protoc_outputs)
RUBYLIB=../ruby/lib:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_ruby.txt --text_format_failure_list text_format_failure_list_ruby.txt ./conformance_ruby.rb
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

@ -149,24 +149,154 @@ 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) );
string GetDefaultValue(FieldDescriptor::Type type) {
switch (type) {
case FieldDescriptor::TYPE_INT32:
case FieldDescriptor::TYPE_INT64:
case FieldDescriptor::TYPE_UINT32:
case FieldDescriptor::TYPE_UINT64:
case FieldDescriptor::TYPE_ENUM:
case FieldDescriptor::TYPE_BOOL:
return varint(0);
case FieldDescriptor::TYPE_SINT32:
return zz32(0);
case FieldDescriptor::TYPE_SINT64:
return zz64(0);
case FieldDescriptor::TYPE_FIXED32:
case FieldDescriptor::TYPE_SFIXED32:
return u32(0);
case FieldDescriptor::TYPE_FIXED64:
case FieldDescriptor::TYPE_SFIXED64:
return u64(0);
case FieldDescriptor::TYPE_FLOAT:
return flt(0);
case FieldDescriptor::TYPE_DOUBLE:
return dbl(0);
case FieldDescriptor::TYPE_STRING:
case FieldDescriptor::TYPE_BYTES:
case FieldDescriptor::TYPE_MESSAGE:
return delim("");
default:
return "";
}
return "";
}
string GetNonDefaultValue(FieldDescriptor::Type type) {
switch (type) {
case FieldDescriptor::TYPE_INT32:
case FieldDescriptor::TYPE_INT64:
case FieldDescriptor::TYPE_UINT32:
case FieldDescriptor::TYPE_UINT64:
case FieldDescriptor::TYPE_ENUM:
case FieldDescriptor::TYPE_BOOL:
return varint(1);
case FieldDescriptor::TYPE_SINT32:
return zz32(1);
case FieldDescriptor::TYPE_SINT64:
return zz64(1);
case FieldDescriptor::TYPE_FIXED32:
case FieldDescriptor::TYPE_SFIXED32:
return u32(1);
case FieldDescriptor::TYPE_FIXED64:
case FieldDescriptor::TYPE_SFIXED64:
return u64(1);
case FieldDescriptor::TYPE_FLOAT:
return flt(1);
case FieldDescriptor::TYPE_DOUBLE:
return dbl(1);
case FieldDescriptor::TYPE_STRING:
case FieldDescriptor::TYPE_BYTES:
return delim("a");
case FieldDescriptor::TYPE_MESSAGE:
return delim(cat(tag(1, WireFormatLite::WIRETYPE_VARINT), varint(1234)));
default:
return "";
}
return "";
}
#define UNKNOWN_FIELD 666
const FieldDescriptor* GetFieldForType(FieldDescriptor::Type type,
bool repeated, bool is_proto3) {
enum class Packed {
UNSPECIFIED = 0,
TRUE = 1,
FALSE = 2,
};
const FieldDescriptor* GetFieldForType(FieldDescriptor::Type type,
bool repeated, bool is_proto3,
Packed packed = Packed::UNSPECIFIED) {
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) {
if ((packed == Packed::TRUE && !f->is_packed()) ||
(packed == Packed::FALSE && f->is_packed())) {
continue;
}
return f;
}
}
GOOGLE_LOG(FATAL) << "Couldn't find field with type " << (int)type;
string packed_string = "";
const string repeated_string = repeated ? "Repeated " : "Singular ";
const string proto_string = is_proto3 ? "Proto3" : "Proto2";
if (packed == Packed::TRUE) {
packed_string = "Packed ";
}
if (packed == Packed::FALSE) {
packed_string = "Unpacked ";
}
GOOGLE_LOG(FATAL) << "Couldn't find field with type: "
<< repeated_string.c_str() << packed_string.c_str()
<< FieldDescriptor::TypeName(type) << " for "
<< proto_string.c_str();
return nullptr;
}
const FieldDescriptor* GetFieldForMapType(FieldDescriptor::Type key_type,
FieldDescriptor::Type value_type,
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->is_map()) {
const Descriptor* map_entry = f->message_type();
const FieldDescriptor* key = map_entry->field(0);
const FieldDescriptor* value = map_entry->field(1);
if (key->type() == key_type && value->type() == value_type) {
return f;
}
}
}
const string proto_string = is_proto3 ? "Proto3" : "Proto2";
GOOGLE_LOG(FATAL) << "Couldn't find map field with type: "
<< FieldDescriptor::TypeName(key_type) << " and "
<< FieldDescriptor::TypeName(key_type) << " for "
<< proto_string.c_str();
return nullptr;
}
const FieldDescriptor* GetFieldForOneofType(FieldDescriptor::Type type,
bool is_proto3,
bool exclusive = false) {
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->containing_oneof() && ((f->type() == type) ^ exclusive)) {
return f;
}
}
const string proto_string = is_proto3 ? "Proto3" : "Proto2";
GOOGLE_LOG(FATAL) << "Couldn't find oneof field with type: "
<< FieldDescriptor::TypeName(type) << " for "
<< proto_string.c_str();
return nullptr;
}
@ -187,6 +317,35 @@ std::unique_ptr<Message> NewTestMessage(bool is_proto3) {
return prototype;
}
bool IsProto3Default(FieldDescriptor::Type type, const string& binary_data) {
switch (type) {
case FieldDescriptor::TYPE_DOUBLE:
return binary_data == dbl(0);
case FieldDescriptor::TYPE_FLOAT:
return binary_data == flt(0);
case FieldDescriptor::TYPE_BOOL:
case FieldDescriptor::TYPE_INT64:
case FieldDescriptor::TYPE_UINT64:
case FieldDescriptor::TYPE_INT32:
case FieldDescriptor::TYPE_UINT32:
case FieldDescriptor::TYPE_SINT32:
case FieldDescriptor::TYPE_SINT64:
case FieldDescriptor::TYPE_ENUM:
return binary_data == varint(0);
case FieldDescriptor::TYPE_FIXED64:
case FieldDescriptor::TYPE_SFIXED64:
return binary_data == u64(0);
case FieldDescriptor::TYPE_FIXED32:
case FieldDescriptor::TYPE_SFIXED32:
return binary_data == u32(0);
case FieldDescriptor::TYPE_STRING:
case FieldDescriptor::TYPE_BYTES:
return binary_data == delim("");
default:
return false;
}
}
} // anonymous namespace
namespace google {
@ -375,12 +534,20 @@ void BinaryAndJsonConformanceSuite::RunValidProtobufTest(
void BinaryAndJsonConformanceSuite::RunValidBinaryProtobufTest(
const string& test_name, ConformanceLevel level,
const string& input_protobuf, bool is_proto3) {
RunValidBinaryProtobufTest(test_name, level, input_protobuf, input_protobuf,
is_proto3);
}
void BinaryAndJsonConformanceSuite::RunValidBinaryProtobufTest(
const string& test_name, ConformanceLevel level,
const string& input_protobuf, const string& expected_protobuf,
bool is_proto3) {
std::unique_ptr<Message> prototype = NewTestMessage(is_proto3);
ConformanceRequestSetting setting(
level, conformance::PROTOBUF, conformance::PROTOBUF,
conformance::BINARY_TEST,
*prototype, test_name, input_protobuf);
RunValidBinaryInputTest(setting, input_protobuf);
RunValidBinaryInputTest(setting, expected_protobuf, true);
}
void BinaryAndJsonConformanceSuite::RunValidProtobufTestWithMessage(
@ -494,7 +661,6 @@ void BinaryAndJsonConformanceSuite::ExpectSerializeFailureForJson(
}
}
//TODO: proto2?
void BinaryAndJsonConformanceSuite::TestPrematureEOFForType(
FieldDescriptor::Type type) {
// Incomplete values for each wire type.
@ -594,31 +760,475 @@ void BinaryAndJsonConformanceSuite::TestValidDataForType(
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);
// Test singular data for singular fields.
for (size_t i = 0; i < values.size(); i++) {
string proto = cat(tag(field->number(), wire_type), values[i].first);
// In proto3, default primitive fields should not be encoded.
string expected_proto =
is_proto3 && IsProto3Default(field->type(), values[i].second)
? ""
: cat(tag(field->number(), wire_type), values[i].second);
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(expected_proto);
string text = test_message->DebugString();
RunValidProtobufTest(StrCat("ValidDataScalar", type_name, "[", i, "]"),
REQUIRED, proto, text, is_proto3);
RunValidBinaryProtobufTest(
StrCat("ValidDataScalarBinary", type_name, "[", i, "]"), RECOMMENDED,
proto, expected_proto, is_proto3);
}
// Test repeated data for singular fields.
// For scalar message fields, repeated values are merged, which is tested
// separately.
if (type != FieldDescriptor::TYPE_MESSAGE) {
string proto;
for (size_t i = 0; i < values.size(); i++) {
proto += cat(tag(field->number(), wire_type), values[i].first);
}
string expected_proto =
cat(tag(field->number(), wire_type), values.back().second);
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(expected_proto);
string text = test_message->DebugString();
RunValidProtobufTest("RepeatedScalarSelectsLast" + type_name, REQUIRED,
proto, text, is_proto3);
}
// Test repeated fields.
if (FieldDescriptor::IsTypePackable(type)) {
const FieldDescriptor* packed_field =
GetFieldForType(type, true, is_proto3, Packed::TRUE);
const FieldDescriptor* unpacked_field =
GetFieldForType(type, true, is_proto3, Packed::FALSE);
string default_proto_packed;
string default_proto_unpacked;
string default_proto_packed_expected;
string default_proto_unpacked_expected;
string packed_proto_packed;
string packed_proto_unpacked;
string packed_proto_expected;
string unpacked_proto_packed;
string unpacked_proto_unpacked;
string unpacked_proto_expected;
for (size_t i = 0; i < values.size(); i++) {
default_proto_unpacked +=
cat(tag(rep_field->number(), wire_type), values[i].first);
default_proto_unpacked_expected +=
cat(tag(rep_field->number(), wire_type), values[i].second);
default_proto_packed += values[i].first;
default_proto_packed_expected += values[i].second;
packed_proto_unpacked +=
cat(tag(packed_field->number(), wire_type), values[i].first);
packed_proto_packed += values[i].first;
packed_proto_expected += values[i].second;
unpacked_proto_unpacked +=
cat(tag(unpacked_field->number(), wire_type), values[i].first);
unpacked_proto_packed += values[i].first;
unpacked_proto_expected +=
cat(tag(unpacked_field->number(), wire_type), values[i].second);
}
default_proto_packed = cat(
tag(rep_field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(default_proto_packed));
default_proto_packed_expected = cat(
tag(rep_field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(default_proto_packed_expected));
packed_proto_packed = cat(tag(packed_field->number(),
WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(packed_proto_packed));
packed_proto_expected =
cat(tag(packed_field->number(),
WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(packed_proto_expected));
unpacked_proto_packed =
cat(tag(unpacked_field->number(),
WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(unpacked_proto_packed));
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(default_proto_packed_expected);
string text = test_message->DebugString();
// Ensures both packed and unpacked data can be parsed.
RunValidProtobufTest(
StrCat("ValidDataRepeated", type_name, ".UnpackedInput"), REQUIRED,
default_proto_unpacked, text, is_proto3);
RunValidProtobufTest(
StrCat("ValidDataRepeated", type_name, ".PackedInput"), REQUIRED,
default_proto_packed, text, is_proto3);
// proto2 should encode as unpacked by default and proto3 should encode as
// packed by default.
string expected_proto = rep_field->is_packed()
? default_proto_packed_expected
: default_proto_unpacked_expected;
RunValidBinaryProtobufTest(StrCat("ValidDataRepeated", type_name,
".UnpackedInput.DefaultOutput"),
RECOMMENDED, default_proto_unpacked,
expected_proto, is_proto3);
RunValidBinaryProtobufTest(
StrCat("ValidDataRepeated", type_name, ".PackedInput.DefaultOutput"),
RECOMMENDED, default_proto_packed, expected_proto, is_proto3);
RunValidBinaryProtobufTest(
StrCat("ValidDataRepeated", type_name, ".UnpackedInput.PackedOutput"),
RECOMMENDED, packed_proto_unpacked, packed_proto_expected, is_proto3);
RunValidBinaryProtobufTest(
StrCat("ValidDataRepeated", type_name, ".PackedInput.PackedOutput"),
RECOMMENDED, packed_proto_packed, packed_proto_expected, is_proto3);
RunValidBinaryProtobufTest(StrCat("ValidDataRepeated", type_name,
".UnpackedInput.UnpackedOutput"),
RECOMMENDED, unpacked_proto_unpacked,
unpacked_proto_expected, is_proto3);
RunValidBinaryProtobufTest(
StrCat("ValidDataRepeated", type_name, ".PackedInput.UnpackedOutput"),
RECOMMENDED, unpacked_proto_packed, unpacked_proto_expected,
is_proto3);
} else {
string proto;
string expected_proto;
for (size_t i = 0; i < values.size(); i++) {
proto += cat(tag(rep_field->number(), wire_type), values[i].first);
expected_proto +=
cat(tag(rep_field->number(), wire_type), values[i].second);
}
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(expected_proto);
string text = test_message->DebugString();
RunValidProtobufTest(StrCat("ValidDataRepeated", type_name), REQUIRED,
proto, text, is_proto3);
}
}
}
void BinaryAndJsonConformanceSuite::TestValidDataForRepeatedScalarMessage() {
std::vector<std::string> values = {
delim(cat(
tag(2, WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(cat(tag(1, WireFormatLite::WIRETYPE_VARINT), varint(1234),
tag(2, WireFormatLite::WIRETYPE_VARINT), varint(1234),
tag(31, WireFormatLite::WIRETYPE_VARINT), varint(1234))))),
delim(cat(
tag(2, WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(cat(tag(1, WireFormatLite::WIRETYPE_VARINT), varint(4321),
tag(3, WireFormatLite::WIRETYPE_VARINT), varint(4321),
tag(31, WireFormatLite::WIRETYPE_VARINT), varint(4321))))),
};
const std::string expected =
R"({
corecursive: {
optional_int32: 4321,
optional_int64: 1234,
optional_uint32: 4321,
repeated_int32: [1234, 4321],
}
})";
for (int is_proto3 = 0; is_proto3 < 2; is_proto3++) {
string proto;
string text = field->name() + ": " + values.back().second;
const FieldDescriptor* field =
GetFieldForType(FieldDescriptor::TYPE_MESSAGE, false, is_proto3);
for (size_t i = 0; i < values.size(); i++) {
proto += cat(tag(field->number(), wire_type), values[i].first);
proto +=
cat(tag(field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
values[i]);
}
RunValidProtobufTest("RepeatedScalarSelectsLast" + type_name, REQUIRED,
proto, text, is_proto3);
proto.clear();
text.clear();
RunValidProtobufTest("RepeatedScalarMessageMerge", REQUIRED, proto,
field->name() + ": " + expected, is_proto3);
}
}
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 + " ";
void BinaryAndJsonConformanceSuite::TestValidDataForMapType(
FieldDescriptor::Type key_type, FieldDescriptor::Type value_type) {
const string key_type_name =
UpperCase(string(".") + FieldDescriptor::TypeName(key_type));
const string value_type_name =
UpperCase(string(".") + FieldDescriptor::TypeName(value_type));
WireFormatLite::WireType key_wire_type = WireFormatLite::WireTypeForFieldType(
static_cast<WireFormatLite::FieldType>(key_type));
WireFormatLite::WireType value_wire_type =
WireFormatLite::WireTypeForFieldType(
static_cast<WireFormatLite::FieldType>(value_type));
string key1_data = cat(tag(1, key_wire_type), GetDefaultValue(key_type));
string value1_data =
cat(tag(2, value_wire_type), GetDefaultValue(value_type));
string key2_data = cat(tag(1, key_wire_type), GetNonDefaultValue(key_type));
string value2_data =
cat(tag(2, value_wire_type), GetNonDefaultValue(value_type));
for (int is_proto3 = 0; is_proto3 < 2; is_proto3++) {
const FieldDescriptor* field =
GetFieldForMapType(key_type, value_type, is_proto3);
{
// Tests map with default key and value.
string proto =
cat(tag(field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(cat(key1_data, value1_data)));
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(proto);
string text = test_message->DebugString();
RunValidProtobufTest(
StrCat("ValidDataMap", key_type_name, value_type_name, ".Default"),
REQUIRED, proto, text, is_proto3);
}
{
// Tests map with missing default key and value.
string proto =
cat(tag(field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(""));
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(proto);
string text = test_message->DebugString();
RunValidProtobufTest(StrCat("ValidDataMap", key_type_name,
value_type_name, ".MissingDefault"),
REQUIRED, proto, text, is_proto3);
}
{
// Tests map with non-default key and value.
string proto =
cat(tag(field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(cat(key2_data, value2_data)));
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(proto);
string text = test_message->DebugString();
RunValidProtobufTest(
StrCat("ValidDataMap", key_type_name, value_type_name, ".NonDefault"),
REQUIRED, proto, text, is_proto3);
}
{
// Tests map with unordered key and value.
string proto =
cat(tag(field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(cat(value2_data, key2_data)));
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(proto);
string text = test_message->DebugString();
RunValidProtobufTest(
StrCat("ValidDataMap", key_type_name, value_type_name, ".Unordered"),
REQUIRED, proto, text, is_proto3);
}
RunValidProtobufTest("ValidDataRepeated" + type_name, REQUIRED,
{
// Tests map with duplicate key.
string proto1 =
cat(tag(field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(cat(key2_data, value1_data)));
string proto2 =
cat(tag(field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(cat(key2_data, value2_data)));
string proto = cat(proto1, proto2);
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(proto2);
string text = test_message->DebugString();
RunValidProtobufTest(StrCat("ValidDataMap", key_type_name,
value_type_name, ".DuplicateKey"),
REQUIRED, proto, text, is_proto3);
}
{
// Tests map with duplicate key in map entry.
string proto =
cat(tag(field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(cat(key1_data, key2_data, value2_data)));
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(proto);
string text = test_message->DebugString();
RunValidProtobufTest(StrCat("ValidDataMap", key_type_name,
value_type_name, ".DuplicateKeyInMapEntry"),
REQUIRED, proto, text, is_proto3);
}
{
// Tests map with duplicate value in map entry.
string proto =
cat(tag(field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(cat(key2_data, value1_data, value2_data)));
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(proto);
string text = test_message->DebugString();
RunValidProtobufTest(StrCat("ValidDataMap", key_type_name,
value_type_name, ".DuplicateValueInMapEntry"),
REQUIRED, proto, text, is_proto3);
}
}
}
void BinaryAndJsonConformanceSuite::TestOverwriteMessageValueMap() {
string key_data =
cat(tag(1, WireFormatLite::WIRETYPE_LENGTH_DELIMITED), delim(""));
string field1_data = cat(tag(1, WireFormatLite::WIRETYPE_VARINT), varint(1));
string field2_data = cat(tag(2, WireFormatLite::WIRETYPE_VARINT), varint(1));
string field31_data =
cat(tag(31, WireFormatLite::WIRETYPE_VARINT), varint(1));
string submsg1_data = delim(cat(field1_data, field31_data));
string submsg2_data = delim(cat(field2_data, field31_data));
string value1_data =
cat(tag(2, WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(cat(tag(2, WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
submsg1_data)));
string value2_data =
cat(tag(2, WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(cat(tag(2, WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
submsg2_data)));
for (int is_proto3 = 0; is_proto3 < 2; is_proto3++) {
const FieldDescriptor* field = GetFieldForMapType(
FieldDescriptor::TYPE_STRING, FieldDescriptor::TYPE_MESSAGE, is_proto3);
string proto1 =
cat(tag(field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(cat(key_data, value1_data)));
string proto2 =
cat(tag(field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(cat(key_data, value2_data)));
string proto = cat(proto1, proto2);
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(proto2);
string text = test_message->DebugString();
RunValidProtobufTest("ValidDataMap.STRING.MESSAGE.MergeValue", REQUIRED,
proto, text, is_proto3);
}
}
// TODO: proto2?
void BinaryAndJsonConformanceSuite::TestValidDataForOneofType(
FieldDescriptor::Type type) {
const string type_name =
UpperCase(string(".") + FieldDescriptor::TypeName(type));
WireFormatLite::WireType wire_type = WireFormatLite::WireTypeForFieldType(
static_cast<WireFormatLite::FieldType>(type));
for (int is_proto3 = 0; is_proto3 < 2; is_proto3++) {
const FieldDescriptor* field = GetFieldForOneofType(type, is_proto3);
const string default_value =
cat(tag(field->number(), wire_type), GetDefaultValue(type));
const string non_default_value =
cat(tag(field->number(), wire_type), GetNonDefaultValue(type));
{
// Tests oneof with default value.
const string proto = default_value;
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(proto);
string text = test_message->DebugString();
RunValidProtobufTest(StrCat("ValidDataOneof", type_name, ".DefaultValue"),
REQUIRED, proto, text, is_proto3);
RunValidBinaryProtobufTest(
StrCat("ValidDataOneofBinary", type_name, ".DefaultValue"),
RECOMMENDED, proto, proto, is_proto3);
}
{
// Tests oneof with non-default value.
const string proto = non_default_value;
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(proto);
string text = test_message->DebugString();
RunValidProtobufTest(
StrCat("ValidDataOneof", type_name, ".NonDefaultValue"), REQUIRED,
proto, text, is_proto3);
RunValidBinaryProtobufTest(
StrCat("ValidDataOneofBinary", type_name, ".NonDefaultValue"),
RECOMMENDED, proto, proto, is_proto3);
}
{
// Tests oneof with multiple values of the same field.
const string proto = StrCat(default_value, non_default_value);
const string expected_proto = non_default_value;
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(expected_proto);
string text = test_message->DebugString();
RunValidProtobufTest(
StrCat("ValidDataOneof", type_name, ".MultipleValuesForSameField"),
REQUIRED, proto, text, is_proto3);
RunValidBinaryProtobufTest(StrCat("ValidDataOneofBinary", type_name,
".MultipleValuesForSameField"),
RECOMMENDED, proto, expected_proto, is_proto3);
}
{
// Tests oneof with multiple values of the different fields.
const FieldDescriptor* other_field =
GetFieldForOneofType(type, is_proto3, true);
FieldDescriptor::Type other_type = other_field->type();
WireFormatLite::WireType other_wire_type =
WireFormatLite::WireTypeForFieldType(
static_cast<WireFormatLite::FieldType>(other_type));
const string other_value =
cat(tag(other_field->number(), other_wire_type),
GetDefaultValue(other_type));
const string proto = StrCat(other_value, non_default_value);
const string expected_proto = non_default_value;
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(expected_proto);
string text = test_message->DebugString();
RunValidProtobufTest(StrCat("ValidDataOneof", type_name,
".MultipleValuesForDifferentField"),
REQUIRED, proto, text, is_proto3);
RunValidBinaryProtobufTest(StrCat("ValidDataOneofBinary", type_name,
".MultipleValuesForDifferentField"),
RECOMMENDED, proto, expected_proto, is_proto3);
}
}
}
void BinaryAndJsonConformanceSuite::TestMergeOneofMessage() {
string field1_data = cat(tag(1, WireFormatLite::WIRETYPE_VARINT), varint(1));
string field2a_data = cat(tag(2, WireFormatLite::WIRETYPE_VARINT), varint(1));
string field2b_data = cat(tag(2, WireFormatLite::WIRETYPE_VARINT), varint(1));
string field89_data =
cat(tag(89, WireFormatLite::WIRETYPE_VARINT), varint(1));
string submsg1_data =
cat(tag(2, WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(cat(field1_data, field2a_data, field89_data)));
string submsg2_data = cat(tag(2, WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(cat(field2b_data, field89_data)));
string merged_data =
cat(tag(2, WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(cat(field1_data, field2b_data, field89_data, field89_data)));
for (int is_proto3 = 0; is_proto3 < 2; is_proto3++) {
const FieldDescriptor* field =
GetFieldForOneofType(FieldDescriptor::TYPE_MESSAGE, is_proto3);
string proto1 =
cat(tag(field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(submsg1_data));
string proto2 =
cat(tag(field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(submsg2_data));
string proto = cat(proto1, proto2);
string expected_proto =
cat(tag(field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(merged_data));
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(expected_proto);
string text = test_message->DebugString();
RunValidProtobufTest("ValidDataOneof.MESSAGE.Merge", REQUIRED, proto, text,
is_proto3);
RunValidBinaryProtobufTest("ValidDataOneofBinary.MESSAGE.Merge",
RECOMMENDED, proto, expected_proto, is_proto3);
}
}
void BinaryAndJsonConformanceSuite::TestIllegalTags() {
// field num 0 is illegal
string nullfield[] = {
@ -713,89 +1323,190 @@ void BinaryAndJsonConformanceSuite::RunSuiteImpl() {
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<int32>(1LL << 33))},
{varint((1LL << 33) - 1),
std::to_string(static_cast<int32>((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<uint32>(1LL << 33))},
{varint((1LL << 33) - 1),
std::to_string(static_cast<uint32>((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)}
});
TestValidDataForType(
FieldDescriptor::TYPE_DOUBLE,
{
{dbl(0), dbl(0)},
{dbl(0.1), dbl(0.1)},
{dbl(1.7976931348623157e+308), dbl(1.7976931348623157e+308)},
{dbl(2.22507385850720138309e-308), dbl(2.22507385850720138309e-308)},
});
TestValidDataForType(
FieldDescriptor::TYPE_FLOAT,
{
{flt(0), flt(0)},
{flt(0.1), flt(0.1)},
{flt(1.00000075e-36), flt(1.00000075e-36)},
{flt(3.402823e+38), flt(3.402823e+38)}, // 3.40282347e+38
{flt(1.17549435e-38f), flt(1.17549435e-38)},
});
TestValidDataForType(FieldDescriptor::TYPE_INT64,
{
{varint(0), varint(0)},
{varint(12345), varint(12345)},
{varint(kInt64Max), varint(kInt64Max)},
{varint(kInt64Min), varint(kInt64Min)},
});
TestValidDataForType(FieldDescriptor::TYPE_UINT64,
{
{varint(0), varint(0)},
{varint(12345), varint(12345)},
{varint(kUint64Max), varint(kUint64Max)},
});
TestValidDataForType(FieldDescriptor::TYPE_INT32,
{
{varint(0), varint(0)},
{varint(12345), varint(12345)},
{longvarint(12345, 2), varint(12345)},
{longvarint(12345, 7), varint(12345)},
{varint(kInt32Max), varint(kInt32Max)},
{varint(kInt32Min), varint(kInt32Min)},
{varint(1LL << 33), varint(0)},
{varint((1LL << 33) - 1), varint(-1)},
});
TestValidDataForType(
FieldDescriptor::TYPE_UINT32,
{
{varint(0), varint(0)},
{varint(12345), varint(12345)},
{longvarint(12345, 2), varint(12345)},
{longvarint(12345, 7), varint(12345)},
{varint(kUint32Max), varint(kUint32Max)}, // UINT32_MAX
{varint(1LL << 33), varint(0)},
{varint((1LL << 33) - 1), varint((1LL << 32) - 1)},
});
TestValidDataForType(FieldDescriptor::TYPE_FIXED64,
{
{u64(0), u64(0)},
{u64(12345), u64(12345)},
{u64(kUint64Max), u64(kUint64Max)},
});
TestValidDataForType(FieldDescriptor::TYPE_FIXED32,
{
{u32(0), u32(0)},
{u32(12345), u32(12345)},
{u32(kUint32Max), u32(kUint32Max)}, // UINT32_MAX
});
TestValidDataForType(FieldDescriptor::TYPE_SFIXED64,
{
{u64(0), u64(0)},
{u64(12345), u64(12345)},
{u64(kInt64Max), u64(kInt64Max)},
{u64(kInt64Min), u64(kInt64Min)},
});
TestValidDataForType(FieldDescriptor::TYPE_SFIXED32,
{
{u32(0), u32(0)},
{u32(12345), u32(12345)},
{u32(kInt32Max), u32(kInt32Max)},
{u32(kInt32Min), u32(kInt32Min)},
});
// Bools should be serialized as 0 for false and 1 for true. Parsers should
// also interpret any nonzero value as true.
TestValidDataForType(FieldDescriptor::TYPE_BOOL,
{
{varint(0), varint(0)},
{varint(1), varint(1)},
{varint(12345678), varint(1)},
});
TestValidDataForType(FieldDescriptor::TYPE_SINT32,
{
{zz32(0), zz32(0)},
{zz32(12345), zz32(12345)},
{zz32(kInt32Max), zz32(kInt32Max)},
{zz32(kInt32Min), zz32(kInt32Min)},
});
TestValidDataForType(FieldDescriptor::TYPE_SINT64,
{
{zz64(0), zz64(0)},
{zz64(12345), zz64(12345)},
{zz64(kInt64Max), zz64(kInt64Max)},
{zz64(kInt64Min), zz64(kInt64Min)},
});
TestValidDataForType(
FieldDescriptor::TYPE_STRING,
{
{delim(""), delim("")},
{delim("Hello world!"), delim("Hello world!")},
{delim("\'\"\?\\\a\b\f\n\r\t\v"),
delim("\'\"\?\\\a\b\f\n\r\t\v")}, // escape
{delim("谷歌"), delim("谷歌")}, // Google in Chinese
{delim("\u8C37\u6B4C"), delim("谷歌")}, // unicode escape
{delim("\u8c37\u6b4c"), delim("谷歌")}, // lowercase unicode
{delim("\xF0\x9F\x98\x81"), delim("\xF0\x9F\x98\x81")}, // emoji: 😁
});
TestValidDataForType(FieldDescriptor::TYPE_BYTES,
{
{delim(""), delim("")},
{delim("\x01\x02"), delim("\x01\x02")},
{delim("\xfb"), delim("\xfb")},
});
TestValidDataForType(FieldDescriptor::TYPE_ENUM, {
{varint(0), varint(0)},
{varint(1), varint(1)},
{varint(2), varint(2)},
{varint(-1), varint(-1)},
});
TestValidDataForRepeatedScalarMessage();
TestValidDataForType(
FieldDescriptor::TYPE_MESSAGE,
{
{delim(""), delim("")},
{delim(cat(tag(1, WireFormatLite::WIRETYPE_VARINT), varint(1234))),
delim(cat(tag(1, WireFormatLite::WIRETYPE_VARINT), varint(1234)))},
});
TestValidDataForMapType(FieldDescriptor::TYPE_INT32,
FieldDescriptor::TYPE_INT32);
TestValidDataForMapType(FieldDescriptor::TYPE_INT64,
FieldDescriptor::TYPE_INT64);
TestValidDataForMapType(FieldDescriptor::TYPE_UINT32,
FieldDescriptor::TYPE_UINT32);
TestValidDataForMapType(FieldDescriptor::TYPE_UINT64,
FieldDescriptor::TYPE_UINT64);
TestValidDataForMapType(FieldDescriptor::TYPE_SINT32,
FieldDescriptor::TYPE_SINT32);
TestValidDataForMapType(FieldDescriptor::TYPE_SINT64,
FieldDescriptor::TYPE_SINT64);
TestValidDataForMapType(FieldDescriptor::TYPE_FIXED32,
FieldDescriptor::TYPE_FIXED32);
TestValidDataForMapType(FieldDescriptor::TYPE_FIXED64,
FieldDescriptor::TYPE_FIXED64);
TestValidDataForMapType(FieldDescriptor::TYPE_SFIXED32,
FieldDescriptor::TYPE_SFIXED32);
TestValidDataForMapType(FieldDescriptor::TYPE_SFIXED64,
FieldDescriptor::TYPE_SFIXED64);
TestValidDataForMapType(FieldDescriptor::TYPE_INT32,
FieldDescriptor::TYPE_FLOAT);
TestValidDataForMapType(FieldDescriptor::TYPE_INT32,
FieldDescriptor::TYPE_DOUBLE);
TestValidDataForMapType(FieldDescriptor::TYPE_BOOL,
FieldDescriptor::TYPE_BOOL);
TestValidDataForMapType(FieldDescriptor::TYPE_STRING,
FieldDescriptor::TYPE_STRING);
TestValidDataForMapType(FieldDescriptor::TYPE_STRING,
FieldDescriptor::TYPE_BYTES);
TestValidDataForMapType(FieldDescriptor::TYPE_STRING,
FieldDescriptor::TYPE_ENUM);
TestValidDataForMapType(FieldDescriptor::TYPE_STRING,
FieldDescriptor::TYPE_MESSAGE);
// Additional test to check overwriting message value map.
TestOverwriteMessageValueMap();
TestValidDataForOneofType(FieldDescriptor::TYPE_UINT32);
TestValidDataForOneofType(FieldDescriptor::TYPE_BOOL);
TestValidDataForOneofType(FieldDescriptor::TYPE_UINT64);
TestValidDataForOneofType(FieldDescriptor::TYPE_FLOAT);
TestValidDataForOneofType(FieldDescriptor::TYPE_DOUBLE);
TestValidDataForOneofType(FieldDescriptor::TYPE_STRING);
TestValidDataForOneofType(FieldDescriptor::TYPE_BYTES);
TestValidDataForOneofType(FieldDescriptor::TYPE_ENUM);
TestValidDataForOneofType(FieldDescriptor::TYPE_MESSAGE);
// Additional test to check merging oneof message.
TestMergeOneofMessage();
// 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!\"}",
@ -1978,6 +2689,10 @@ void BinaryAndJsonConformanceSuite::RunSuiteImpl() {
})",
"repeated_timestamp: {seconds: -62135596800}"
"repeated_timestamp: {seconds: 253402300799 nanos: 999999999}");
RunValidJsonTest(
"TimestampLeap", REQUIRED,
R"({"optionalTimestamp": "1993-02-10T00:00:00.000Z"})",
"optional_timestamp: {seconds: 729302400}");
RunValidJsonTest("TimestampWithPositiveOffset", REQUIRED,
R"({"optionalTimestamp": "1970-01-01T08:00:01+08:00"})",
"optional_timestamp: {seconds: 1}");

@ -63,6 +63,11 @@ class BinaryAndJsonConformanceSuite : public ConformanceTestSuite {
ConformanceLevel level,
const string& input_protobuf,
bool is_proto3);
void RunValidBinaryProtobufTest(const string& test_name,
ConformanceLevel level,
const string& input_protobuf,
const string& expected_protobuf,
bool is_proto3);
void RunValidProtobufTestWithMessage(
const string& test_name, ConformanceLevel level,
const Message *input,
@ -109,6 +114,12 @@ class BinaryAndJsonConformanceSuite : public ConformanceTestSuite {
void TestValidDataForType(
google::protobuf::FieldDescriptor::Type,
std::vector<std::pair<std::string, std::string>> values);
void TestValidDataForRepeatedScalarMessage();
void TestValidDataForMapType(google::protobuf::FieldDescriptor::Type,
google::protobuf::FieldDescriptor::Type);
void TestValidDataForOneofType(google::protobuf::FieldDescriptor::Type);
void TestMergeOneofMessage();
void TestOverwriteMessageValueMap();
std::unique_ptr<google::protobuf::util::TypeResolver>
type_resolver_;

@ -60,32 +60,6 @@ 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) {

@ -68,7 +68,8 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) {
switch (request.payloadOneOfCase) {
case ConformanceRequest_Payload_OneOfCase_GPBUnsetOneOfCase:
Die(@"Request didn't have a payload: %@", request);
response.runtimeError =
[NSString stringWithFormat:@"Request didn't have a payload: %@", request];
break;
case ConformanceRequest_Payload_OneOfCase_ProtobufPayload: {
@ -78,7 +79,10 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) {
} else if ([request.messageType isEqual:@"protobuf_test_messages.proto2.TestAllTypesProto2"]) {
msgClass = [TestAllTypesProto2 class];
} else {
Die(@"Protobuf request had an unknown message_type: %@", request.messageType);
response.runtimeError =
[NSString stringWithFormat:@"Protobuf request had an unknown message_type: %@",
request.messageType];
break;
}
NSError *error = nil;
testMessage = [msgClass parseFromData:request.protobufPayload error:&error];
@ -108,7 +112,8 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) {
switch (request.requestedOutputFormat) {
case WireFormat_GPBUnrecognizedEnumeratorValue:
case WireFormat_Unspecified:
Die(@"Unrecognized/unspecified output format: %@", request);
response.runtimeError =
[NSString stringWithFormat:@"Unrecognized/unspecified output format: %@", request];
break;
case WireFormat_Protobuf:

@ -54,6 +54,25 @@ using google::protobuf::util::MessageDifferencer;
using google::protobuf::util::Status;
using std::string;
namespace {
static string ToOctString(const string& binary_string) {
string oct_string;
for (size_t i = 0; i < binary_string.size(); i++) {
uint8_t c = binary_string.at(i);
uint8_t high = c / 64;
uint8_t mid = (c % 64) / 8;
uint8_t low = c % 8;
oct_string.push_back('\\');
oct_string.push_back('0' + high);
oct_string.push_back('0' + mid);
oct_string.push_back('0' + low);
}
return oct_string;
}
} // namespace
namespace google {
namespace protobuf {
@ -220,18 +239,18 @@ void ConformanceTestSuite::RunValidInputTest(
void ConformanceTestSuite::RunValidBinaryInputTest(
const ConformanceRequestSetting& setting,
const string& equivalent_wire_format) {
const string& equivalent_wire_format, bool require_same_wire_format) {
const ConformanceRequest& request = setting.GetRequest();
ConformanceResponse response;
RunTest(setting.GetTestName(), request, &response);
VerifyResponse(setting, equivalent_wire_format, response, true);
VerifyResponse(setting, equivalent_wire_format, response, true,
require_same_wire_format);
}
void ConformanceTestSuite::VerifyResponse(
const ConformanceRequestSetting& setting,
const string& equivalent_wire_format,
const ConformanceResponse& response,
bool need_report_success) {
const string& equivalent_wire_format, const ConformanceResponse& response,
bool need_report_success, bool require_same_wire_format) {
Message* test_message = setting.GetTestMessage();
const ConformanceRequest& request = setting.GetRequest();
const string& test_name = setting.GetTestName();
@ -270,8 +289,19 @@ void ConformanceTestSuite::VerifyResponse(
string differences;
differencer.ReportDifferencesToString(&differences);
bool check;
check = differencer.Compare(*reference_message, *test_message);
bool check = false;
if (require_same_wire_format) {
GOOGLE_DCHECK_EQ(response.result_case(),
ConformanceResponse::kProtobufPayload);
const string& protobuf_payload = response.protobuf_payload();
check = equivalent_wire_format == protobuf_payload;
differences = StrCat("Expect: ", ToOctString(equivalent_wire_format),
", but got: ", ToOctString(protobuf_payload));
} else {
check = differencer.Compare(*reference_message, *test_message);
}
if (check) {
if (need_report_success) {
ReportSuccess(test_name);

@ -38,14 +38,15 @@
#ifndef CONFORMANCE_CONFORMANCE_TEST_H
#define CONFORMANCE_CONFORMANCE_TEST_H
#include <functional>
#include <string>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/util/type_resolver.h>
#include <google/protobuf/wire_format_lite.h>
#include <functional>
#include <string>
#include <vector>
#include "conformance.pb.h"
namespace conformance {
@ -88,7 +89,13 @@ class ForkPipeRunner : public ConformanceTestRunner {
static int Run(int argc, char *argv[],
const std::vector<ConformanceTestSuite*>& suites);
ForkPipeRunner(const std::string &executable)
ForkPipeRunner(const std::string& executable,
const std::vector<string>& executable_args)
: child_pid_(-1),
executable_(executable),
executable_args_(executable_args) {}
explicit ForkPipeRunner(const std::string& executable)
: child_pid_(-1), executable_(executable) {}
virtual ~ForkPipeRunner() {}
@ -108,6 +115,7 @@ class ForkPipeRunner : public ConformanceTestRunner {
int read_fd_;
pid_t child_pid_;
std::string executable_;
const std::vector<string> executable_args_;
std::string current_test_name_;
};
@ -257,11 +265,10 @@ class ConformanceTestSuite {
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);
void VerifyResponse(const ConformanceRequestSetting& setting,
const string& equivalent_wire_format,
const conformance::ConformanceResponse& response,
bool need_report_success, bool require_same_wire_format);
void ReportSuccess(const std::string& test_name);
void ReportFailure(const string& test_name,
@ -276,7 +283,8 @@ class ConformanceTestSuite {
void RunValidInputTest(const ConformanceRequestSetting& setting,
const string& equivalent_text_format);
void RunValidBinaryInputTest(const ConformanceRequestSetting& setting,
const string& equivalent_wire_format);
const string& equivalent_wire_format,
bool require_same_wire_format = false);
void RunTest(const std::string& test_name,
const conformance::ConformanceRequest& request,

@ -195,7 +195,8 @@ int ForkPipeRunner::Run(
}
bool all_ok = true;
for (ConformanceTestSuite* suite : suites) {
char *program;
string program;
std::vector<string> program_args;
string failure_list_filename;
conformance::FailureSet failure_list;
@ -221,15 +222,15 @@ int ForkPipeRunner::Run(
UsageError();
}
} else {
if (arg != argc - 1) {
fprintf(stderr, "Too many arguments.\n");
UsageError();
program += argv[arg];
while (arg < argc) {
program_args.push_back(argv[arg]);
arg++;
}
program = argv[arg];
}
}
ForkPipeRunner runner(program);
ForkPipeRunner runner(program, program_args);
std::string output;
all_ok = all_ok &&
@ -295,8 +296,14 @@ void ForkPipeRunner::SpawnTestProgram() {
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.
std::vector<const char *> argv;
argv.push_back(executable.get());
for (int i = 0; i < executable_args_.size(); ++i) {
argv.push_back(executable_args_[i].c_str());
}
argv.push_back(nullptr);
// Never returns.
CHECK_SYSCALL(execv(executable.get(), const_cast<char **>(argv.data())));
}
}

@ -1,13 +1,114 @@
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
Recommended.Proto2.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT32.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOutput.ProtobufOutput
Required.Proto3.ProtobufInput.RepeatedScalarMessageMerge.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataMap.STRING.MESSAGE.MergeValue.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.INT32.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.INT64.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.ProtobufOutput

@ -4,17 +4,80 @@ Recommended.FieldMaskTooManyUnderscore.JsonOutput
Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput
Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput
Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter
Recommended.Proto3.ProtobufInput.ValidDataOneofBinary.MESSAGE.Merge.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOutput.ProtobufOutput
Required.Proto3.JsonInput.DoubleFieldTooSmall
Required.Proto3.JsonInput.FloatFieldTooLarge
Required.Proto3.JsonInput.FloatFieldTooSmall
Required.Proto3.JsonInput.DoubleFieldTooSmall
Required.Proto3.JsonInput.Int32FieldLeadingSpace
Required.Proto3.JsonInput.Int32FieldNotInteger
Required.Proto3.JsonInput.Int64FieldNotInteger
Required.Proto3.JsonInput.OneofFieldDuplicate
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
Required.Proto3.ProtobufInput.RepeatedScalarMessageMerge.JsonOutput
Required.Proto3.ProtobufInput.RepeatedScalarMessageMerge.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.JsonOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.JsonOutput
Required.Proto3.ProtobufInput.ValidDataScalar.FLOAT[2].JsonOutput
Required.Proto3.ProtobufInput.ValidDataOneof.MESSAGE.Merge.JsonOutput
Required.Proto3.ProtobufInput.ValidDataOneof.MESSAGE.Merge.ProtobufOutput

@ -17,10 +17,37 @@ Recommended.Proto3.JsonInput.StringFieldUnpairedLowSurrogate
Recommended.Proto3.JsonInput.TimestampHas3FractionalDigits.Validator
Recommended.Proto3.JsonInput.TimestampHas6FractionalDigits.Validator
Recommended.Proto3.ProtobufInput.OneofZeroBytes.JsonOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.ENUM[3].ProtobufOutput
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
@ -32,13 +59,50 @@ 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.RejectTopLevelNull
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
Required.Proto3.ProtobufInput.ValidDataRepeated.BYTES.JsonOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.BYTES.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.JsonOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.JsonOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.STRING.JsonOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.STRING.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataScalar.FLOAT[2].JsonOutput
Required.TimestampProtoInputTooLarge.JsonOutput
Required.TimestampProtoInputTooSmall.JsonOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOutput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataOneof.BYTES.DefaultValue.JsonOutput

@ -6,16 +6,26 @@ Recommended.Proto3.JsonInput.DoubleFieldNegativeInfinityNotQuoted
Recommended.Proto3.JsonInput.FloatFieldInfinityNotQuoted
Recommended.Proto3.JsonInput.FloatFieldNanNotQuoted
Recommended.Proto3.JsonInput.FloatFieldNegativeInfinityNotQuoted
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.BOOL[0].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.BYTES[0].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.DOUBLE[0].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.ENUM[0].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.FIXED32[0].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.FIXED64[0].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.FLOAT[0].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.INT32[0].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.INT32[6].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.INT64[0].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.SFIXED32[0].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.SFIXED64[0].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.SINT32[0].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.SINT64[0].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.STRING[0].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.UINT32[0].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.UINT32[5].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.UINT64[0].ProtobufOutput
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

@ -15,6 +15,65 @@ Recommended.Proto3.JsonInput.StringFieldUnpairedHighSurrogate
Recommended.Proto3.JsonInput.StringFieldUnpairedLowSurrogate
Recommended.Proto3.JsonInput.TimestampHas3FractionalDigits.Validator
Recommended.Proto3.JsonInput.TimestampHas6FractionalDigits.Validator
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.ENUM[3].ProtobufOutput
Required.DurationProtoInputTooLarge.JsonOutput
Required.DurationProtoInputTooSmall.JsonOutput
Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
@ -27,6 +86,12 @@ Required.Proto3.JsonInput.DurationRepeatedValue.JsonOutput
Required.Proto3.JsonInput.FloatFieldInfinity.JsonOutput
Required.Proto3.JsonInput.FloatFieldNan.JsonOutput
Required.Proto3.JsonInput.FloatFieldNegativeInfinity.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.OneofFieldDuplicate
Required.Proto3.JsonInput.OptionalBoolWrapper.JsonOutput
Required.Proto3.JsonInput.OptionalBytesWrapper.JsonOutput
@ -37,8 +102,7 @@ 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.RejectTopLevelNull
Required.Proto3.JsonInput.RepeatedBoolWrapper.JsonOutput
Required.Proto3.JsonInput.RepeatedBytesWrapper.JsonOutput
Required.Proto3.JsonInput.RepeatedDoubleWrapper.JsonOutput
@ -54,13 +118,9 @@ 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.ProtobufInput.ValidDataMap.STRING.MESSAGE.MissingDefault.JsonOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.JsonOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.JsonOutput
Required.Proto3.ProtobufInput.ValidDataScalar.FLOAT[2].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

@ -1,66 +0,0 @@
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

@ -5,7 +5,7 @@
<title>Google Protocol Buffers tools</title>
<summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
<description>See project site for more info.</description>
<version>3.9.0-rc1</version>
<version>3.11.0-rc0</version>
<authors>Google Inc.</authors>
<owners>protobuf-packages</owners>
<licenseUrl>https://github.com/protocolbuffers/protobuf/blob/master/LICENSE</licenseUrl>

@ -18,13 +18,9 @@
<PackageReference Include="NUnitLite" Version="3.6.1" />
</ItemGroup>
<!--
- Override target frameworks on non-Windows to just .NET Core
- Doing this conditionally in the initial PropertyGroup confuses
- Visual Studio.
-->
<PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
</PropertyGroup>
<!-- Needed for the net45 build to work on Unix. See https://github.com/dotnet/designs/pull/33 -->
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0-preview.2" PrivateAssets="All" />
</ItemGroup>
</Project>

@ -39,24 +39,8 @@ TEST_VERSION=3.0.0
# 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
OLD_VERSION=$1
OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/$OLD_VERSION/protoc-$OLD_VERSION-linux-x86_64.exe
echo "Running compatibility tests with $OLD_VERSION"

@ -52,8 +52,12 @@ $PROTOC -Isrc -Icsharp/protos \
csharp/protos/unittest_proto3.proto \
csharp/protos/unittest_import_proto3.proto \
csharp/protos/unittest_import_public_proto3.proto \
csharp/protos/unittest.proto \
csharp/protos/unittest_import.proto \
csharp/protos/unittest_import_public.proto \
src/google/protobuf/unittest_well_known_types.proto \
src/google/protobuf/test_messages_proto3.proto
src/google/protobuf/test_messages_proto3.proto \
src/google/protobuf/test_messages_proto2.proto
# AddressBook sample protos
$PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \

File diff suppressed because it is too large Load Diff

@ -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.
// 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.proto to test importing.
syntax = "proto2";
// We don't put this in a package within proto2 because we need to make sure
// that the generated code doesn't depend on being in the proto2 namespace.
// In test_util.h we do
// "using namespace unittest_import = protobuf_unittest_import".
package protobuf_unittest_import_proto2;
option optimize_for = SPEED;
option cc_enable_arenas = true;
option csharp_namespace = "Google.Protobuf.TestProtos.Proto2";
// Test public import
import public "unittest_import_public.proto";
message ImportMessage {
optional int32 d = 1;
}
enum ImportEnum {
IMPORT_FOO = 7;
IMPORT_BAR = 8;
IMPORT_BAZ = 9;
}
// To use an enum in a map, it must has the first value as 0.
enum ImportEnumForMap {
UNKNOWN = 0;
FOO = 1;
BAR = 2;
}

@ -0,0 +1,41 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Author: liujisi@google.com (Pherl Liu)
syntax = "proto2";
package protobuf_unittest_import_proto2;
option csharp_namespace = "Google.Protobuf.TestProtos.Proto2";
message PublicImportMessage {
optional int32 e = 1;
}

@ -48,7 +48,9 @@ namespace Google.Protobuf.Conformance
// 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(ProtobufTestMessages.Proto3.TestAllTypesProto3.Descriptor);
var typeRegistry = TypeRegistry.FromMessages(
ProtobufTestMessages.Proto3.TestAllTypesProto3.Descriptor,
ProtobufTestMessages.Proto2.TestAllTypesProto2.Descriptor);
int count = 0;
while (RunTest(input, output, typeRegistry))
@ -81,7 +83,7 @@ namespace Google.Protobuf.Conformance
private static ConformanceResponse PerformRequest(ConformanceRequest request, TypeRegistry typeRegistry)
{
ProtobufTestMessages.Proto3.TestAllTypesProto3 message;
IMessage message;
try
{
switch (request.PayloadCase)
@ -101,7 +103,13 @@ namespace Google.Protobuf.Conformance
}
else if (request.MessageType.Equals("protobuf_test_messages.proto2.TestAllTypesProto2"))
{
return new ConformanceResponse { Skipped = "CSharp doesn't support proto2" };
ExtensionRegistry registry = new ExtensionRegistry()
{
ProtobufTestMessages.Proto2.TestMessagesProto2Extensions.ExtensionInt32,
ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.MessageSetCorrectExtension1.Extensions.MessageSetExtension,
ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.MessageSetCorrectExtension2.Extensions.MessageSetExtension
};
message = ProtobufTestMessages.Proto2.TestAllTypesProto2.Parser.WithExtensionRegistry(registry).ParseFrom(request.ProtobufPayload);
}
else
{

@ -33,6 +33,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
@ -756,5 +757,52 @@ namespace Google.Protobuf.Collections
Assert.True(list1.Contains(SampleNaNs.SignallingFlipped));
Assert.False(list2.Contains(SampleNaNs.SignallingFlipped));
}
[Test]
public void Capacity_Increase()
{
// Unfortunately this case tests implementation details of RepeatedField. This is necessary
var list = new RepeatedField<int>() { 1, 2, 3 };
Assert.AreEqual(8, list.Capacity);
Assert.AreEqual(3, list.Count);
list.Capacity = 10; // Set capacity to a larger value to trigger growth
Assert.AreEqual(10, list.Capacity, "Capacity increased");
Assert.AreEqual(3, list.Count);
CollectionAssert.AreEqual(new int[] {1, 2, 3}, list.ToArray(), "We didn't lose our data in the resize");
}
[Test]
public void Capacity_Decrease()
{
var list = new RepeatedField<int>() { 1, 2, 3 };
Assert.AreEqual(8, list.Capacity);
Assert.DoesNotThrow(() => list.Capacity = 5, "Can decrease capacity if new capacity is greater than list.Count");
Assert.AreEqual(5, list.Capacity);
Assert.DoesNotThrow(() => list.Capacity = 3, "Can set capacity exactly to list.Count" );
Assert.Throws<ArgumentOutOfRangeException>(() => list.Capacity = 2, "Can't set the capacity smaller than list.Count" );
Assert.Throws<ArgumentOutOfRangeException>(() => list.Capacity = 0, "Can't set the capacity to zero" );
Assert.Throws<ArgumentOutOfRangeException>(() => list.Capacity = -1, "Can't set the capacity to negative" );
}
[Test]
public void Capacity_Zero()
{
var list = new RepeatedField<int>() { 1 };
list.RemoveAt(0);
Assert.AreEqual(0, list.Count);
Assert.AreEqual(8, list.Capacity);
Assert.DoesNotThrow(() => list.Capacity = 0, "Can set Capacity to 0");
Assert.AreEqual(0, list.Capacity);
}
}
}

@ -0,0 +1,102 @@
using Google.Protobuf.TestProtos.Proto2;
using NUnit.Framework;
using static Google.Protobuf.TestProtos.Proto2.UnittestExtensions;
namespace Google.Protobuf
{
public class ExtensionSetTest
{
[Test]
public void EmptyExtensionSet()
{
ExtensionSet<TestAllExtensions> extensions = new ExtensionSet<TestAllExtensions>();
Assert.AreEqual(0, extensions.CalculateSize());
}
[Test]
public void MergeExtensionSet()
{
ExtensionSet<TestAllExtensions> extensions = null;
ExtensionSet.Set(ref extensions, OptionalBoolExtension, true);
ExtensionSet<TestAllExtensions> other = null;
Assert.IsFalse(ExtensionSet.Has(ref other, OptionalBoolExtension));
ExtensionSet.MergeFrom(ref other, extensions);
Assert.IsTrue(ExtensionSet.Has(ref other, OptionalBoolExtension));
}
[Test]
public void TestMergeCodedInput()
{
var message = new TestAllExtensions();
message.SetExtension(OptionalBoolExtension, true);
var serialized = message.ToByteArray();
var other = TestAllExtensions.Parser
.WithExtensionRegistry(new ExtensionRegistry() { OptionalBoolExtension })
.ParseFrom(serialized);
Assert.AreEqual(message, other);
Assert.AreEqual(message.CalculateSize(), other.CalculateSize());
}
[Test]
public void TestMergeMessage()
{
var message = new TestAllExtensions();
message.SetExtension(OptionalBoolExtension, true);
var other = new TestAllExtensions();
Assert.AreNotEqual(message, other);
Assert.AreNotEqual(message.CalculateSize(), other.CalculateSize());
other.MergeFrom(message);
Assert.AreEqual(message, other);
Assert.AreEqual(message.CalculateSize(), other.CalculateSize());
}
[Test]
public void TestEquals()
{
var message = new TestAllExtensions();
message.SetExtension(OptionalBoolExtension, true);
var other = new TestAllExtensions();
Assert.AreNotEqual(message, other);
Assert.AreNotEqual(message.CalculateSize(), other.CalculateSize());
other.SetExtension(OptionalBoolExtension, true);
Assert.AreEqual(message, other);
Assert.AreEqual(message.CalculateSize(), other.CalculateSize());
}
[Test]
public void TestHashCode()
{
var message = new TestAllExtensions();
var hashCode = message.GetHashCode();
message.SetExtension(OptionalBoolExtension, true);
Assert.AreNotEqual(hashCode, message.GetHashCode());
}
[Test]
public void TestClone()
{
var message = new TestAllExtensions();
message.SetExtension(OptionalBoolExtension, true);
var other = message.Clone();
Assert.AreEqual(message, other);
Assert.AreEqual(message.CalculateSize(), message.CalculateSize());
}
}
}

@ -0,0 +1,368 @@
using Google.Protobuf.TestProtos.Proto2;
using Proto2 = Google.Protobuf.TestProtos.Proto2;
using NUnit.Framework;
using static Google.Protobuf.TestProtos.Proto2.UnittestExtensions;
namespace Google.Protobuf
{
/// <summary>
/// Tests around the generated TestAllTypes message in unittest.proto
/// </summary>
public partial class GeneratedMessageTest
{
[Test]
public void DefaultProto2Values()
{
var message = new TestAllTypes();
Assert.AreEqual(false, message.OptionalBool);
Assert.AreEqual(ByteString.Empty, message.OptionalBytes);
Assert.AreEqual(0.0, message.OptionalDouble);
Assert.AreEqual(0, message.OptionalFixed32);
Assert.AreEqual(0L, message.OptionalFixed64);
Assert.AreEqual(0.0f, message.OptionalFloat);
Assert.AreEqual(ForeignEnum.ForeignFoo, message.OptionalForeignEnum);
Assert.IsNull(message.OptionalForeignMessage);
Assert.AreEqual(ImportEnum.ImportFoo, message.OptionalImportEnum);
Assert.IsNull(message.OptionalImportMessage);
Assert.AreEqual(0, message.OptionalInt32);
Assert.AreEqual(0L, message.OptionalInt64);
Assert.AreEqual(Proto2.TestAllTypes.Types.NestedEnum.Foo, message.OptionalNestedEnum);
Assert.IsNull(message.OptionalNestedMessage);
Assert.IsNull(message.OptionalPublicImportMessage);
Assert.AreEqual(0, message.OptionalSfixed32);
Assert.AreEqual(0L, message.OptionalSfixed64);
Assert.AreEqual(0, message.OptionalSint32);
Assert.AreEqual(0L, message.OptionalSint64);
Assert.AreEqual("", message.OptionalString);
Assert.AreEqual(0U, message.OptionalUint32);
Assert.AreEqual(0UL, message.OptionalUint64);
// 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.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(Proto2.TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase);
Assert.AreEqual(0, message.OneofUint32);
Assert.AreEqual("", message.OneofString);
Assert.AreEqual(ByteString.Empty, message.OneofBytes);
Assert.IsNull(message.OneofNestedMessage);
Assert.AreEqual(true, message.DefaultBool);
Assert.AreEqual(ByteString.CopyFromUtf8("world"), message.DefaultBytes);
Assert.AreEqual("123", message.DefaultCord);
Assert.AreEqual(52e3, message.DefaultDouble);
Assert.AreEqual(47, message.DefaultFixed32);
Assert.AreEqual(48, message.DefaultFixed64);
Assert.AreEqual(51.5, message.DefaultFloat);
Assert.AreEqual(ForeignEnum.ForeignBar, message.DefaultForeignEnum);
Assert.AreEqual(ImportEnum.ImportBar, message.DefaultImportEnum);
Assert.AreEqual(41, message.DefaultInt32);
Assert.AreEqual(42, message.DefaultInt64);
Assert.AreEqual(Proto2.TestAllTypes.Types.NestedEnum.Bar, message.DefaultNestedEnum);
Assert.AreEqual(49, message.DefaultSfixed32);
Assert.AreEqual(-50, message.DefaultSfixed64);
Assert.AreEqual(-45, message.DefaultSint32);
Assert.AreEqual(46, message.DefaultSint64);
Assert.AreEqual("hello", message.DefaultString);
Assert.AreEqual("abc", message.DefaultStringPiece);
Assert.AreEqual(43, message.DefaultUint32);
Assert.AreEqual(44, message.DefaultUint64);
Assert.False(message.HasDefaultBool);
Assert.False(message.HasDefaultBytes);
Assert.False(message.HasDefaultCord);
Assert.False(message.HasDefaultDouble);
Assert.False(message.HasDefaultFixed32);
Assert.False(message.HasDefaultFixed64);
Assert.False(message.HasDefaultFloat);
Assert.False(message.HasDefaultForeignEnum);
Assert.False(message.HasDefaultImportEnum);
Assert.False(message.HasDefaultInt32);
Assert.False(message.HasDefaultInt64);
Assert.False(message.HasDefaultNestedEnum);
Assert.False(message.HasDefaultSfixed32);
Assert.False(message.HasDefaultSfixed64);
Assert.False(message.HasDefaultSint32);
Assert.False(message.HasDefaultSint64);
Assert.False(message.HasDefaultString);
Assert.False(message.HasDefaultStringPiece);
Assert.False(message.HasDefaultUint32);
Assert.False(message.HasDefaultUint64);
}
[Test]
public void DefaultExtensionValues()
{
var message = new TestAllExtensions();
Assert.AreEqual(false, message.GetExtension(OptionalBoolExtension));
Assert.AreEqual(ByteString.Empty, message.GetExtension(OptionalBytesExtension));
Assert.AreEqual(0.0, message.GetExtension(OptionalDoubleExtension));
Assert.AreEqual(0, message.GetExtension(OptionalFixed32Extension));
Assert.AreEqual(0L, message.GetExtension(OptionalFixed64Extension));
Assert.AreEqual(0.0f, message.GetExtension(OptionalFloatExtension));
Assert.AreEqual(ForeignEnum.ForeignFoo, message.GetExtension(OptionalForeignEnumExtension));
Assert.IsNull(message.GetExtension(OptionalForeignMessageExtension));
Assert.AreEqual(ImportEnum.ImportFoo, message.GetExtension(OptionalImportEnumExtension));
Assert.IsNull(message.GetExtension(OptionalImportMessageExtension));
Assert.AreEqual(0, message.GetExtension(OptionalInt32Extension));
Assert.AreEqual(0L, message.GetExtension(OptionalInt64Extension));
Assert.AreEqual(Proto2.TestAllTypes.Types.NestedEnum.Foo, message.GetExtension(OptionalNestedEnumExtension));
Assert.IsNull(message.GetExtension(OptionalNestedMessageExtension));
Assert.IsNull(message.GetExtension(OptionalPublicImportMessageExtension));
Assert.AreEqual(0, message.GetExtension(OptionalSfixed32Extension));
Assert.AreEqual(0L, message.GetExtension(OptionalSfixed64Extension));
Assert.AreEqual(0, message.GetExtension(OptionalSint32Extension));
Assert.AreEqual(0L, message.GetExtension(OptionalSint64Extension));
Assert.AreEqual("", message.GetExtension(OptionalStringExtension));
Assert.AreEqual(0U, message.GetExtension(OptionalUint32Extension));
Assert.AreEqual(0UL, message.GetExtension(OptionalUint64Extension));
// Repeated fields
Assert.IsNull(message.GetExtension(RepeatedBoolExtension));
Assert.IsNull(message.GetExtension(RepeatedBytesExtension));
Assert.IsNull(message.GetExtension(RepeatedDoubleExtension));
Assert.IsNull(message.GetExtension(RepeatedFixed32Extension));
Assert.IsNull(message.GetExtension(RepeatedFixed64Extension));
Assert.IsNull(message.GetExtension(RepeatedFloatExtension));
Assert.IsNull(message.GetExtension(RepeatedForeignEnumExtension));
Assert.IsNull(message.GetExtension(RepeatedForeignMessageExtension));
Assert.IsNull(message.GetExtension(RepeatedImportEnumExtension));
Assert.IsNull(message.GetExtension(RepeatedImportMessageExtension));
Assert.IsNull(message.GetExtension(RepeatedNestedEnumExtension));
Assert.IsNull(message.GetExtension(RepeatedNestedMessageExtension));
Assert.IsNull(message.GetExtension(RepeatedSfixed32Extension));
Assert.IsNull(message.GetExtension(RepeatedSfixed64Extension));
Assert.IsNull(message.GetExtension(RepeatedSint32Extension));
Assert.IsNull(message.GetExtension(RepeatedSint64Extension));
Assert.IsNull(message.GetExtension(RepeatedStringExtension));
Assert.IsNull(message.GetExtension(RepeatedUint32Extension));
Assert.IsNull(message.GetExtension(RepeatedUint64Extension));
// Oneof fields
Assert.AreEqual(0, message.GetExtension(OneofUint32Extension));
Assert.AreEqual("", message.GetExtension(OneofStringExtension));
Assert.AreEqual(ByteString.Empty, message.GetExtension(OneofBytesExtension));
Assert.IsNull(message.GetExtension(OneofNestedMessageExtension));
Assert.AreEqual(true, message.GetExtension(DefaultBoolExtension));
Assert.AreEqual(ByteString.CopyFromUtf8("world"), message.GetExtension(DefaultBytesExtension));
Assert.AreEqual("123", message.GetExtension(DefaultCordExtension));
Assert.AreEqual(52e3, message.GetExtension(DefaultDoubleExtension));
Assert.AreEqual(47, message.GetExtension(DefaultFixed32Extension));
Assert.AreEqual(48, message.GetExtension(DefaultFixed64Extension));
Assert.AreEqual(51.5, message.GetExtension(DefaultFloatExtension));
Assert.AreEqual(ForeignEnum.ForeignBar, message.GetExtension(DefaultForeignEnumExtension));
Assert.AreEqual(ImportEnum.ImportBar, message.GetExtension(DefaultImportEnumExtension));
Assert.AreEqual(41, message.GetExtension(DefaultInt32Extension));
Assert.AreEqual(42, message.GetExtension(DefaultInt64Extension));
Assert.AreEqual(Proto2.TestAllTypes.Types.NestedEnum.Bar, message.GetExtension(DefaultNestedEnumExtension));
Assert.AreEqual(49, message.GetExtension(DefaultSfixed32Extension));
Assert.AreEqual(-50, message.GetExtension(DefaultSfixed64Extension));
Assert.AreEqual(-45, message.GetExtension(DefaultSint32Extension));
Assert.AreEqual(46, message.GetExtension(DefaultSint64Extension));
Assert.AreEqual("hello", message.GetExtension(DefaultStringExtension));
Assert.AreEqual("abc", message.GetExtension(DefaultStringPieceExtension));
Assert.AreEqual(43, message.GetExtension(DefaultUint32Extension));
Assert.AreEqual(44, message.GetExtension(DefaultUint64Extension));
Assert.False(message.HasExtension(DefaultBoolExtension));
Assert.False(message.HasExtension(DefaultBytesExtension));
Assert.False(message.HasExtension(DefaultCordExtension));
Assert.False(message.HasExtension(DefaultDoubleExtension));
Assert.False(message.HasExtension(DefaultFixed32Extension));
Assert.False(message.HasExtension(DefaultFixed64Extension));
Assert.False(message.HasExtension(DefaultFloatExtension));
Assert.False(message.HasExtension(DefaultForeignEnumExtension));
Assert.False(message.HasExtension(DefaultImportEnumExtension));
Assert.False(message.HasExtension(DefaultInt32Extension));
Assert.False(message.HasExtension(DefaultInt64Extension));
Assert.False(message.HasExtension(DefaultNestedEnumExtension));
Assert.False(message.HasExtension(DefaultSfixed32Extension));
Assert.False(message.HasExtension(DefaultSfixed64Extension));
Assert.False(message.HasExtension(DefaultSint32Extension));
Assert.False(message.HasExtension(DefaultSint64Extension));
Assert.False(message.HasExtension(DefaultStringExtension));
Assert.False(message.HasExtension(DefaultStringPieceExtension));
Assert.False(message.HasExtension(DefaultUint32Extension));
Assert.False(message.HasExtension(DefaultUint64Extension));
}
[Test]
public void FieldPresence()
{
var message = new TestAllTypes();
Assert.False(message.HasOptionalBool);
Assert.False(message.OptionalBool);
message.OptionalBool = true;
Assert.True(message.HasOptionalBool);
Assert.True(message.OptionalBool);
message.OptionalBool = false;
Assert.True(message.HasOptionalBool);
Assert.False(message.OptionalBool);
message.ClearOptionalBool();
Assert.False(message.HasOptionalBool);
Assert.False(message.OptionalBool);
Assert.False(message.HasDefaultBool);
Assert.True(message.DefaultBool);
message.DefaultBool = false;
Assert.True(message.HasDefaultBool);
Assert.False(message.DefaultBool);
message.DefaultBool = true;
Assert.True(message.HasDefaultBool);
Assert.True(message.DefaultBool);
message.ClearDefaultBool();
Assert.False(message.HasDefaultBool);
Assert.True(message.DefaultBool);
}
[Test]
public void RequiredFields()
{
var message = new TestRequired();
Assert.False(message.IsInitialized());
message.A = 1;
message.B = 2;
message.C = 3;
Assert.True(message.IsInitialized());
}
[Test]
public void RequiredFieldsInExtensions()
{
var message = new TestAllExtensions();
Assert.True(message.IsInitialized());
message.SetExtension(TestRequired.Extensions.Single, new TestRequired());
Assert.False(message.IsInitialized());
var extensionMessage = message.GetExtension(TestRequired.Extensions.Single);
extensionMessage.A = 1;
extensionMessage.B = 2;
extensionMessage.C = 3;
Assert.True(message.IsInitialized());
message.GetOrInitializeExtension(TestRequired.Extensions.Multi);
Assert.True(message.IsInitialized());
message.GetExtension(TestRequired.Extensions.Multi).Add(new TestRequired());
Assert.False(message.IsInitialized());
extensionMessage = message.GetExtension(TestRequired.Extensions.Multi)[0];
extensionMessage.A = 1;
extensionMessage.B = 2;
extensionMessage.C = 3;
Assert.True(message.IsInitialized());
message.SetExtension(UnittestExtensions.OptionalBoolExtension, true);
Assert.True(message.IsInitialized());
message.GetOrInitializeExtension(UnittestExtensions.RepeatedBoolExtension).Add(true);
Assert.True(message.IsInitialized());
}
[Test]
public void RequiredFieldInNestedMessageMapValue()
{
var message = new TestRequiredMap();
message.Foo.Add(0, new TestRequiredMap.Types.NestedMessage());
Assert.False(message.IsInitialized());
message.Foo[0].RequiredInt32 = 12;
Assert.True(message.IsInitialized());
}
[Test]
public void RoundTrip_Groups()
{
var message = new TestAllTypes
{
OptionalGroup = new TestAllTypes.Types.OptionalGroup
{
A = 10
},
RepeatedGroup =
{
new TestAllTypes.Types.RepeatedGroup { A = 10 },
new TestAllTypes.Types.RepeatedGroup { A = 20 },
new TestAllTypes.Types.RepeatedGroup { A = 30 }
}
};
byte[] bytes = message.ToByteArray();
TestAllTypes parsed = Proto2.TestAllTypes.Parser.ParseFrom(bytes);
Assert.AreEqual(message, parsed);
}
[Test]
public void RoundTrip_ExtensionGroups()
{
var message = new TestAllExtensions();
message.SetExtension(UnittestExtensions.OptionalGroupExtension, new OptionalGroup_extension { A = 10 });
message.GetOrInitializeExtension(UnittestExtensions.RepeatedGroupExtension).AddRange(new[]
{
new RepeatedGroup_extension { A = 10 },
new RepeatedGroup_extension { A = 20 },
new RepeatedGroup_extension { A = 30 }
});
byte[] bytes = message.ToByteArray();
TestAllExtensions extendable_parsed = TestAllExtensions.Parser.WithExtensionRegistry(new ExtensionRegistry() { UnittestExtensions.OptionalGroupExtension, UnittestExtensions.RepeatedGroupExtension }).ParseFrom(bytes);
Assert.AreEqual(message, extendable_parsed);
}
[Test]
public void RoundTrip_NestedExtensionGroup()
{
var message = new TestGroupExtension();
message.SetExtension(TestNestedExtension.Extensions.OptionalGroupExtension, new TestNestedExtension.Types.OptionalGroup_extension { A = 10 });
byte[] bytes = message.ToByteArray();
TestGroupExtension extendable_parsed = TestGroupExtension.Parser.WithExtensionRegistry(new ExtensionRegistry() { TestNestedExtension.Extensions.OptionalGroupExtension }).ParseFrom(bytes);
Assert.AreEqual(message, extendable_parsed);
}
}
}

@ -33,6 +33,7 @@
using System;
using System.IO;
using Google.Protobuf.TestProtos;
using Proto2 = Google.Protobuf.TestProtos.Proto2;
using NUnit.Framework;
using System.Collections;
using System.Collections.Generic;
@ -44,7 +45,7 @@ namespace Google.Protobuf
/// <summary>
/// Tests around the generated TestAllTypes message.
/// </summary>
public class GeneratedMessageTest
public partial class GeneratedMessageTest
{
[Test]
public void EmptyMessageFieldDistinctFromMissingMessageField()

@ -18,14 +18,10 @@
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
</ItemGroup>
<!--
- Override target frameworks on non-Windows to just .NET Core
- Doing this conditionally in the initial PropertyGroup confuses
- Visual Studio.
-->
<PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
</PropertyGroup>
<!-- Needed for the net45 build to work on Unix. See https://github.com/dotnet/designs/pull/33 -->
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0-preview.2" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="testprotos.pb" />

@ -33,64 +33,19 @@
using Google.Protobuf.Reflection;
using Google.Protobuf.WellKnownTypes;
using NUnit.Framework;
using System;
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.UnittestCustomOptionsProto3Extensions;
using static UnitTest.Issues.TestProtos.DummyMessageContainingEnum.Types;
using static Google.Protobuf.Test.Reflection.CustomOptionNumber;
#pragma warning disable CS0618
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,
}
/// <summary>
/// The majority of the testing here is done via parsed descriptors. That's simpler to
/// achieve (and more important) than constructing a CodedInputStream manually.
@ -99,23 +54,41 @@ namespace Google.Protobuf.Test.Reflection
{
delegate bool OptionFetcher<T>(int field, out T value);
OptionFetcher<E> EnumFetcher<E>(CustomOptions options)
{
return (int i, out E v) => {
if (options.TryGetInt32(i, out int value))
{
v = (E)(object)value;
return true;
}
else
{
v = default(E);
return false;
}
};
}
[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);
var d = CustomOptionOtherValues.Descriptor;
var options = d.CustomOptions;
AssertOption(-100, options.TryGetInt32, Int32Opt, d.GetOption);
AssertOption(12.3456789f, options.TryGetFloat, FloatOpt, d.GetOption);
AssertOption(1.234567890123456789d, options.TryGetDouble, DoubleOpt, d.GetOption);
AssertOption("Hello, \"World\"", options.TryGetString, StringOpt, d.GetOption);
AssertOption(ByteString.CopyFromUtf8("Hello\0World"), options.TryGetBytes, BytesOpt, d.GetOption);
AssertOption(TestEnumType.TestOptionEnumType2, EnumFetcher<TestEnumType>(options), EnumOpt, d.GetOption);
}
[Test]
public void MessageOptions()
{
var options = VariousComplexOptions.Descriptor.CustomOptions;
AssertOption(new ComplexOptionType1 { Foo = 42, Foo4 = { 99, 88 } }, options.TryGetMessage, ComplexOpt1);
var d = VariousComplexOptions.Descriptor;
var options = d.CustomOptions;
AssertOption(new ComplexOptionType1 { Foo = 42, Foo4 = { 99, 88 } }, options.TryGetMessage, ComplexOpt1, d.GetOption);
AssertOption(new ComplexOptionType2
{
Baz = 987,
@ -123,72 +96,74 @@ namespace Google.Protobuf.Test.Reflection
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);
options.TryGetMessage, ComplexOpt2, d.GetOption);
AssertOption(new ComplexOptionType3 { Qux = 9 }, options.TryGetMessage, ComplexOpt3, d.GetOption);
}
[Test]
public void OptionLocations()
{
var fileOptions = UnittestCustomOptionsProto3Reflection.Descriptor.CustomOptions;
AssertOption(9876543210UL, fileOptions.TryGetUInt64, FileOpt1);
AssertOption(9876543210UL, fileOptions.TryGetUInt64, FileOpt1, UnittestCustomOptionsProto3Reflection.Descriptor.GetOption);
var messageOptions = TestMessageWithCustomOptions.Descriptor.CustomOptions;
AssertOption(-56, messageOptions.TryGetInt32, MessageOpt1);
AssertOption(-56, messageOptions.TryGetInt32, MessageOpt1, TestMessageWithCustomOptions.Descriptor.GetOption);
var fieldOptions = TestMessageWithCustomOptions.Descriptor.Fields["field1"].CustomOptions;
AssertOption(8765432109UL, fieldOptions.TryGetFixed64, FieldOpt1);
AssertOption(8765432109UL, fieldOptions.TryGetFixed64, FieldOpt1, TestMessageWithCustomOptions.Descriptor.Fields["field1"].GetOption);
var oneofOptions = TestMessageWithCustomOptions.Descriptor.Oneofs[0].CustomOptions;
AssertOption(-99, oneofOptions.TryGetInt32, OneofOpt1);
AssertOption(-99, oneofOptions.TryGetInt32, OneofOpt1, TestMessageWithCustomOptions.Descriptor.Oneofs[0].GetOption);
var enumOptions = TestMessageWithCustomOptions.Descriptor.EnumTypes[0].CustomOptions;
AssertOption(-789, enumOptions.TryGetSFixed32, EnumOpt1);
AssertOption(-789, enumOptions.TryGetSFixed32, EnumOpt1, TestMessageWithCustomOptions.Descriptor.EnumTypes[0].GetOption);
var enumValueOptions = TestMessageWithCustomOptions.Descriptor.EnumTypes[0].FindValueByNumber(2).CustomOptions;
AssertOption(123, enumValueOptions.TryGetInt32, EnumValueOpt1);
AssertOption(123, enumValueOptions.TryGetInt32, EnumValueOpt1, TestMessageWithCustomOptions.Descriptor.EnumTypes[0].FindValueByNumber(2).GetOption);
var service = UnittestCustomOptionsProto3Reflection.Descriptor.Services
.Single(s => s.Name == "TestServiceWithCustomOptions");
var serviceOptions = service.CustomOptions;
AssertOption(-9876543210, serviceOptions.TryGetSInt64, ServiceOpt1);
AssertOption(-9876543210, serviceOptions.TryGetSInt64, ServiceOpt1, service.GetOption);
var methodOptions = service.Methods[0].CustomOptions;
AssertOption((int)UnitTest.Issues.TestProtos.MethodOpt1.Val2, methodOptions.TryGetInt32, CustomOptionNumber.MethodOpt1);
AssertOption(UnitTest.Issues.TestProtos.MethodOpt1.Val2, EnumFetcher<UnitTest.Issues.TestProtos.MethodOpt1>(methodOptions), UnittestCustomOptionsProto3Extensions.MethodOpt1, service.Methods[0].GetOption);
}
[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);
var d = CustomOptionMinIntegerValues.Descriptor;
var options = d.CustomOptions;
AssertOption(false, options.TryGetBool, BoolOpt, d.GetOption);
AssertOption(int.MinValue, options.TryGetInt32, Int32Opt, d.GetOption);
AssertOption(long.MinValue, options.TryGetInt64, Int64Opt, d.GetOption);
AssertOption(uint.MinValue, options.TryGetUInt32, Uint32Opt, d.GetOption);
AssertOption(ulong.MinValue, options.TryGetUInt64, Uint64Opt, d.GetOption);
AssertOption(int.MinValue, options.TryGetSInt32, Sint32Opt, d.GetOption);
AssertOption(long.MinValue, options.TryGetSInt64, Sint64Opt, d.GetOption);
AssertOption(uint.MinValue, options.TryGetUInt32, Fixed32Opt, d.GetOption);
AssertOption(ulong.MinValue, options.TryGetUInt64, Fixed64Opt, d.GetOption);
AssertOption(int.MinValue, options.TryGetInt32, Sfixed32Opt, d.GetOption);
AssertOption(long.MinValue, options.TryGetInt64, Sfixed64Opt, d.GetOption);
}
[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);
var d = CustomOptionMaxIntegerValues.Descriptor;
var options = d.CustomOptions;
AssertOption(true, options.TryGetBool, BoolOpt, d.GetOption);
AssertOption(int.MaxValue, options.TryGetInt32, Int32Opt, d.GetOption);
AssertOption(long.MaxValue, options.TryGetInt64, Int64Opt, d.GetOption);
AssertOption(uint.MaxValue, options.TryGetUInt32, Uint32Opt, d.GetOption);
AssertOption(ulong.MaxValue, options.TryGetUInt64, Uint64Opt, d.GetOption);
AssertOption(int.MaxValue, options.TryGetSInt32, Sint32Opt, d.GetOption);
AssertOption(long.MaxValue, options.TryGetSInt64, Sint64Opt, d.GetOption);
AssertOption(uint.MaxValue, options.TryGetFixed32, Fixed32Opt, d.GetOption);
AssertOption(ulong.MaxValue, options.TryGetFixed64, Fixed64Opt, d.GetOption);
AssertOption(int.MaxValue, options.TryGetSFixed32, Sfixed32Opt, d.GetOption);
AssertOption(long.MaxValue, options.TryGetSFixed64, Sfixed64Opt, d.GetOption);
}
[Test]
@ -196,17 +171,19 @@ namespace Google.Protobuf.Test.Reflection
{
// Just two examples
var messageOptions = AggregateMessage.Descriptor.CustomOptions;
AssertOption(new Aggregate { I = 101, S = "MessageAnnotation" }, messageOptions.TryGetMessage, AggregateMsgOpt);
AssertOption(new Aggregate { I = 101, S = "MessageAnnotation" }, messageOptions.TryGetMessage, Msgopt, AggregateMessage.Descriptor.GetOption);
var fieldOptions = AggregateMessage.Descriptor.Fields["fieldname"].CustomOptions;
AssertOption(new Aggregate { S = "FieldAnnotation" }, fieldOptions.TryGetMessage, AggregateFieldOpt);
AssertOption(new Aggregate { S = "FieldAnnotation" }, fieldOptions.TryGetMessage, Fieldopt, AggregateMessage.Descriptor.Fields["fieldname"].GetOption);
}
private void AssertOption<T>(T expected, OptionFetcher<T> fetcher, CustomOptionNumber field)
private void AssertOption<T, D>(T expected, OptionFetcher<T> fetcher, Extension<D, T> extension, Func<Extension<D, T>, T> descriptorOptionFetcher) where D : IExtendableMessage<D>
{
T actual;
Assert.IsTrue(fetcher((int)field, out actual));
Assert.AreEqual(expected, actual);
T customOptionsValue;
T extensionValue = descriptorOptionFetcher(extension);
Assert.IsTrue(fetcher(extension.FieldNumber, out customOptionsValue));
Assert.AreEqual(expected, customOptionsValue);
Assert.AreEqual(expected, extensionValue);
}
}
}

@ -31,11 +31,14 @@
#endregion
using Google.Protobuf.TestProtos;
using Proto2 = Google.Protobuf.TestProtos.Proto2;
using NUnit.Framework;
using System;
using System.Collections;
using System.Collections.Generic;
using static Google.Protobuf.TestProtos.Proto2.UnittestExtensions;
namespace Google.Protobuf.Reflection
{
public class FieldAccessTest
@ -44,36 +47,36 @@ namespace Google.Protobuf.Reflection
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));
var fields = TestProtos.TestAllTypes.Descriptor.Fields;
Assert.AreEqual(message.SingleBool, fields[TestProtos.TestAllTypes.SingleBoolFieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleBytes, fields[TestProtos.TestAllTypes.SingleBytesFieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleDouble, fields[TestProtos.TestAllTypes.SingleDoubleFieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleFixed32, fields[TestProtos.TestAllTypes.SingleFixed32FieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleFixed64, fields[TestProtos.TestAllTypes.SingleFixed64FieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleFloat, fields[TestProtos.TestAllTypes.SingleFloatFieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleForeignEnum, fields[TestProtos.TestAllTypes.SingleForeignEnumFieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleForeignMessage, fields[TestProtos.TestAllTypes.SingleForeignMessageFieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleImportEnum, fields[TestProtos.TestAllTypes.SingleImportEnumFieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleImportMessage, fields[TestProtos.TestAllTypes.SingleImportMessageFieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleInt32, fields[TestProtos.TestAllTypes.SingleInt32FieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleInt64, fields[TestProtos.TestAllTypes.SingleInt64FieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleNestedEnum, fields[TestProtos.TestAllTypes.SingleNestedEnumFieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleNestedMessage, fields[TestProtos.TestAllTypes.SingleNestedMessageFieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SinglePublicImportMessage, fields[TestProtos.TestAllTypes.SinglePublicImportMessageFieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleSint32, fields[TestProtos.TestAllTypes.SingleSint32FieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleSint64, fields[TestProtos.TestAllTypes.SingleSint64FieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleString, fields[TestProtos.TestAllTypes.SingleStringFieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleSfixed32, fields[TestProtos.TestAllTypes.SingleSfixed32FieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleSfixed64, fields[TestProtos.TestAllTypes.SingleSfixed64FieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleUint32, fields[TestProtos.TestAllTypes.SingleUint32FieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.SingleUint64, fields[TestProtos.TestAllTypes.SingleUint64FieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.OneofBytes, fields[TestProtos.TestAllTypes.OneofBytesFieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.OneofString, fields[TestProtos.TestAllTypes.OneofStringFieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.OneofNestedMessage, fields[TestProtos.TestAllTypes.OneofNestedMessageFieldNumber].Accessor.GetValue(message));
Assert.AreEqual(message.OneofUint32, fields[TestProtos.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);
var list = (IList) fields[TestProtos.TestAllTypes.RepeatedInt32FieldNumber].Accessor.GetValue(message);
Assert.AreEqual(message.RepeatedInt32, list);
Assert.AreEqual(message.RepeatedInt32[0], list[0]); // Just in case there was any doubt...
@ -86,36 +89,35 @@ namespace Google.Protobuf.Reflection
}
[Test]
public void Clear()
public void GetValue_IncorrectType()
{
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);
IMessage message = SampleMessages.CreateFullTestAllTypes();
var fields = message.Descriptor.Fields;
Assert.Throws<InvalidCastException>(() => fields[TestProtos.TestAllTypes.SingleBoolFieldNumber].Accessor.GetValue(new TestMap()));
}
var expected = new TestAllTypes(SampleMessages.CreateFullTestAllTypes())
{
SingleBool = false,
SingleInt32 = 0,
SingleString = "",
SingleBytes = ByteString.Empty,
SingleForeignEnum = 0,
SingleForeignMessage = null,
};
expected.RepeatedDouble.Clear();
[Test]
public void HasValue_Proto3()
{
IMessage message = SampleMessages.CreateFullTestAllTypes();
var fields = message.Descriptor.Fields;
Assert.Throws<InvalidOperationException>(() => fields[TestProtos.TestAllTypes.SingleBoolFieldNumber].Accessor.HasValue(message));
}
Assert.AreEqual(expected, message);
[Test]
public void HasValue()
{
IMessage message = new Proto2.TestAllTypes();
var fields = message.Descriptor.Fields;
var accessor = fields[Proto2.TestAllTypes.OptionalBoolFieldNumber].Accessor;
// 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);
Assert.False(accessor.HasValue(message));
accessor.SetValue(message, true);
Assert.True(accessor.HasValue(message));
accessor.Clear(message);
Assert.False(accessor.HasValue(message));
}
[Test]
@ -123,14 +125,14 @@ namespace Google.Protobuf.Reflection
{
// 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 fields = TestProtos.TestAllTypes.Descriptor.Fields;
fields[TestProtos.TestAllTypes.SingleBoolFieldNumber].Accessor.SetValue(message, false);
fields[TestProtos.TestAllTypes.SingleInt32FieldNumber].Accessor.SetValue(message, 500);
fields[TestProtos.TestAllTypes.SingleStringFieldNumber].Accessor.SetValue(message, "It's a string");
fields[TestProtos.TestAllTypes.SingleBytesFieldNumber].Accessor.SetValue(message, ByteString.CopyFrom(99, 98, 97));
fields[TestProtos.TestAllTypes.SingleForeignEnumFieldNumber].Accessor.SetValue(message, ForeignEnum.ForeignFoo);
fields[TestProtos.TestAllTypes.SingleForeignMessageFieldNumber].Accessor.SetValue(message, new ForeignMessage { C = 12345 });
fields[TestProtos.TestAllTypes.SingleDoubleFieldNumber].Accessor.SetValue(message, 20150701.5);
var expected = new TestAllTypes(SampleMessages.CreateFullTestAllTypes())
{
@ -151,7 +153,7 @@ namespace Google.Protobuf.Reflection
{
IMessage message = SampleMessages.CreateFullTestAllTypes();
var fields = message.Descriptor.Fields;
Assert.Throws<InvalidCastException>(() => fields[TestAllTypes.SingleBoolFieldNumber].Accessor.SetValue(message, "This isn't a bool"));
Assert.Throws<InvalidCastException>(() => fields[TestProtos.TestAllTypes.SingleBoolFieldNumber].Accessor.SetValue(message, "This isn't a bool"));
}
[Test]
@ -167,52 +169,100 @@ namespace Google.Protobuf.Reflection
{
IMessage message = SampleMessages.CreateFullTestAllTypes();
var fields = message.Descriptor.Fields;
Assert.Throws<InvalidOperationException>(() => 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<InvalidCastException>(() => fields[TestAllTypes.SingleBoolFieldNumber].Accessor.GetValue(new TestMap()));
Assert.Throws<InvalidOperationException>(() => fields[TestProtos.TestAllTypes.RepeatedDoubleFieldNumber].Accessor.SetValue(message, new double[10]));
}
[Test]
public void Oneof()
{
var message = new TestAllTypes();
var descriptor = TestAllTypes.Descriptor;
var descriptor = TestProtos.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));
Assert.AreSame(descriptor.Fields[TestProtos.TestAllTypes.OneofStringFieldNumber], oneof.Accessor.GetCaseFieldDescriptor(message));
message.OneofUint32 = 10;
Assert.AreSame(descriptor.Fields[TestAllTypes.OneofUint32FieldNumber], oneof.Accessor.GetCaseFieldDescriptor(message));
Assert.AreSame(descriptor.Fields[TestProtos.TestAllTypes.OneofUint32FieldNumber], oneof.Accessor.GetCaseFieldDescriptor(message));
oneof.Accessor.Clear(message);
Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase);
Assert.AreEqual(TestProtos.TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase);
}
[Test]
public void Clear()
{
var message = SampleMessages.CreateFullTestAllTypes();
var fields = TestProtos.TestAllTypes.Descriptor.Fields;
fields[TestProtos.TestAllTypes.SingleBoolFieldNumber].Accessor.Clear(message);
fields[TestProtos.TestAllTypes.SingleInt32FieldNumber].Accessor.Clear(message);
fields[TestProtos.TestAllTypes.SingleStringFieldNumber].Accessor.Clear(message);
fields[TestProtos.TestAllTypes.SingleBytesFieldNumber].Accessor.Clear(message);
fields[TestProtos.TestAllTypes.SingleForeignEnumFieldNumber].Accessor.Clear(message);
fields[TestProtos.TestAllTypes.SingleForeignMessageFieldNumber].Accessor.Clear(message);
fields[TestProtos.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 FieldDescriptor_ByName()
{
var descriptor = TestAllTypes.Descriptor;
var descriptor = TestProtos.TestAllTypes.Descriptor;
Assert.AreSame(
descriptor.Fields[TestAllTypes.SingleBoolFieldNumber],
descriptor.Fields[TestProtos.TestAllTypes.SingleBoolFieldNumber],
descriptor.Fields["single_bool"]);
}
[Test]
public void FieldDescriptor_NotFound()
{
var descriptor = TestAllTypes.Descriptor;
var descriptor = TestProtos.TestAllTypes.Descriptor;
Assert.Throws<KeyNotFoundException>(() => descriptor.Fields[999999].ToString());
Assert.Throws<KeyNotFoundException>(() => descriptor.Fields["not found"].ToString());
}
[Test]
public void GetExtensionValue()
{
var message = SampleMessages.CreateFullTestAllExtensions();
// test that the reflector works, since the reflector just runs through IExtendableMessage
Assert.AreEqual(message.GetExtension(OptionalBoolExtension), Proto2.TestAllExtensions.Descriptor.FindFieldByNumber(OptionalBoolExtension.FieldNumber).Accessor.GetValue(message));
}
[Test]
public void GetRepeatedExtensionValue()
{
// check to make sure repeated accessor uses GetOrRegister
var message = new Proto2.TestAllExtensions();
Assert.IsNull(message.GetExtension(RepeatedBoolExtension));
Assert.IsNotNull(Proto2.TestAllExtensions.Descriptor.FindFieldByNumber(RepeatedBoolExtension.FieldNumber).Accessor.GetValue(message));
Assert.IsNotNull(message.GetExtension(RepeatedBoolExtension));
message.ClearExtension(RepeatedBoolExtension);
Assert.IsNull(message.GetExtension(RepeatedBoolExtension));
}
}
}

@ -32,6 +32,9 @@
using System;
using Google.Protobuf.TestProtos;
using Proto2 = Google.Protobuf.TestProtos.Proto2;
using static Google.Protobuf.TestProtos.Proto2.UnittestExtensions;
namespace Google.Protobuf
{
@ -60,7 +63,7 @@ namespace Google.Protobuf
SingleImportMessage = new ImportMessage { D = 20 },
SingleInt32 = 100,
SingleInt64 = 3210987654321,
SingleNestedEnum = TestAllTypes.Types.NestedEnum.Foo,
SingleNestedEnum = TestProtos.TestAllTypes.Types.NestedEnum.Foo,
SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 },
SinglePublicImportMessage = new PublicImportMessage { E = 54 },
SingleSfixed32 = -123,
@ -82,7 +85,7 @@ namespace Google.Protobuf
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 },
RepeatedNestedEnum = { TestProtos.TestAllTypes.Types.NestedEnum.Foo, TestProtos.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 },
@ -95,5 +98,110 @@ namespace Google.Protobuf
OneofString = "Oneof string"
};
}
public static Proto2.TestAllTypes CreateFullTestAllTypesProto2()
{
return new Proto2.TestAllTypes
{
OptionalBool = true,
OptionalBytes = ByteString.CopyFrom(1, 2, 3, 4),
OptionalDouble = 23.5,
OptionalFixed32 = 23,
OptionalFixed64 = 1234567890123,
OptionalFloat = 12.25f,
OptionalForeignEnum = Proto2.ForeignEnum.ForeignBar,
OptionalForeignMessage = new Proto2.ForeignMessage { C = 10 },
OptionalImportEnum = Proto2.ImportEnum.ImportBaz,
OptionalImportMessage = new Proto2.ImportMessage { D = 20 },
OptionalInt32 = 100,
OptionalInt64 = 3210987654321,
OptionalNestedEnum = Proto2.TestAllTypes.Types.NestedEnum.Foo,
OptionalNestedMessage = new Proto2.TestAllTypes.Types.NestedMessage { Bb = 35 },
OptionalPublicImportMessage = new Proto2.PublicImportMessage { E = 54 },
OptionalSfixed32 = -123,
OptionalSfixed64 = -12345678901234,
OptionalSint32 = -456,
OptionalSint64 = -12345678901235,
OptionalString = "test",
OptionalUint32 = UInt32.MaxValue,
OptionalUint64 = UInt64.MaxValue,
OptionalGroup = new Proto2.TestAllTypes.Types.OptionalGroup { A = 10 },
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 = { Proto2.ForeignEnum.ForeignFoo, Proto2.ForeignEnum.ForeignBar },
RepeatedForeignMessage = { new Proto2.ForeignMessage(), new Proto2.ForeignMessage { C = 10 } },
RepeatedImportEnum = { Proto2.ImportEnum.ImportBaz, Proto2.ImportEnum.ImportFoo },
RepeatedImportMessage = { new Proto2.ImportMessage { D = 20 }, new Proto2.ImportMessage { D = 25 } },
RepeatedInt32 = { 100, 200 },
RepeatedInt64 = { 3210987654321, Int64.MaxValue },
RepeatedNestedEnum = { Proto2.TestAllTypes.Types.NestedEnum.Foo, Proto2.TestAllTypes.Types.NestedEnum.Neg },
RepeatedNestedMessage = { new Proto2.TestAllTypes.Types.NestedMessage { Bb = 35 }, new Proto2.TestAllTypes.Types.NestedMessage { Bb = 10 } },
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 },
RepeatedGroup = { new Proto2.TestAllTypes.Types.RepeatedGroup { A = 10 }, new Proto2.TestAllTypes.Types.RepeatedGroup { A = 20 } },
OneofString = "Oneof string"
};
}
public static Proto2.TestAllExtensions CreateFullTestAllExtensions()
{
var message = new Proto2.TestAllExtensions();
message.SetExtension(OptionalBoolExtension, true);
message.SetExtension(OptionalBytesExtension, ByteString.CopyFrom(1, 2, 3, 4));
message.SetExtension(OptionalDoubleExtension, 23.5);
message.SetExtension(OptionalFixed32Extension, 23u);
message.SetExtension(OptionalFixed64Extension, 1234567890123u);
message.SetExtension(OptionalFloatExtension, 12.25f);
message.SetExtension(OptionalForeignEnumExtension, Proto2.ForeignEnum.ForeignBar);
message.SetExtension(OptionalForeignMessageExtension, new Proto2.ForeignMessage { C = 10 });
message.SetExtension(OptionalImportEnumExtension, Proto2.ImportEnum.ImportBaz);
message.SetExtension(OptionalImportMessageExtension, new Proto2.ImportMessage { D = 20 });
message.SetExtension(OptionalInt32Extension, 100);
message.SetExtension(OptionalInt64Extension, 3210987654321);
message.SetExtension(OptionalNestedEnumExtension, Proto2.TestAllTypes.Types.NestedEnum.Foo);
message.SetExtension(OptionalNestedMessageExtension, new Proto2.TestAllTypes.Types.NestedMessage { Bb = 35 });
message.SetExtension(OptionalPublicImportMessageExtension, new Proto2.PublicImportMessage { E = 54 });
message.SetExtension(OptionalSfixed32Extension, -123);
message.SetExtension(OptionalSfixed64Extension, -12345678901234);
message.SetExtension(OptionalSint32Extension, -456);
message.SetExtension(OptionalSint64Extension, -12345678901235);
message.SetExtension(OptionalStringExtension, "test");
message.SetExtension(OptionalUint32Extension, UInt32.MaxValue);
message.SetExtension(OptionalUint64Extension, UInt64.MaxValue);
message.SetExtension(OptionalGroupExtension, new Proto2.OptionalGroup_extension { A = 10 });
message.GetOrInitializeExtension(RepeatedBoolExtension).AddRange(new[] { true, false });
message.GetOrInitializeExtension(RepeatedBytesExtension).AddRange(new[] { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6), ByteString.CopyFrom(new byte[1000]) });
message.GetOrInitializeExtension(RepeatedDoubleExtension).AddRange(new[] { -12.25, 23.5 });
message.GetOrInitializeExtension(RepeatedFixed32Extension).AddRange(new[] { UInt32.MaxValue, 23u });
message.GetOrInitializeExtension(RepeatedFixed64Extension).AddRange(new[] { UInt64.MaxValue, 1234567890123ul });
message.GetOrInitializeExtension(RepeatedFloatExtension).AddRange(new[] { 100f, 12.25f });
message.GetOrInitializeExtension(RepeatedForeignEnumExtension).AddRange(new[] { Proto2.ForeignEnum.ForeignFoo, Proto2.ForeignEnum.ForeignBar });
message.GetOrInitializeExtension(RepeatedForeignMessageExtension).AddRange(new[] { new Proto2.ForeignMessage(), new Proto2.ForeignMessage { C = 10 } });
message.GetOrInitializeExtension(RepeatedImportEnumExtension).AddRange(new[] { Proto2.ImportEnum.ImportBaz, Proto2.ImportEnum.ImportFoo });
message.GetOrInitializeExtension(RepeatedImportMessageExtension).AddRange(new[] { new Proto2.ImportMessage { D = 20 }, new Proto2.ImportMessage { D = 25 } });
message.GetOrInitializeExtension(RepeatedInt32Extension).AddRange(new[] { 100, 200 });
message.GetOrInitializeExtension(RepeatedInt64Extension).AddRange(new[] { 3210987654321, Int64.MaxValue });
message.GetOrInitializeExtension(RepeatedNestedEnumExtension).AddRange(new[] { Proto2.TestAllTypes.Types.NestedEnum.Foo, Proto2.TestAllTypes.Types.NestedEnum.Neg });
message.GetOrInitializeExtension(RepeatedNestedMessageExtension).AddRange(new[] { new Proto2.TestAllTypes.Types.NestedMessage { Bb = 35 }, new Proto2.TestAllTypes.Types.NestedMessage { Bb = 10 } });
message.GetOrInitializeExtension(RepeatedSfixed32Extension).AddRange(new[] { -123, 123 });
message.GetOrInitializeExtension(RepeatedSfixed64Extension).AddRange(new[] { -12345678901234, 12345678901234 });
message.GetOrInitializeExtension(RepeatedSint32Extension).AddRange(new[] { -456, 100 });
message.GetOrInitializeExtension(RepeatedSint64Extension).AddRange(new[] { -12345678901235, 123 });
message.GetOrInitializeExtension(RepeatedStringExtension).AddRange(new[] { "foo", "bar" });
message.GetOrInitializeExtension(RepeatedUint32Extension).AddRange(new[] { UInt32.MaxValue, UInt32.MinValue });
message.GetOrInitializeExtension(RepeatedUint64Extension).AddRange(new[] { UInt64.MaxValue, UInt32.MinValue });
message.GetOrInitializeExtension(RepeatedGroupExtension).AddRange(new[] { new Proto2.RepeatedGroup_extension { A = 10 }, new Proto2.RepeatedGroup_extension { A = 20 } });
message.SetExtension(OneofStringExtension, "Oneof string");
return message;
}
}
}

@ -29,7 +29,7 @@ namespace ProtobufTestMessages.Proto3 {
"dWYvYW55LnByb3RvGh5nb29nbGUvcHJvdG9idWYvZHVyYXRpb24ucHJvdG8a",
"IGdvb2dsZS9wcm90b2J1Zi9maWVsZF9tYXNrLnByb3RvGhxnb29nbGUvcHJv",
"dG9idWYvc3RydWN0LnByb3RvGh9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1w",
"LnByb3RvGh5nb29nbGUvcHJvdG9idWYvd3JhcHBlcnMucHJvdG8ipz0KElRl",
"LnByb3RvGh5nb29nbGUvcHJvdG9idWYvd3JhcHBlcnMucHJvdG8iv0QKElRl",
"c3RBbGxUeXBlc1Byb3RvMxIWCg5vcHRpb25hbF9pbnQzMhgBIAEoBRIWCg5v",
"cHRpb25hbF9pbnQ2NBgCIAEoAxIXCg9vcHRpb25hbF91aW50MzIYAyABKA0S",
"FwoPb3B0aW9uYWxfdWludDY0GAQgASgEEhcKD29wdGlvbmFsX3NpbnQzMhgF",
@ -69,149 +69,170 @@ namespace ProtobufTestMessages.Proto3 {
"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",
"GAoMcGFja2VkX2ludDMyGEsgAygFQgIQARIYCgxwYWNrZWRfaW50NjQYTCAD",
"KANCAhABEhkKDXBhY2tlZF91aW50MzIYTSADKA1CAhABEhkKDXBhY2tlZF91",
"aW50NjQYTiADKARCAhABEhkKDXBhY2tlZF9zaW50MzIYTyADKBFCAhABEhkK",
"DXBhY2tlZF9zaW50NjQYUCADKBJCAhABEhoKDnBhY2tlZF9maXhlZDMyGFEg",
"AygHQgIQARIaCg5wYWNrZWRfZml4ZWQ2NBhSIAMoBkICEAESGwoPcGFja2Vk",
"X3NmaXhlZDMyGFMgAygPQgIQARIbCg9wYWNrZWRfc2ZpeGVkNjQYVCADKBBC",
"AhABEhgKDHBhY2tlZF9mbG9hdBhVIAMoAkICEAESGQoNcGFja2VkX2RvdWJs",
"ZRhWIAMoAUICEAESFwoLcGFja2VkX2Jvb2wYVyADKAhCAhABElwKEnBhY2tl",
"ZF9uZXN0ZWRfZW51bRhYIAMoDjI8LnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMu",
"cHJvdG8zLlRlc3RBbGxUeXBlc1Byb3RvMy5OZXN0ZWRFbnVtQgIQARIaCg51",
"bnBhY2tlZF9pbnQzMhhZIAMoBUICEAASGgoOdW5wYWNrZWRfaW50NjQYWiAD",
"KANCAhAAEhsKD3VucGFja2VkX3VpbnQzMhhbIAMoDUICEAASGwoPdW5wYWNr",
"ZWRfdWludDY0GFwgAygEQgIQABIbCg91bnBhY2tlZF9zaW50MzIYXSADKBFC",
"AhAAEhsKD3VucGFja2VkX3NpbnQ2NBheIAMoEkICEAASHAoQdW5wYWNrZWRf",
"Zml4ZWQzMhhfIAMoB0ICEAASHAoQdW5wYWNrZWRfZml4ZWQ2NBhgIAMoBkIC",
"EAASHQoRdW5wYWNrZWRfc2ZpeGVkMzIYYSADKA9CAhAAEh0KEXVucGFja2Vk",
"X3NmaXhlZDY0GGIgAygQQgIQABIaCg51bnBhY2tlZF9mbG9hdBhjIAMoAkIC",
"EAASGwoPdW5wYWNrZWRfZG91YmxlGGQgAygBQgIQABIZCg11bnBhY2tlZF9i",
"b29sGGUgAygIQgIQABJeChR1bnBhY2tlZF9uZXN0ZWRfZW51bRhmIAMoDjI8",
"LnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlc1By",
"b3RvMy5OZXN0ZWRFbnVtQgIQABJdCg9tYXBfaW50MzJfaW50MzIYOCADKAsy",
"RC5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXNQ",
"cm90bzMuTWFwSW50MzJJbnQzMkVudHJ5El0KD21hcF9pbnQ2NF9pbnQ2NBg5",
"IAMoCzJELnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLlRlc3RBbGxU",
"eXBlc1Byb3RvMy5NYXBJbnQ2NEludDY0RW50cnkSYQoRbWFwX3VpbnQzMl91",
"aW50MzIYOiADKAsyRi5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMy5U",
"ZXN0QWxsVHlwZXNQcm90bzMuTWFwVWludDMyVWludDMyRW50cnkSYQoRbWFw",
"X3VpbnQ2NF91aW50NjQYOyADKAsyRi5wcm90b2J1Zl90ZXN0X21lc3NhZ2Vz",
"LnByb3RvMy5UZXN0QWxsVHlwZXNQcm90bzMuTWFwVWludDY0VWludDY0RW50",
"cnkSYQoRbWFwX3NpbnQzMl9zaW50MzIYPCADKAsyRi5wcm90b2J1Zl90ZXN0",
"X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXNQcm90bzMuTWFwU2ludDMy",
"U2ludDMyRW50cnkSYQoRbWFwX3NpbnQ2NF9zaW50NjQYPSADKAsyRi5wcm90",
"b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXNQcm90bzMu",
"TWFwU2ludDY0U2ludDY0RW50cnkSZQoTbWFwX2ZpeGVkMzJfZml4ZWQzMhg+",
"IAMoCzJILnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLlRlc3RBbGxU",
"eXBlc1Byb3RvMy5NYXBGaXhlZDMyRml4ZWQzMkVudHJ5EmUKE21hcF9maXhl",
"ZDY0X2ZpeGVkNjQYPyADKAsySC5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnBy",
"b3RvMy5UZXN0QWxsVHlwZXNQcm90bzMuTWFwRml4ZWQ2NEZpeGVkNjRFbnRy",
"eRJpChVtYXBfc2ZpeGVkMzJfc2ZpeGVkMzIYQCADKAsySi5wcm90b2J1Zl90",
"ZXN0X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXNQcm90bzMuTWFwU2Zp",
"eGVkMzJTZml4ZWQzMkVudHJ5EmkKFW1hcF9zZml4ZWQ2NF9zZml4ZWQ2NBhB",
"IAMoCzJKLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLlRlc3RBbGxU",
"eXBlc1Byb3RvMy5NYXBTZml4ZWQ2NFNmaXhlZDY0RW50cnkSXQoPbWFwX2lu",
"dDMyX2Zsb2F0GEIgAygLMkQucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90",
"bzMuVGVzdEFsbFR5cGVzUHJvdG8zLk1hcEludDMyRmxvYXRFbnRyeRJfChBt",
"YXBfaW50MzJfZG91YmxlGEMgAygLMkUucHJvdG9idWZfdGVzdF9tZXNzYWdl",
"cy5wcm90bzMuVGVzdEFsbFR5cGVzUHJvdG8zLk1hcEludDMyRG91YmxlRW50",
"cnkSWQoNbWFwX2Jvb2xfYm9vbBhEIAMoCzJCLnByb3RvYnVmX3Rlc3RfbWVz",
"c2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlc1Byb3RvMy5NYXBCb29sQm9vbEVu",
"dHJ5EmEKEW1hcF9zdHJpbmdfc3RyaW5nGEUgAygLMkYucHJvdG9idWZfdGVz",
"dF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzUHJvdG8zLk1hcFN0cmlu",
"Z1N0cmluZ0VudHJ5El8KEG1hcF9zdHJpbmdfYnl0ZXMYRiADKAsyRS5wcm90",
"b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXNQcm90bzMu",
"TWFwU3RyaW5nQnl0ZXNFbnRyeRJwChltYXBfc3RyaW5nX25lc3RlZF9tZXNz",
"YWdlGEcgAygLMk0ucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuVGVz",
"dEFsbFR5cGVzUHJvdG8zLk1hcFN0cmluZ05lc3RlZE1lc3NhZ2VFbnRyeRJy",
"ChptYXBfc3RyaW5nX2ZvcmVpZ25fbWVzc2FnZRhIIAMoCzJOLnByb3RvYnVm",
"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"));
"dHJpbmdGb3JlaWduTWVzc2FnZUVudHJ5EmoKFm1hcF9zdHJpbmdfbmVzdGVk",
"X2VudW0YSSADKAsySi5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMy5U",
"ZXN0QWxsVHlwZXNQcm90bzMuTWFwU3RyaW5nTmVzdGVkRW51bUVudHJ5EmwK",
"F21hcF9zdHJpbmdfZm9yZWlnbl9lbnVtGEogAygLMksucHJvdG9idWZfdGVz",
"dF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzUHJvdG8zLk1hcFN0cmlu",
"Z0ZvcmVpZ25FbnVtRW50cnkSFgoMb25lb2ZfdWludDMyGG8gASgNSAASXwoU",
"b25lb2ZfbmVzdGVkX21lc3NhZ2UYcCABKAsyPy5wcm90b2J1Zl90ZXN0X21l",
"c3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXNQcm90bzMuTmVzdGVkTWVzc2Fn",
"ZUgAEhYKDG9uZW9mX3N0cmluZxhxIAEoCUgAEhUKC29uZW9mX2J5dGVzGHIg",
"ASgMSAASFAoKb25lb2ZfYm9vbBhzIAEoCEgAEhYKDG9uZW9mX3VpbnQ2NBh0",
"IAEoBEgAEhUKC29uZW9mX2Zsb2F0GHUgASgCSAASFgoMb25lb2ZfZG91Ymxl",
"GHYgASgBSAASUgoKb25lb2ZfZW51bRh3IAEoDjI8LnByb3RvYnVmX3Rlc3Rf",
"bWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlc1Byb3RvMy5OZXN0ZWRFbnVt",
"SAASOgoVb3B0aW9uYWxfYm9vbF93cmFwcGVyGMkBIAEoCzIaLmdvb2dsZS5w",
"cm90b2J1Zi5Cb29sVmFsdWUSPAoWb3B0aW9uYWxfaW50MzJfd3JhcHBlchjK",
"ASABKAsyGy5nb29nbGUucHJvdG9idWYuSW50MzJWYWx1ZRI8ChZvcHRpb25h",
"bF9pbnQ2NF93cmFwcGVyGMsBIAEoCzIbLmdvb2dsZS5wcm90b2J1Zi5JbnQ2",
"NFZhbHVlEj4KF29wdGlvbmFsX3VpbnQzMl93cmFwcGVyGMwBIAEoCzIcLmdv",
"b2dsZS5wcm90b2J1Zi5VSW50MzJWYWx1ZRI+ChdvcHRpb25hbF91aW50NjRf",
"d3JhcHBlchjNASABKAsyHC5nb29nbGUucHJvdG9idWYuVUludDY0VmFsdWUS",
"PAoWb3B0aW9uYWxfZmxvYXRfd3JhcHBlchjOASABKAsyGy5nb29nbGUucHJv",
"dG9idWYuRmxvYXRWYWx1ZRI+ChdvcHRpb25hbF9kb3VibGVfd3JhcHBlchjP",
"ASABKAsyHC5nb29nbGUucHJvdG9idWYuRG91YmxlVmFsdWUSPgoXb3B0aW9u",
"YWxfc3RyaW5nX3dyYXBwZXIY0AEgASgLMhwuZ29vZ2xlLnByb3RvYnVmLlN0",
"cmluZ1ZhbHVlEjwKFm9wdGlvbmFsX2J5dGVzX3dyYXBwZXIY0QEgASgLMhsu",
"Z29vZ2xlLnByb3RvYnVmLkJ5dGVzVmFsdWUSOgoVcmVwZWF0ZWRfYm9vbF93",
"cmFwcGVyGNMBIAMoCzIaLmdvb2dsZS5wcm90b2J1Zi5Cb29sVmFsdWUSPAoW",
"cmVwZWF0ZWRfaW50MzJfd3JhcHBlchjUASADKAsyGy5nb29nbGUucHJvdG9i",
"dWYuSW50MzJWYWx1ZRI8ChZyZXBlYXRlZF9pbnQ2NF93cmFwcGVyGNUBIAMo",
"CzIbLmdvb2dsZS5wcm90b2J1Zi5JbnQ2NFZhbHVlEj4KF3JlcGVhdGVkX3Vp",
"bnQzMl93cmFwcGVyGNYBIAMoCzIcLmdvb2dsZS5wcm90b2J1Zi5VSW50MzJW",
"YWx1ZRI+ChdyZXBlYXRlZF91aW50NjRfd3JhcHBlchjXASADKAsyHC5nb29n",
"bGUucHJvdG9idWYuVUludDY0VmFsdWUSPAoWcmVwZWF0ZWRfZmxvYXRfd3Jh",
"cHBlchjYASADKAsyGy5nb29nbGUucHJvdG9idWYuRmxvYXRWYWx1ZRI+Chdy",
"ZXBlYXRlZF9kb3VibGVfd3JhcHBlchjZASADKAsyHC5nb29nbGUucHJvdG9i",
"dWYuRG91YmxlVmFsdWUSPgoXcmVwZWF0ZWRfc3RyaW5nX3dyYXBwZXIY2gEg",
"AygLMhwuZ29vZ2xlLnByb3RvYnVmLlN0cmluZ1ZhbHVlEjwKFnJlcGVhdGVk",
"X2J5dGVzX3dyYXBwZXIY2wEgAygLMhsuZ29vZ2xlLnByb3RvYnVmLkJ5dGVz",
"VmFsdWUSNQoRb3B0aW9uYWxfZHVyYXRpb24YrQIgASgLMhkuZ29vZ2xlLnBy",
"b3RvYnVmLkR1cmF0aW9uEjcKEm9wdGlvbmFsX3RpbWVzdGFtcBiuAiABKAsy",
"Gi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wEjgKE29wdGlvbmFsX2ZpZWxk",
"X21hc2sYrwIgASgLMhouZ29vZ2xlLnByb3RvYnVmLkZpZWxkTWFzaxIxCg9v",
"cHRpb25hbF9zdHJ1Y3QYsAIgASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVj",
"dBIrCgxvcHRpb25hbF9hbnkYsQIgASgLMhQuZ29vZ2xlLnByb3RvYnVmLkFu",
"eRIvCg5vcHRpb25hbF92YWx1ZRiyAiABKAsyFi5nb29nbGUucHJvdG9idWYu",
"VmFsdWUSNQoRcmVwZWF0ZWRfZHVyYXRpb24YtwIgAygLMhkuZ29vZ2xlLnBy",
"b3RvYnVmLkR1cmF0aW9uEjcKEnJlcGVhdGVkX3RpbWVzdGFtcBi4AiADKAsy",
"Gi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wEjcKEnJlcGVhdGVkX2ZpZWxk",
"bWFzaxi5AiADKAsyGi5nb29nbGUucHJvdG9idWYuRmllbGRNYXNrEjEKD3Jl",
"cGVhdGVkX3N0cnVjdBjEAiADKAsyFy5nb29nbGUucHJvdG9idWYuU3RydWN0",
"EisKDHJlcGVhdGVkX2FueRi7AiADKAsyFC5nb29nbGUucHJvdG9idWYuQW55",
"Ei8KDnJlcGVhdGVkX3ZhbHVlGLwCIAMoCzIWLmdvb2dsZS5wcm90b2J1Zi5W",
"YWx1ZRI4ChNyZXBlYXRlZF9saXN0X3ZhbHVlGL0CIAMoCzIaLmdvb2dsZS5w",
"cm90b2J1Zi5MaXN0VmFsdWUSEwoKZmllbGRuYW1lMRiRAyABKAUSFAoLZmll",
"bGRfbmFtZTIYkgMgASgFEhUKDF9maWVsZF9uYW1lMxiTAyABKAUSFgoNZmll",
"bGRfX25hbWU0XxiUAyABKAUSFAoLZmllbGQwbmFtZTUYlQMgASgFEhYKDWZp",
"ZWxkXzBfbmFtZTYYlgMgASgFEhMKCmZpZWxkTmFtZTcYlwMgASgFEhMKCkZp",
"ZWxkTmFtZTgYmAMgASgFEhQKC2ZpZWxkX05hbWU5GJkDIAEoBRIVCgxGaWVs",
"ZF9OYW1lMTAYmgMgASgFEhUKDEZJRUxEX05BTUUxMRibAyABKAUSFQoMRklF",
"TERfbmFtZTEyGJwDIAEoBRIXCg5fX2ZpZWxkX25hbWUxMxidAyABKAUSFwoO",
"X19GaWVsZF9uYW1lMTQYngMgASgFEhYKDWZpZWxkX19uYW1lMTUYnwMgASgF",
"EhYKDWZpZWxkX19OYW1lMTYYoAMgASgFEhcKDmZpZWxkX25hbWUxN19fGKED",
"IAEoBRIXCg5GaWVsZF9uYW1lMThfXxiiAyABKAUaYgoNTmVzdGVkTWVzc2Fn",
"ZRIJCgFhGAEgASgFEkYKC2NvcmVjdXJzaXZlGAIgASgLMjEucHJvdG9idWZf",
"dGVzdF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzUHJvdG8zGjQKEk1h",
"cEludDMySW50MzJFbnRyeRILCgNrZXkYASABKAUSDQoFdmFsdWUYAiABKAU6",
"AjgBGjQKEk1hcEludDY0SW50NjRFbnRyeRILCgNrZXkYASABKAMSDQoFdmFs",
"dWUYAiABKAM6AjgBGjYKFE1hcFVpbnQzMlVpbnQzMkVudHJ5EgsKA2tleRgB",
"IAEoDRINCgV2YWx1ZRgCIAEoDToCOAEaNgoUTWFwVWludDY0VWludDY0RW50",
"cnkSCwoDa2V5GAEgASgEEg0KBXZhbHVlGAIgASgEOgI4ARo2ChRNYXBTaW50",
"MzJTaW50MzJFbnRyeRILCgNrZXkYASABKBESDQoFdmFsdWUYAiABKBE6AjgB",
"GjYKFE1hcFNpbnQ2NFNpbnQ2NEVudHJ5EgsKA2tleRgBIAEoEhINCgV2YWx1",
"ZRgCIAEoEjoCOAEaOAoWTWFwRml4ZWQzMkZpeGVkMzJFbnRyeRILCgNrZXkY",
"ASABKAcSDQoFdmFsdWUYAiABKAc6AjgBGjgKFk1hcEZpeGVkNjRGaXhlZDY0",
"RW50cnkSCwoDa2V5GAEgASgGEg0KBXZhbHVlGAIgASgGOgI4ARo6ChhNYXBT",
"Zml4ZWQzMlNmaXhlZDMyRW50cnkSCwoDa2V5GAEgASgPEg0KBXZhbHVlGAIg",
"ASgPOgI4ARo6ChhNYXBTZml4ZWQ2NFNmaXhlZDY0RW50cnkSCwoDa2V5GAEg",
"ASgQEg0KBXZhbHVlGAIgASgQOgI4ARo0ChJNYXBJbnQzMkZsb2F0RW50cnkS",
"CwoDa2V5GAEgASgFEg0KBXZhbHVlGAIgASgCOgI4ARo1ChNNYXBJbnQzMkRv",
"dWJsZUVudHJ5EgsKA2tleRgBIAEoBRINCgV2YWx1ZRgCIAEoAToCOAEaMgoQ",
"TWFwQm9vbEJvb2xFbnRyeRILCgNrZXkYASABKAgSDQoFdmFsdWUYAiABKAg6",
"AjgBGjYKFE1hcFN0cmluZ1N0cmluZ0VudHJ5EgsKA2tleRgBIAEoCRINCgV2",
"YWx1ZRgCIAEoCToCOAEaNQoTTWFwU3RyaW5nQnl0ZXNFbnRyeRILCgNrZXkY",
"ASABKAkSDQoFdmFsdWUYAiABKAw6AjgBGn4KG01hcFN0cmluZ05lc3RlZE1l",
"c3NhZ2VFbnRyeRILCgNrZXkYASABKAkSTgoFdmFsdWUYAiABKAsyPy5wcm90",
"b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXNQcm90bzMu",
"TmVzdGVkTWVzc2FnZToCOAEabQocTWFwU3RyaW5nRm9yZWlnbk1lc3NhZ2VF",
"bnRyeRILCgNrZXkYASABKAkSPAoFdmFsdWUYAiABKAsyLS5wcm90b2J1Zl90",
"ZXN0X21lc3NhZ2VzLnByb3RvMy5Gb3JlaWduTWVzc2FnZToCOAEaeAoYTWFw",
"U3RyaW5nTmVzdGVkRW51bUVudHJ5EgsKA2tleRgBIAEoCRJLCgV2YWx1ZRgC",
"IAEoDjI8LnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLlRlc3RBbGxU",
"eXBlc1Byb3RvMy5OZXN0ZWRFbnVtOgI4ARpnChlNYXBTdHJpbmdGb3JlaWdu",
"RW51bUVudHJ5EgsKA2tleRgBIAEoCRI5CgV2YWx1ZRgCIAEoDjIqLnByb3Rv",
"YnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLkZvcmVpZ25FbnVtOgI4ASI5CgpO",
"ZXN0ZWRFbnVtEgcKA0ZPTxAAEgcKA0JBUhABEgcKA0JBWhACEhAKA05FRxD/",
"//////////8BIlkKC0FsaWFzZWRFbnVtEg0KCUFMSUFTX0ZPTxAAEg0KCUFM",
"SUFTX0JBUhABEg0KCUFMSUFTX0JBWhACEgcKA1FVWBACEgcKA3F1eBACEgcK",
"A2JBehACGgIQAUINCgtvbmVvZl9maWVsZEoGCPUDEP8DIhsKDkZvcmVpZ25N",
"ZXNzYWdlEgkKAWMYASABKAUqQAoLRm9yZWlnbkVudW0SDwoLRk9SRUlHTl9G",
"T08QABIPCgtGT1JFSUdOX0JBUhABEg8KC0ZPUkVJR05fQkFaEAJCOAooY29t",
"Lmdvb2dsZS5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvM0gB+AEBogIG",
"UHJvdG8zYgZwcm90bzM="));
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),
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", "PackedInt32", "PackedInt64", "PackedUint32", "PackedUint64", "PackedSint32", "PackedSint64", "PackedFixed32", "PackedFixed64", "PackedSfixed32", "PackedSfixed64", "PackedFloat", "PackedDouble", "PackedBool", "PackedNestedEnum", "UnpackedInt32", "UnpackedInt64", "UnpackedUint32", "UnpackedUint64", "UnpackedSint32", "UnpackedSint64", "UnpackedFixed32", "UnpackedFixed64", "UnpackedSfixed32", "UnpackedSfixed64", "UnpackedFloat", "UnpackedDouble", "UnpackedBool", "UnpackedNestedEnum", "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)
}));
@ -307,6 +328,34 @@ namespace ProtobufTestMessages.Proto3 {
repeatedForeignEnum_ = other.repeatedForeignEnum_.Clone();
repeatedStringPiece_ = other.repeatedStringPiece_.Clone();
repeatedCord_ = other.repeatedCord_.Clone();
packedInt32_ = other.packedInt32_.Clone();
packedInt64_ = other.packedInt64_.Clone();
packedUint32_ = other.packedUint32_.Clone();
packedUint64_ = other.packedUint64_.Clone();
packedSint32_ = other.packedSint32_.Clone();
packedSint64_ = other.packedSint64_.Clone();
packedFixed32_ = other.packedFixed32_.Clone();
packedFixed64_ = other.packedFixed64_.Clone();
packedSfixed32_ = other.packedSfixed32_.Clone();
packedSfixed64_ = other.packedSfixed64_.Clone();
packedFloat_ = other.packedFloat_.Clone();
packedDouble_ = other.packedDouble_.Clone();
packedBool_ = other.packedBool_.Clone();
packedNestedEnum_ = other.packedNestedEnum_.Clone();
unpackedInt32_ = other.unpackedInt32_.Clone();
unpackedInt64_ = other.unpackedInt64_.Clone();
unpackedUint32_ = other.unpackedUint32_.Clone();
unpackedUint64_ = other.unpackedUint64_.Clone();
unpackedSint32_ = other.unpackedSint32_.Clone();
unpackedSint64_ = other.unpackedSint64_.Clone();
unpackedFixed32_ = other.unpackedFixed32_.Clone();
unpackedFixed64_ = other.unpackedFixed64_.Clone();
unpackedSfixed32_ = other.unpackedSfixed32_.Clone();
unpackedSfixed64_ = other.unpackedSfixed64_.Clone();
unpackedFloat_ = other.unpackedFloat_.Clone();
unpackedDouble_ = other.unpackedDouble_.Clone();
unpackedBool_ = other.unpackedBool_.Clone();
unpackedNestedEnum_ = other.unpackedNestedEnum_.Clone();
mapInt32Int32_ = other.mapInt32Int32_.Clone();
mapInt64Int64_ = other.mapInt64Int64_.Clone();
mapUint32Uint32_ = other.mapUint32Uint32_.Clone();
@ -882,6 +931,292 @@ namespace ProtobufTestMessages.Proto3 {
get { return repeatedCord_; }
}
/// <summary>Field number for the "packed_int32" field.</summary>
public const int PackedInt32FieldNumber = 75;
private static readonly pb::FieldCodec<int> _repeated_packedInt32_codec
= pb::FieldCodec.ForInt32(602);
private readonly pbc::RepeatedField<int> packedInt32_ = new pbc::RepeatedField<int>();
/// <summary>
/// Packed
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<int> PackedInt32 {
get { return packedInt32_; }
}
/// <summary>Field number for the "packed_int64" field.</summary>
public const int PackedInt64FieldNumber = 76;
private static readonly pb::FieldCodec<long> _repeated_packedInt64_codec
= pb::FieldCodec.ForInt64(610);
private readonly pbc::RepeatedField<long> packedInt64_ = new pbc::RepeatedField<long>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<long> PackedInt64 {
get { return packedInt64_; }
}
/// <summary>Field number for the "packed_uint32" field.</summary>
public const int PackedUint32FieldNumber = 77;
private static readonly pb::FieldCodec<uint> _repeated_packedUint32_codec
= pb::FieldCodec.ForUInt32(618);
private readonly pbc::RepeatedField<uint> packedUint32_ = new pbc::RepeatedField<uint>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<uint> PackedUint32 {
get { return packedUint32_; }
}
/// <summary>Field number for the "packed_uint64" field.</summary>
public const int PackedUint64FieldNumber = 78;
private static readonly pb::FieldCodec<ulong> _repeated_packedUint64_codec
= pb::FieldCodec.ForUInt64(626);
private readonly pbc::RepeatedField<ulong> packedUint64_ = new pbc::RepeatedField<ulong>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<ulong> PackedUint64 {
get { return packedUint64_; }
}
/// <summary>Field number for the "packed_sint32" field.</summary>
public const int PackedSint32FieldNumber = 79;
private static readonly pb::FieldCodec<int> _repeated_packedSint32_codec
= pb::FieldCodec.ForSInt32(634);
private readonly pbc::RepeatedField<int> packedSint32_ = new pbc::RepeatedField<int>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<int> PackedSint32 {
get { return packedSint32_; }
}
/// <summary>Field number for the "packed_sint64" field.</summary>
public const int PackedSint64FieldNumber = 80;
private static readonly pb::FieldCodec<long> _repeated_packedSint64_codec
= pb::FieldCodec.ForSInt64(642);
private readonly pbc::RepeatedField<long> packedSint64_ = new pbc::RepeatedField<long>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<long> PackedSint64 {
get { return packedSint64_; }
}
/// <summary>Field number for the "packed_fixed32" field.</summary>
public const int PackedFixed32FieldNumber = 81;
private static readonly pb::FieldCodec<uint> _repeated_packedFixed32_codec
= pb::FieldCodec.ForFixed32(650);
private readonly pbc::RepeatedField<uint> packedFixed32_ = new pbc::RepeatedField<uint>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<uint> PackedFixed32 {
get { return packedFixed32_; }
}
/// <summary>Field number for the "packed_fixed64" field.</summary>
public const int PackedFixed64FieldNumber = 82;
private static readonly pb::FieldCodec<ulong> _repeated_packedFixed64_codec
= pb::FieldCodec.ForFixed64(658);
private readonly pbc::RepeatedField<ulong> packedFixed64_ = new pbc::RepeatedField<ulong>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<ulong> PackedFixed64 {
get { return packedFixed64_; }
}
/// <summary>Field number for the "packed_sfixed32" field.</summary>
public const int PackedSfixed32FieldNumber = 83;
private static readonly pb::FieldCodec<int> _repeated_packedSfixed32_codec
= pb::FieldCodec.ForSFixed32(666);
private readonly pbc::RepeatedField<int> packedSfixed32_ = new pbc::RepeatedField<int>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<int> PackedSfixed32 {
get { return packedSfixed32_; }
}
/// <summary>Field number for the "packed_sfixed64" field.</summary>
public const int PackedSfixed64FieldNumber = 84;
private static readonly pb::FieldCodec<long> _repeated_packedSfixed64_codec
= pb::FieldCodec.ForSFixed64(674);
private readonly pbc::RepeatedField<long> packedSfixed64_ = new pbc::RepeatedField<long>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<long> PackedSfixed64 {
get { return packedSfixed64_; }
}
/// <summary>Field number for the "packed_float" field.</summary>
public const int PackedFloatFieldNumber = 85;
private static readonly pb::FieldCodec<float> _repeated_packedFloat_codec
= pb::FieldCodec.ForFloat(682);
private readonly pbc::RepeatedField<float> packedFloat_ = new pbc::RepeatedField<float>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<float> PackedFloat {
get { return packedFloat_; }
}
/// <summary>Field number for the "packed_double" field.</summary>
public const int PackedDoubleFieldNumber = 86;
private static readonly pb::FieldCodec<double> _repeated_packedDouble_codec
= pb::FieldCodec.ForDouble(690);
private readonly pbc::RepeatedField<double> packedDouble_ = new pbc::RepeatedField<double>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<double> PackedDouble {
get { return packedDouble_; }
}
/// <summary>Field number for the "packed_bool" field.</summary>
public const int PackedBoolFieldNumber = 87;
private static readonly pb::FieldCodec<bool> _repeated_packedBool_codec
= pb::FieldCodec.ForBool(698);
private readonly pbc::RepeatedField<bool> packedBool_ = new pbc::RepeatedField<bool>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<bool> PackedBool {
get { return packedBool_; }
}
/// <summary>Field number for the "packed_nested_enum" field.</summary>
public const int PackedNestedEnumFieldNumber = 88;
private static readonly pb::FieldCodec<global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum> _repeated_packedNestedEnum_codec
= pb::FieldCodec.ForEnum(706, x => (int) x, x => (global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum) x);
private readonly pbc::RepeatedField<global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum> packedNestedEnum_ = new pbc::RepeatedField<global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum> PackedNestedEnum {
get { return packedNestedEnum_; }
}
/// <summary>Field number for the "unpacked_int32" field.</summary>
public const int UnpackedInt32FieldNumber = 89;
private static readonly pb::FieldCodec<int> _repeated_unpackedInt32_codec
= pb::FieldCodec.ForInt32(712);
private readonly pbc::RepeatedField<int> unpackedInt32_ = new pbc::RepeatedField<int>();
/// <summary>
/// Unpacked
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<int> UnpackedInt32 {
get { return unpackedInt32_; }
}
/// <summary>Field number for the "unpacked_int64" field.</summary>
public const int UnpackedInt64FieldNumber = 90;
private static readonly pb::FieldCodec<long> _repeated_unpackedInt64_codec
= pb::FieldCodec.ForInt64(720);
private readonly pbc::RepeatedField<long> unpackedInt64_ = new pbc::RepeatedField<long>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<long> UnpackedInt64 {
get { return unpackedInt64_; }
}
/// <summary>Field number for the "unpacked_uint32" field.</summary>
public const int UnpackedUint32FieldNumber = 91;
private static readonly pb::FieldCodec<uint> _repeated_unpackedUint32_codec
= pb::FieldCodec.ForUInt32(728);
private readonly pbc::RepeatedField<uint> unpackedUint32_ = new pbc::RepeatedField<uint>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<uint> UnpackedUint32 {
get { return unpackedUint32_; }
}
/// <summary>Field number for the "unpacked_uint64" field.</summary>
public const int UnpackedUint64FieldNumber = 92;
private static readonly pb::FieldCodec<ulong> _repeated_unpackedUint64_codec
= pb::FieldCodec.ForUInt64(736);
private readonly pbc::RepeatedField<ulong> unpackedUint64_ = new pbc::RepeatedField<ulong>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<ulong> UnpackedUint64 {
get { return unpackedUint64_; }
}
/// <summary>Field number for the "unpacked_sint32" field.</summary>
public const int UnpackedSint32FieldNumber = 93;
private static readonly pb::FieldCodec<int> _repeated_unpackedSint32_codec
= pb::FieldCodec.ForSInt32(744);
private readonly pbc::RepeatedField<int> unpackedSint32_ = new pbc::RepeatedField<int>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<int> UnpackedSint32 {
get { return unpackedSint32_; }
}
/// <summary>Field number for the "unpacked_sint64" field.</summary>
public const int UnpackedSint64FieldNumber = 94;
private static readonly pb::FieldCodec<long> _repeated_unpackedSint64_codec
= pb::FieldCodec.ForSInt64(752);
private readonly pbc::RepeatedField<long> unpackedSint64_ = new pbc::RepeatedField<long>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<long> UnpackedSint64 {
get { return unpackedSint64_; }
}
/// <summary>Field number for the "unpacked_fixed32" field.</summary>
public const int UnpackedFixed32FieldNumber = 95;
private static readonly pb::FieldCodec<uint> _repeated_unpackedFixed32_codec
= pb::FieldCodec.ForFixed32(765);
private readonly pbc::RepeatedField<uint> unpackedFixed32_ = new pbc::RepeatedField<uint>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<uint> UnpackedFixed32 {
get { return unpackedFixed32_; }
}
/// <summary>Field number for the "unpacked_fixed64" field.</summary>
public const int UnpackedFixed64FieldNumber = 96;
private static readonly pb::FieldCodec<ulong> _repeated_unpackedFixed64_codec
= pb::FieldCodec.ForFixed64(769);
private readonly pbc::RepeatedField<ulong> unpackedFixed64_ = new pbc::RepeatedField<ulong>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<ulong> UnpackedFixed64 {
get { return unpackedFixed64_; }
}
/// <summary>Field number for the "unpacked_sfixed32" field.</summary>
public const int UnpackedSfixed32FieldNumber = 97;
private static readonly pb::FieldCodec<int> _repeated_unpackedSfixed32_codec
= pb::FieldCodec.ForSFixed32(781);
private readonly pbc::RepeatedField<int> unpackedSfixed32_ = new pbc::RepeatedField<int>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<int> UnpackedSfixed32 {
get { return unpackedSfixed32_; }
}
/// <summary>Field number for the "unpacked_sfixed64" field.</summary>
public const int UnpackedSfixed64FieldNumber = 98;
private static readonly pb::FieldCodec<long> _repeated_unpackedSfixed64_codec
= pb::FieldCodec.ForSFixed64(785);
private readonly pbc::RepeatedField<long> unpackedSfixed64_ = new pbc::RepeatedField<long>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<long> UnpackedSfixed64 {
get { return unpackedSfixed64_; }
}
/// <summary>Field number for the "unpacked_float" field.</summary>
public const int UnpackedFloatFieldNumber = 99;
private static readonly pb::FieldCodec<float> _repeated_unpackedFloat_codec
= pb::FieldCodec.ForFloat(797);
private readonly pbc::RepeatedField<float> unpackedFloat_ = new pbc::RepeatedField<float>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<float> UnpackedFloat {
get { return unpackedFloat_; }
}
/// <summary>Field number for the "unpacked_double" field.</summary>
public const int UnpackedDoubleFieldNumber = 100;
private static readonly pb::FieldCodec<double> _repeated_unpackedDouble_codec
= pb::FieldCodec.ForDouble(801);
private readonly pbc::RepeatedField<double> unpackedDouble_ = new pbc::RepeatedField<double>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<double> UnpackedDouble {
get { return unpackedDouble_; }
}
/// <summary>Field number for the "unpacked_bool" field.</summary>
public const int UnpackedBoolFieldNumber = 101;
private static readonly pb::FieldCodec<bool> _repeated_unpackedBool_codec
= pb::FieldCodec.ForBool(808);
private readonly pbc::RepeatedField<bool> unpackedBool_ = new pbc::RepeatedField<bool>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<bool> UnpackedBool {
get { return unpackedBool_; }
}
/// <summary>Field number for the "unpacked_nested_enum" field.</summary>
public const int UnpackedNestedEnumFieldNumber = 102;
private static readonly pb::FieldCodec<global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum> _repeated_unpackedNestedEnum_codec
= pb::FieldCodec.ForEnum(816, x => (int) x, x => (global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum) x);
private readonly pbc::RepeatedField<global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum> unpackedNestedEnum_ = new pbc::RepeatedField<global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum> UnpackedNestedEnum {
get { return unpackedNestedEnum_; }
}
/// <summary>Field number for the "map_int32_int32" field.</summary>
public const int MapInt32Int32FieldNumber = 56;
private static readonly pbc::MapField<int, int>.Codec _map_mapInt32Int32_codec
@ -1805,6 +2140,34 @@ namespace ProtobufTestMessages.Proto3 {
if(!repeatedForeignEnum_.Equals(other.repeatedForeignEnum_)) return false;
if(!repeatedStringPiece_.Equals(other.repeatedStringPiece_)) return false;
if(!repeatedCord_.Equals(other.repeatedCord_)) return false;
if(!packedInt32_.Equals(other.packedInt32_)) return false;
if(!packedInt64_.Equals(other.packedInt64_)) return false;
if(!packedUint32_.Equals(other.packedUint32_)) return false;
if(!packedUint64_.Equals(other.packedUint64_)) return false;
if(!packedSint32_.Equals(other.packedSint32_)) return false;
if(!packedSint64_.Equals(other.packedSint64_)) return false;
if(!packedFixed32_.Equals(other.packedFixed32_)) return false;
if(!packedFixed64_.Equals(other.packedFixed64_)) return false;
if(!packedSfixed32_.Equals(other.packedSfixed32_)) return false;
if(!packedSfixed64_.Equals(other.packedSfixed64_)) return false;
if(!packedFloat_.Equals(other.packedFloat_)) return false;
if(!packedDouble_.Equals(other.packedDouble_)) return false;
if(!packedBool_.Equals(other.packedBool_)) return false;
if(!packedNestedEnum_.Equals(other.packedNestedEnum_)) return false;
if(!unpackedInt32_.Equals(other.unpackedInt32_)) return false;
if(!unpackedInt64_.Equals(other.unpackedInt64_)) return false;
if(!unpackedUint32_.Equals(other.unpackedUint32_)) return false;
if(!unpackedUint64_.Equals(other.unpackedUint64_)) return false;
if(!unpackedSint32_.Equals(other.unpackedSint32_)) return false;
if(!unpackedSint64_.Equals(other.unpackedSint64_)) return false;
if(!unpackedFixed32_.Equals(other.unpackedFixed32_)) return false;
if(!unpackedFixed64_.Equals(other.unpackedFixed64_)) return false;
if(!unpackedSfixed32_.Equals(other.unpackedSfixed32_)) return false;
if(!unpackedSfixed64_.Equals(other.unpackedSfixed64_)) return false;
if(!unpackedFloat_.Equals(other.unpackedFloat_)) return false;
if(!unpackedDouble_.Equals(other.unpackedDouble_)) return false;
if(!unpackedBool_.Equals(other.unpackedBool_)) return false;
if(!unpackedNestedEnum_.Equals(other.unpackedNestedEnum_)) return false;
if (!MapInt32Int32.Equals(other.MapInt32Int32)) return false;
if (!MapInt64Int64.Equals(other.MapInt64Int64)) return false;
if (!MapUint32Uint32.Equals(other.MapUint32Uint32)) return false;
@ -1933,6 +2296,34 @@ namespace ProtobufTestMessages.Proto3 {
hash ^= repeatedForeignEnum_.GetHashCode();
hash ^= repeatedStringPiece_.GetHashCode();
hash ^= repeatedCord_.GetHashCode();
hash ^= packedInt32_.GetHashCode();
hash ^= packedInt64_.GetHashCode();
hash ^= packedUint32_.GetHashCode();
hash ^= packedUint64_.GetHashCode();
hash ^= packedSint32_.GetHashCode();
hash ^= packedSint64_.GetHashCode();
hash ^= packedFixed32_.GetHashCode();
hash ^= packedFixed64_.GetHashCode();
hash ^= packedSfixed32_.GetHashCode();
hash ^= packedSfixed64_.GetHashCode();
hash ^= packedFloat_.GetHashCode();
hash ^= packedDouble_.GetHashCode();
hash ^= packedBool_.GetHashCode();
hash ^= packedNestedEnum_.GetHashCode();
hash ^= unpackedInt32_.GetHashCode();
hash ^= unpackedInt64_.GetHashCode();
hash ^= unpackedUint32_.GetHashCode();
hash ^= unpackedUint64_.GetHashCode();
hash ^= unpackedSint32_.GetHashCode();
hash ^= unpackedSint64_.GetHashCode();
hash ^= unpackedFixed32_.GetHashCode();
hash ^= unpackedFixed64_.GetHashCode();
hash ^= unpackedSfixed32_.GetHashCode();
hash ^= unpackedSfixed64_.GetHashCode();
hash ^= unpackedFloat_.GetHashCode();
hash ^= unpackedDouble_.GetHashCode();
hash ^= unpackedBool_.GetHashCode();
hash ^= unpackedNestedEnum_.GetHashCode();
hash ^= MapInt32Int32.GetHashCode();
hash ^= MapInt64Int64.GetHashCode();
hash ^= MapUint32Uint32.GetHashCode();
@ -2156,6 +2547,34 @@ namespace ProtobufTestMessages.Proto3 {
mapStringForeignMessage_.WriteTo(output, _map_mapStringForeignMessage_codec);
mapStringNestedEnum_.WriteTo(output, _map_mapStringNestedEnum_codec);
mapStringForeignEnum_.WriteTo(output, _map_mapStringForeignEnum_codec);
packedInt32_.WriteTo(output, _repeated_packedInt32_codec);
packedInt64_.WriteTo(output, _repeated_packedInt64_codec);
packedUint32_.WriteTo(output, _repeated_packedUint32_codec);
packedUint64_.WriteTo(output, _repeated_packedUint64_codec);
packedSint32_.WriteTo(output, _repeated_packedSint32_codec);
packedSint64_.WriteTo(output, _repeated_packedSint64_codec);
packedFixed32_.WriteTo(output, _repeated_packedFixed32_codec);
packedFixed64_.WriteTo(output, _repeated_packedFixed64_codec);
packedSfixed32_.WriteTo(output, _repeated_packedSfixed32_codec);
packedSfixed64_.WriteTo(output, _repeated_packedSfixed64_codec);
packedFloat_.WriteTo(output, _repeated_packedFloat_codec);
packedDouble_.WriteTo(output, _repeated_packedDouble_codec);
packedBool_.WriteTo(output, _repeated_packedBool_codec);
packedNestedEnum_.WriteTo(output, _repeated_packedNestedEnum_codec);
unpackedInt32_.WriteTo(output, _repeated_unpackedInt32_codec);
unpackedInt64_.WriteTo(output, _repeated_unpackedInt64_codec);
unpackedUint32_.WriteTo(output, _repeated_unpackedUint32_codec);
unpackedUint64_.WriteTo(output, _repeated_unpackedUint64_codec);
unpackedSint32_.WriteTo(output, _repeated_unpackedSint32_codec);
unpackedSint64_.WriteTo(output, _repeated_unpackedSint64_codec);
unpackedFixed32_.WriteTo(output, _repeated_unpackedFixed32_codec);
unpackedFixed64_.WriteTo(output, _repeated_unpackedFixed64_codec);
unpackedSfixed32_.WriteTo(output, _repeated_unpackedSfixed32_codec);
unpackedSfixed64_.WriteTo(output, _repeated_unpackedSfixed64_codec);
unpackedFloat_.WriteTo(output, _repeated_unpackedFloat_codec);
unpackedDouble_.WriteTo(output, _repeated_unpackedDouble_codec);
unpackedBool_.WriteTo(output, _repeated_unpackedBool_codec);
unpackedNestedEnum_.WriteTo(output, _repeated_unpackedNestedEnum_codec);
if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) {
output.WriteRawTag(248, 6);
output.WriteUInt32(OneofUint32);
@ -2429,6 +2848,34 @@ namespace ProtobufTestMessages.Proto3 {
size += repeatedForeignEnum_.CalculateSize(_repeated_repeatedForeignEnum_codec);
size += repeatedStringPiece_.CalculateSize(_repeated_repeatedStringPiece_codec);
size += repeatedCord_.CalculateSize(_repeated_repeatedCord_codec);
size += packedInt32_.CalculateSize(_repeated_packedInt32_codec);
size += packedInt64_.CalculateSize(_repeated_packedInt64_codec);
size += packedUint32_.CalculateSize(_repeated_packedUint32_codec);
size += packedUint64_.CalculateSize(_repeated_packedUint64_codec);
size += packedSint32_.CalculateSize(_repeated_packedSint32_codec);
size += packedSint64_.CalculateSize(_repeated_packedSint64_codec);
size += packedFixed32_.CalculateSize(_repeated_packedFixed32_codec);
size += packedFixed64_.CalculateSize(_repeated_packedFixed64_codec);
size += packedSfixed32_.CalculateSize(_repeated_packedSfixed32_codec);
size += packedSfixed64_.CalculateSize(_repeated_packedSfixed64_codec);
size += packedFloat_.CalculateSize(_repeated_packedFloat_codec);
size += packedDouble_.CalculateSize(_repeated_packedDouble_codec);
size += packedBool_.CalculateSize(_repeated_packedBool_codec);
size += packedNestedEnum_.CalculateSize(_repeated_packedNestedEnum_codec);
size += unpackedInt32_.CalculateSize(_repeated_unpackedInt32_codec);
size += unpackedInt64_.CalculateSize(_repeated_unpackedInt64_codec);
size += unpackedUint32_.CalculateSize(_repeated_unpackedUint32_codec);
size += unpackedUint64_.CalculateSize(_repeated_unpackedUint64_codec);
size += unpackedSint32_.CalculateSize(_repeated_unpackedSint32_codec);
size += unpackedSint64_.CalculateSize(_repeated_unpackedSint64_codec);
size += unpackedFixed32_.CalculateSize(_repeated_unpackedFixed32_codec);
size += unpackedFixed64_.CalculateSize(_repeated_unpackedFixed64_codec);
size += unpackedSfixed32_.CalculateSize(_repeated_unpackedSfixed32_codec);
size += unpackedSfixed64_.CalculateSize(_repeated_unpackedSfixed64_codec);
size += unpackedFloat_.CalculateSize(_repeated_unpackedFloat_codec);
size += unpackedDouble_.CalculateSize(_repeated_unpackedDouble_codec);
size += unpackedBool_.CalculateSize(_repeated_unpackedBool_codec);
size += unpackedNestedEnum_.CalculateSize(_repeated_unpackedNestedEnum_codec);
size += mapInt32Int32_.CalculateSize(_map_mapInt32Int32_codec);
size += mapInt64Int64_.CalculateSize(_map_mapInt64Int64_codec);
size += mapUint32Uint32_.CalculateSize(_map_mapUint32Uint32_codec);
@ -2700,6 +3147,34 @@ namespace ProtobufTestMessages.Proto3 {
repeatedForeignEnum_.Add(other.repeatedForeignEnum_);
repeatedStringPiece_.Add(other.repeatedStringPiece_);
repeatedCord_.Add(other.repeatedCord_);
packedInt32_.Add(other.packedInt32_);
packedInt64_.Add(other.packedInt64_);
packedUint32_.Add(other.packedUint32_);
packedUint64_.Add(other.packedUint64_);
packedSint32_.Add(other.packedSint32_);
packedSint64_.Add(other.packedSint64_);
packedFixed32_.Add(other.packedFixed32_);
packedFixed64_.Add(other.packedFixed64_);
packedSfixed32_.Add(other.packedSfixed32_);
packedSfixed64_.Add(other.packedSfixed64_);
packedFloat_.Add(other.packedFloat_);
packedDouble_.Add(other.packedDouble_);
packedBool_.Add(other.packedBool_);
packedNestedEnum_.Add(other.packedNestedEnum_);
unpackedInt32_.Add(other.unpackedInt32_);
unpackedInt64_.Add(other.unpackedInt64_);
unpackedUint32_.Add(other.unpackedUint32_);
unpackedUint64_.Add(other.unpackedUint64_);
unpackedSint32_.Add(other.unpackedSint32_);
unpackedSint64_.Add(other.unpackedSint64_);
unpackedFixed32_.Add(other.unpackedFixed32_);
unpackedFixed64_.Add(other.unpackedFixed64_);
unpackedSfixed32_.Add(other.unpackedSfixed32_);
unpackedSfixed64_.Add(other.unpackedSfixed64_);
unpackedFloat_.Add(other.unpackedFloat_);
unpackedDouble_.Add(other.unpackedDouble_);
unpackedBool_.Add(other.unpackedBool_);
unpackedNestedEnum_.Add(other.unpackedNestedEnum_);
mapInt32Int32_.Add(other.mapInt32Int32_);
mapInt64Int64_.Add(other.mapInt64Int64_);
mapUint32Uint32_.Add(other.mapUint32Uint32_);
@ -3190,6 +3665,146 @@ namespace ProtobufTestMessages.Proto3 {
mapStringForeignEnum_.AddEntriesFrom(input, _map_mapStringForeignEnum_codec);
break;
}
case 602:
case 600: {
packedInt32_.AddEntriesFrom(input, _repeated_packedInt32_codec);
break;
}
case 610:
case 608: {
packedInt64_.AddEntriesFrom(input, _repeated_packedInt64_codec);
break;
}
case 618:
case 616: {
packedUint32_.AddEntriesFrom(input, _repeated_packedUint32_codec);
break;
}
case 626:
case 624: {
packedUint64_.AddEntriesFrom(input, _repeated_packedUint64_codec);
break;
}
case 634:
case 632: {
packedSint32_.AddEntriesFrom(input, _repeated_packedSint32_codec);
break;
}
case 642:
case 640: {
packedSint64_.AddEntriesFrom(input, _repeated_packedSint64_codec);
break;
}
case 650:
case 653: {
packedFixed32_.AddEntriesFrom(input, _repeated_packedFixed32_codec);
break;
}
case 658:
case 657: {
packedFixed64_.AddEntriesFrom(input, _repeated_packedFixed64_codec);
break;
}
case 666:
case 669: {
packedSfixed32_.AddEntriesFrom(input, _repeated_packedSfixed32_codec);
break;
}
case 674:
case 673: {
packedSfixed64_.AddEntriesFrom(input, _repeated_packedSfixed64_codec);
break;
}
case 682:
case 685: {
packedFloat_.AddEntriesFrom(input, _repeated_packedFloat_codec);
break;
}
case 690:
case 689: {
packedDouble_.AddEntriesFrom(input, _repeated_packedDouble_codec);
break;
}
case 698:
case 696: {
packedBool_.AddEntriesFrom(input, _repeated_packedBool_codec);
break;
}
case 706:
case 704: {
packedNestedEnum_.AddEntriesFrom(input, _repeated_packedNestedEnum_codec);
break;
}
case 714:
case 712: {
unpackedInt32_.AddEntriesFrom(input, _repeated_unpackedInt32_codec);
break;
}
case 722:
case 720: {
unpackedInt64_.AddEntriesFrom(input, _repeated_unpackedInt64_codec);
break;
}
case 730:
case 728: {
unpackedUint32_.AddEntriesFrom(input, _repeated_unpackedUint32_codec);
break;
}
case 738:
case 736: {
unpackedUint64_.AddEntriesFrom(input, _repeated_unpackedUint64_codec);
break;
}
case 746:
case 744: {
unpackedSint32_.AddEntriesFrom(input, _repeated_unpackedSint32_codec);
break;
}
case 754:
case 752: {
unpackedSint64_.AddEntriesFrom(input, _repeated_unpackedSint64_codec);
break;
}
case 762:
case 765: {
unpackedFixed32_.AddEntriesFrom(input, _repeated_unpackedFixed32_codec);
break;
}
case 770:
case 769: {
unpackedFixed64_.AddEntriesFrom(input, _repeated_unpackedFixed64_codec);
break;
}
case 778:
case 781: {
unpackedSfixed32_.AddEntriesFrom(input, _repeated_unpackedSfixed32_codec);
break;
}
case 786:
case 785: {
unpackedSfixed64_.AddEntriesFrom(input, _repeated_unpackedSfixed64_codec);
break;
}
case 794:
case 797: {
unpackedFloat_.AddEntriesFrom(input, _repeated_unpackedFloat_codec);
break;
}
case 802:
case 801: {
unpackedDouble_.AddEntriesFrom(input, _repeated_unpackedDouble_codec);
break;
}
case 810:
case 808: {
unpackedBool_.AddEntriesFrom(input, _repeated_unpackedBool_codec);
break;
}
case 818:
case 816: {
unpackedNestedEnum_.AddEntriesFrom(input, _repeated_unpackedNestedEnum_codec);
break;
}
case 888: {
OneofUint32 = input.ReadUInt32();
break;

File diff suppressed because one or more lines are too long

@ -165,7 +165,7 @@ namespace UnitTest.Issues.TestProtos {
}
/// <summary>Holder for extension identifiers generated from the top level of unittest_custom_options_proto3.proto</summary>
internal static partial class UnittestCustomOptionsProto3Extensions {
public static partial class UnittestCustomOptionsProto3Extensions {
public static readonly pb::Extension<global::Google.Protobuf.Reflection.FileOptions, ulong> FileOpt1 =
new pb::Extension<global::Google.Protobuf.Reflection.FileOptions, ulong>(7736974, pb::FieldCodec.ForUInt64(61895792, 0UL));
public static readonly pb::Extension<global::Google.Protobuf.Reflection.MessageOptions, int> MessageOpt1 =
@ -2138,7 +2138,7 @@ namespace UnitTest.Issues.TestProtos {
#region Extensions
/// <summary>Container for extensions for other messages declared in the ComplexOptionType4 message type.</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
internal static partial class Extensions {
public static partial class Extensions {
public static readonly pb::Extension<global::Google.Protobuf.Reflection.MessageOptions, global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4> ComplexOpt4 =
new pb::Extension<global::Google.Protobuf.Reflection.MessageOptions, global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4>(7633546, pb::FieldCodec.ForMessage(61068370, global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4.Parser));
}

@ -0,0 +1,210 @@
// <auto-generated>
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: unittest_import.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#region Designer generated code
using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections;
using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace Google.Protobuf.TestProtos.Proto2 {
/// <summary>Holder for reflection information generated from unittest_import.proto</summary>
public static partial class UnittestImportReflection {
#region Descriptor
/// <summary>File descriptor for unittest_import.proto</summary>
public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
}
private static pbr::FileDescriptor descriptor;
static UnittestImportReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"ChV1bml0dGVzdF9pbXBvcnQucHJvdG8SH3Byb3RvYnVmX3VuaXR0ZXN0X2lt",
"cG9ydF9wcm90bzIaHHVuaXR0ZXN0X2ltcG9ydF9wdWJsaWMucHJvdG8iGgoN",
"SW1wb3J0TWVzc2FnZRIJCgFkGAEgASgFKjwKCkltcG9ydEVudW0SDgoKSU1Q",
"T1JUX0ZPTxAHEg4KCklNUE9SVF9CQVIQCBIOCgpJTVBPUlRfQkFaEAkqMQoQ",
"SW1wb3J0RW51bUZvck1hcBILCgdVTktOT1dOEAASBwoDRk9PEAESBwoDQkFS",
"EAJCKUgB+AEBqgIhR29vZ2xlLlByb3RvYnVmLlRlc3RQcm90b3MuUHJvdG8y",
"UAA="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Protobuf.TestProtos.Proto2.UnittestImportPublicReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.TestProtos.Proto2.ImportEnum), typeof(global::Google.Protobuf.TestProtos.Proto2.ImportEnumForMap), }, null, new pbr::GeneratedClrTypeInfo[] {
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.Proto2.ImportMessage), global::Google.Protobuf.TestProtos.Proto2.ImportMessage.Parser, new[]{ "D" }, null, null, null, null)
}));
}
#endregion
}
#region Enums
public enum ImportEnum {
[pbr::OriginalName("IMPORT_FOO")] ImportFoo = 7,
[pbr::OriginalName("IMPORT_BAR")] ImportBar = 8,
[pbr::OriginalName("IMPORT_BAZ")] ImportBaz = 9,
}
/// <summary>
/// To use an enum in a map, it must has the first value as 0.
/// </summary>
public enum ImportEnumForMap {
[pbr::OriginalName("UNKNOWN")] Unknown = 0,
[pbr::OriginalName("FOO")] Foo = 1,
[pbr::OriginalName("BAR")] Bar = 2,
}
#endregion
#region Messages
public sealed partial class ImportMessage : pb::IMessage<ImportMessage> {
private static readonly pb::MessageParser<ImportMessage> _parser = new pb::MessageParser<ImportMessage>(() => new ImportMessage());
private pb::UnknownFieldSet _unknownFields;
private int _hasBits0;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<ImportMessage> Parser { get { return _parser; } }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.TestProtos.Proto2.UnittestImportReflection.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() {
_hasBits0 = other._hasBits0;
d_ = other.d_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public ImportMessage Clone() {
return new ImportMessage(this);
}
/// <summary>Field number for the "d" field.</summary>
public const int DFieldNumber = 1;
private readonly static int DDefaultValue = 0;
private int d_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int D {
get { if ((_hasBits0 & 1) != 0) { return d_; } else { return DDefaultValue; } }
set {
_hasBits0 |= 1;
d_ = value;
}
}
/// <summary>Gets whether the "d" field is set</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool HasD {
get { return (_hasBits0 & 1) != 0; }
}
/// <summary>Clears the value of the "d" field</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void ClearD() {
_hasBits0 &= ~1;
}
[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;
}
if (ReferenceEquals(other, this)) {
return true;
}
if (D != other.D) return false;
return Equals(_unknownFields, other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
if (HasD) 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 (HasD) {
output.WriteRawTag(8);
output.WriteInt32(D);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
if (HasD) {
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;
}
if (other.HasD) {
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:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
D = input.ReadInt32();
break;
}
}
}
}
}
#endregion
}
#endregion Designer generated code

@ -0,0 +1,188 @@
// <auto-generated>
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: unittest_import_public.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#region Designer generated code
using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections;
using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace Google.Protobuf.TestProtos.Proto2 {
/// <summary>Holder for reflection information generated from unittest_import_public.proto</summary>
public static partial class UnittestImportPublicReflection {
#region Descriptor
/// <summary>File descriptor for unittest_import_public.proto</summary>
public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
}
private static pbr::FileDescriptor descriptor;
static UnittestImportPublicReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"Chx1bml0dGVzdF9pbXBvcnRfcHVibGljLnByb3RvEh9wcm90b2J1Zl91bml0",
"dGVzdF9pbXBvcnRfcHJvdG8yIiAKE1B1YmxpY0ltcG9ydE1lc3NhZ2USCQoB",
"ZRgBIAEoBUIkqgIhR29vZ2xlLlByb3RvYnVmLlRlc3RQcm90b3MuUHJvdG8y"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.Proto2.PublicImportMessage), global::Google.Protobuf.TestProtos.Proto2.PublicImportMessage.Parser, new[]{ "E" }, null, null, null, null)
}));
}
#endregion
}
#region Messages
public sealed partial class PublicImportMessage : pb::IMessage<PublicImportMessage> {
private static readonly pb::MessageParser<PublicImportMessage> _parser = new pb::MessageParser<PublicImportMessage>(() => new PublicImportMessage());
private pb::UnknownFieldSet _unknownFields;
private int _hasBits0;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<PublicImportMessage> Parser { get { return _parser; } }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.TestProtos.Proto2.UnittestImportPublicReflection.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() {
_hasBits0 = other._hasBits0;
e_ = other.e_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public PublicImportMessage Clone() {
return new PublicImportMessage(this);
}
/// <summary>Field number for the "e" field.</summary>
public const int EFieldNumber = 1;
private readonly static int EDefaultValue = 0;
private int e_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int E {
get { if ((_hasBits0 & 1) != 0) { return e_; } else { return EDefaultValue; } }
set {
_hasBits0 |= 1;
e_ = value;
}
}
/// <summary>Gets whether the "e" field is set</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool HasE {
get { return (_hasBits0 & 1) != 0; }
}
/// <summary>Clears the value of the "e" field</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void ClearE() {
_hasBits0 &= ~1;
}
[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;
}
if (ReferenceEquals(other, this)) {
return true;
}
if (E != other.E) return false;
return Equals(_unknownFields, other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
if (HasE) 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 (HasE) {
output.WriteRawTag(8);
output.WriteInt32(E);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
if (HasE) {
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;
}
if (other.HasE) {
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:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
E = input.ReadInt32();
break;
}
}
}
}
}
#endregion
}
#endregion Designer generated code

@ -33,12 +33,25 @@
using System;
using System.IO;
using Google.Protobuf.TestProtos;
using Proto2 = Google.Protobuf.TestProtos.Proto2;
using NUnit.Framework;
namespace Google.Protobuf
{
public class UnknownFieldSetTest
{
public class Data
{
public static System.Collections.IEnumerable Messages
{
get
{
yield return SampleMessages.CreateFullTestAllTypesProto2();
yield return SampleMessages.CreateFullTestAllTypes();
}
}
}
[Test]
public void EmptyUnknownFieldSet()
{
@ -60,24 +73,23 @@ namespace Google.Protobuf
}
[Test]
public void TestMergeCodedInput()
[TestCaseSource(typeof(Data), "Messages")]
public void TestMergeCodedInput(IMessage message)
{
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());
var newMessage = message.Descriptor.Parser.ParseFrom(emptyMessage.ToByteArray());
Assert.AreEqual(message, newMessage);
Assert.AreEqual(message.CalculateSize(), newMessage.CalculateSize());
}
[Test]
public void TestMergeMessage()
[TestCaseSource(typeof(Data), "Messages")]
public void TestMergeMessage(IMessage message)
{
var message = SampleMessages.CreateFullTestAllTypes();
var emptyMessage = new TestEmptyMessage();
var otherEmptyMessage = new TestEmptyMessage();
emptyMessage.MergeFrom(message.ToByteArray());
@ -88,9 +100,9 @@ namespace Google.Protobuf
}
[Test]
public void TestEquals()
[TestCaseSource(typeof(Data), "Messages")]
public void TestEquals(IMessage message)
{
var message = SampleMessages.CreateFullTestAllTypes();
var emptyMessage = new TestEmptyMessage();
var otherEmptyMessage = new TestEmptyMessage();
Assert.AreEqual(emptyMessage, otherEmptyMessage);
@ -101,9 +113,9 @@ namespace Google.Protobuf
}
[Test]
public void TestHashCode()
[TestCaseSource(typeof(Data), "Messages")]
public void TestHashCode(IMessage message)
{
var message = SampleMessages.CreateFullTestAllTypes();
var emptyMessage = new TestEmptyMessage();
int hashCode = emptyMessage.GetHashCode();
emptyMessage.MergeFrom(message.ToByteArray());
@ -111,7 +123,8 @@ namespace Google.Protobuf
}
[Test]
public void TestClone()
[TestCaseSource(typeof(Data), "Messages")]
public void TestClone(IMessage message)
{
var emptyMessage = new TestEmptyMessage();
var otherEmptyMessage = new TestEmptyMessage();
@ -119,7 +132,6 @@ namespace Google.Protobuf
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());
@ -127,9 +139,9 @@ namespace Google.Protobuf
}
[Test]
public void TestDiscardUnknownFields()
[TestCaseSource(typeof(Data), "Messages")]
public void TestDiscardUnknownFields(IMessage message)
{
var message = SampleMessages.CreateFullTestAllTypes();
var goldenEmptyMessage = new TestEmptyMessage();
byte[] data = message.ToByteArray();
int fullSize = message.CalculateSize();

@ -55,7 +55,7 @@ namespace Google.Protobuf
private readonly byte[] bytes;
/// <summary>
/// Unsafe operations that can cause IO Failure and/or other catestrophic side-effects.
/// Unsafe operations that can cause IO Failure and/or other catastrophic side-effects.
/// </summary>
internal static class Unsafe
{
@ -110,7 +110,7 @@ namespace Google.Protobuf
get { return Length == 0; }
}
#if NETSTANDARD2_0
#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY
/// <summary>
/// Provides read-only access to the data of this <see cref="ByteString"/>.
/// No data is copied so this is the most efficient way of accessing.
@ -218,7 +218,7 @@ namespace Google.Protobuf
return new ByteString(portion);
}
#if NETSTANDARD2_0
#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY
/// <summary>
/// Constructs a <see cref="ByteString" /> from a read only span. The contents
/// are copied, so further modifications to the span will not

@ -148,6 +148,10 @@ namespace Google.Protobuf.Collections
{
var sizeCalculator = codec.ValueSizeCalculator;
int size = count * CodedOutputStream.ComputeRawVarint32Size(tag);
if (codec.EndTag != 0)
{
size += count * CodedOutputStream.ComputeRawVarint32Size(codec.EndTag);
}
for (int i = 0; i < count; i++)
{
size += sizeCalculator(array[i]);
@ -216,14 +220,46 @@ namespace Google.Protobuf.Collections
}
}
/// <summary>
/// Gets and sets the capacity of the RepeatedField's internal array. WHen set, the internal array is reallocated to the given capacity.
/// <exception cref="ArgumentOutOfRangeException">The new value is less than Count -or- when Count is less than 0.</exception>
/// </summary>
public int Capacity
{
get { return array.Length; }
set
{
if (value < count)
{
throw new ArgumentOutOfRangeException("Capacity", value,
$"Cannot set Capacity to a value smaller than the current item count, {count}");
}
if (value >= 0 && value != array.Length)
{
SetSize(value);
}
}
}
// May increase the size of the internal array, but will never shrink it.
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);
SetSize(newSize);
}
}
// Sets the internal array to an exact size.
private void SetSize(int size)
{
if (size != array.Length)
{
var tmp = new T[size];
Array.Copy(array, 0, tmp, 0, count);
array = tmp;
}
}

@ -35,7 +35,7 @@ using System;
namespace Google.Protobuf
{
/// <summary>
/// Represents a non-generic extension definition
/// Represents a non-generic extension definition. This API is experimental and subject to change.
/// </summary>
public abstract class Extension
{
@ -44,9 +44,9 @@ namespace Google.Protobuf
/// <summary>
/// Internal use. Creates a new extension with the specified field number.
/// </summary>
protected Extension(int number)
protected Extension(int fieldNumber)
{
FieldNumber = number;
FieldNumber = fieldNumber;
}
internal abstract IExtensionValue CreateValue();
@ -58,7 +58,8 @@ namespace Google.Protobuf
}
/// <summary>
/// Represents a type-safe extension identifier used for getting and setting single extension values in <see cref="IExtendableMessage{T}"/> instances
/// Represents a type-safe extension identifier used for getting and setting single extension values in <see cref="IExtendableMessage{T}"/> instances.
/// This API is experimental and subject to change.
/// </summary>
/// <typeparam name="TTarget">The message type this field applies to</typeparam>
/// <typeparam name="TValue">The field value type of this extension</typeparam>
@ -69,7 +70,7 @@ namespace Google.Protobuf
/// <summary>
/// Creates a new extension identifier with the specified field number and codec
/// </summary>
public Extension(int number, FieldCodec<TValue> codec) : base(number)
public Extension(int fieldNumber, FieldCodec<TValue> codec) : base(fieldNumber)
{
this.codec = codec;
}
@ -85,7 +86,8 @@ namespace Google.Protobuf
}
/// <summary>
/// Represents a type-safe extension identifier used for getting repeated extension values in <see cref="IExtendableMessage{T}"/> instances
/// Represents a type-safe extension identifier used for getting repeated extension values in <see cref="IExtendableMessage{T}"/> instances.
/// This API is experimental and subject to change.
/// </summary>
/// <typeparam name="TTarget">The message type this field applies to</typeparam>
/// <typeparam name="TValue">The repeated field value type of this extension</typeparam>
@ -96,7 +98,7 @@ namespace Google.Protobuf
/// <summary>
/// Creates a new repeated extension identifier with the specified field number and codec
/// </summary>
public RepeatedExtension(int number, FieldCodec<TValue> codec) : base(number)
public RepeatedExtension(int fieldNumber, FieldCodec<TValue> codec) : base(fieldNumber)
{
this.codec = codec;
}

@ -38,7 +38,7 @@ using System.Linq;
namespace Google.Protobuf
{
/// <summary>
/// Provides extensions to messages while parsing
/// Provides extensions to messages while parsing. This API is experimental and subject to change.
/// </summary>
public sealed class ExtensionRegistry : ICollection<Extension>, IDeepCloneable<ExtensionRegistry>
{
@ -67,9 +67,9 @@ namespace Google.Protobuf
/// </summary>
bool ICollection<Extension>.IsReadOnly => false;
internal bool ContainsInputField(CodedInputStream stream, Type target, out Extension extension)
{
return extensions.TryGetValue(new ObjectIntPair<Type>(target, WireFormat.GetTagFieldNumber(stream.LastTag)), out extension);
internal bool ContainsInputField(CodedInputStream stream, Type target, out Extension extension)
{
return extensions.TryGetValue(new ObjectIntPair<Type>(target, WireFormat.GetTagFieldNumber(stream.LastTag)), out extension);
}
/// <summary>
@ -82,24 +82,14 @@ namespace Google.Protobuf
extensions.Add(new ObjectIntPair<Type>(extension.TargetType, extension.FieldNumber), extension);
}
/// <summary>
/// Adds the specified extensions to the registry
/// </summary>
public void Add(params Extension[] newExtensions)
{
ProtoPreconditions.CheckNotNull(newExtensions, nameof(newExtensions));
Add((IEnumerable<Extension>)newExtensions);
}
/// <summary>
/// Adds the specified extensions to the reigstry
/// </summary>
public void Add(IEnumerable<Extension> newExtensions)
public void AddRange(IEnumerable<Extension> extensions)
{
ProtoPreconditions.CheckNotNull(newExtensions, nameof(newExtensions));
ProtoPreconditions.CheckNotNull(extensions, nameof(extensions));
foreach (var extension in newExtensions)
foreach (var extension in extensions)
Add(extension);
}
@ -134,10 +124,10 @@ namespace Google.Protobuf
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<Type>(extension.TargetType, extension.FieldNumber), extension);
for (int i = 0; i < array.Length; i++)
{
Extension extension = array[i];
extensions.Add(new ObjectIntPair<Type>(extension.TargetType, extension.FieldNumber), extension);
}
}

@ -40,11 +40,11 @@ namespace Google.Protobuf
/// <summary>
/// Methods for managing <see cref="ExtensionSet{TTarget}"/>s with null checking.
///
/// Most users will not use this class directly
/// Most users will not use this class directly and its API is experimental and subject to change.
/// </summary>
public static class ExtensionSet
{
private static bool GetValue<TTarget>(ref ExtensionSet<TTarget> set, Extension extension, out IExtensionValue value) where TTarget : IExtendableMessage<TTarget>
private static bool TryGetValue<TTarget>(ref ExtensionSet<TTarget> set, Extension extension, out IExtensionValue value) where TTarget : IExtendableMessage<TTarget>
{
if (set == null)
{
@ -60,7 +60,7 @@ namespace Google.Protobuf
public static TValue Get<TTarget, TValue>(ref ExtensionSet<TTarget> set, Extension<TTarget, TValue> extension) where TTarget : IExtendableMessage<TTarget>
{
IExtensionValue value;
if (GetValue(ref set, extension, out value))
if (TryGetValue(ref set, extension, out value))
{
return ((ExtensionValue<TValue>)value).GetValue();
}
@ -76,7 +76,7 @@ namespace Google.Protobuf
public static RepeatedField<TValue> Get<TTarget, TValue>(ref ExtensionSet<TTarget> set, RepeatedExtension<TTarget, TValue> extension) where TTarget : IExtendableMessage<TTarget>
{
IExtensionValue value;
if (GetValue(ref set, extension, out value))
if (TryGetValue(ref set, extension, out value))
{
return ((RepeatedExtensionValue<TValue>)value).GetValue();
}
@ -89,7 +89,7 @@ namespace Google.Protobuf
/// <summary>
/// Gets the value of the specified repeated extension, registering it if it doesn't exist
/// </summary>
public static RepeatedField<TValue> GetOrRegister<TTarget, TValue>(ref ExtensionSet<TTarget> set, RepeatedExtension<TTarget, TValue> extension) where TTarget : IExtendableMessage<TTarget>
public static RepeatedField<TValue> GetOrInitialize<TTarget, TValue>(ref ExtensionSet<TTarget> set, RepeatedExtension<TTarget, TValue> extension) where TTarget : IExtendableMessage<TTarget>
{
IExtensionValue value;
if (set == null)
@ -111,10 +111,12 @@ namespace Google.Protobuf
}
/// <summary>
/// Sets the value of the specified extension
/// Sets the value of the specified extension. This will make a new instance of ExtensionSet if the set is null.
/// </summary>
public static void Set<TTarget, TValue>(ref ExtensionSet<TTarget> set, Extension<TTarget, TValue> extension, TValue value) where TTarget : IExtendableMessage<TTarget>
{
ProtoPreconditions.CheckNotNullUnconstrained(value, nameof(value));
IExtensionValue extensionValue;
if (set == null)
{
@ -140,14 +142,7 @@ namespace Google.Protobuf
public static bool Has<TTarget, TValue>(ref ExtensionSet<TTarget> set, Extension<TTarget, TValue> extension) where TTarget : IExtendableMessage<TTarget>
{
IExtensionValue value;
if (GetValue(ref set, extension, out value))
{
return ((ExtensionValue<TValue>)value).HasValue;
}
else
{
return false;
}
return TryGetValue(ref set, extension, out value);
}
/// <summary>
@ -337,5 +332,10 @@ namespace Google.Protobuf
value.WriteTo(stream);
}
}
internal bool IsInitialized()
{
return ValuesByNumber.Values.All(v => v.IsInitialized());
}
}
}

@ -32,6 +32,7 @@
using Google.Protobuf.Collections;
using System;
using System.Linq;
namespace Google.Protobuf
{
@ -41,11 +42,11 @@ namespace Google.Protobuf
void MergeFrom(IExtensionValue value);
void WriteTo(CodedOutputStream output);
int CalculateSize();
bool IsInitialized();
}
internal sealed class ExtensionValue<T> : IExtensionValue
{
private bool hasValue;
private T field;
private FieldCodec<T> codec;
@ -57,10 +58,6 @@ namespace Google.Protobuf
public int CalculateSize()
{
if (!hasValue)
{
return 0;
}
return codec.CalculateSizeWithTag(field);
}
@ -68,7 +65,6 @@ namespace Google.Protobuf
{
return new ExtensionValue<T>(codec)
{
hasValue = hasValue,
field = field is IDeepCloneable<T> ? (field as IDeepCloneable<T>).Clone() : field
};
}
@ -80,7 +76,6 @@ namespace Google.Protobuf
return other is ExtensionValue<T>
&& codec.Equals((other as ExtensionValue<T>).codec)
&& hasValue.Equals((other as ExtensionValue<T>).hasValue)
&& Equals(field, (other as ExtensionValue<T>).field);
// we check for equality in the codec since we could have equal field values however the values could be written in different ways
}
@ -90,7 +85,6 @@ namespace Google.Protobuf
unchecked
{
int hash = 17;
hash = hash * 31 + hasValue.GetHashCode();
hash = hash * 31 + field.GetHashCode();
hash = hash * 31 + codec.GetHashCode();
return hash;
@ -99,7 +93,6 @@ namespace Google.Protobuf
public void MergeFrom(CodedInputStream input)
{
hasValue = true;
codec.ValueMerger(input, ref field);
}
@ -107,24 +100,18 @@ namespace Google.Protobuf
{
if (value is ExtensionValue<T>)
{
var extensionValue = value as ExtensionValue<T>;
if (extensionValue.hasValue)
{
hasValue |= codec.FieldMerger(ref field, extensionValue.field);
}
var extensionValue = value as ExtensionValue<T>;
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.Tag);
codec.ValueWriter(output, field);
if (codec.EndTag != 0)
{
output.WriteTag(codec.EndTag);
}
output.WriteTag(codec.EndTag);
}
}
@ -132,11 +119,20 @@ namespace Google.Protobuf
public void SetValue(T value)
{
hasValue = true;
field = value;
}
public bool HasValue => hasValue;
public bool IsInitialized()
{
if (field is IMessage)
{
return (field as IMessage).IsInitialized();
}
else
{
return true;
}
}
}
internal sealed class RepeatedExtensionValue<T> : IExtensionValue
@ -203,5 +199,26 @@ namespace Google.Protobuf
}
public RepeatedField<T> GetValue() => field;
public bool IsInitialized()
{
for (int i = 0; i < field.Count; i++)
{
var element = field[i];
if (element is IMessage)
{
if (!(element as IMessage).IsInitialized())
{
return false;
}
}
else
{
break;
}
}
return true;
}
}
}

@ -45,15 +45,180 @@ namespace Google.Protobuf
{
// TODO: Avoid the "dual hit" of lambda expressions: create open delegates instead. (At least test...)
/// <summary>
/// Retrieves a codec suitable for a string field with the given tag.
/// </summary>
/// <param name="tag">The tag.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<string> ForString(uint tag)
{
return FieldCodec.ForString(tag, "");
}
/// <summary>
/// Retrieves a codec suitable for a bytes field with the given tag.
/// </summary>
/// <param name="tag">The tag.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<ByteString> ForBytes(uint tag)
{
return FieldCodec.ForBytes(tag, ByteString.Empty);
}
/// <summary>
/// Retrieves a codec suitable for a bool field with the given tag.
/// </summary>
/// <param name="tag">The tag.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<bool> ForBool(uint tag)
{
return FieldCodec.ForBool(tag, false);
}
/// <summary>
/// Retrieves a codec suitable for an int32 field with the given tag.
/// </summary>
/// <param name="tag">The tag.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<int> ForInt32(uint tag)
{
return FieldCodec.ForInt32(tag, 0);
}
/// <summary>
/// Retrieves a codec suitable for an sint32 field with the given tag.
/// </summary>
/// <param name="tag">The tag.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<int> ForSInt32(uint tag)
{
return FieldCodec.ForSInt32(tag, 0);
}
/// <summary>
/// Retrieves a codec suitable for a fixed32 field with the given tag.
/// </summary>
/// <param name="tag">The tag.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<uint> ForFixed32(uint tag)
{
return FieldCodec.ForFixed32(tag, 0);
}
/// <summary>
/// Retrieves a codec suitable for an sfixed32 field with the given tag.
/// </summary>
/// <param name="tag">The tag.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<int> ForSFixed32(uint tag)
{
return FieldCodec.ForSFixed32(tag, 0);
}
/// <summary>
/// Retrieves a codec suitable for a uint32 field with the given tag.
/// </summary>
/// <param name="tag">The tag.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<uint> ForUInt32(uint tag)
{
return FieldCodec.ForUInt32(tag, 0);
}
/// <summary>
/// Retrieves a codec suitable for an int64 field with the given tag.
/// </summary>
/// <param name="tag">The tag.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<long> ForInt64(uint tag)
{
return FieldCodec.ForInt64(tag, 0);
}
/// <summary>
/// Retrieves a codec suitable for an sint64 field with the given tag.
/// </summary>
/// <param name="tag">The tag.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<long> ForSInt64(uint tag)
{
return FieldCodec.ForSInt64(tag, 0);
}
/// <summary>
/// Retrieves a codec suitable for a fixed64 field with the given tag.
/// </summary>
/// <param name="tag">The tag.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<ulong> ForFixed64(uint tag)
{
return FieldCodec.ForFixed64(tag, 0);
}
/// <summary>
/// Retrieves a codec suitable for an sfixed64 field with the given tag.
/// </summary>
/// <param name="tag">The tag.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<long> ForSFixed64(uint tag)
{
return FieldCodec.ForSFixed64(tag, 0);
}
/// <summary>
/// Retrieves a codec suitable for a uint64 field with the given tag.
/// </summary>
/// <param name="tag">The tag.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<ulong> ForUInt64(uint tag)
{
return FieldCodec.ForUInt64(tag, 0);
}
/// <summary>
/// Retrieves a codec suitable for a float field with the given tag.
/// </summary>
/// <param name="tag">The tag.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<float> ForFloat(uint tag)
{
return FieldCodec.ForFloat(tag, 0);
}
/// <summary>
/// Retrieves a codec suitable for a double field with the given tag.
/// </summary>
/// <param name="tag">The tag.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<double> ForDouble(uint tag)
{
return FieldCodec.ForDouble(tag, 0);
}
// Enums are tricky. We can probably use expression trees to build these delegates automatically,
// but it's easy to generate the code for it.
/// <summary>
/// Retrieves a codec suitable for an enum field with the given tag.
/// </summary>
/// <param name="tag">The tag.</param>
/// <param name="toInt32">A conversion function from <see cref="Int32"/> to the enum type.</param>
/// <param name="fromInt32">A conversion function from the enum type to <see cref="Int32"/>.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<T> ForEnum<T>(uint tag, Func<T, int> toInt32, Func<int, T> fromInt32)
{
return FieldCodec.ForEnum(tag, toInt32, fromInt32, default(T));
}
/// <summary>
/// Retrieves a codec suitable for a string field with the given tag.
/// </summary>
/// <param name="tag">The tag.</param>
/// <param name="defaultValue">The default value.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<string> ForString(uint tag, string defaultValue = "")
public static FieldCodec<string> ForString(uint tag, string defaultValue)
{
return new FieldCodec<string>(input => input.ReadString(), (output, value) => output.WriteString(value), CodedOutputStream.ComputeStringSize, tag);
return new FieldCodec<string>(input => input.ReadString(), (output, value) => output.WriteString(value), CodedOutputStream.ComputeStringSize, tag, defaultValue);
}
/// <summary>
@ -62,9 +227,9 @@ namespace Google.Protobuf
/// <param name="tag">The tag.</param>
/// <param name="defaultValue">The default value.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<ByteString> ForBytes(uint tag, ByteString defaultValue = null)
public static FieldCodec<ByteString> ForBytes(uint tag, ByteString defaultValue)
{
return new FieldCodec<ByteString>(input => input.ReadBytes(), (output, value) => output.WriteBytes(value), CodedOutputStream.ComputeBytesSize, tag);
return new FieldCodec<ByteString>(input => input.ReadBytes(), (output, value) => output.WriteBytes(value), CodedOutputStream.ComputeBytesSize, tag, defaultValue);
}
/// <summary>
@ -73,9 +238,9 @@ namespace Google.Protobuf
/// <param name="tag">The tag.</param>
/// <param name="defaultValue">The default value.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<bool> ForBool(uint tag, bool defaultValue = false)
public static FieldCodec<bool> ForBool(uint tag, bool defaultValue)
{
return new FieldCodec<bool>(input => input.ReadBool(), (output, value) => output.WriteBool(value), CodedOutputStream.BoolSize, tag);
return new FieldCodec<bool>(input => input.ReadBool(), (output, value) => output.WriteBool(value), CodedOutputStream.BoolSize, tag, defaultValue);
}
/// <summary>
@ -84,9 +249,9 @@ namespace Google.Protobuf
/// <param name="tag">The tag.</param>
/// <param name="defaultValue">The default value.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<int> ForInt32(uint tag, int defaultValue = 0)
public static FieldCodec<int> ForInt32(uint tag, int defaultValue)
{
return new FieldCodec<int>(input => input.ReadInt32(), (output, value) => output.WriteInt32(value), CodedOutputStream.ComputeInt32Size, tag);
return new FieldCodec<int>(input => input.ReadInt32(), (output, value) => output.WriteInt32(value), CodedOutputStream.ComputeInt32Size, tag, defaultValue);
}
/// <summary>
@ -95,9 +260,9 @@ namespace Google.Protobuf
/// <param name="tag">The tag.</param>
/// <param name="defaultValue">The default value.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<int> ForSInt32(uint tag, int defaultValue = 0)
public static FieldCodec<int> ForSInt32(uint tag, int defaultValue)
{
return new FieldCodec<int>(input => input.ReadSInt32(), (output, value) => output.WriteSInt32(value), CodedOutputStream.ComputeSInt32Size, tag);
return new FieldCodec<int>(input => input.ReadSInt32(), (output, value) => output.WriteSInt32(value), CodedOutputStream.ComputeSInt32Size, tag, defaultValue);
}
/// <summary>
@ -106,9 +271,9 @@ namespace Google.Protobuf
/// <param name="tag">The tag.</param>
/// <param name="defaultValue">The default value.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<uint> ForFixed32(uint tag, uint defaultValue = 0)
public static FieldCodec<uint> ForFixed32(uint tag, uint defaultValue)
{
return new FieldCodec<uint>(input => input.ReadFixed32(), (output, value) => output.WriteFixed32(value), 4, tag);
return new FieldCodec<uint>(input => input.ReadFixed32(), (output, value) => output.WriteFixed32(value), 4, tag, defaultValue);
}
/// <summary>
@ -117,9 +282,9 @@ namespace Google.Protobuf
/// <param name="tag">The tag.</param>
/// <param name="defaultValue">The default value.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<int> ForSFixed32(uint tag, int defaultValue = 0)
public static FieldCodec<int> ForSFixed32(uint tag, int defaultValue)
{
return new FieldCodec<int>(input => input.ReadSFixed32(), (output, value) => output.WriteSFixed32(value), 4, tag);
return new FieldCodec<int>(input => input.ReadSFixed32(), (output, value) => output.WriteSFixed32(value), 4, tag, defaultValue);
}
/// <summary>
@ -128,9 +293,9 @@ namespace Google.Protobuf
/// <param name="tag">The tag.</param>
/// <param name="defaultValue">The default value.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<uint> ForUInt32(uint tag, uint defaultValue = 0)
public static FieldCodec<uint> ForUInt32(uint tag, uint defaultValue)
{
return new FieldCodec<uint>(input => input.ReadUInt32(), (output, value) => output.WriteUInt32(value), CodedOutputStream.ComputeUInt32Size, tag);
return new FieldCodec<uint>(input => input.ReadUInt32(), (output, value) => output.WriteUInt32(value), CodedOutputStream.ComputeUInt32Size, tag, defaultValue);
}
/// <summary>
@ -139,9 +304,9 @@ namespace Google.Protobuf
/// <param name="tag">The tag.</param>
/// <param name="defaultValue">The default value.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<long> ForInt64(uint tag, long defaultValue = 0)
public static FieldCodec<long> ForInt64(uint tag, long defaultValue)
{
return new FieldCodec<long>(input => input.ReadInt64(), (output, value) => output.WriteInt64(value), CodedOutputStream.ComputeInt64Size, tag);
return new FieldCodec<long>(input => input.ReadInt64(), (output, value) => output.WriteInt64(value), CodedOutputStream.ComputeInt64Size, tag, defaultValue);
}
/// <summary>
@ -150,9 +315,9 @@ namespace Google.Protobuf
/// <param name="tag">The tag.</param>
/// <param name="defaultValue">The default value.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<long> ForSInt64(uint tag, long defaultValue = 0)
public static FieldCodec<long> ForSInt64(uint tag, long defaultValue)
{
return new FieldCodec<long>(input => input.ReadSInt64(), (output, value) => output.WriteSInt64(value), CodedOutputStream.ComputeSInt64Size, tag);
return new FieldCodec<long>(input => input.ReadSInt64(), (output, value) => output.WriteSInt64(value), CodedOutputStream.ComputeSInt64Size, tag, defaultValue);
}
/// <summary>
@ -161,9 +326,9 @@ namespace Google.Protobuf
/// <param name="tag">The tag.</param>
/// <param name="defaultValue">The default value.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<ulong> ForFixed64(uint tag, ulong defaultValue = 0)
public static FieldCodec<ulong> ForFixed64(uint tag, ulong defaultValue)
{
return new FieldCodec<ulong>(input => input.ReadFixed64(), (output, value) => output.WriteFixed64(value), 8, tag);
return new FieldCodec<ulong>(input => input.ReadFixed64(), (output, value) => output.WriteFixed64(value), 8, tag, defaultValue);
}
/// <summary>
@ -172,9 +337,9 @@ namespace Google.Protobuf
/// <param name="tag">The tag.</param>
/// <param name="defaultValue">The default value.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<long> ForSFixed64(uint tag, long defaultValue = 0)
public static FieldCodec<long> ForSFixed64(uint tag, long defaultValue)
{
return new FieldCodec<long>(input => input.ReadSFixed64(), (output, value) => output.WriteSFixed64(value), 8, tag);
return new FieldCodec<long>(input => input.ReadSFixed64(), (output, value) => output.WriteSFixed64(value), 8, tag, defaultValue);
}
/// <summary>
@ -183,9 +348,9 @@ namespace Google.Protobuf
/// <param name="tag">The tag.</param>
/// <param name="defaultValue">The default value.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<ulong> ForUInt64(uint tag, ulong defaultValue = 0)
public static FieldCodec<ulong> ForUInt64(uint tag, ulong defaultValue)
{
return new FieldCodec<ulong>(input => input.ReadUInt64(), (output, value) => output.WriteUInt64(value), CodedOutputStream.ComputeUInt64Size, tag);
return new FieldCodec<ulong>(input => input.ReadUInt64(), (output, value) => output.WriteUInt64(value), CodedOutputStream.ComputeUInt64Size, tag, defaultValue);
}
/// <summary>
@ -194,9 +359,9 @@ namespace Google.Protobuf
/// <param name="tag">The tag.</param>
/// <param name="defaultValue">The default value.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<float> ForFloat(uint tag, float defaultValue = 0)
public static FieldCodec<float> ForFloat(uint tag, float defaultValue)
{
return new FieldCodec<float>(input => input.ReadFloat(), (output, value) => output.WriteFloat(value), CodedOutputStream.FloatSize, tag);
return new FieldCodec<float>(input => input.ReadFloat(), (output, value) => output.WriteFloat(value), CodedOutputStream.FloatSize, tag, defaultValue);
}
/// <summary>
@ -205,9 +370,9 @@ namespace Google.Protobuf
/// <param name="tag">The tag.</param>
/// <param name="defaultValue">The default value.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<double> ForDouble(uint tag, double defaultValue = 0)
public static FieldCodec<double> ForDouble(uint tag, double defaultValue)
{
return new FieldCodec<double>(input => input.ReadDouble(), (output, value) => output.WriteDouble(value), CodedOutputStream.DoubleSize, tag);
return new FieldCodec<double>(input => input.ReadDouble(), (output, value) => output.WriteDouble(value), CodedOutputStream.DoubleSize, tag, defaultValue);
}
// Enums are tricky. We can probably use expression trees to build these delegates automatically,
@ -221,12 +386,12 @@ namespace Google.Protobuf
/// <param name="fromInt32">A conversion function from the enum type to <see cref="Int32"/>.</param>
/// <param name="defaultValue">The default value.</param>
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<T> ForEnum<T>(uint tag, Func<T, int> toInt32, Func<int, T> fromInt32, T defaultValue = default(T))
public static FieldCodec<T> ForEnum<T>(uint tag, Func<T, int> toInt32, Func<int, T> fromInt32, T defaultValue)
{
return new FieldCodec<T>(input => fromInt32(
input.ReadEnum()),
(output, value) => output.WriteEnum(toInt32(value)),
value => CodedOutputStream.ComputeEnumSize(toInt32(value)), tag);
value => CodedOutputStream.ComputeEnumSize(toInt32(value)), tag, defaultValue);
}
/// <summary>
@ -237,8 +402,15 @@ namespace Google.Protobuf
/// <returns>A codec for the given tag.</returns>
public static FieldCodec<T> ForMessage<T>(uint tag, MessageParser<T> parser) where T : class, IMessage<T>
{
return new FieldCodec<T>(input => { T message = parser.CreateTemplate(); input.ReadMessage(message); return message; },
(output, value) => output.WriteMessage(value), (CodedInputStream i, ref T v) =>
return new FieldCodec<T>(
input =>
{
T message = parser.CreateTemplate();
input.ReadMessage(message);
return message;
},
(output, value) => output.WriteMessage(value),
(CodedInputStream i, ref T v) =>
{
if (v == null)
{
@ -262,7 +434,8 @@ namespace Google.Protobuf
v.MergeFrom(v2);
}
return true;
}, message => CodedOutputStream.ComputeMessageSize(message), tag);
},
message => CodedOutputStream.ComputeMessageSize(message), tag);
}
/// <summary>
@ -274,8 +447,16 @@ namespace Google.Protobuf
/// <returns>A codec for given tag</returns>
public static FieldCodec<T> ForGroup<T>(uint startTag, uint endTag, MessageParser<T> parser) where T : class, IMessage<T>
{
return new FieldCodec<T>(input => { T message = parser.CreateTemplate(); input.ReadGroup(message); return message; },
(output, value) => output.WriteGroup(value), (CodedInputStream i, ref T v) => {
return new FieldCodec<T>(
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();
@ -298,7 +479,8 @@ namespace Google.Protobuf
v.MergeFrom(v2);
}
return true;
}, message => CodedOutputStream.ComputeGroupSize(message), startTag, endTag);
},
message => CodedOutputStream.ComputeGroupSize(message), startTag, endTag);
}
/// <summary>
@ -524,7 +706,8 @@ namespace Google.Protobuf
Func<CodedInputStream, T> reader,
Action<CodedOutputStream, T> writer,
int fixedSize,
uint tag) : this(reader, writer, _ => fixedSize, tag)
uint tag,
T defaultValue) : this(reader, writer, _ => fixedSize, tag, defaultValue)
{
FixedSize = fixedSize;
}
@ -534,7 +717,7 @@ namespace Google.Protobuf
Action<CodedOutputStream, T> writer,
Func<T, int> sizeCalculator,
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)
T defaultValue) : this(reader, writer, (CodedInputStream i, ref T v) => v = reader(i), (ref T v, T v2) => { v = v2; return true; }, sizeCalculator, tag, 0, defaultValue)
{
}
@ -566,6 +749,7 @@ namespace Google.Protobuf
ValueSizeCalculator = sizeCalculator;
FixedSize = 0;
Tag = tag;
EndTag = endTag;
DefaultValue = defaultValue;
tagSize = CodedOutputStream.ComputeRawVarint32Size(tag);
if (endTag != 0)

@ -4,7 +4,7 @@
<Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description>
<Copyright>Copyright 2015, Google Inc.</Copyright>
<AssemblyTitle>Google Protocol Buffers</AssemblyTitle>
<VersionPrefix>3.9.0-rc1</VersionPrefix>
<VersionPrefix>3.11.0-rc0</VersionPrefix>
<LangVersion>6</LangVersion>
<Authors>Google Inc.</Authors>
<TargetFrameworks>netstandard1.0;netstandard2.0;net45</TargetFrameworks>
@ -22,16 +22,16 @@
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>
<!--
- Override target frameworks on non-Windows to just .NET Core
- Doing this conditionally in the initial PropertyGroup confuses
- Visual Studio.
-->
<PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
<TargetFrameworks>netstandard1.0;netstandard2.0</TargetFrameworks>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' or '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<!-- Needed for the net45 build to work on Unix. See https://github.com/dotnet/designs/pull/33 -->
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0-preview.2"/>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' or '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.Memory" Version="4.5.2"/>
</ItemGroup>

@ -35,7 +35,8 @@ using Google.Protobuf.Collections;
namespace Google.Protobuf
{
/// <summary>
/// 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
/// 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.
/// This interface is experiemental and is subject to change.
/// </summary>
public interface IExtendableMessage<T> : IMessage<T> where T : IExtendableMessage<T>
{
@ -46,14 +47,14 @@ namespace Google.Protobuf
/// <summary>
/// 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 <see cref="IExtendableMessage{T}.GetOrRegisterExtension{TValue}(RepeatedExtension{T, TValue})"/>
/// For a version of this method that never returns null, use <see cref="IExtendableMessage{T}.GetOrInitializeExtension{TValue}(RepeatedExtension{T, TValue})"/>
/// </summary>
RepeatedField<TValue> GetExtension<TValue>(RepeatedExtension<T, TValue> extension);
/// <summary>
/// Gets the value of the specified repeated extension, registering it if it isn't
/// <summary>
/// Gets the value of the specified repeated extension, registering it if it hasn't already been registered.
/// </summary>
RepeatedField<TValue> GetOrRegisterExtension<TValue>(RepeatedExtension<T, TValue> extension);
RepeatedField<TValue> GetOrInitializeExtension<TValue>(RepeatedExtension<T, TValue> extension);
/// <summary>
/// Sets the value of the specified extension
@ -65,13 +66,13 @@ namespace Google.Protobuf
/// </summary>
bool HasExtension<TValue>(Extension<T, TValue> extension);
/// <summary>
/// Clears the value of the specified extension
/// <summary>
/// Clears the value of the specified extension
/// </summary>
void ClearExtension<TValue>(Extension<T, TValue> extension);
/// <summary>
/// Clears the value of the specified repeated extension
/// <summary>
/// Clears the value of the specified repeated extension
/// </summary>
void ClearExtension<TValue>(RepeatedExtension<T, TValue> extension);
}

@ -148,11 +148,16 @@ namespace Google.Protobuf
/// </summary>
public static bool IsInitialized(this IMessage message)
{
if (message.Descriptor.File.Proto.Syntax != "proto2")
if (message.Descriptor.File.Syntax == Syntax.Proto3)
{
return true;
}
if (!message.Descriptor.IsExtensionsInitialized(message))
{
return false;
}
return message.Descriptor
.Fields
.InDeclarationOrder()
@ -160,8 +165,16 @@ namespace Google.Protobuf
{
if (f.IsMap)
{
var map = (IDictionary)f.Accessor.GetValue(message);
return map.Values.OfType<IMessage>().All(IsInitialized);
var valueField = f.MessageType.Fields[2];
if (valueField.FieldType == FieldType.Message)
{
var map = (IDictionary)f.Accessor.GetValue(message);
return map.Values.Cast<IMessage>().All(IsInitialized);
}
else
{
return true;
}
}
else if (f.IsRepeated && f.FieldType == FieldType.Message || f.FieldType == FieldType.Group)
{

@ -254,11 +254,8 @@ namespace Google.Protobuf.Reflection
if (extensionValue is ExtensionValue<T>)
{
ExtensionValue<T> single = extensionValue as ExtensionValue<T>;
if (single.HasValue)
{
value = single.GetValue();
return true;
}
value = single.GetValue();
return true;
}
else if (extensionValue is RepeatedExtensionValue<T>)
{
@ -279,11 +276,8 @@ namespace Google.Protobuf.Reflection
var typeArgs = typeInfo.GenericTypeArguments;
if (typeArgs.Length == 1 && typeArgs[0].GetTypeInfo().IsEnum)
{
if ((bool)typeInfo.GetDeclaredProperty(nameof(ExtensionValue<T>.HasValue)).GetValue(extensionValue))
{
value = (T)typeInfo.GetDeclaredMethod(nameof(ExtensionValue<T>.GetValue)).Invoke(extensionValue, EmptyParameters);
return true;
}
value = (T)typeInfo.GetDeclaredMethod(nameof(ExtensionValue<T>.GetValue)).Invoke(extensionValue, EmptyParameters);
return true;
}
}
else if (type.GetGenericTypeDefinition() == typeof(RepeatedExtensionValue<>))

@ -12,7 +12,7 @@ using scg = global::System.Collections.Generic;
namespace Google.Protobuf.Reflection {
/// <summary>Holder for reflection information generated from google/protobuf/descriptor.proto</summary>
internal static partial class DescriptorReflection {
public static partial class DescriptorReflection {
#region Descriptor
/// <summary>File descriptor for google/protobuf/descriptor.proto</summary>
@ -193,7 +193,7 @@ namespace Google.Protobuf.Reflection {
/// The protocol compiler can output a FileDescriptorSet containing the .proto
/// files it parses.
/// </summary>
internal sealed partial class FileDescriptorSet : pb::IMessage<FileDescriptorSet> {
public sealed partial class FileDescriptorSet : pb::IMessage<FileDescriptorSet> {
private static readonly pb::MessageParser<FileDescriptorSet> _parser = new pb::MessageParser<FileDescriptorSet>(() => new FileDescriptorSet());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@ -317,7 +317,7 @@ namespace Google.Protobuf.Reflection {
/// <summary>
/// Describes a complete .proto file.
/// </summary>
internal sealed partial class FileDescriptorProto : pb::IMessage<FileDescriptorProto> {
public sealed partial class FileDescriptorProto : pb::IMessage<FileDescriptorProto> {
private static readonly pb::MessageParser<FileDescriptorProto> _parser = new pb::MessageParser<FileDescriptorProto>(() => new FileDescriptorProto());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@ -800,7 +800,7 @@ namespace Google.Protobuf.Reflection {
/// <summary>
/// Describes a message type.
/// </summary>
internal sealed partial class DescriptorProto : pb::IMessage<DescriptorProto> {
public sealed partial class DescriptorProto : pb::IMessage<DescriptorProto> {
private static readonly pb::MessageParser<DescriptorProto> _parser = new pb::MessageParser<DescriptorProto>(() => new DescriptorProto());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@ -1151,7 +1151,7 @@ namespace Google.Protobuf.Reflection {
/// <summary>Container for nested types declared in the DescriptorProto message type.</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static partial class Types {
internal sealed partial class ExtensionRange : pb::IMessage<ExtensionRange> {
public sealed partial class ExtensionRange : pb::IMessage<ExtensionRange> {
private static readonly pb::MessageParser<ExtensionRange> _parser = new pb::MessageParser<ExtensionRange>(() => new ExtensionRange());
private pb::UnknownFieldSet _unknownFields;
private int _hasBits0;
@ -1391,7 +1391,7 @@ namespace Google.Protobuf.Reflection {
/// fields or extension ranges in the same message. Reserved ranges may
/// not overlap.
/// </summary>
internal sealed partial class ReservedRange : pb::IMessage<ReservedRange> {
public sealed partial class ReservedRange : pb::IMessage<ReservedRange> {
private static readonly pb::MessageParser<ReservedRange> _parser = new pb::MessageParser<ReservedRange>(() => new ReservedRange());
private pb::UnknownFieldSet _unknownFields;
private int _hasBits0;
@ -1587,10 +1587,11 @@ namespace Google.Protobuf.Reflection {
}
internal sealed partial class ExtensionRangeOptions : pb::IExtendableMessage<ExtensionRangeOptions> {
public sealed partial class ExtensionRangeOptions : pb::IExtendableMessage<ExtensionRangeOptions> {
private static readonly pb::MessageParser<ExtensionRangeOptions> _parser = new pb::MessageParser<ExtensionRangeOptions>(() => new ExtensionRangeOptions());
private pb::UnknownFieldSet _unknownFields;
internal pb::ExtensionSet<ExtensionRangeOptions> _extensions;
private pb::ExtensionSet<ExtensionRangeOptions> _Extensions => _extensions;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<ExtensionRangeOptions> Parser { get { return _parser; } }
@ -1732,8 +1733,8 @@ namespace Google.Protobuf.Reflection {
public pbc::RepeatedField<TValue> GetExtension<TValue>(pb::RepeatedExtension<ExtensionRangeOptions, TValue> extension) {
return pb::ExtensionSet.Get(ref _extensions, extension);
}
public pbc::RepeatedField<TValue> GetOrRegisterExtension<TValue>(pb::RepeatedExtension<ExtensionRangeOptions, TValue> extension) {
return pb::ExtensionSet.GetOrRegister(ref _extensions, extension);
public pbc::RepeatedField<TValue> GetOrInitializeExtension<TValue>(pb::RepeatedExtension<ExtensionRangeOptions, TValue> extension) {
return pb::ExtensionSet.GetOrInitialize(ref _extensions, extension);
}
public void SetExtension<TValue>(pb::Extension<ExtensionRangeOptions, TValue> extension, TValue value) {
pb::ExtensionSet.Set(ref _extensions, extension, value);
@ -1753,7 +1754,7 @@ namespace Google.Protobuf.Reflection {
/// <summary>
/// Describes a field within a message.
/// </summary>
internal sealed partial class FieldDescriptorProto : pb::IMessage<FieldDescriptorProto> {
public sealed partial class FieldDescriptorProto : pb::IMessage<FieldDescriptorProto> {
private static readonly pb::MessageParser<FieldDescriptorProto> _parser = new pb::MessageParser<FieldDescriptorProto>(() => new FieldDescriptorProto());
private pb::UnknownFieldSet _unknownFields;
private int _hasBits0;
@ -2298,7 +2299,7 @@ namespace Google.Protobuf.Reflection {
/// <summary>Container for nested types declared in the FieldDescriptorProto message type.</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static partial class Types {
internal enum Type {
public enum Type {
/// <summary>
/// 0 is reserved for errors.
/// Order is weird for historical reasons.
@ -2349,7 +2350,7 @@ namespace Google.Protobuf.Reflection {
[pbr::OriginalName("TYPE_SINT64")] Sint64 = 18,
}
internal enum Label {
public enum Label {
/// <summary>
/// 0 is reserved for errors
/// </summary>
@ -2366,7 +2367,7 @@ namespace Google.Protobuf.Reflection {
/// <summary>
/// Describes a oneof.
/// </summary>
internal sealed partial class OneofDescriptorProto : pb::IMessage<OneofDescriptorProto> {
public sealed partial class OneofDescriptorProto : pb::IMessage<OneofDescriptorProto> {
private static readonly pb::MessageParser<OneofDescriptorProto> _parser = new pb::MessageParser<OneofDescriptorProto>(() => new OneofDescriptorProto());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@ -2554,7 +2555,7 @@ namespace Google.Protobuf.Reflection {
/// <summary>
/// Describes an enum type.
/// </summary>
internal sealed partial class EnumDescriptorProto : pb::IMessage<EnumDescriptorProto> {
public sealed partial class EnumDescriptorProto : pb::IMessage<EnumDescriptorProto> {
private static readonly pb::MessageParser<EnumDescriptorProto> _parser = new pb::MessageParser<EnumDescriptorProto>(() => new EnumDescriptorProto());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@ -2818,7 +2819,7 @@ namespace Google.Protobuf.Reflection {
/// is inclusive such that it can appropriately represent the entire int32
/// domain.
/// </summary>
internal sealed partial class EnumReservedRange : pb::IMessage<EnumReservedRange> {
public sealed partial class EnumReservedRange : pb::IMessage<EnumReservedRange> {
private static readonly pb::MessageParser<EnumReservedRange> _parser = new pb::MessageParser<EnumReservedRange>(() => new EnumReservedRange());
private pb::UnknownFieldSet _unknownFields;
private int _hasBits0;
@ -3017,7 +3018,7 @@ namespace Google.Protobuf.Reflection {
/// <summary>
/// Describes a value within an enum.
/// </summary>
internal sealed partial class EnumValueDescriptorProto : pb::IMessage<EnumValueDescriptorProto> {
public sealed partial class EnumValueDescriptorProto : pb::IMessage<EnumValueDescriptorProto> {
private static readonly pb::MessageParser<EnumValueDescriptorProto> _parser = new pb::MessageParser<EnumValueDescriptorProto>(() => new EnumValueDescriptorProto());
private pb::UnknownFieldSet _unknownFields;
private int _hasBits0;
@ -3248,7 +3249,7 @@ namespace Google.Protobuf.Reflection {
/// <summary>
/// Describes a service.
/// </summary>
internal sealed partial class ServiceDescriptorProto : pb::IMessage<ServiceDescriptorProto> {
public sealed partial class ServiceDescriptorProto : pb::IMessage<ServiceDescriptorProto> {
private static readonly pb::MessageParser<ServiceDescriptorProto> _parser = new pb::MessageParser<ServiceDescriptorProto>(() => new ServiceDescriptorProto());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@ -3456,7 +3457,7 @@ namespace Google.Protobuf.Reflection {
/// <summary>
/// Describes a method of a service.
/// </summary>
internal sealed partial class MethodDescriptorProto : pb::IMessage<MethodDescriptorProto> {
public sealed partial class MethodDescriptorProto : pb::IMessage<MethodDescriptorProto> {
private static readonly pb::MessageParser<MethodDescriptorProto> _parser = new pb::MessageParser<MethodDescriptorProto>(() => new MethodDescriptorProto());
private pb::UnknownFieldSet _unknownFields;
private int _hasBits0;
@ -3815,10 +3816,11 @@ namespace Google.Protobuf.Reflection {
}
internal sealed partial class FileOptions : pb::IExtendableMessage<FileOptions> {
public sealed partial class FileOptions : pb::IExtendableMessage<FileOptions> {
private static readonly pb::MessageParser<FileOptions> _parser = new pb::MessageParser<FileOptions>(() => new FileOptions());
private pb::UnknownFieldSet _unknownFields;
internal pb::ExtensionSet<FileOptions> _extensions;
private pb::ExtensionSet<FileOptions> _Extensions => _extensions;
private int _hasBits0;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<FileOptions> Parser { get { return _parser; } }
@ -4869,8 +4871,8 @@ namespace Google.Protobuf.Reflection {
public pbc::RepeatedField<TValue> GetExtension<TValue>(pb::RepeatedExtension<FileOptions, TValue> extension) {
return pb::ExtensionSet.Get(ref _extensions, extension);
}
public pbc::RepeatedField<TValue> GetOrRegisterExtension<TValue>(pb::RepeatedExtension<FileOptions, TValue> extension) {
return pb::ExtensionSet.GetOrRegister(ref _extensions, extension);
public pbc::RepeatedField<TValue> GetOrInitializeExtension<TValue>(pb::RepeatedExtension<FileOptions, TValue> extension) {
return pb::ExtensionSet.GetOrInitialize(ref _extensions, extension);
}
public void SetExtension<TValue>(pb::Extension<FileOptions, TValue> extension, TValue value) {
pb::ExtensionSet.Set(ref _extensions, extension, value);
@ -4892,7 +4894,7 @@ namespace Google.Protobuf.Reflection {
/// <summary>
/// Generated classes can be optimized for speed or code size.
/// </summary>
internal enum OptimizeMode {
public enum OptimizeMode {
/// <summary>
/// Generate complete code for parsing, serialization,
/// </summary>
@ -4912,10 +4914,11 @@ namespace Google.Protobuf.Reflection {
}
internal sealed partial class MessageOptions : pb::IExtendableMessage<MessageOptions> {
public sealed partial class MessageOptions : pb::IExtendableMessage<MessageOptions> {
private static readonly pb::MessageParser<MessageOptions> _parser = new pb::MessageParser<MessageOptions>(() => new MessageOptions());
private pb::UnknownFieldSet _unknownFields;
internal pb::ExtensionSet<MessageOptions> _extensions;
private pb::ExtensionSet<MessageOptions> _Extensions => _extensions;
private int _hasBits0;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<MessageOptions> Parser { get { return _parser; } }
@ -5277,8 +5280,8 @@ namespace Google.Protobuf.Reflection {
public pbc::RepeatedField<TValue> GetExtension<TValue>(pb::RepeatedExtension<MessageOptions, TValue> extension) {
return pb::ExtensionSet.Get(ref _extensions, extension);
}
public pbc::RepeatedField<TValue> GetOrRegisterExtension<TValue>(pb::RepeatedExtension<MessageOptions, TValue> extension) {
return pb::ExtensionSet.GetOrRegister(ref _extensions, extension);
public pbc::RepeatedField<TValue> GetOrInitializeExtension<TValue>(pb::RepeatedExtension<MessageOptions, TValue> extension) {
return pb::ExtensionSet.GetOrInitialize(ref _extensions, extension);
}
public void SetExtension<TValue>(pb::Extension<MessageOptions, TValue> extension, TValue value) {
pb::ExtensionSet.Set(ref _extensions, extension, value);
@ -5295,10 +5298,11 @@ namespace Google.Protobuf.Reflection {
}
internal sealed partial class FieldOptions : pb::IExtendableMessage<FieldOptions> {
public sealed partial class FieldOptions : pb::IExtendableMessage<FieldOptions> {
private static readonly pb::MessageParser<FieldOptions> _parser = new pb::MessageParser<FieldOptions>(() => new FieldOptions());
private pb::UnknownFieldSet _unknownFields;
internal pb::ExtensionSet<FieldOptions> _extensions;
private pb::ExtensionSet<FieldOptions> _Extensions => _extensions;
private int _hasBits0;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<FieldOptions> Parser { get { return _parser; } }
@ -5752,8 +5756,8 @@ namespace Google.Protobuf.Reflection {
public pbc::RepeatedField<TValue> GetExtension<TValue>(pb::RepeatedExtension<FieldOptions, TValue> extension) {
return pb::ExtensionSet.Get(ref _extensions, extension);
}
public pbc::RepeatedField<TValue> GetOrRegisterExtension<TValue>(pb::RepeatedExtension<FieldOptions, TValue> extension) {
return pb::ExtensionSet.GetOrRegister(ref _extensions, extension);
public pbc::RepeatedField<TValue> GetOrInitializeExtension<TValue>(pb::RepeatedExtension<FieldOptions, TValue> extension) {
return pb::ExtensionSet.GetOrInitialize(ref _extensions, extension);
}
public void SetExtension<TValue>(pb::Extension<FieldOptions, TValue> extension, TValue value) {
pb::ExtensionSet.Set(ref _extensions, extension, value);
@ -5772,7 +5776,7 @@ namespace Google.Protobuf.Reflection {
/// <summary>Container for nested types declared in the FieldOptions message type.</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static partial class Types {
internal enum CType {
public enum CType {
/// <summary>
/// Default mode.
/// </summary>
@ -5781,7 +5785,7 @@ namespace Google.Protobuf.Reflection {
[pbr::OriginalName("STRING_PIECE")] StringPiece = 2,
}
internal enum JSType {
public enum JSType {
/// <summary>
/// Use the default type.
/// </summary>
@ -5801,10 +5805,11 @@ namespace Google.Protobuf.Reflection {
}
internal sealed partial class OneofOptions : pb::IExtendableMessage<OneofOptions> {
public sealed partial class OneofOptions : pb::IExtendableMessage<OneofOptions> {
private static readonly pb::MessageParser<OneofOptions> _parser = new pb::MessageParser<OneofOptions>(() => new OneofOptions());
private pb::UnknownFieldSet _unknownFields;
internal pb::ExtensionSet<OneofOptions> _extensions;
private pb::ExtensionSet<OneofOptions> _Extensions => _extensions;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<OneofOptions> Parser { get { return _parser; } }
@ -5946,8 +5951,8 @@ namespace Google.Protobuf.Reflection {
public pbc::RepeatedField<TValue> GetExtension<TValue>(pb::RepeatedExtension<OneofOptions, TValue> extension) {
return pb::ExtensionSet.Get(ref _extensions, extension);
}
public pbc::RepeatedField<TValue> GetOrRegisterExtension<TValue>(pb::RepeatedExtension<OneofOptions, TValue> extension) {
return pb::ExtensionSet.GetOrRegister(ref _extensions, extension);
public pbc::RepeatedField<TValue> GetOrInitializeExtension<TValue>(pb::RepeatedExtension<OneofOptions, TValue> extension) {
return pb::ExtensionSet.GetOrInitialize(ref _extensions, extension);
}
public void SetExtension<TValue>(pb::Extension<OneofOptions, TValue> extension, TValue value) {
pb::ExtensionSet.Set(ref _extensions, extension, value);
@ -5964,10 +5969,11 @@ namespace Google.Protobuf.Reflection {
}
internal sealed partial class EnumOptions : pb::IExtendableMessage<EnumOptions> {
public sealed partial class EnumOptions : pb::IExtendableMessage<EnumOptions> {
private static readonly pb::MessageParser<EnumOptions> _parser = new pb::MessageParser<EnumOptions>(() => new EnumOptions());
private pb::UnknownFieldSet _unknownFields;
internal pb::ExtensionSet<EnumOptions> _extensions;
private pb::ExtensionSet<EnumOptions> _Extensions => _extensions;
private int _hasBits0;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<EnumOptions> Parser { get { return _parser; } }
@ -6203,8 +6209,8 @@ namespace Google.Protobuf.Reflection {
public pbc::RepeatedField<TValue> GetExtension<TValue>(pb::RepeatedExtension<EnumOptions, TValue> extension) {
return pb::ExtensionSet.Get(ref _extensions, extension);
}
public pbc::RepeatedField<TValue> GetOrRegisterExtension<TValue>(pb::RepeatedExtension<EnumOptions, TValue> extension) {
return pb::ExtensionSet.GetOrRegister(ref _extensions, extension);
public pbc::RepeatedField<TValue> GetOrInitializeExtension<TValue>(pb::RepeatedExtension<EnumOptions, TValue> extension) {
return pb::ExtensionSet.GetOrInitialize(ref _extensions, extension);
}
public void SetExtension<TValue>(pb::Extension<EnumOptions, TValue> extension, TValue value) {
pb::ExtensionSet.Set(ref _extensions, extension, value);
@ -6221,10 +6227,11 @@ namespace Google.Protobuf.Reflection {
}
internal sealed partial class EnumValueOptions : pb::IExtendableMessage<EnumValueOptions> {
public sealed partial class EnumValueOptions : pb::IExtendableMessage<EnumValueOptions> {
private static readonly pb::MessageParser<EnumValueOptions> _parser = new pb::MessageParser<EnumValueOptions>(() => new EnumValueOptions());
private pb::UnknownFieldSet _unknownFields;
internal pb::ExtensionSet<EnumValueOptions> _extensions;
private pb::ExtensionSet<EnumValueOptions> _Extensions => _extensions;
private int _hasBits0;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<EnumValueOptions> Parser { get { return _parser; } }
@ -6415,8 +6422,8 @@ namespace Google.Protobuf.Reflection {
public pbc::RepeatedField<TValue> GetExtension<TValue>(pb::RepeatedExtension<EnumValueOptions, TValue> extension) {
return pb::ExtensionSet.Get(ref _extensions, extension);
}
public pbc::RepeatedField<TValue> GetOrRegisterExtension<TValue>(pb::RepeatedExtension<EnumValueOptions, TValue> extension) {
return pb::ExtensionSet.GetOrRegister(ref _extensions, extension);
public pbc::RepeatedField<TValue> GetOrInitializeExtension<TValue>(pb::RepeatedExtension<EnumValueOptions, TValue> extension) {
return pb::ExtensionSet.GetOrInitialize(ref _extensions, extension);
}
public void SetExtension<TValue>(pb::Extension<EnumValueOptions, TValue> extension, TValue value) {
pb::ExtensionSet.Set(ref _extensions, extension, value);
@ -6433,10 +6440,11 @@ namespace Google.Protobuf.Reflection {
}
internal sealed partial class ServiceOptions : pb::IExtendableMessage<ServiceOptions> {
public sealed partial class ServiceOptions : pb::IExtendableMessage<ServiceOptions> {
private static readonly pb::MessageParser<ServiceOptions> _parser = new pb::MessageParser<ServiceOptions>(() => new ServiceOptions());
private pb::UnknownFieldSet _unknownFields;
internal pb::ExtensionSet<ServiceOptions> _extensions;
private pb::ExtensionSet<ServiceOptions> _Extensions => _extensions;
private int _hasBits0;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<ServiceOptions> Parser { get { return _parser; } }
@ -6627,8 +6635,8 @@ namespace Google.Protobuf.Reflection {
public pbc::RepeatedField<TValue> GetExtension<TValue>(pb::RepeatedExtension<ServiceOptions, TValue> extension) {
return pb::ExtensionSet.Get(ref _extensions, extension);
}
public pbc::RepeatedField<TValue> GetOrRegisterExtension<TValue>(pb::RepeatedExtension<ServiceOptions, TValue> extension) {
return pb::ExtensionSet.GetOrRegister(ref _extensions, extension);
public pbc::RepeatedField<TValue> GetOrInitializeExtension<TValue>(pb::RepeatedExtension<ServiceOptions, TValue> extension) {
return pb::ExtensionSet.GetOrInitialize(ref _extensions, extension);
}
public void SetExtension<TValue>(pb::Extension<ServiceOptions, TValue> extension, TValue value) {
pb::ExtensionSet.Set(ref _extensions, extension, value);
@ -6645,10 +6653,11 @@ namespace Google.Protobuf.Reflection {
}
internal sealed partial class MethodOptions : pb::IExtendableMessage<MethodOptions> {
public sealed partial class MethodOptions : pb::IExtendableMessage<MethodOptions> {
private static readonly pb::MessageParser<MethodOptions> _parser = new pb::MessageParser<MethodOptions>(() => new MethodOptions());
private pb::UnknownFieldSet _unknownFields;
internal pb::ExtensionSet<MethodOptions> _extensions;
private pb::ExtensionSet<MethodOptions> _Extensions => _extensions;
private int _hasBits0;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<MethodOptions> Parser { get { return _parser; } }
@ -6880,8 +6889,8 @@ namespace Google.Protobuf.Reflection {
public pbc::RepeatedField<TValue> GetExtension<TValue>(pb::RepeatedExtension<MethodOptions, TValue> extension) {
return pb::ExtensionSet.Get(ref _extensions, extension);
}
public pbc::RepeatedField<TValue> GetOrRegisterExtension<TValue>(pb::RepeatedExtension<MethodOptions, TValue> extension) {
return pb::ExtensionSet.GetOrRegister(ref _extensions, extension);
public pbc::RepeatedField<TValue> GetOrInitializeExtension<TValue>(pb::RepeatedExtension<MethodOptions, TValue> extension) {
return pb::ExtensionSet.GetOrInitialize(ref _extensions, extension);
}
public void SetExtension<TValue>(pb::Extension<MethodOptions, TValue> extension, TValue value) {
pb::ExtensionSet.Set(ref _extensions, extension, value);
@ -6905,7 +6914,7 @@ namespace Google.Protobuf.Reflection {
/// or neither? HTTP based RPC implementation may choose GET verb for safe
/// methods, and PUT verb for idempotent methods instead of the default POST.
/// </summary>
internal enum IdempotencyLevel {
public enum IdempotencyLevel {
[pbr::OriginalName("IDEMPOTENCY_UNKNOWN")] IdempotencyUnknown = 0,
/// <summary>
/// implies idempotent
@ -6930,7 +6939,7 @@ namespace Google.Protobuf.Reflection {
/// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
/// in them.
/// </summary>
internal sealed partial class UninterpretedOption : pb::IMessage<UninterpretedOption> {
public sealed partial class UninterpretedOption : pb::IMessage<UninterpretedOption> {
private static readonly pb::MessageParser<UninterpretedOption> _parser = new pb::MessageParser<UninterpretedOption>(() => new UninterpretedOption());
private pb::UnknownFieldSet _unknownFields;
private int _hasBits0;
@ -7309,7 +7318,7 @@ namespace Google.Protobuf.Reflection {
/// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
/// "foo.(bar.baz).qux".
/// </summary>
internal sealed partial class NamePart : pb::IMessage<NamePart> {
public sealed partial class NamePart : pb::IMessage<NamePart> {
private static readonly pb::MessageParser<NamePart> _parser = new pb::MessageParser<NamePart>(() => new NamePart());
private pb::UnknownFieldSet _unknownFields;
private int _hasBits0;
@ -7502,7 +7511,7 @@ namespace Google.Protobuf.Reflection {
/// Encapsulates information about the original source file from which a
/// FileDescriptorProto was generated.
/// </summary>
internal sealed partial class SourceCodeInfo : pb::IMessage<SourceCodeInfo> {
public sealed partial class SourceCodeInfo : pb::IMessage<SourceCodeInfo> {
private static readonly pb::MessageParser<SourceCodeInfo> _parser = new pb::MessageParser<SourceCodeInfo>(() => new SourceCodeInfo());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@ -7670,7 +7679,7 @@ namespace Google.Protobuf.Reflection {
/// <summary>Container for nested types declared in the SourceCodeInfo message type.</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static partial class Types {
internal sealed partial class Location : pb::IMessage<Location> {
public sealed partial class Location : pb::IMessage<Location> {
private static readonly pb::MessageParser<Location> _parser = new pb::MessageParser<Location>(() => new Location());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@ -8004,7 +8013,7 @@ namespace Google.Protobuf.Reflection {
/// file. A GeneratedCodeInfo message is associated with only one generated
/// source file, but may contain references to different source .proto files.
/// </summary>
internal sealed partial class GeneratedCodeInfo : pb::IMessage<GeneratedCodeInfo> {
public sealed partial class GeneratedCodeInfo : pb::IMessage<GeneratedCodeInfo> {
private static readonly pb::MessageParser<GeneratedCodeInfo> _parser = new pb::MessageParser<GeneratedCodeInfo>(() => new GeneratedCodeInfo());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@ -8131,7 +8140,7 @@ namespace Google.Protobuf.Reflection {
/// <summary>Container for nested types declared in the GeneratedCodeInfo message type.</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static partial class Types {
internal sealed partial class Annotation : pb::IMessage<Annotation> {
public sealed partial class Annotation : pb::IMessage<Annotation> {
private static readonly pb::MessageParser<Annotation> _parser = new pb::MessageParser<Annotation>(() => new Annotation());
private pb::UnknownFieldSet _unknownFields;
private int _hasBits0;

@ -128,17 +128,16 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// The (possibly empty) set of custom options for this enum.
/// </summary>
//[Obsolete("CustomOptions are obsolete. Use GetOption")]
[Obsolete("CustomOptions are obsolete. Use GetOption")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/* // uncomment this in the full proto2 support PR
/// <summary>
/// Gets a single value enum option for this descriptor
/// </summary>
public T GetOption<T>(Extension<EnumOptions, T> extension)
{
var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> clonable ? clonable.Clone() : value;
return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
}
/// <summary>
@ -148,6 +147,5 @@ namespace Google.Protobuf.Reflection
{
return Proto.Options.GetExtension(extension).Clone();
}
*/
}
}

@ -73,27 +73,25 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// The (possibly empty) set of custom options for this enum value.
/// </summary>
//[Obsolete("CustomOptions are obsolete. Use GetOption")]
[Obsolete("CustomOptions are obsolete. Use GetOption")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/* // uncomment this in the full proto2 support PR
/// <summary>
/// Gets a single value enum option for this descriptor
/// Gets a single value enum value option for this descriptor
/// </summary>
public T GetOption<T>(Extension<EnumValueOptions, T> extension)
{
var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> clonable ? clonable.Clone() : value;
return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
}
/// <summary>
/// Gets a repeated value enum option for this descriptor
/// Gets a repeated value enum value option for this descriptor
/// </summary>
public RepeatedField<T> GetOption<T>(RepeatedExtension<EnumValueOptions, T> extension)
{
return Proto.Options.GetExtension(extension).Clone();
}
*/
}
}

@ -39,7 +39,7 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// A collection to simplify retrieving the descriptors of extensions in a descriptor for a message
/// </summary>
public class ExtensionCollection
public sealed class ExtensionCollection
{
private IDictionary<MessageDescriptor, IList<FieldDescriptor>> extensionsByTypeInDeclarationOrder;
private IDictionary<MessageDescriptor, IList<FieldDescriptor>> extensionsByTypeInNumberOrder;
@ -48,14 +48,32 @@ namespace Google.Protobuf.Reflection
{
UnorderedExtensions = DescriptorUtil.ConvertAndMakeReadOnly(
file.Proto.Extension,
(extension, i) => new FieldDescriptor(extension, file, null, i, null, extensions?[i]));
(extension, i) => {
if (extensions?.Length != 0)
{
return new FieldDescriptor(extension, file, null, i, null, extensions?[i]);
}
else
{
return new FieldDescriptor(extension, file, null, i, null, null); // return null if there's no extensions in this array for old code-gen
}
});
}
internal ExtensionCollection(MessageDescriptor message, Extension[] extensions)
{
UnorderedExtensions = DescriptorUtil.ConvertAndMakeReadOnly(
message.Proto.Extension,
(extension, i) => new FieldDescriptor(extension, message.File, message, i, null, extensions?[i]));
(extension, i) => {
if (extensions?.Length != 0)
{
return new FieldDescriptor(extension, message.File, message, i, null, extensions?[i]);
}
else
{
return new FieldDescriptor(extension, message.File, message, i, null, null);
}
});
}
/// <summary>

@ -66,7 +66,10 @@ namespace Google.Protobuf.Reflection
internal FieldDescriptorProto Proto { get; }
internal Extension Extension { get; }
/// <summary>
/// An extension identifier for this field, or <c>null</c> if this field isn't an extension.
/// </summary>
public Extension Extension { get; }
internal FieldDescriptor(FieldDescriptorProto proto, FileDescriptor file,
MessageDescriptor parent, int index, string propertyName, Extension extension)
@ -201,7 +204,25 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// Returns <c>true</c> if this field is a packed, repeated field; <c>false</c> otherwise.
/// </summary>
public bool IsPacked => File.Proto.Syntax == "proto2" ? Proto.Options?.Packed ?? false : !Proto.Options.HasPacked || Proto.Options.Packed;
public bool IsPacked
{
get
{
if (File.Syntax != Syntax.Proto3)
{
return Proto.Options?.Packed ?? false;
}
else
{
return !Proto.Options.HasPacked || Proto.Options.Packed;
}
}
}
/// <summary>
/// Returns <c>true</c> if this field extends another message type; <c>false</c> otherwise.
/// </summary>
public bool IsExtension => Proto.HasExtendee;
/// <summary>
/// Returns the type of the field.
@ -277,27 +298,25 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// The (possibly empty) set of custom options for this field.
/// </summary>
//[Obsolete("CustomOptions are obsolete. Use GetOption")]
[Obsolete("CustomOptions are obsolete. Use GetOption")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/* // uncomment this in the full proto2 support PR
/// <summary>
/// Gets a single value enum option for this descriptor
/// Gets a single value field option for this descriptor
/// </summary>
public T GetOption<T>(Extension<FieldOptions, T> extension)
{
var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> clonable ? clonable.Clone() : value;
return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
}
/// <summary>
/// Gets a repeated value enum option for this descriptor
/// Gets a repeated value field option for this descriptor
/// </summary>
public RepeatedField<T> GetOption<T>(RepeatedExtension<FieldOptions, T> extension)
{
return Proto.Options.GetExtension(extension).Clone();
}
*/
/// <summary>
/// Look up and cross-link all field types etc.
@ -378,6 +397,11 @@ namespace Google.Protobuf.Reflection
private IFieldAccessor CreateAccessor()
{
if (Extension != null)
{
return new ExtensionAccessor(this);
}
// If we're given no property name, that's because we really don't want an accessor.
// This could be because it's a map message, or it could be that we're loading a FileDescriptor dynamically.
// TODO: Support dynamic messages.
@ -386,10 +410,6 @@ namespace Google.Protobuf.Reflection
return null;
}
if (Extension != null)
{
return new ExtensionAccessor(this);
}
var property = ContainingType.ClrType.GetProperty(propertyName);
if (property == null)
{

@ -42,6 +42,25 @@ using static Google.Protobuf.Reflection.SourceCodeInfo.Types;
namespace Google.Protobuf.Reflection
{
/// <summary>
/// The syntax of a .proto file
/// </summary>
public enum Syntax
{
/// <summary>
/// Proto2 syntax
/// </summary>
Proto2,
/// <summary>
/// Proto3 syntax
/// </summary>
Proto3,
/// <summary>
/// An unknown declared syntax
/// </summary>
Unknown
}
/// <summary>
/// Describes a .proto file, including everything defined within.
/// IDescriptor is implemented such that the File property returns this descriptor,
@ -87,6 +106,19 @@ namespace Google.Protobuf.Reflection
Extensions = new ExtensionCollection(this, generatedCodeInfo?.Extensions);
declarations = new Lazy<Dictionary<IDescriptor, DescriptorDeclaration>>(CreateDeclarationMap, LazyThreadSafetyMode.ExecutionAndPublication);
if (!proto.HasSyntax || proto.Syntax == "proto2")
{
Syntax = Syntax.Proto2;
}
else if (proto.Syntax == "proto3")
{
Syntax = Syntax.Proto3;
}
else
{
Syntax = Syntax.Unknown;
}
}
private Dictionary<IDescriptor, DescriptorDeclaration> CreateDeclarationMap()
@ -217,6 +249,11 @@ namespace Google.Protobuf.Reflection
/// </value>
internal FileDescriptorProto Proto { get; }
/// <summary>
/// The syntax of the file
/// </summary>
public Syntax Syntax { get; }
/// <value>
/// The file name.
/// </value>
@ -407,7 +444,7 @@ namespace Google.Protobuf.Reflection
private static void AddAllExtensions(FileDescriptor[] dependencies, GeneratedClrTypeInfo generatedInfo, ExtensionRegistry registry)
{
registry.Add(dependencies.SelectMany(GetAllDependedExtensions).Concat(GetAllGeneratedExtensions(generatedInfo)).ToArray());
registry.AddRange(dependencies.SelectMany(GetAllDependedExtensions).Concat(GetAllGeneratedExtensions(generatedInfo)).ToArray());
}
private static IEnumerable<Extension> GetAllGeneratedExtensions(GeneratedClrTypeInfo generated)
@ -504,27 +541,25 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// The (possibly empty) set of custom options for this file.
/// </summary>
//[Obsolete("CustomOptions are obsolete. Use GetOption")]
[Obsolete("CustomOptions are obsolete. Use GetOption")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/* // uncomment this in the full proto2 support PR
/// <summary>
/// Gets a single value enum option for this descriptor
/// Gets a single value file option for this descriptor
/// </summary>
public T GetOption<T>(Extension<FileOptions, T> extension)
{
var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> clonable ? clonable.Clone() : value;
return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
}
/// <summary>
/// Gets a repeated value enum option for this descriptor
/// Gets a repeated value file option for this descriptor
/// </summary>
public RepeatedField<T> GetOption<T>(RepeatedExtension<FileOptions, T> extension)
{
return Proto.Options.GetExtension(extension).Clone();
}
*/
/// <summary>
/// Performs initialization for the given generic type argument.

@ -51,11 +51,6 @@ namespace Google.Protobuf.Reflection
/// </summary>
void Clear(IMessage message);
/// <summary>
/// Indicates whether the field in the specified message is set. For proto3 fields, this throws an <see cref="InvalidOperationException"/>
/// </summary>
bool HasValue(IMessage message);
/// <summary>
/// Fetches the field value. For repeated values, this will be an
/// <see cref="IList"/> implementation. For map values, this will be an
@ -63,6 +58,11 @@ namespace Google.Protobuf.Reflection
/// </summary>
object GetValue(IMessage message);
/// <summary>
/// Indicates whether the field in the specified message is set. For proto3 fields, this throws an <see cref="InvalidOperationException"/>
/// </summary>
bool HasValue(IMessage message);
/// <summary>
/// Mutator for single "simple" fields only.
/// </summary>

@ -34,6 +34,7 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
#if NET35
// Needed for ReadOnlyDictionary, which does not exist in .NET 3.5
using Google.Protobuf.Collections;
@ -63,6 +64,7 @@ namespace Google.Protobuf.Reflection
private readonly IList<FieldDescriptor> fieldsInDeclarationOrder;
private readonly IList<FieldDescriptor> fieldsInNumberOrder;
private readonly IDictionary<string, FieldDescriptor> jsonFieldMap;
private Func<IMessage, bool> extensionSetIsInitialized;
internal MessageDescriptor(DescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int typeIndex, GeneratedClrTypeInfo generatedCodeInfo)
: base(file, file.ComputeFullName(parent, proto.Name), typeIndex)
@ -134,6 +136,21 @@ namespace Google.Protobuf.Reflection
internal DescriptorProto Proto { get; }
internal bool IsExtensionsInitialized(IMessage message)
{
if (Proto.ExtensionRange.Count == 0)
{
return true;
}
if (extensionSetIsInitialized == null)
{
extensionSetIsInitialized = ReflectionUtil.CreateIsInitializedCaller(ClrType);
}
return extensionSetIsInitialized(message);
}
/// <summary>
/// The CLR type used to represent message instances from this descriptor.
/// </summary>
@ -243,27 +260,25 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// The (possibly empty) set of custom options for this message.
/// </summary>
//[Obsolete("CustomOptions are obsolete. Use GetOption")]
[Obsolete("CustomOptions are obsolete. Use GetOption")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/* // uncomment this in the full proto2 support PR
/// <summary>
/// Gets a single value enum option for this descriptor
/// Gets a single value message option for this descriptor
/// </summary>
public T GetOption<T>(Extension<MessageOptions, T> extension)
{
var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> clonable ? clonable.Clone() : value;
return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
}
/// <summary>
/// Gets a repeated value enum option for this descriptor
/// Gets a repeated value message option for this descriptor
/// </summary>
public Collections.RepeatedField<T> GetOption<T>(RepeatedExtension<MessageOptions, T> extension)
{
return Proto.Options.GetExtension(extension).Clone();
}
*/
/// <summary>
/// Looks up and cross-links all fields and nested types.

@ -73,27 +73,25 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// The (possibly empty) set of custom options for this method.
/// </summary>
//[Obsolete("CustomOptions are obsolete. Use GetOption")]
[Obsolete("CustomOptions are obsolete. Use GetOption")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/* // uncomment this in the full proto2 support PR
/// <summary>
/// Gets a single value enum option for this descriptor
/// Gets a single value method option for this descriptor
/// </summary>
public T GetOption<T>(Extension<MethodOptions, T> extension)
{
var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> clonable ? clonable.Clone() : value;
return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
}
/// <summary>
/// Gets a repeated value enum option for this descriptor
/// Gets a repeated value method option for this descriptor
/// </summary>
public RepeatedField<T> GetOption<T>(RepeatedExtension<MethodOptions, T> extension)
{
return Proto.Options.GetExtension(extension).Clone();
}
*/
internal MethodDescriptor(MethodDescriptorProto proto, FileDescriptor file,
ServiceDescriptor parent, int index)

@ -105,27 +105,25 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// The (possibly empty) set of custom options for this oneof.
/// </summary>
//[Obsolete("CustomOptions are obsolete. Use GetOption")]
[Obsolete("CustomOptions are obsolete. Use GetOption")]
public CustomOptions CustomOptions => new CustomOptions(proto.Options._extensions?.ValuesByNumber);
/* // uncomment this in the full proto2 support PR
/// <summary>
/// Gets a single value enum option for this descriptor
/// Gets a single value oneof option for this descriptor
/// </summary>
public T GetOption<T>(Extension<OneofOptions, T> extension)
{
var value = proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> clonable ? clonable.Clone() : value;
return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
}
/// <summary>
/// Gets a repeated value enum option for this descriptor
/// Gets a repeated value oneof option for this descriptor
/// </summary>
public RepeatedField<T> GetOption<T>(RepeatedExtension<OneofOptions, T> extension)
{
return proto.Options.GetExtension(extension).Clone();
}
*/
internal void CrossLink()
{

@ -115,12 +115,15 @@ namespace Google.Protobuf.Reflection
internal static Func<IMessage, bool> CreateFuncIMessageBool(MethodInfo method) =>
GetReflectionHelper(method.DeclaringType, method.ReturnType).CreateFuncIMessageBool(method);
internal static Func<IMessage, bool> CreateIsInitializedCaller(Type msg) =>
((IExtensionSetReflector)Activator.CreateInstance(typeof(ExtensionSetReflector<>).MakeGenericType(msg))).CreateIsInitializedCaller();
/// <summary>
/// Creates a delegate which will execute the given method after casting the first argument to
/// the type that declares the method, and the second argument to the first parameter type of the method.
/// </summary>
internal static IExtensionReflectionHelper CreateExtensionHelper(Extension extension) =>
(IExtensionReflectionHelper)Activator.CreateInstance(typeof(ExtensionReflectionHelper<,>).MakeGenericType(extension.TargetType, extension.GetType().GenericTypeArguments[1]));
(IExtensionReflectionHelper)Activator.CreateInstance(typeof(ExtensionReflectionHelper<,>).MakeGenericType(extension.TargetType, extension.GetType().GenericTypeArguments[1]), extension);
/// <summary>
/// Creates a reflection helper for the given type arguments. Currently these are created on demand
@ -150,6 +153,11 @@ namespace Google.Protobuf.Reflection
void ClearExtension(IMessage message);
}
private interface IExtensionSetReflector
{
Func<IMessage, bool> CreateIsInitializedCaller();
}
private class ReflectionHelper<T1, T2> : IReflectionHelper
{
@ -222,7 +230,7 @@ namespace Google.Protobuf.Reflection
}
else if (extension is RepeatedExtension<T1, T3>)
{
return extensionMessage.GetExtension(extension as RepeatedExtension<T1, T3>);
return extensionMessage.GetOrInitializeExtension(extension as RepeatedExtension<T1, T3>);
}
else
{
@ -300,6 +308,28 @@ namespace Google.Protobuf.Reflection
}
}
private class ExtensionSetReflector<T1> : IExtensionSetReflector where T1 : IExtendableMessage<T1>
{
public Func<IMessage, bool> CreateIsInitializedCaller()
{
var prop = typeof(T1).GetTypeInfo().GetDeclaredProperty("_Extensions");
#if NET35
var getFunc = (Func<T1, ExtensionSet<T1>>)prop.GetGetMethod(true).CreateDelegate(typeof(Func<T1, ExtensionSet<T1>>));
#else
var getFunc = (Func<T1, ExtensionSet<T1>>)prop.GetMethod.CreateDelegate(typeof(Func<T1, ExtensionSet<T1>>));
#endif
var initializedFunc = (Func<ExtensionSet<T1>, bool>)
typeof(ExtensionSet<T1>)
.GetTypeInfo()
.GetDeclaredMethod("IsInitialized")
.CreateDelegate(typeof(Func<ExtensionSet<T1>, bool>));
return (m) => {
var set = getFunc((T1)m);
return set == null || initializedFunc(set);
};
}
}
// Runtime compatibility checking code - see ReflectionHelper<T1, T2>.CreateFuncIMessageInt32 for
// details about why we're doing this.

@ -94,27 +94,25 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// The (possibly empty) set of custom options for this service.
/// </summary>
//[Obsolete("CustomOptions are obsolete. Use GetOption")]
[Obsolete("CustomOptions are obsolete. Use GetOption")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/* // uncomment this in the full proto2 support PR
/// <summary>
/// Gets a single value enum option for this descriptor
/// Gets a single value service option for this descriptor
/// </summary>
public T GetOption<T>(Extension<ServiceOptions, T> extension)
{
var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> clonable ? clonable.Clone() : value;
return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
}
/// <summary>
/// Gets a repeated value enum option for this descriptor
/// Gets a repeated value service option for this descriptor
/// </summary>
public RepeatedField<T> GetOption<T>(RepeatedExtension<ServiceOptions, T> extension)
{
return Proto.Options.GetExtension(extension).Clone();
}
*/
internal void CrossLink()
{

@ -57,20 +57,7 @@ namespace Google.Protobuf.Reflection
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
if (descriptor.File.Syntax == Syntax.Proto3)
{
hasDelegate = message => {
throw new InvalidOperationException("HasValue is not implemented for proto3 fields");
@ -85,6 +72,19 @@ namespace Google.Protobuf.Reflection
: Activator.CreateInstance(clrType);
clearDelegate = message => SetValue(message, defaultValue);
}
else
{
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);
}
}
public override void Clear(IMessage message)

@ -62,7 +62,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// if (duration.seconds &lt; 0 &amp;&amp; duration.nanos > 0) {
/// duration.seconds += 1;
/// duration.nanos -= 1000000000;
/// } else if (durations.seconds > 0 &amp;&amp; duration.nanos &lt; 0) {
/// } else if (duration.seconds > 0 &amp;&amp; duration.nanos &lt; 0) {
/// duration.seconds -= 1;
/// duration.nanos += 1000000000;
/// }

@ -0,0 +1,184 @@
As part of the 3.10 release of Google.Protobuf, experimental proto2 support has been released. This document outlines the new changes brought about to include proto2 support. This does not break existing proto3 support and users may continue to use proto3 features without changing their current code. Again the generated code and public API associated with proto2 is experimental and subject to change in the future. APIs for proto2 may be added, removed, or adjusted as feedback is received.
Generated code for proto2 may also be modified by adding, removing, or adjusting APIs as feedback is received.
### Enabling proto2 features
For information about specific proto2 features, please read the [proto2 language guide](https://developers.google.com/protocol-buffers/docs/proto).
Much like other languages, proto2 features are used with proto2 files with the syntax declaration `syntax = "proto2";`. However, please note, proto3 is still the recommended version of protobuf and proto2 support is meant for legacy system interop and advanced uses.
# Generated code
### Messages
Messages in proto2 files are very similar to their proto3 counterparts. They expose the usual property for getting and setting, but they also include properties and methods to handle field presence.
For `optional`/`required` field XYZ, a `HasXYZ` property is included for checking presence and a `ClearXYZ` method is included for clearing the value.
```proto
message Foo {
optional Bar bar = 1;
required Baz baz = 2;
}
```
```cs
var foo = new Foo();
Assert.IsNull(foo.Bar);
Assert.False(foo.HasBar);
foo.Bar = new Bar();
Assert.True(foo.HasBar);
foo.ClearBar();
```
### Messages with extension ranges
Messages which define extension ranges implement the `IExtendableMessage` interface as shown below.
See inline comments for more info.
```cs
public interface IExtendableMessage<T> : IMessage<T> where T : IExtendableMessage<T>
{
// Gets the value of a single value extension. If the extension isn't present, this returns the default value.
TValue GetExtension<TValue>(Extension<T, TValue> extension);
// Gets the value of a repeated extension. If the extension hasn't been set, this returns null to prevent unnecessary allocations.
RepeatedField<TValue> GetExtension<TValue>(RepeatedExtension<T, TValue> extension);
// Gets the value of a repeated extension. This will initialize the value of the repeated field and will never return null.
RepeatedField<TValue> GetOrInitializeExtension<TValue>(RepeatedExtension<T, TValue> extension);
// Sets the value of the extension
void SetExtension<TValue>(Extension<T, TValue> extension, TValue value);
// Returns whether the extension is present in the message
bool HasExtension<TValue>(Extension<T, TValue> extension);
// Clears the value of the extension, removing it from the message
void ClearExtension<TValue>(Extension<T, TValue> extension);
// Clears the value of the repeated extension, removing it from the message. Calling GetExtension after this will always return null.
void ClearExtension<TValue>(RepeatedExtension<T, TValue> extension);
}
```
### Extensions
Extensions are generated in static containers like reflection classes and type classes.
For example for a file called `foo.proto` containing extensions in the file scope, a
`FooExtensions` class is created containing the extensions defined in the file scope.
For easy access, this class can be used with `using static` to bring all extensions into scope.
```proto
option csharp_namespace = "FooBar";
extend Foo {
optional Baz foo_ext = 124;
}
message Baz {
extend Foo {
repeated Baz repeated_foo_ext = 125;
}
}
```
```cs
public static partial class FooExtensions {
public static readonly Extension<Foo, Baz> FooExt = /* initialization */;
}
public partial class Baz {
public partial static class Extensions {
public static readonly RepeatedExtension<Foo, Baz> RepeatedFooExt = /* initialization */;
}
}
```
```cs
using static FooBar.FooExtensions;
using static FooBar.Baz.Extensions;
var foo = new Foo();
foo.SetExtension(FooExt, new Baz());
foo.GetOrInitializeExtension(RepeatedFooExt).Add(new Baz());
```
# APIs
### Message initialization
Initialization refers to checking the status of required fields in a proto2 message. If a message is uninitialized, not all required fields are set in either the message itself or any of its submessages. In other languages, missing required fields throw errors depending on the merge method used. This could cause unforseen errors at runtime if the incorrect method is used.
However, in this implementation, parsers and input streams don't check messages for initialization on their own and throw errors. Instead it's up to you to handle messages with missing required fields in whatever way you see fit.
Checking message initialization can be done manually via the `IsInitialized` extension method in `MessageExtensions`.
### Extension registries
Just like in Java, extension registries can be constructed to parse extensions when reading new messages
from input streams. The API is fairly similar to the Java API with some added bonuses with C# syntax sugars.
```proto
message Baz {
extend Foo {
optional Baz foo_ext = 124;
}
}
```
```cs
var registry = new ExtensionRegistry()
{
Baz.Extensions.FooExt
};
var foo = Foo.Factory.WithExtensionRegistry(registry).ParseFrom(input);
Assert.True(foo.HasExtension(Bas.Extensions.FooExt));
var fooNoRegistry = Foo.Factory.ParseFrom(input);
Assert.False(foo.HasExtension(Bas.Extensions.FooExt));
```
### Custom options
Due to their limited use and lack of type safety, the original `CustomOptions` APIs are now deprecated. Using the new generated extension identifiers, you can access extensions safely through the GetOption APIs. Note that cloneable values such as
repeated fields and messages will be deep cloned.
Example based on custom options usage example [here](https://github.com/protocolbuffers/protobuf/issues/5007#issuecomment-411604515).
```cs
foreach (var service in input.Services)
{
Console.WriteLine($" {service.Name}");
foreach (var method in service.Methods)
{
var rule = method.GetOption(AnnotationsExtensions.Http);
if (rule != null)
{
Console.WriteLine($" {method.Name}: {rule}");
}
else
{
Console.WriteLine($" {method.Name}: no HTTP binding");
}
}
}
```
### Reflection
Reflection APIs have been extended to enable accessing the new proto2 portions of the library and generated code.
* FieldDescriptor.Extension
* Gets the extension identifier behind an extension field, allowing it to be added to an ExtensionRegistry
* FieldDescriptor.IsExtension
* Returns whether a field is an extension of another type.
* FieldDescriptor.ExtendeeType
* Returns the extended type of an extension field
* IFieldAccessor.HasValue
* Returns whether a field's value is set. For proto3 fields, throws an InvalidOperationException.
* FileDescriptor.Syntax
* Gets the syntax of a file
* FileDescriptor.Extensions
* An immutable list of extensions defined in the file
* MessageDescriptor.Extensions
* An immutable list of extensions defined in the message
```cs
var extensions = Baz.Descriptor.Extensions.GetExtensionsInDeclarationOrder(Foo.Descriptor);
var registry = new ExtensionRegistry();
registry.AddRange(extensions.Select(f => f.Extension));
var baz = Foo.Descriptor.Parser.WithExtensionRegistry(registry).ParseFrom(input);
foreach (var field in extensions)
{
if (field.Accessor.HasValue(baz))
{
Console.WriteLine($"{field.Name}: {field.Accessor.GetValue(baz)}");
}
}
```

@ -205,3 +205,10 @@ with info about your project (name and website) so we can add an entry for you.
* Website: https://github.com/envoyproxy/protoc-gen-validate
* Extensions: 1071
1. protokt
* Website: https://github.com/toasttab/protokt (Currently Private but will be open soon.)
* Extensions: 1072
1. Dart port of protocol buffers
* Website https://github.com/dart-lang/protobuf
* Extensions: 1073

@ -16,6 +16,7 @@ These are projects we know about implementing Protocol Buffers for other program
* C: https://github.com/cloudwu/pbc/
* C: https://github.com/haberman/upb/wiki
* C: https://github.com/squidfunk/protobluff
* C: https://github.com/eerimoq/pbtools
* C++: https://github.com/google/protobuf (Google-official implementation)
* C/C++: http://spbc.sf.net/
* C#: http://code.google.com/p/protobuf-csharp-port
@ -23,11 +24,11 @@ These are projects we know about implementing Protocol Buffers for other program
* C#/.NET/WCF/VB: http://code.google.com/p/protobuf-net/
* Clojure: http://github.com/ninjudd/clojure-protobuf
* Clojure: https://github.com/clojusc/protobuf
* Clojure: https://protojure.github.io
* Common Lisp: http://github.com/ndantam/s-protobuf
* Common Lisp: http://github.com/brown/protobuf
* D: https://github.com/dcarp/protobuf-d
* D: https://github.com/msoucy/dproto
* D: http://256.makerslocal.org/wiki/index.php/ProtocolBuffer
* D: https://github.com/opticron/ProtocolBuffer
* Dart: https://github.com/dart-lang/dart-protobuf (runtime) https://github.com/dart-lang/dart-protoc-plugin (code generator)
* Delphi: http://sourceforge.net/projects/protobuf-delphi/
@ -59,6 +60,7 @@ These are projects we know about implementing Protocol Buffers for other program
* Javascript: http://code.google.com/p/protobuf-for-node/
* Javascript: http://code.google.com/p/protostuff/
* Julia: https://github.com/tanmaykm/ProtoBuf.jl
* Kotlin: https://github.com/marcoferrer/kroto-plus
* Kotlin: https://github.com/Kotlin/kotlinx.serialization
* Lua: http://code.google.com/p/protoc-gen-lua/
* Lua: http://github.com/indygreg/lua-protobuf
@ -111,6 +113,7 @@ GRPC (http://www.grpc.io/) is Google's RPC implementation for Protocol Buffers.
* http://deltavsoft.com/RcfUserGuide/Protobufs (C++)
* http://code.google.com/p/protobuf-mina-rpc/ (Python client, Java server)
* http://code.google.com/p/casocklib/ (C++)
* https://protojure.github.io (Clojure)
* http://code.google.com/p/cxf-protobuf/ (Java)
* http://code.google.com/p/protobuf-remote/ (C++/C#)
* http://code.google.com/p/protobuf-rpc-pro/ (Java)

@ -4,6 +4,10 @@
# the WORKSPACE file in the same directory with this BUILD file for an
# example.
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_binary", "java_lite_proto_library", "java_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
# For each .proto file, a proto_library target should be defined. This target
# is not bound to any particular language. Instead, it defines the dependency
# graph of the .proto files (i.e., proto imports) and serves as the provider

@ -1,31 +1,24 @@
workspace(name = "com_google_protobuf_examples")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# This com_google_protobuf repository is required for proto_library rule.
# It provides the protocol compiler binary (i.e., protoc).
http_archive(
#
# We declare it as local_repository so we can test changes
# before they get merged. You'll want to use the following instead:
#
# http_archive(
# name = "com_google_protobuf",
# strip_prefix = "protobuf-master",
# urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
# )
local_repository(
name = "com_google_protobuf",
strip_prefix = "protobuf-master",
urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
path = "..",
)
# This com_google_protobuf_cc repository is required for cc_proto_library
# rule. It provides protobuf C++ runtime. Note that it actually is the same
# repo as com_google_protobuf but has to be given a different name as
# required by bazel.
http_archive(
name = "com_google_protobuf_cc",
strip_prefix = "protobuf-master",
urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
)
# Similar to com_google_protobuf_cc but for Java (i.e., java_proto_library).
http_archive(
name = "com_google_protobuf_java",
strip_prefix = "protobuf-master",
urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
)
# Similar to com_google_protobuf_cc but for Java lite. If you are building
# Similar to com_google_protobuf but for Java lite. If you are building
# for Android, the lite version should be prefered because it has a much
# smaller code size.
http_archive(
@ -34,17 +27,6 @@ http_archive(
urls = ["https://github.com/protocolbuffers/protobuf/archive/javalite.zip"],
)
http_archive(
name = "bazel_skylib",
sha256 = "bbccf674aa441c266df9894182d80de104cabd19be98be002f6d478aaa31574d",
strip_prefix = "bazel-skylib-2169ae1c374aab4a09aa90e65efe1a3aad4e279b",
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/2169ae1c374aab4a09aa90e65efe1a3aad4e279b.tar.gz"],
)
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()
load("@bazel_skylib//lib:versions.bzl", "versions")
versions.check(minimum_bazel_version = "0.5.4")

@ -2,34 +2,31 @@ import 'dart:io';
import 'dart_tutorial/addressbook.pb.dart';
// This function fills in a Person message based on user input.
/// This function fills in a Person message based on user input.
Person promptForAddress() {
Person person = Person();
final person = Person();
print('Enter person ID: ');
String input = stdin.readLineSync();
final input = stdin.readLineSync();
person.id = int.parse(input);
print('Enter name');
person.name = stdin.readLineSync();
print('Enter email address (blank for none) : ');
String email = stdin.readLineSync();
if (email.isNotEmpty) {
person.email = email;
}
final email = stdin.readLineSync();
if (email.isNotEmpty) person.email = email;
while (true) {
print('Enter a phone number (or leave blank to finish): ');
String number = stdin.readLineSync();
final number = stdin.readLineSync();
if (number.isEmpty) break;
Person_PhoneNumber phoneNumber = Person_PhoneNumber();
final phoneNumber = Person_PhoneNumber()..number = number;
phoneNumber.number = number;
print('Is this a mobile, home, or work phone? ');
String type = stdin.readLineSync();
final type = stdin.readLineSync();
switch (type) {
case 'mobile':
phoneNumber.type = Person_PhoneType.MOBILE;
@ -49,15 +46,15 @@ Person promptForAddress() {
return person;
}
// Reads the entire address book from a file, adds one person based
// on user input, then writes it back out to the same file.
main(List<String> arguments) {
/// Reads the entire address book from a file, adds one person based
/// on user input, then writes it back out to the same file.
void main(List<String> arguments) {
if (arguments.length != 1) {
print('Usage: add_person ADDRESS_BOOK_FILE');
exit(-1);
}
File file = File(arguments.first);
final file = File(arguments.first);
AddressBook addressBook;
if (!file.existsSync()) {
print('File not found. Creating new file.');

@ -3,16 +3,16 @@ import 'dart:io';
import 'dart_tutorial/addressbook.pb.dart';
import 'dart_tutorial/addressbook.pbenum.dart';
// Iterates though all people in the AddressBook and prints info about them.
/// Iterates though all people in the AddressBook and prints info about them.
void printAddressBook(AddressBook addressBook) {
for (Person person in addressBook.people) {
for (var person in addressBook.people) {
print('Person ID: ${person.id}');
print(' Name: ${person.name}');
if (person.hasEmail()) {
print(' E-mail address:${person.email}');
}
for (Person_PhoneNumber phoneNumber in person.phones) {
for (var phoneNumber in person.phones) {
switch (phoneNumber.type) {
case Person_PhoneType.MOBILE:
print(' Mobile phone #: ');
@ -32,16 +32,16 @@ void printAddressBook(AddressBook addressBook) {
}
}
// Reads the entire address book from a file and prints all
// the information inside.
main(List<String> arguments) {
/// Reads the entire address book from a file and prints all
/// the information inside.
void main(List<String> arguments) {
if (arguments.length != 1) {
print('Usage: list_person ADDRESS_BOOK_FILE');
exit(-1);
}
// Read the existing address book.
File file = new File(arguments.first);
AddressBook addressBook = new AddressBook.fromBuffer(file.readAsBytesSync());
final file = new File(arguments.first);
final addressBook = new AddressBook.fromBuffer(file.readAsBytesSync());
printAddressBook(addressBook);
}

@ -1 +0,0 @@
../../third_party/zlib.BUILD

@ -23,7 +23,7 @@ If you are using Maven, use the following:
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.6.1</version>
<version>3.9.2</version>
</dependency>
```
@ -37,7 +37,7 @@ protobuf-java-util package:
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
<version>3.6.1</version>
<version>3.9.2</version>
</dependency>
```
@ -45,7 +45,7 @@ protobuf-java-util package:
If you are using Gradle, add the following to your `build.gradle` file's dependencies:
```
compile 'com.google.protobuf:protobuf-java:3.6.1'
compile 'com.google.protobuf:protobuf-java:3.9.2'
```
Again, be sure to check that the version number maches (or is newer than) the version number of protoc that you are using.

@ -4,7 +4,7 @@
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-bom</artifactId>
<version>3.9.0-rc-1</version>
<version>3.11.0-rc-0</version>
<packaging>pom</packaging>
<name>Protocol Buffers [BOM]</name>
@ -29,8 +29,8 @@
<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<name>3-Clause BSD License</name>
<url>https://opensource.org/licenses/BSD-3-Clause</url>
</license>
</licenses>

@ -17,41 +17,13 @@ TEST_VERSION=`grep "^ <version>.*</version>" pom.xml | sed "s| <version>\(.*\)
# 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
""|2.5.0)
OLD_VERSION=2.5.0
OLD_VERSION_PROTOC=https://github.com/xfxyjwf/protobuf-compiler-release/raw/master/v2.5.0/linux/protoc
;;
2.6.1)
OLD_VERSION=2.6.1
OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/2.6.1-build2/protoc-2.6.1-build2-linux-x86_64.exe
;;
3.0.0-beta-1)
OLD_VERSION=3.0.0-beta-1
OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-1/protoc-3.0.0-beta-1-linux-x86_64.exe
;;
3.0.0-beta-2)
OLD_VERSION=3.0.0-beta-2
OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-2/protoc-3.0.0-beta-2-linux-x86_64.exe
;;
3.0.0-beta-3)
OLD_VERSION=3.0.0-beta-3
OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-3/protoc-3.0.0-beta-3-linux-x86_64.exe
;;
3.0.0-beta-4)
OLD_VERSION=3.0.0-beta-4
OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-4/protoc-3.0.0-beta-4-linux-x86_64.exe
;;
*)
echo "[ERROR]: Unknown version number: $1"
exit 1
;;
esac
OLD_VERSION=$1
OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/$OLD_VERSION/protoc-$OLD_VERSION-linux-x86_64.exe
# Extract the latest protobuf version number.
VERSION_NUMBER=`grep "^ <version>.*</version>" ../../pom.xml | sed "s| <version>\(.*\)</version>|\1|"`
echo "Running compatibility tests between $VERSION_NUMBER and $OLD_VERSION"
echo "Running compatibility tests between current $VERSION_NUMBER and released $OLD_VERSION"
# Check protoc
[ -f ../../../src/protoc ] || {

@ -4,7 +4,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.9.0-rc-1</version>
<version>3.11.0-rc-0</version>
</parent>
<artifactId>protobuf-java</artifactId>
@ -37,6 +37,11 @@
<artifactId>guava</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
@ -144,6 +149,7 @@
<extensions>true</extensions>
<configuration>
<instructions>
<Automatic-Module-Name>com.google.protobuf</Automatic-Module-Name> <!-- Java9+ Jigsaw module name -->
<Bundle-DocURL>https://developers.google.com/protocol-buffers/</Bundle-DocURL>
<Bundle-SymbolicName>com.google.protobuf</Bundle-SymbolicName>
<Export-Package>com.google.protobuf;version=${project.version}</Export-Package>

@ -193,7 +193,7 @@ public abstract class AbstractMessage
if (list.isEmpty()) {
return Collections.emptyMap();
}
Map result = new HashMap();
Map result = new HashMap<>();
Iterator iterator = list.iterator();
Message entry = (Message) iterator.next();
Descriptors.Descriptor descriptor = entry.getDescriptorForType();

@ -146,6 +146,15 @@ public abstract class AbstractMessageLite<
Builder.addAll(values, list);
}
/** Interface for an enum which signifies which field in a {@code oneof} was specified. */
protected interface InternalOneOfEnum {
/**
* Retrieves the field number of the field which was set in this {@code oneof}, or {@code 0} if
* none were.
*/
int getNumber();
}
/**
* A partial implementation of the {@link Message.Builder} interface which implements as many
* methods of that interface as possible in terms of other methods.

@ -30,6 +30,10 @@
package com.google.protobuf;
import static com.google.protobuf.TextFormatEscaper.escapeBytes;
import static java.lang.Integer.toHexString;
import static java.lang.System.identityHashCode;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -49,6 +53,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.NoSuchElementException;
/**
@ -1268,7 +1273,17 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
@Override
public final String toString() {
return String.format(
"<ByteString@%s size=%d>", Integer.toHexString(System.identityHashCode(this)), size());
Locale.ROOT,
"<ByteString@%s size=%d contents=\"%s\">",
toHexString(identityHashCode(this)),
size(),
truncateAndEscapeForDisplay());
}
private String truncateAndEscapeForDisplay() {
final int limit = 50;
return size() <= limit ? escapeBytes(this) : escapeBytes(substring(0, limit - 3)) + "...";
}
/**

@ -59,26 +59,16 @@ final class ExtensionRegistryFactory {
/** Construct a new, empty instance. */
public static ExtensionRegistryLite create() {
if (EXTENSION_REGISTRY_CLASS != null) {
try {
return invokeSubclassFactory("newInstance");
} catch (Exception e) {
// return a Lite registry.
}
}
return new ExtensionRegistryLite();
ExtensionRegistryLite result = invokeSubclassFactory("newInstance");
return result != null ? result : new ExtensionRegistryLite();
}
/** Get the unmodifiable singleton empty instance. */
public static ExtensionRegistryLite createEmpty() {
if (EXTENSION_REGISTRY_CLASS != null) {
try {
return invokeSubclassFactory("getEmptyRegistry");
} catch (Exception e) {
// return a Lite registry.
}
}
return EMPTY_REGISTRY_LITE;
ExtensionRegistryLite result = invokeSubclassFactory("getEmptyRegistry");
return result != null ? result : EMPTY_REGISTRY_LITE;
}
@ -87,9 +77,17 @@ final class ExtensionRegistryFactory {
&& EXTENSION_REGISTRY_CLASS.isAssignableFrom(registry.getClass());
}
private static final ExtensionRegistryLite invokeSubclassFactory(String methodName)
throws Exception {
return (ExtensionRegistryLite)
EXTENSION_REGISTRY_CLASS.getDeclaredMethod(methodName).invoke(null);
/* @Nullable */
private static final ExtensionRegistryLite invokeSubclassFactory(String methodName) {
if (EXTENSION_REGISTRY_CLASS == null) {
return null;
}
try {
return (ExtensionRegistryLite)
EXTENSION_REGISTRY_CLASS.getDeclaredMethod(methodName).invoke(null);
} catch (Exception e) {
return null;
}
}
}

@ -83,19 +83,21 @@ public class ExtensionRegistryLite {
// Visible for testing.
static final String EXTENSION_CLASS_NAME = "com.google.protobuf.Extension";
/* @Nullable */
static Class<?> resolveExtensionClass() {
try {
return Class.forName(EXTENSION_CLASS_NAME);
} catch (ClassNotFoundException e) {
// See comment in ExtensionRegistryFactory on the potential expense of this.
return null;
private static class ExtensionClassHolder {
/* @Nullable */
static final Class<?> INSTANCE = resolveExtensionClass();
/* @Nullable */
static Class<?> resolveExtensionClass() {
try {
return Class.forName(EXTENSION_CLASS_NAME);
} catch (ClassNotFoundException e) {
// See comment in ExtensionRegistryFactory on the potential expense of this.
return null;
}
}
}
/* @Nullable */
private static final Class<?> extensionClass = resolveExtensionClass();
public static boolean isEagerlyParseMessageSets() {
return eagerlyParseMessageSets;
}
@ -175,7 +177,7 @@ public class ExtensionRegistryLite {
}
if (doFullRuntimeInheritanceCheck && ExtensionRegistryFactory.isFullRegistry(this)) {
try {
this.getClass().getMethod("add", extensionClass).invoke(this, extension);
this.getClass().getMethod("add", ExtensionClassHolder.INSTANCE).invoke(this, extension);
} catch (Exception e) {
throw new IllegalArgumentException(
String.format("Could not invoke ExtensionRegistry#add for %s", extension), e);

@ -48,8 +48,7 @@ import java.util.Map;
*
* @author kenton@google.com Kenton Varda
*/
final class FieldSet<
FieldDescriptorType extends FieldSet.FieldDescriptorLite<FieldDescriptorType>> {
final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
/**
* Interface for a FieldDescriptor or lite extension descriptor. This prevents FieldSet from
* depending on {@link Descriptors.FieldDescriptor}.
@ -72,18 +71,26 @@ final class FieldSet<
MessageLite.Builder internalMergeFrom(MessageLite.Builder to, MessageLite from);
}
private final SmallSortedMap<FieldDescriptorType, Object> fields;
private static final int DEFAULT_FIELD_MAP_ARRAY_SIZE = 16;
private final SmallSortedMap<T, Object> fields;
private boolean isImmutable;
private boolean hasLazyField = false;
private boolean hasLazyField;
/** Construct a new FieldSet. */
private FieldSet() {
this.fields = SmallSortedMap.newFieldMap(16);
this.fields = SmallSortedMap.newFieldMap(DEFAULT_FIELD_MAP_ARRAY_SIZE);
}
/** Construct an empty FieldSet. This is only used to initialize DEFAULT_INSTANCE. */
@SuppressWarnings("unused")
private FieldSet(final boolean dummy) {
this.fields = SmallSortedMap.newFieldMap(0);
this(SmallSortedMap.<T>newFieldMap(0));
makeImmutable();
}
private FieldSet(SmallSortedMap<T, Object> fields) {
this.fields = fields;
makeImmutable();
}
@ -98,6 +105,11 @@ final class FieldSet<
return DEFAULT_INSTANCE;
}
/** Construct a new Builder. */
public static <T extends FieldDescriptorLite<T>> Builder<T> newBuilder() {
return new Builder<T>();
}
@SuppressWarnings("rawtypes")
private static final FieldSet DEFAULT_INSTANCE = new FieldSet(true);
@ -152,18 +164,16 @@ final class FieldSet<
* @return the newly cloned FieldSet
*/
@Override
public FieldSet<FieldDescriptorType> clone() {
public FieldSet<T> clone() {
// We can't just call fields.clone because List objects in the map
// should not be shared.
FieldSet<FieldDescriptorType> clone = FieldSet.newFieldSet();
FieldSet<T> clone = FieldSet.newFieldSet();
for (int i = 0; i < fields.getNumArrayEntries(); i++) {
Map.Entry<FieldDescriptorType, Object> entry = fields.getArrayEntryAt(i);
FieldDescriptorType descriptor = entry.getKey();
clone.setField(descriptor, entry.getValue());
Map.Entry<T, Object> entry = fields.getArrayEntryAt(i);
clone.setField(entry.getKey(), entry.getValue());
}
for (Map.Entry<FieldDescriptorType, Object> entry : fields.getOverflowEntries()) {
FieldDescriptorType descriptor = entry.getKey();
clone.setField(descriptor, entry.getValue());
for (Map.Entry<T, Object> entry : fields.getOverflowEntries()) {
clone.setField(entry.getKey(), entry.getValue());
}
clone.hasLazyField = hasLazyField;
return clone;
@ -179,15 +189,9 @@ final class FieldSet<
}
/** Get a simple map containing all the fields. */
public Map<FieldDescriptorType, Object> getAllFields() {
public Map<T, Object> getAllFields() {
if (hasLazyField) {
SmallSortedMap<FieldDescriptorType, Object> result = SmallSortedMap.newFieldMap(16);
for (int i = 0; i < fields.getNumArrayEntries(); i++) {
cloneFieldEntry(result, fields.getArrayEntryAt(i));
}
for (Map.Entry<FieldDescriptorType, Object> entry : fields.getOverflowEntries()) {
cloneFieldEntry(result, entry);
}
SmallSortedMap<T, Object> result = cloneAllFieldsMap(fields, /* copyList */ false);
if (fields.isImmutable()) {
result.makeImmutable();
}
@ -196,12 +200,26 @@ final class FieldSet<
return fields.isImmutable() ? fields : Collections.unmodifiableMap(fields);
}
private void cloneFieldEntry(
Map<FieldDescriptorType, Object> map, Map.Entry<FieldDescriptorType, Object> entry) {
FieldDescriptorType key = entry.getKey();
private static <T extends FieldDescriptorLite<T>> SmallSortedMap<T, Object> cloneAllFieldsMap(
SmallSortedMap<T, Object> fields, boolean copyList) {
SmallSortedMap<T, Object> result = SmallSortedMap.newFieldMap(DEFAULT_FIELD_MAP_ARRAY_SIZE);
for (int i = 0; i < fields.getNumArrayEntries(); i++) {
cloneFieldEntry(result, fields.getArrayEntryAt(i), copyList);
}
for (Map.Entry<T, Object> entry : fields.getOverflowEntries()) {
cloneFieldEntry(result, entry, copyList);
}
return result;
}
private static <T extends FieldDescriptorLite<T>> void cloneFieldEntry(
Map<T, Object> map, Map.Entry<T, Object> entry, boolean copyList) {
T key = entry.getKey();
Object value = entry.getValue();
if (value instanceof LazyField) {
map.put(key, ((LazyField) value).getValue());
} else if (copyList && value instanceof List) {
map.put(key, new ArrayList<>((List<?>) value));
} else {
map.put(key, value);
}
@ -211,9 +229,9 @@ final class FieldSet<
* Get an iterator to the field map. This iterator should not be leaked out of the protobuf
* library as it is not protected from mutation when fields is not immutable.
*/
public Iterator<Map.Entry<FieldDescriptorType, Object>> iterator() {
public Iterator<Map.Entry<T, Object>> iterator() {
if (hasLazyField) {
return new LazyIterator<FieldDescriptorType>(fields.entrySet().iterator());
return new LazyIterator<T>(fields.entrySet().iterator());
}
return fields.entrySet().iterator();
}
@ -223,15 +241,15 @@ final class FieldSet<
* should not be leaked out of the protobuf library as it is not protected from mutation when
* fields is not immutable.
*/
Iterator<Map.Entry<FieldDescriptorType, Object>> descendingIterator() {
Iterator<Map.Entry<T, Object>> descendingIterator() {
if (hasLazyField) {
return new LazyIterator<FieldDescriptorType>(fields.descendingEntrySet().iterator());
return new LazyIterator<T>(fields.descendingEntrySet().iterator());
}
return fields.descendingEntrySet().iterator();
}
/** Useful for implementing {@link Message#hasField(Descriptors.FieldDescriptor)}. */
public boolean hasField(final FieldDescriptorType descriptor) {
public boolean hasField(final T descriptor) {
if (descriptor.isRepeated()) {
throw new IllegalArgumentException("hasField() can only be called on non-repeated fields.");
}
@ -244,7 +262,7 @@ final class FieldSet<
* returns {@code null} if the field is not set; in this case it is up to the caller to fetch the
* field's default value.
*/
public Object getField(final FieldDescriptorType descriptor) {
public Object getField(final T descriptor) {
Object o = fields.get(descriptor);
if (o instanceof LazyField) {
return ((LazyField) o).getValue();
@ -256,7 +274,7 @@ final class FieldSet<
* Useful for implementing {@link Message.Builder#setField(Descriptors.FieldDescriptor,Object)}.
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public void setField(final FieldDescriptorType descriptor, Object value) {
public void setField(final T descriptor, Object value) {
if (descriptor.isRepeated()) {
if (!(value instanceof List)) {
throw new IllegalArgumentException(
@ -282,7 +300,7 @@ final class FieldSet<
}
/** Useful for implementing {@link Message.Builder#clearField(Descriptors.FieldDescriptor)}. */
public void clearField(final FieldDescriptorType descriptor) {
public void clearField(final T descriptor) {
fields.remove(descriptor);
if (fields.isEmpty()) {
hasLazyField = false;
@ -290,7 +308,7 @@ final class FieldSet<
}
/** Useful for implementing {@link Message#getRepeatedFieldCount(Descriptors.FieldDescriptor)}. */
public int getRepeatedFieldCount(final FieldDescriptorType descriptor) {
public int getRepeatedFieldCount(final T descriptor) {
if (!descriptor.isRepeated()) {
throw new IllegalArgumentException(
"getRepeatedField() can only be called on repeated fields.");
@ -305,7 +323,7 @@ final class FieldSet<
}
/** Useful for implementing {@link Message#getRepeatedField(Descriptors.FieldDescriptor,int)}. */
public Object getRepeatedField(final FieldDescriptorType descriptor, final int index) {
public Object getRepeatedField(final T descriptor, final int index) {
if (!descriptor.isRepeated()) {
throw new IllegalArgumentException(
"getRepeatedField() can only be called on repeated fields.");
@ -325,8 +343,7 @@ final class FieldSet<
* Message.Builder#setRepeatedField(Descriptors.FieldDescriptor,int,Object)}.
*/
@SuppressWarnings("unchecked")
public void setRepeatedField(
final FieldDescriptorType descriptor, final int index, final Object value) {
public void setRepeatedField(final T descriptor, final int index, final Object value) {
if (!descriptor.isRepeated()) {
throw new IllegalArgumentException(
"getRepeatedField() can only be called on repeated fields.");
@ -346,7 +363,7 @@ final class FieldSet<
* Message.Builder#addRepeatedField(Descriptors.FieldDescriptor,Object)}.
*/
@SuppressWarnings("unchecked")
public void addRepeatedField(final FieldDescriptorType descriptor, final Object value) {
public void addRepeatedField(final T descriptor, final Object value) {
if (!descriptor.isRepeated()) {
throw new IllegalArgumentException(
"addRepeatedField() can only be called on repeated fields.");
@ -373,53 +390,45 @@ final class FieldSet<
*
* @throws IllegalArgumentException The value is not of the right type.
*/
private static void verifyType(final WireFormat.FieldType type, final Object value) {
checkNotNull(value);
private void verifyType(final WireFormat.FieldType type, final Object value) {
if (!isValidType(type, value)) {
// TODO(kenton): When chaining calls to setField(), it can be hard to
// tell from the stack trace which exact call failed, since the whole
// chain is considered one line of code. It would be nice to print
// more information here, e.g. naming the field. We used to do that.
// But we can't now that FieldSet doesn't use descriptors. Maybe this
// isn't a big deal, though, since it would only really apply when using
// reflection and generally people don't chain reflection setters.
throw new IllegalArgumentException(
"Wrong object type used with protocol message reflection.");
}
}
boolean isValid = false;
private static boolean isValidType(final WireFormat.FieldType type, final Object value) {
checkNotNull(value);
switch (type.getJavaType()) {
case INT:
isValid = value instanceof Integer;
break;
return value instanceof Integer;
case LONG:
isValid = value instanceof Long;
break;
return value instanceof Long;
case FLOAT:
isValid = value instanceof Float;
break;
return value instanceof Float;
case DOUBLE:
isValid = value instanceof Double;
break;
return value instanceof Double;
case BOOLEAN:
isValid = value instanceof Boolean;
break;
return value instanceof Boolean;
case STRING:
isValid = value instanceof String;
break;
return value instanceof String;
case BYTE_STRING:
isValid = value instanceof ByteString || value instanceof byte[];
break;
return value instanceof ByteString || value instanceof byte[];
case ENUM:
// TODO(kenton): Caller must do type checking here, I guess.
isValid = (value instanceof Integer || value instanceof Internal.EnumLite);
break;
return (value instanceof Integer || value instanceof Internal.EnumLite);
case MESSAGE:
// TODO(kenton): Caller must do type checking here, I guess.
isValid = (value instanceof MessageLite) || (value instanceof LazyField);
break;
}
if (!isValid) {
// TODO(kenton): When chaining calls to setField(), it can be hard to
// tell from the stack trace which exact call failed, since the whole
// chain is considered one line of code. It would be nice to print
// more information here, e.g. naming the field. We used to do that.
// But we can't now that FieldSet doesn't use descriptors. Maybe this
// isn't a big deal, though, since it would only really apply when using
// reflection and generally people don't chain reflection setters.
throw new IllegalArgumentException(
"Wrong object type used with protocol message reflection.");
return (value instanceof MessageLite) || (value instanceof LazyField);
}
return false;
}
// =================================================================
@ -436,7 +445,7 @@ final class FieldSet<
return false;
}
}
for (final Map.Entry<FieldDescriptorType, Object> entry : fields.getOverflowEntries()) {
for (final Map.Entry<T, Object> entry : fields.getOverflowEntries()) {
if (!isInitialized(entry)) {
return false;
}
@ -445,8 +454,9 @@ final class FieldSet<
}
@SuppressWarnings("unchecked")
private boolean isInitialized(final Map.Entry<FieldDescriptorType, Object> entry) {
final FieldDescriptorType descriptor = entry.getKey();
private static <T extends FieldDescriptorLite<T>> boolean isInitialized(
final Map.Entry<T, Object> entry) {
final T descriptor = entry.getKey();
if (descriptor.getLiteJavaType() == WireFormat.JavaType.MESSAGE) {
if (descriptor.isRepeated()) {
for (final MessageLite element : (List<MessageLite>) entry.getValue()) {
@ -485,16 +495,16 @@ final class FieldSet<
}
/** Like {@link Message.Builder#mergeFrom(Message)}, but merges from another {@link FieldSet}. */
public void mergeFrom(final FieldSet<FieldDescriptorType> other) {
public void mergeFrom(final FieldSet<T> other) {
for (int i = 0; i < other.fields.getNumArrayEntries(); i++) {
mergeFromField(other.fields.getArrayEntryAt(i));
}
for (final Map.Entry<FieldDescriptorType, Object> entry : other.fields.getOverflowEntries()) {
for (final Map.Entry<T, Object> entry : other.fields.getOverflowEntries()) {
mergeFromField(entry);
}
}
private Object cloneIfMutable(Object value) {
private static Object cloneIfMutable(Object value) {
if (value instanceof byte[]) {
byte[] bytes = (byte[]) value;
byte[] copy = new byte[bytes.length];
@ -506,8 +516,8 @@ final class FieldSet<
}
@SuppressWarnings({"unchecked", "rawtypes"})
private void mergeFromField(final Map.Entry<FieldDescriptorType, Object> entry) {
final FieldDescriptorType descriptor = entry.getKey();
private void mergeFromField(final Map.Entry<T, Object> entry) {
final T descriptor = entry.getKey();
Object otherValue = entry.getValue();
if (otherValue instanceof LazyField) {
otherValue = ((LazyField) otherValue).getValue();
@ -516,7 +526,7 @@ final class FieldSet<
if (descriptor.isRepeated()) {
Object value = getField(descriptor);
if (value == null) {
value = new ArrayList();
value = new ArrayList<>();
}
for (Object element : (List) otherValue) {
((List) value).add(cloneIfMutable(element));
@ -532,7 +542,6 @@ final class FieldSet<
descriptor
.internalMergeFrom(((MessageLite) value).toBuilder(), (MessageLite) otherValue)
.build();
fields.put(descriptor, value);
}
} else {
@ -567,10 +576,10 @@ final class FieldSet<
/** See {@link Message#writeTo(CodedOutputStream)}. */
public void writeTo(final CodedOutputStream output) throws IOException {
for (int i = 0; i < fields.getNumArrayEntries(); i++) {
final Map.Entry<FieldDescriptorType, Object> entry = fields.getArrayEntryAt(i);
final Map.Entry<T, Object> entry = fields.getArrayEntryAt(i);
writeField(entry.getKey(), entry.getValue(), output);
}
for (final Map.Entry<FieldDescriptorType, Object> entry : fields.getOverflowEntries()) {
for (final Map.Entry<T, Object> entry : fields.getOverflowEntries()) {
writeField(entry.getKey(), entry.getValue(), output);
}
}
@ -580,15 +589,14 @@ final class FieldSet<
for (int i = 0; i < fields.getNumArrayEntries(); i++) {
writeMessageSetTo(fields.getArrayEntryAt(i), output);
}
for (final Map.Entry<FieldDescriptorType, Object> entry : fields.getOverflowEntries()) {
for (final Map.Entry<T, Object> entry : fields.getOverflowEntries()) {
writeMessageSetTo(entry, output);
}
}
private void writeMessageSetTo(
final Map.Entry<FieldDescriptorType, Object> entry, final CodedOutputStream output)
private void writeMessageSetTo(final Map.Entry<T, Object> entry, final CodedOutputStream output)
throws IOException {
final FieldDescriptorType descriptor = entry.getKey();
final T descriptor = entry.getKey();
if (descriptor.getLiteJavaType() == WireFormat.JavaType.MESSAGE
&& !descriptor.isRepeated()
&& !descriptor.isPacked()) {
@ -750,10 +758,10 @@ final class FieldSet<
public int getSerializedSize() {
int size = 0;
for (int i = 0; i < fields.getNumArrayEntries(); i++) {
final Map.Entry<FieldDescriptorType, Object> entry = fields.getArrayEntryAt(i);
final Map.Entry<T, Object> entry = fields.getArrayEntryAt(i);
size += computeFieldSize(entry.getKey(), entry.getValue());
}
for (final Map.Entry<FieldDescriptorType, Object> entry : fields.getOverflowEntries()) {
for (final Map.Entry<T, Object> entry : fields.getOverflowEntries()) {
size += computeFieldSize(entry.getKey(), entry.getValue());
}
return size;
@ -765,14 +773,14 @@ final class FieldSet<
for (int i = 0; i < fields.getNumArrayEntries(); i++) {
size += getMessageSetSerializedSize(fields.getArrayEntryAt(i));
}
for (final Map.Entry<FieldDescriptorType, Object> entry : fields.getOverflowEntries()) {
for (final Map.Entry<T, Object> entry : fields.getOverflowEntries()) {
size += getMessageSetSerializedSize(entry);
}
return size;
}
private int getMessageSetSerializedSize(final Map.Entry<FieldDescriptorType, Object> entry) {
final FieldDescriptorType descriptor = entry.getKey();
private int getMessageSetSerializedSize(final Map.Entry<T, Object> entry) {
final T descriptor = entry.getKey();
Object value = entry.getValue();
if (descriptor.getLiteJavaType() == WireFormat.JavaType.MESSAGE
&& !descriptor.isRepeated()
@ -904,4 +912,385 @@ final class FieldSet<
return computeElementSize(type, number, value);
}
}
/**
* A FieldSet Builder that accept a {@link MessageLite.Builder} as a field value. This is useful
* for implementing methods in {@link MessageLite.Builder}.
*/
static final class Builder<T extends FieldDescriptorLite<T>> {
private SmallSortedMap<T, Object> fields;
private boolean hasLazyField;
private boolean isMutable;
private boolean hasNestedBuilders;
private Builder() {
this(SmallSortedMap.<T>newFieldMap(DEFAULT_FIELD_MAP_ARRAY_SIZE));
}
private Builder(SmallSortedMap<T, Object> fields) {
this.fields = fields;
this.isMutable = true;
}
/** Creates the FieldSet */
public FieldSet<T> build() {
if (fields.isEmpty()) {
return FieldSet.emptySet();
}
isMutable = false;
SmallSortedMap<T, Object> fieldsForBuild = fields;
if (hasNestedBuilders) {
// Make a copy of the fields map with all Builders replaced by Message.
fieldsForBuild = cloneAllFieldsMap(fields, /* copyList */ false);
replaceBuilders(fieldsForBuild);
}
FieldSet<T> fieldSet = new FieldSet<>(fieldsForBuild);
fieldSet.hasLazyField = hasLazyField;
return fieldSet;
}
private static <T extends FieldDescriptorLite<T>> void replaceBuilders(
SmallSortedMap<T, Object> fieldMap) {
for (int i = 0; i < fieldMap.getNumArrayEntries(); i++) {
replaceBuilders(fieldMap.getArrayEntryAt(i));
}
for (Map.Entry<T, Object> entry : fieldMap.getOverflowEntries()) {
replaceBuilders(entry);
}
}
private static <T extends FieldDescriptorLite<T>> void replaceBuilders(
Map.Entry<T, Object> entry) {
entry.setValue(replaceBuilders(entry.getKey(), entry.getValue()));
}
private static <T extends FieldDescriptorLite<T>> Object replaceBuilders(
T descriptor, Object value) {
if (value == null) {
return value;
}
if (descriptor.getLiteJavaType() == WireFormat.JavaType.MESSAGE) {
if (descriptor.isRepeated()) {
if (!(value instanceof List)) {
throw new IllegalStateException(
"Repeated field should contains a List but actually contains type: "
+ value.getClass());
}
@SuppressWarnings("unchecked") // We just check that value is an instance of List above.
List<Object> list = (List<Object>) value;
for (int i = 0; i < list.size(); i++) {
Object oldElement = list.get(i);
Object newElement = replaceBuilder(oldElement);
if (newElement != oldElement) {
// If the list contains a Message.Builder, then make a copy of that list and then
// modify the Message.Builder into a Message and return the new list. This way, the
// existing Message.Builder will still be able to modify the inner fields of the
// original FieldSet.Builder.
if (list == value) {
list = new ArrayList<>(list);
}
list.set(i, newElement);
}
}
return list;
} else {
return replaceBuilder(value);
}
}
return value;
}
private static Object replaceBuilder(Object value) {
return (value instanceof MessageLite.Builder) ? ((MessageLite.Builder) value).build() : value;
}
/** Returns a new Builder using the fields from {@code fieldSet}. */
public static <T extends FieldDescriptorLite<T>> Builder<T> fromFieldSet(FieldSet<T> fieldSet) {
Builder<T> builder = new Builder<T>(cloneAllFieldsMap(fieldSet.fields, /* copyList */ true));
builder.hasLazyField = fieldSet.hasLazyField;
return builder;
}
// =================================================================
/** Get a simple map containing all the fields. */
public Map<T, Object> getAllFields() {
if (hasLazyField) {
SmallSortedMap<T, Object> result = cloneAllFieldsMap(fields, /* copyList */ false);
if (fields.isImmutable()) {
result.makeImmutable();
} else {
replaceBuilders(result);
}
return result;
}
return fields.isImmutable() ? fields : Collections.unmodifiableMap(fields);
}
/** Useful for implementing {@link Message#hasField(Descriptors.FieldDescriptor)}. */
public boolean hasField(final T descriptor) {
if (descriptor.isRepeated()) {
throw new IllegalArgumentException("hasField() can only be called on non-repeated fields.");
}
return fields.get(descriptor) != null;
}
/**
* Useful for implementing {@link Message#getField(Descriptors.FieldDescriptor)}. This method
* returns {@code null} if the field is not set; in this case it is up to the caller to fetch
* the field's default value.
*/
public Object getField(final T descriptor) {
Object value = getFieldAllowBuilders(descriptor);
return replaceBuilders(descriptor, value);
}
/** Same as {@link #getField(F)}, but allow a {@link MessageLite.Builder} to be returned. */
Object getFieldAllowBuilders(final T descriptor) {
Object o = fields.get(descriptor);
if (o instanceof LazyField) {
return ((LazyField) o).getValue();
}
return o;
}
private void ensureIsMutable() {
if (!isMutable) {
fields = cloneAllFieldsMap(fields, /* copyList */ true);
isMutable = true;
}
}
/**
* Useful for implementing {@link Message.Builder#setField(Descriptors.FieldDescriptor,
* Object)}.
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public void setField(final T descriptor, Object value) {
ensureIsMutable();
if (descriptor.isRepeated()) {
if (!(value instanceof List)) {
throw new IllegalArgumentException(
"Wrong object type used with protocol message reflection.");
}
// Wrap the contents in a new list so that the caller cannot change
// the list's contents after setting it.
final List newList = new ArrayList();
newList.addAll((List) value);
for (final Object element : newList) {
verifyType(descriptor.getLiteType(), element);
hasNestedBuilders = hasNestedBuilders || element instanceof MessageLite.Builder;
}
value = newList;
} else {
verifyType(descriptor.getLiteType(), value);
}
if (value instanceof LazyField) {
hasLazyField = true;
}
hasNestedBuilders = hasNestedBuilders || value instanceof MessageLite.Builder;
fields.put(descriptor, value);
}
/** Useful for implementing {@link Message.Builder#clearField(Descriptors.FieldDescriptor)}. */
public void clearField(final T descriptor) {
ensureIsMutable();
fields.remove(descriptor);
if (fields.isEmpty()) {
hasLazyField = false;
}
}
/**
* Useful for implementing {@link Message#getRepeatedFieldCount(Descriptors.FieldDescriptor)}.
*/
public int getRepeatedFieldCount(final T descriptor) {
if (!descriptor.isRepeated()) {
throw new IllegalArgumentException(
"getRepeatedField() can only be called on repeated fields.");
}
final Object value = getField(descriptor);
if (value == null) {
return 0;
} else {
return ((List<?>) value).size();
}
}
/**
* Useful for implementing {@link Message#getRepeatedField(Descriptors.FieldDescriptor, int)}.
*/
public Object getRepeatedField(final T descriptor, final int index) {
if (hasNestedBuilders) {
ensureIsMutable();
}
Object value = getRepeatedFieldAllowBuilders(descriptor, index);
return replaceBuilder(value);
}
/**
* Same as {@link #getRepeatedField(F, int)}, but allow a {@link MessageLite.Builder} to be
* returned.
*/
Object getRepeatedFieldAllowBuilders(final T descriptor, final int index) {
if (!descriptor.isRepeated()) {
throw new IllegalArgumentException(
"getRepeatedField() can only be called on repeated fields.");
}
final Object value = getFieldAllowBuilders(descriptor);
if (value == null) {
throw new IndexOutOfBoundsException();
} else {
return ((List<?>) value).get(index);
}
}
/**
* Useful for implementing {@link Message.Builder#setRepeatedField(Descriptors.FieldDescriptor,
* int, Object)}.
*/
@SuppressWarnings("unchecked")
public void setRepeatedField(final T descriptor, final int index, final Object value) {
ensureIsMutable();
if (!descriptor.isRepeated()) {
throw new IllegalArgumentException(
"getRepeatedField() can only be called on repeated fields.");
}
hasNestedBuilders = hasNestedBuilders || value instanceof MessageLite.Builder;
final Object list = getField(descriptor);
if (list == null) {
throw new IndexOutOfBoundsException();
}
verifyType(descriptor.getLiteType(), value);
((List<Object>) list).set(index, value);
}
/**
* Useful for implementing {@link Message.Builder#addRepeatedField(Descriptors.FieldDescriptor,
* Object)}.
*/
@SuppressWarnings("unchecked")
public void addRepeatedField(final T descriptor, final Object value) {
ensureIsMutable();
if (!descriptor.isRepeated()) {
throw new IllegalArgumentException(
"addRepeatedField() can only be called on repeated fields.");
}
hasNestedBuilders = hasNestedBuilders || value instanceof MessageLite.Builder;
verifyType(descriptor.getLiteType(), value);
final Object existingValue = getField(descriptor);
List<Object> list;
if (existingValue == null) {
list = new ArrayList<>();
fields.put(descriptor, list);
} else {
list = (List<Object>) existingValue;
}
list.add(value);
}
/**
* Verifies that the given object is of the correct type to be a valid value for the given
* field. (For repeated fields, this checks if the object is the right type to be one element of
* the field.)
*
* @throws IllegalArgumentException The value is not of the right type.
*/
private static void verifyType(final WireFormat.FieldType type, final Object value) {
if (!FieldSet.isValidType(type, value)) {
// Builder can accept Message.Builder values even though FieldSet will reject.
if (type.getJavaType() == WireFormat.JavaType.MESSAGE
&& value instanceof MessageLite.Builder) {
return;
}
throw new IllegalArgumentException(
"Wrong object type used with protocol message reflection.");
}
}
/**
* See {@link Message#isInitialized()}. Note: Since {@code FieldSet} itself does not have any
* way of knowing about required fields that aren't actually present in the set, it is up to the
* caller to check that all required fields are present.
*/
public boolean isInitialized() {
for (int i = 0; i < fields.getNumArrayEntries(); i++) {
if (!FieldSet.isInitialized(fields.getArrayEntryAt(i))) {
return false;
}
}
for (final Map.Entry<T, Object> entry : fields.getOverflowEntries()) {
if (!FieldSet.isInitialized(entry)) {
return false;
}
}
return true;
}
/**
* Like {@link Message.Builder#mergeFrom(Message)}, but merges from another {@link FieldSet}.
*/
public void mergeFrom(final FieldSet<T> other) {
ensureIsMutable();
for (int i = 0; i < other.fields.getNumArrayEntries(); i++) {
mergeFromField(other.fields.getArrayEntryAt(i));
}
for (final Map.Entry<T, Object> entry : other.fields.getOverflowEntries()) {
mergeFromField(entry);
}
}
@SuppressWarnings({"unchecked", "rawtypes"})
private void mergeFromField(final Map.Entry<T, Object> entry) {
final T descriptor = entry.getKey();
Object otherValue = entry.getValue();
if (otherValue instanceof LazyField) {
otherValue = ((LazyField) otherValue).getValue();
}
if (descriptor.isRepeated()) {
Object value = getField(descriptor);
if (value == null) {
value = new ArrayList<>();
}
for (Object element : (List) otherValue) {
((List) value).add(FieldSet.cloneIfMutable(element));
}
fields.put(descriptor, value);
} else if (descriptor.getLiteJavaType() == WireFormat.JavaType.MESSAGE) {
Object value = getField(descriptor);
if (value == null) {
fields.put(descriptor, FieldSet.cloneIfMutable(otherValue));
} else {
// Merge the messages.
if (value instanceof MessageLite.Builder) {
descriptor.internalMergeFrom((MessageLite.Builder) value, (MessageLite) otherValue);
} else {
value =
descriptor
.internalMergeFrom(((MessageLite) value).toBuilder(), (MessageLite) otherValue)
.build();
fields.put(descriptor, value);
}
}
} else {
fields.put(descriptor, cloneIfMutable(otherValue));
}
}
}
}

@ -115,7 +115,8 @@ public abstract class GeneratedMessageLite<
@SuppressWarnings("unchecked") // Guaranteed by isInstance + runtime
@Override
public boolean equals(Object other) {
public boolean equals(
Object other) {
if (this == other) {
return true;
}
@ -348,16 +349,20 @@ public abstract class GeneratedMessageLite<
* Called before any method that would mutate the builder to ensure that it correctly copies any
* state before the write happens to preserve immutability guarantees.
*/
protected void copyOnWrite() {
protected final void copyOnWrite() {
if (isBuilt) {
MessageType newInstance =
(MessageType) instance.dynamicMethod(MethodToInvoke.NEW_MUTABLE_INSTANCE);
mergeFromInstance(newInstance, instance);
instance = newInstance;
copyOnWriteInternal();
isBuilt = false;
}
}
protected void copyOnWriteInternal() {
MessageType newInstance =
(MessageType) instance.dynamicMethod(MethodToInvoke.NEW_MUTABLE_INSTANCE);
mergeFromInstance(newInstance, instance);
instance = newInstance;
}
@Override
public final boolean isInitialized() {
return GeneratedMessageLite.isInitialized(instance, /* shouldMemoize= */ false);
@ -919,12 +924,8 @@ public abstract class GeneratedMessageLite<
}
@Override
protected void copyOnWrite() {
if (!isBuilt) {
return;
}
super.copyOnWrite();
protected void copyOnWriteInternal() {
super.copyOnWriteInternal();
instance.extensions = instance.extensions.clone();
}
@ -1238,7 +1239,7 @@ public abstract class GeneratedMessageLite<
Object fromFieldSetType(final Object value) {
if (descriptor.isRepeated()) {
if (descriptor.getLiteJavaType() == WireFormat.JavaType.ENUM) {
final List result = new ArrayList();
final List result = new ArrayList<>();
for (final Object element : (List) value) {
result.add(singularFromFieldSetType(element));
}
@ -1263,7 +1264,7 @@ public abstract class GeneratedMessageLite<
Object toFieldSetType(final Object value) {
if (descriptor.isRepeated()) {
if (descriptor.getLiteJavaType() == WireFormat.JavaType.ENUM) {
final List result = new ArrayList();
final List result = new ArrayList<>();
for (final Object element : (List) value) {
result.add(singularToFieldSetType(element));
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save