commit
a118acc476
1367 changed files with 165824 additions and 109141 deletions
@ -0,0 +1,18 @@ |
||||
mergeable: |
||||
pull_requests: |
||||
label: |
||||
and: |
||||
- must_exclude: |
||||
regex: '^disposition/DO NOT MERGE' |
||||
message: 'Pull request marked not mergeable' |
||||
- or: |
||||
- and: |
||||
- must_include: |
||||
regex: 'release notes: yes' |
||||
message: 'Please include release note: yes' |
||||
- must_include: |
||||
regex: '^(c#|c\+\+|cleanup|conformance tests|integration|java|javascript|go|objective-c|php|python|ruby)' |
||||
message: 'Please include at least a language label (e.g., c++, java, python). Or apply one of the following labels: cleanup, conformance tests, integration.' |
||||
- must_include: |
||||
regex: 'release notes: no' |
||||
message: 'Please include release note: no' |
@ -0,0 +1,98 @@ |
||||
# Contributing to Protocol Buffers |
||||
|
||||
We welcome your contributions to protocol buffers. This doc describes the |
||||
process to contribute patches to protobuf and the general guidelines we |
||||
expect contributors to follow. |
||||
|
||||
## Before You Start |
||||
|
||||
We accept patches in the form of github pull requests. If you are new to |
||||
github, please read [How to create github pull requests](https://help.github.com/articles/about-pull-requests/) |
||||
first. |
||||
|
||||
### Contributor License Agreements |
||||
|
||||
Contributions to this project must be accompanied by a Contributor License |
||||
Agreement. You (or your employer) retain the copyright to your contribution, |
||||
this simply gives us permission to use and redistribute your contributions |
||||
as part of the project. |
||||
|
||||
* If you are an individual writing original source code and you're sure you |
||||
own the intellectual property, then you'll need to sign an [individual CLA](https://cla.developers.google.com/about/google-individual?csw=1). |
||||
* If you work for a company that wants to allow you to contribute your work, |
||||
then you'll need to sign a [corporate CLA](https://cla.developers.google.com/about/google-corporate?csw=1). |
||||
|
||||
### Coding Style |
||||
|
||||
This project follows [Google’s Coding Style Guides](https://github.com/google/styleguide). |
||||
Before sending out your pull request, please familiarize yourself with the |
||||
corresponding style guides and make sure the proposed code change is style |
||||
conforming. |
||||
|
||||
## Contributing Process |
||||
|
||||
Most pull requests should go to the master branch and the change will be |
||||
included in the next major/minor version release (e.g., 3.6.0 release). If you |
||||
need to include a bug fix in a patch release (e.g., 3.5.2), make sure it’s |
||||
already merged to master, and then create a pull request cherry-picking the |
||||
commits from master branch to the release branch (e.g., branch 3.5.x). |
||||
|
||||
For each pull request, a protobuf team member will be assigned to review the |
||||
pull request. For minor cleanups, the pull request may be merged right away |
||||
after an initial review. For larger changes, you will likely receive multiple |
||||
rounds of comments and it may take some time to complete. We will try to keep |
||||
our response time within 7-days but if you don’t get any response in a few |
||||
days, feel free to comment on the threads to get our attention. We also expect |
||||
you to respond to our comments within a reasonable amount of time. If we don’t |
||||
hear from you for 2 weeks or longer, we may close the pull request. You can |
||||
still send the pull request again once you have time to work on it. |
||||
|
||||
Once a pull request is merged, we will take care of the rest and get it into |
||||
the final release. |
||||
|
||||
## Pull Request Guidelines |
||||
|
||||
* If you are a Googler, it is preferable to first create an internal CL and |
||||
have it reviewed and submitted. The code propagation process will deliver the |
||||
change to GitHub. |
||||
* Create small PRs that are narrowly focused on addressing a single concern. |
||||
We often receive PRs that are trying to fix several things at a time, but if |
||||
only one fix is considered acceptable, nothing gets merged and both author's |
||||
& review's time is wasted. Create more PRs to address different concerns and |
||||
everyone will be happy. |
||||
* For speculative changes, consider opening an issue and discussing it first. |
||||
If you are suggesting a behavioral or API change, make sure you get explicit |
||||
support from a protobuf team member before sending us the pull request. |
||||
* Provide a good PR description as a record of what change is being made and |
||||
why it was made. Link to a GitHub issue if it exists. |
||||
* Don't fix code style and formatting unless you are already changing that |
||||
line to address an issue. PRs with irrelevant changes won't be merged. If |
||||
you do want to fix formatting or style, do that in a separate PR. |
||||
* Unless your PR is trivial, you should expect there will be reviewer comments |
||||
that you'll need to address before merging. We expect you to be reasonably |
||||
responsive to those comments, otherwise the PR will be closed after 2-3 weeks |
||||
of inactivity. |
||||
* Maintain clean commit history and use meaningful commit messages. PRs with |
||||
messy commit history are difficult to review and won't be merged. Use rebase |
||||
-i upstream/master to curate your commit history and/or to bring in latest |
||||
changes from master (but avoid rebasing in the middle of a code review). |
||||
* Keep your PR up to date with upstream/master (if there are merge conflicts, |
||||
we can't really merge your change). |
||||
* All tests need to be passing before your change can be merged. We recommend |
||||
you run tests locally before creating your PR to catch breakages early on. |
||||
Ultimately, the green signal will be provided by our testing infrastructure. |
||||
The reviewer will help you if there are test failures that seem not related |
||||
to the change you are making. |
||||
|
||||
## Reviewer Guidelines |
||||
|
||||
* Make sure that all tests are passing before approval. |
||||
* Apply the "release notes: yes" label if the pull request's description should |
||||
be included in the next release (e.g., any new feature / bug fix). |
||||
Apply the "release notes: no" label if the pull request's description should |
||||
not be included in the next release (e.g., refactoring changes that does not |
||||
change behavior, integration from Google internal, updating tests, etc.). |
||||
* Apply the appropriate language label (e.g., C++, Java, Python, etc.) to the |
||||
pull request. This will make it easier to identify which languages the pull |
||||
request affects, allowing us to better identify appropriate reviewer, create |
||||
a better release note, and make it easier to identify issues in the future. |
@ -0,0 +1,50 @@ |
||||
|
||||
add_custom_command( |
||||
OUTPUT ${protobuf_source_dir}/conformance/conformance.pb.cc |
||||
DEPENDS protoc ${protobuf_source_dir}/conformance/conformance.proto |
||||
COMMAND protoc ${protobuf_source_dir}/conformance/conformance.proto |
||||
--proto_path=${protobuf_source_dir}/conformance |
||||
--cpp_out=${protobuf_source_dir}/conformance |
||||
) |
||||
|
||||
add_custom_command( |
||||
OUTPUT ${protobuf_source_dir}/src/google/protobuf/test_messages_proto3.pb.cc |
||||
${protobuf_source_dir}/src/google/protobuf/test_messages_proto2.pb.cc |
||||
DEPENDS protoc ${protobuf_source_dir}/src/google/protobuf/test_messages_proto3.proto |
||||
protoc ${protobuf_source_dir}/src/google/protobuf/test_messages_proto2.proto |
||||
COMMAND protoc ${protobuf_source_dir}/src/google/protobuf/test_messages_proto3.proto |
||||
${protobuf_source_dir}/src/google/protobuf/test_messages_proto2.proto |
||||
--proto_path=${protobuf_source_dir}/src |
||||
--cpp_out=${protobuf_source_dir}/src |
||||
) |
||||
|
||||
add_executable(conformance_test_runner |
||||
${protobuf_source_dir}/conformance/conformance.pb.cc |
||||
${protobuf_source_dir}/conformance/conformance_test.cc |
||||
${protobuf_source_dir}/conformance/binary_json_conformance_main.cc |
||||
${protobuf_source_dir}/conformance/binary_json_conformance_suite.cc |
||||
${protobuf_source_dir}/conformance/binary_json_conformance_suite.h |
||||
${protobuf_source_dir}/conformance/conformance_test_runner.cc |
||||
${protobuf_source_dir}/conformance/third_party/jsoncpp/json.h |
||||
${protobuf_source_dir}/conformance/third_party/jsoncpp/jsoncpp.cpp |
||||
${protobuf_source_dir}/src/google/protobuf/test_messages_proto3.pb.cc |
||||
${protobuf_source_dir}/src/google/protobuf/test_messages_proto2.pb.cc |
||||
) |
||||
|
||||
add_executable(conformance_cpp |
||||
${protobuf_source_dir}/conformance/conformance.pb.cc |
||||
${protobuf_source_dir}/conformance/conformance_cpp.cc |
||||
${protobuf_source_dir}/src/google/protobuf/test_messages_proto3.pb.cc |
||||
${protobuf_source_dir}/src/google/protobuf/test_messages_proto2.pb.cc |
||||
) |
||||
|
||||
target_include_directories( |
||||
conformance_test_runner |
||||
PUBLIC ${protobuf_source_dir}/conformance) |
||||
|
||||
target_include_directories( |
||||
conformance_cpp |
||||
PUBLIC ${protobuf_source_dir}/conformance) |
||||
|
||||
target_link_libraries(conformance_test_runner libprotobuf) |
||||
target_link_libraries(conformance_cpp libprotobuf) |
@ -0,0 +1,21 @@ |
||||
"""Creates config_setting that allows selecting based on 'compiler' value.""" |
||||
|
||||
def create_compiler_config_setting(name, value): |
||||
# The "do_not_use_tools_cpp_compiler_present" attribute exists to |
||||
# distinguish between older versions of Bazel that do not support |
||||
# "@bazel_tools//tools/cpp:compiler" flag_value, and newer ones that do. |
||||
# In the future, the only way to select on the compiler will be through |
||||
# flag_values{"@bazel_tools//tools/cpp:compiler"} and the else branch can |
||||
# be removed. |
||||
if hasattr(cc_common, "do_not_use_tools_cpp_compiler_present"): |
||||
native.config_setting( |
||||
name = name, |
||||
flag_values = { |
||||
"@bazel_tools//tools/cpp:compiler": value, |
||||
}, |
||||
) |
||||
else: |
||||
native.config_setting( |
||||
name = name, |
||||
values = {"compiler": value}, |
||||
) |
@ -0,0 +1,121 @@ |
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef CONFORMANCE_BINARY_JSON_CONFORMANCE_SUITE_H |
||||
#define CONFORMANCE_BINARY_JSON_CONFORMANCE_SUITE_H |
||||
|
||||
#include "conformance_test.h" |
||||
#include "third_party/jsoncpp/json.h" |
||||
|
||||
namespace google { |
||||
namespace protobuf { |
||||
|
||||
class BinaryAndJsonConformanceSuite : public ConformanceTestSuite { |
||||
public: |
||||
BinaryAndJsonConformanceSuite() {} |
||||
|
||||
private: |
||||
void RunSuiteImpl(); |
||||
void RunValidJsonTest(const string& test_name, |
||||
ConformanceLevel level, |
||||
const string& input_json, |
||||
const string& equivalent_text_format); |
||||
void RunValidJsonTestWithProtobufInput( |
||||
const string& test_name, |
||||
ConformanceLevel level, |
||||
const protobuf_test_messages::proto3::TestAllTypesProto3& input, |
||||
const string& equivalent_text_format); |
||||
void RunValidJsonIgnoreUnknownTest( |
||||
const string& test_name, ConformanceLevel level, const string& input_json, |
||||
const string& equivalent_text_format); |
||||
void RunValidProtobufTest(const string& test_name, ConformanceLevel level, |
||||
const string& input_protobuf, |
||||
const string& equivalent_text_format, |
||||
bool is_proto3); |
||||
void RunValidBinaryProtobufTest(const string& test_name, |
||||
ConformanceLevel level, |
||||
const string& input_protobuf, |
||||
bool is_proto3); |
||||
void RunValidProtobufTestWithMessage( |
||||
const string& test_name, ConformanceLevel level, |
||||
const Message *input, |
||||
const string& equivalent_text_format, |
||||
bool is_proto3); |
||||
|
||||
bool ParseJsonResponse( |
||||
const conformance::ConformanceResponse& response, |
||||
Message* test_message); |
||||
bool ParseResponse( |
||||
const conformance::ConformanceResponse& response, |
||||
const ConformanceRequestSetting& setting, |
||||
Message* test_message) override; |
||||
|
||||
typedef std::function<bool(const Json::Value&)> Validator; |
||||
void RunValidJsonTestWithValidator(const string& test_name, |
||||
ConformanceLevel level, |
||||
const string& input_json, |
||||
const Validator& validator); |
||||
void ExpectParseFailureForJson(const string& test_name, |
||||
ConformanceLevel level, |
||||
const string& input_json); |
||||
void ExpectSerializeFailureForJson(const string& test_name, |
||||
ConformanceLevel level, |
||||
const string& text_format); |
||||
void ExpectParseFailureForProtoWithProtoVersion (const string& proto, |
||||
const string& test_name, |
||||
ConformanceLevel level, |
||||
bool is_proto3); |
||||
void ExpectParseFailureForProto(const std::string& proto, |
||||
const std::string& test_name, |
||||
ConformanceLevel level); |
||||
void ExpectHardParseFailureForProto(const std::string& proto, |
||||
const std::string& test_name, |
||||
ConformanceLevel level); |
||||
void TestPrematureEOFForType(google::protobuf::FieldDescriptor::Type type); |
||||
void TestIllegalTags(); |
||||
template <class MessageType> |
||||
void TestOneofMessage (MessageType &message, |
||||
bool is_proto3); |
||||
template <class MessageType> |
||||
void TestUnknownMessage (MessageType &message, |
||||
bool is_proto3); |
||||
void TestValidDataForType( |
||||
google::protobuf::FieldDescriptor::Type, |
||||
std::vector<std::pair<std::string, std::string>> values); |
||||
|
||||
std::unique_ptr<google::protobuf::util::TypeResolver> |
||||
type_resolver_; |
||||
std::string type_url_; |
||||
}; |
||||
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#endif // CONFORMANCE_BINARY_JSON_CONFORMANCE_SUITE_H
|
@ -0,0 +1,40 @@ |
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "binary_json_conformance_suite.h" |
||||
#include "conformance_test.h" |
||||
#include "text_format_conformance_suite.h" |
||||
|
||||
int main(int argc, char *argv[]) { |
||||
google::protobuf::BinaryAndJsonConformanceSuite binary_and_json_suite; |
||||
google::protobuf::TextFormatConformanceTestSuite text_format_suite; |
||||
return google::protobuf::ForkPipeRunner::Run( |
||||
argc, argv, {&binary_and_json_suite, &text_format_suite}); |
||||
} |
@ -0,0 +1,66 @@ |
||||
Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput |
||||
Recommended.FieldMaskPathsDontRoundTrip.JsonOutput |
||||
Recommended.FieldMaskTooManyUnderscore.JsonOutput |
||||
Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput |
||||
Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput |
||||
Recommended.Proto3.JsonInput.DurationHas3FractionalDigits.Validator |
||||
Recommended.Proto3.JsonInput.DurationHas6FractionalDigits.Validator |
||||
Recommended.Proto3.JsonInput.MapFieldValueIsNull |
||||
Recommended.Proto3.JsonInput.RepeatedFieldMessageElementIsNull |
||||
Recommended.Proto3.JsonInput.RepeatedFieldPrimitiveElementIsNull |
||||
Recommended.Proto3.JsonInput.StringEndsWithEscapeChar |
||||
Recommended.Proto3.JsonInput.StringFieldSurrogateInWrongOrder |
||||
Recommended.Proto3.JsonInput.StringFieldUnpairedHighSurrogate |
||||
Recommended.Proto3.JsonInput.StringFieldUnpairedLowSurrogate |
||||
Recommended.Proto3.JsonInput.TimestampHas3FractionalDigits.Validator |
||||
Recommended.Proto3.JsonInput.TimestampHas6FractionalDigits.Validator |
||||
Required.DurationProtoInputTooLarge.JsonOutput |
||||
Required.DurationProtoInputTooSmall.JsonOutput |
||||
Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput |
||||
Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput |
||||
Required.Proto3.JsonInput.DoubleFieldMinPositiveValue.JsonOutput |
||||
Required.Proto3.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput |
||||
Required.Proto3.JsonInput.DoubleFieldNan.JsonOutput |
||||
Required.Proto3.JsonInput.DurationMinValue.JsonOutput |
||||
Required.Proto3.JsonInput.DurationRepeatedValue.JsonOutput |
||||
Required.Proto3.JsonInput.FloatFieldInfinity.JsonOutput |
||||
Required.Proto3.JsonInput.FloatFieldNan.JsonOutput |
||||
Required.Proto3.JsonInput.FloatFieldNegativeInfinity.JsonOutput |
||||
Required.Proto3.JsonInput.OneofFieldDuplicate |
||||
Required.Proto3.JsonInput.OptionalBoolWrapper.JsonOutput |
||||
Required.Proto3.JsonInput.OptionalBytesWrapper.JsonOutput |
||||
Required.Proto3.JsonInput.OptionalDoubleWrapper.JsonOutput |
||||
Required.Proto3.JsonInput.OptionalFloatWrapper.JsonOutput |
||||
Required.Proto3.JsonInput.OptionalInt32Wrapper.JsonOutput |
||||
Required.Proto3.JsonInput.OptionalInt64Wrapper.JsonOutput |
||||
Required.Proto3.JsonInput.OptionalStringWrapper.JsonOutput |
||||
Required.Proto3.JsonInput.OptionalUint32Wrapper.JsonOutput |
||||
Required.Proto3.JsonInput.OptionalUint64Wrapper.JsonOutput |
||||
Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput |
||||
Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput |
||||
Required.Proto3.JsonInput.RepeatedBoolWrapper.JsonOutput |
||||
Required.Proto3.JsonInput.RepeatedBytesWrapper.JsonOutput |
||||
Required.Proto3.JsonInput.RepeatedDoubleWrapper.JsonOutput |
||||
Required.Proto3.JsonInput.RepeatedFloatWrapper.JsonOutput |
||||
Required.Proto3.JsonInput.RepeatedInt32Wrapper.JsonOutput |
||||
Required.Proto3.JsonInput.RepeatedInt64Wrapper.JsonOutput |
||||
Required.Proto3.JsonInput.RepeatedStringWrapper.JsonOutput |
||||
Required.Proto3.JsonInput.RepeatedUint32Wrapper.JsonOutput |
||||
Required.Proto3.JsonInput.RepeatedUint64Wrapper.JsonOutput |
||||
Required.Proto3.JsonInput.StringFieldSurrogatePair.JsonOutput |
||||
Required.Proto3.JsonInput.StringFieldSurrogatePair.ProtobufOutput |
||||
Required.Proto3.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput |
||||
Required.Proto3.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput |
||||
Required.Proto3.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput |
||||
Required.Proto3.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput |
||||
Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput |
||||
Required.TimestampProtoInputTooLarge.JsonOutput |
||||
Required.TimestampProtoInputTooSmall.JsonOutput |
||||
Required.Proto3.JsonInput.IgnoreUnknownJsonFalse.ProtobufOutput |
||||
Required.Proto3.JsonInput.IgnoreUnknownJsonNull.ProtobufOutput |
||||
Required.Proto3.JsonInput.IgnoreUnknownJsonNumber.ProtobufOutput |
||||
Required.Proto3.JsonInput.IgnoreUnknownJsonObject.ProtobufOutput |
||||
Required.Proto3.JsonInput.IgnoreUnknownJsonString.ProtobufOutput |
||||
Required.Proto3.JsonInput.IgnoreUnknownJsonTrue.ProtobufOutput |
||||
Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter |
||||
Required.Proto3.JsonInput.RejectTopLevelNull |
@ -0,0 +1,317 @@ |
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "text_format_conformance_suite.h" |
||||
|
||||
#include "conformance_test.h" |
||||
|
||||
#include <google/protobuf/any.pb.h> |
||||
#include <google/protobuf/test_messages_proto2.pb.h> |
||||
#include <google/protobuf/test_messages_proto3.pb.h> |
||||
#include <google/protobuf/text_format.h> |
||||
|
||||
using conformance::ConformanceRequest; |
||||
using conformance::ConformanceResponse; |
||||
using conformance::WireFormat; |
||||
using google::protobuf::Message; |
||||
using google::protobuf::TextFormat; |
||||
using protobuf_test_messages::proto2::TestAllTypesProto2; |
||||
using protobuf_test_messages::proto2::UnknownToTestAllTypes; |
||||
using protobuf_test_messages::proto3::TestAllTypesProto3; |
||||
using std::string; |
||||
|
||||
namespace google { |
||||
namespace protobuf { |
||||
|
||||
TextFormatConformanceTestSuite::TextFormatConformanceTestSuite() { |
||||
SetFailureListFlagName("--text_format_failure_list"); |
||||
} |
||||
|
||||
bool TextFormatConformanceTestSuite::ParseTextFormatResponse( |
||||
const ConformanceResponse& response, |
||||
const ConformanceRequestSetting& setting, Message* test_message) { |
||||
TextFormat::Parser parser; |
||||
const ConformanceRequest& request = setting.GetRequest(); |
||||
if (request.print_unknown_fields()) { |
||||
parser.AllowFieldNumber(true); |
||||
} |
||||
if (!parser.ParseFromString(response.text_payload(), test_message)) { |
||||
GOOGLE_LOG(ERROR) << "INTERNAL ERROR: internal text->protobuf transcode " |
||||
<< "yielded unparseable proto. Text payload: " |
||||
<< response.text_payload(); |
||||
return false; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
bool TextFormatConformanceTestSuite::ParseResponse( |
||||
const ConformanceResponse& response, |
||||
const ConformanceRequestSetting& setting, Message* test_message) { |
||||
const ConformanceRequest& request = setting.GetRequest(); |
||||
WireFormat requested_output = request.requested_output_format(); |
||||
const string& test_name = setting.GetTestName(); |
||||
ConformanceLevel level = setting.GetLevel(); |
||||
|
||||
switch (response.result_case()) { |
||||
case ConformanceResponse::kProtobufPayload: { |
||||
if (requested_output != conformance::PROTOBUF) { |
||||
ReportFailure( |
||||
test_name, level, request, response, |
||||
StrCat("Test was asked for ", WireFormatToString(requested_output), |
||||
" output but provided PROTOBUF instead.") |
||||
.c_str()); |
||||
return false; |
||||
} |
||||
|
||||
if (!test_message->ParseFromString(response.protobuf_payload())) { |
||||
ReportFailure(test_name, level, request, response, |
||||
"Protobuf output we received from test was unparseable."); |
||||
return false; |
||||
} |
||||
|
||||
break; |
||||
} |
||||
|
||||
case ConformanceResponse::kTextPayload: { |
||||
if (requested_output != conformance::TEXT_FORMAT) { |
||||
ReportFailure( |
||||
test_name, level, request, response, |
||||
StrCat("Test was asked for ", WireFormatToString(requested_output), |
||||
" output but provided TEXT_FORMAT instead.") |
||||
.c_str()); |
||||
return false; |
||||
} |
||||
|
||||
if (!ParseTextFormatResponse(response, setting, test_message)) { |
||||
ReportFailure( |
||||
test_name, level, request, response, |
||||
"TEXT_FORMAT output we received from test was unparseable."); |
||||
return false; |
||||
} |
||||
|
||||
break; |
||||
} |
||||
|
||||
default: |
||||
GOOGLE_LOG(FATAL) << test_name |
||||
<< ": unknown payload type: " << response.result_case(); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
void TextFormatConformanceTestSuite::ExpectParseFailure(const string& test_name, |
||||
ConformanceLevel level, |
||||
const string& input) { |
||||
TestAllTypesProto3 prototype; |
||||
// We don't expect output, but if the program erroneously accepts the protobuf
|
||||
// we let it send its response as this. We must not leave it unspecified.
|
||||
ConformanceRequestSetting setting( |
||||
level, conformance::TEXT_FORMAT, conformance::TEXT_FORMAT, |
||||
conformance::TEXT_FORMAT_TEST, prototype, test_name, input); |
||||
const ConformanceRequest& request = setting.GetRequest(); |
||||
ConformanceResponse response; |
||||
string effective_test_name = StrCat(setting.ConformanceLevelToString(level), |
||||
".Proto3.TextFormatInput.", test_name); |
||||
|
||||
RunTest(effective_test_name, request, &response); |
||||
if (response.result_case() == ConformanceResponse::kParseError) { |
||||
ReportSuccess(effective_test_name); |
||||
} else if (response.result_case() == ConformanceResponse::kSkipped) { |
||||
ReportSkip(effective_test_name, request, response); |
||||
} else { |
||||
ReportFailure(effective_test_name, level, request, response, |
||||
"Should have failed to parse, but didn't."); |
||||
} |
||||
} |
||||
|
||||
void TextFormatConformanceTestSuite::RunValidTextFormatTest( |
||||
const string& test_name, ConformanceLevel level, const string& input_text) { |
||||
TestAllTypesProto3 prototype; |
||||
RunValidTextFormatTestWithMessage(test_name, level, input_text, prototype); |
||||
} |
||||
|
||||
void TextFormatConformanceTestSuite::RunValidTextFormatTestProto2( |
||||
const string& test_name, ConformanceLevel level, const string& input_text) { |
||||
TestAllTypesProto2 prototype; |
||||
RunValidTextFormatTestWithMessage(test_name, level, input_text, prototype); |
||||
} |
||||
|
||||
void TextFormatConformanceTestSuite::RunValidTextFormatTestWithMessage( |
||||
const string& test_name, ConformanceLevel level, const string& input_text, |
||||
const Message& prototype) { |
||||
ConformanceRequestSetting setting1( |
||||
level, conformance::TEXT_FORMAT, conformance::PROTOBUF, |
||||
conformance::TEXT_FORMAT_TEST, prototype, test_name, input_text); |
||||
RunValidInputTest(setting1, input_text); |
||||
ConformanceRequestSetting setting2( |
||||
level, conformance::TEXT_FORMAT, conformance::TEXT_FORMAT, |
||||
conformance::TEXT_FORMAT_TEST, prototype, test_name, input_text); |
||||
RunValidInputTest(setting2, input_text); |
||||
} |
||||
|
||||
void TextFormatConformanceTestSuite::RunValidUnknownTextFormatTest( |
||||
const string& test_name, const Message& message) { |
||||
string serialized_input; |
||||
message.SerializeToString(&serialized_input); |
||||
TestAllTypesProto3 prototype; |
||||
ConformanceRequestSetting setting1( |
||||
RECOMMENDED, conformance::PROTOBUF, conformance::TEXT_FORMAT, |
||||
conformance::TEXT_FORMAT_TEST, prototype, test_name + "_Drop", |
||||
serialized_input); |
||||
setting1.SetPrototypeMessageForCompare(message); |
||||
RunValidBinaryInputTest(setting1, ""); |
||||
|
||||
ConformanceRequestSetting setting2( |
||||
RECOMMENDED, conformance::PROTOBUF, conformance::TEXT_FORMAT, |
||||
conformance::TEXT_FORMAT_TEST, prototype, test_name + "_Print", |
||||
serialized_input); |
||||
setting2.SetPrototypeMessageForCompare(message); |
||||
setting2.SetPrintUnknownFields(true); |
||||
RunValidBinaryInputTest(setting2, serialized_input); |
||||
} |
||||
|
||||
void TextFormatConformanceTestSuite::RunSuiteImpl() { |
||||
RunValidTextFormatTest("HelloWorld", REQUIRED, |
||||
"optional_string: 'Hello, World!'"); |
||||
// Integer fields.
|
||||
RunValidTextFormatTest("Int32FieldMaxValue", REQUIRED, |
||||
"optional_int32: 2147483647"); |
||||
RunValidTextFormatTest("Int32FieldMinValue", REQUIRED, |
||||
"optional_int32: -2147483648"); |
||||
RunValidTextFormatTest("Uint32FieldMaxValue", REQUIRED, |
||||
"optional_uint32: 4294967295"); |
||||
RunValidTextFormatTest("Int64FieldMaxValue", REQUIRED, |
||||
"optional_int64: 9223372036854775807"); |
||||
RunValidTextFormatTest("Int64FieldMinValue", REQUIRED, |
||||
"optional_int64: -9223372036854775808"); |
||||
RunValidTextFormatTest("Uint64FieldMaxValue", REQUIRED, |
||||
"optional_uint64: 18446744073709551615"); |
||||
|
||||
// Parsers reject out-of-bound integer values.
|
||||
ExpectParseFailure("Int32FieldTooLarge", REQUIRED, |
||||
"optional_int32: 2147483648"); |
||||
ExpectParseFailure("Int32FieldTooSmall", REQUIRED, |
||||
"optional_int32: -2147483649"); |
||||
ExpectParseFailure("Uint32FieldTooLarge", REQUIRED, |
||||
"optional_uint32: 4294967296"); |
||||
ExpectParseFailure("Int64FieldTooLarge", REQUIRED, |
||||
"optional_int64: 9223372036854775808"); |
||||
ExpectParseFailure("Int64FieldTooSmall", REQUIRED, |
||||
"optional_int64: -9223372036854775809"); |
||||
ExpectParseFailure("Uint64FieldTooLarge", REQUIRED, |
||||
"optional_uint64: 18446744073709551616"); |
||||
|
||||
// Floating point fields
|
||||
RunValidTextFormatTest("FloatField", REQUIRED, |
||||
"optional_float: 3.192837"); |
||||
RunValidTextFormatTest("FloatFieldWithVeryPreciseNumber", REQUIRED, |
||||
"optional_float: 3.123456789123456789"); |
||||
RunValidTextFormatTest("FloatFieldMaxValue", REQUIRED, |
||||
"optional_float: 3.4028235e+38"); |
||||
RunValidTextFormatTest("FloatFieldMinValue", REQUIRED, |
||||
"optional_float: 1.17549e-38"); |
||||
RunValidTextFormatTest("FloatFieldNaNValue", REQUIRED, |
||||
"optional_float: NaN"); |
||||
RunValidTextFormatTest("FloatFieldPosInfValue", REQUIRED, |
||||
"optional_float: inf"); |
||||
RunValidTextFormatTest("FloatFieldNegInfValue", REQUIRED, |
||||
"optional_float: -inf"); |
||||
RunValidTextFormatTest("FloatFieldWithInt32Max", REQUIRED, |
||||
"optional_float: 4294967296"); |
||||
RunValidTextFormatTest("FloatFieldLargerThanInt64", REQUIRED, |
||||
"optional_float: 9223372036854775808"); |
||||
RunValidTextFormatTest("FloatFieldTooLarge", REQUIRED, |
||||
"optional_float: 3.4028235e+39"); |
||||
RunValidTextFormatTest("FloatFieldTooSmall", REQUIRED, |
||||
"optional_float: 1.17549e-39"); |
||||
RunValidTextFormatTest("FloatFieldLargerThanUint64", REQUIRED, |
||||
"optional_float: 18446744073709551616"); |
||||
|
||||
// Group fields
|
||||
RunValidTextFormatTestProto2("GroupFieldNoColon", REQUIRED, |
||||
"Data { group_int32: 1 }"); |
||||
RunValidTextFormatTestProto2("GroupFieldWithColon", REQUIRED, |
||||
"Data: { group_int32: 1 }"); |
||||
RunValidTextFormatTestProto2("GroupFieldEmpty", REQUIRED, |
||||
"Data {}"); |
||||
|
||||
|
||||
// Unknown Fields
|
||||
UnknownToTestAllTypes message; |
||||
// Unable to print unknown Fixed32/Fixed64 fields as if they are known.
|
||||
// Fixed32/Fixed64 fields are not added in the tests.
|
||||
message.set_optional_int32(123); |
||||
message.set_optional_string("hello"); |
||||
message.set_optional_bool(true); |
||||
RunValidUnknownTextFormatTest("ScalarUnknownFields", message); |
||||
|
||||
message.Clear(); |
||||
message.mutable_nested_message()->set_c(111); |
||||
RunValidUnknownTextFormatTest("MessageUnknownFields", message); |
||||
|
||||
message.Clear(); |
||||
message.mutable_optionalgroup()->set_a(321); |
||||
RunValidUnknownTextFormatTest("GroupUnknownFields", message); |
||||
|
||||
message.add_repeated_int32(1); |
||||
message.add_repeated_int32(2); |
||||
message.add_repeated_int32(3); |
||||
RunValidUnknownTextFormatTest("RepeatedUnknownFields", message); |
||||
|
||||
// Any fields
|
||||
RunValidTextFormatTest("AnyField", REQUIRED, |
||||
R"( |
||||
optional_any: { |
||||
[type.googleapis.com/protobuf_test_messages.proto3.TestAllTypesProto3] { |
||||
optional_int32: 12345 |
||||
} |
||||
} |
||||
)"); |
||||
RunValidTextFormatTest("AnyFieldWithRawBytes", REQUIRED, |
||||
R"( |
||||
optional_any: { |
||||
type_url: "type.googleapis.com/protobuf_test_messages.proto3.TestAllTypesProto3" |
||||
value: "\b\271`" |
||||
} |
||||
)"); |
||||
ExpectParseFailure("AnyFieldWithInvalidType", REQUIRED, |
||||
R"( |
||||
optional_any: { |
||||
[type.googleapis.com/unknown] { |
||||
optional_int32: 12345 |
||||
} |
||||
} |
||||
)"); |
||||
} |
||||
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
@ -0,0 +1,8 @@ |
||||
Recommended.Proto3.ProtobufInput.GroupUnknownFields_Drop.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.GroupUnknownFields_Print.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.MessageUnknownFields_Drop.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.MessageUnknownFields_Print.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.RepeatedUnknownFields_Drop.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.RepeatedUnknownFields_Print.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.ScalarUnknownFields_Drop.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.ScalarUnknownFields_Print.TextFormatOutput |
@ -0,0 +1,6 @@ |
||||
Recommended.Proto3.ProtobufInput.GroupUnknownFields_Drop.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.MessageUnknownFields_Drop.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.RepeatedUnknownFields_Drop.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.ScalarUnknownFields_Drop.TextFormatOutput |
||||
Required.Proto3.TextFormatInput.AnyField.ProtobufOutput |
||||
Required.Proto3.TextFormatInput.AnyField.TextFormatOutput |
@ -0,0 +1,8 @@ |
||||
Recommended.Proto3.ProtobufInput.GroupUnknownFields_Drop.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.GroupUnknownFields_Print.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.MessageUnknownFields_Drop.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.MessageUnknownFields_Print.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.RepeatedUnknownFields_Drop.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.RepeatedUnknownFields_Print.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.ScalarUnknownFields_Drop.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.ScalarUnknownFields_Print.TextFormatOutput |
@ -0,0 +1,5 @@ |
||||
# This is the list of text format conformance tests that are known to fail right |
||||
# now. |
||||
# TODO: These should be fixed. |
||||
Required.Proto3.TextFormatInput.FloatFieldMaxValue.ProtobufOutput |
||||
Required.Proto3.TextFormatInput.FloatFieldMaxValue.TextFormatOutput |
@ -0,0 +1,8 @@ |
||||
Recommended.Proto3.ProtobufInput.GroupUnknownFields_Drop.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.GroupUnknownFields_Print.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.MessageUnknownFields_Drop.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.MessageUnknownFields_Print.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.RepeatedUnknownFields_Drop.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.RepeatedUnknownFields_Print.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.ScalarUnknownFields_Drop.TextFormatOutput |
||||
Recommended.Proto3.ProtobufInput.ScalarUnknownFields_Print.TextFormatOutput |
@ -0,0 +1,13 @@ |
||||
@rem Builds Google.Protobuf and runs the tests |
||||
|
||||
dotnet build src/Google.Protobuf.sln || goto :error |
||||
|
||||
echo Running tests. |
||||
|
||||
dotnet test src/Google.Protobuf.Test/Google.Protobuf.Test.csproj || goto :error |
||||
|
||||
goto :EOF |
||||
|
||||
:error |
||||
echo Failed! |
||||
exit /b %errorlevel% |
@ -0,0 +1,21 @@ |
||||
#!/usr/bin/env powershell |
||||
# Install dotnet SDK based on the SDK version from global.json |
||||
|
||||
Set-StrictMode -Version 2 |
||||
$ErrorActionPreference = 'Stop' |
||||
|
||||
# avoid "Unknown error on a send" in Invoke-WebRequest |
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 |
||||
|
||||
$InstallScriptUrl = 'https://dot.net/v1/dotnet-install.ps1' |
||||
$InstallScriptPath = Join-Path "$env:TEMP" 'dotnet-install.ps1' |
||||
$GlobalJsonPath = Join-Path $PSScriptRoot '..' | Join-Path -ChildPath 'global.json' |
||||
|
||||
# Resolve SDK version from global.json file |
||||
$GlobalJson = Get-Content -Raw $GlobalJsonPath | ConvertFrom-Json |
||||
$SDKVersion = $GlobalJson.sdk.version |
||||
|
||||
# Download install script |
||||
Write-Host "Downloading install script: $InstallScriptUrl => $InstallScriptPath" |
||||
Invoke-WebRequest -Uri $InstallScriptUrl -OutFile $InstallScriptPath |
||||
&$InstallScriptPath -Version $SDKVersion |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,250 @@ |
||||
// <auto-generated> |
||||
// Generated by the protocol buffer compiler. DO NOT EDIT! |
||||
// source: benchmarks.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 Benchmarks { |
||||
|
||||
/// <summary>Holder for reflection information generated from benchmarks.proto</summary> |
||||
public static partial class BenchmarksReflection { |
||||
|
||||
#region Descriptor |
||||
/// <summary>File descriptor for benchmarks.proto</summary> |
||||
public static pbr::FileDescriptor Descriptor { |
||||
get { return descriptor; } |
||||
} |
||||
private static pbr::FileDescriptor descriptor; |
||||
|
||||
static BenchmarksReflection() { |
||||
byte[] descriptorData = global::System.Convert.FromBase64String( |
||||
string.Concat( |
||||
"ChBiZW5jaG1hcmtzLnByb3RvEgpiZW5jaG1hcmtzIkcKEEJlbmNobWFya0Rh", |
||||
"dGFzZXQSDAoEbmFtZRgBIAEoCRIUCgxtZXNzYWdlX25hbWUYAiABKAkSDwoH", |
||||
"cGF5bG9hZBgDIAMoDEIgCh5jb20uZ29vZ2xlLnByb3RvYnVmLmJlbmNobWFy", |
||||
"a3NiBnByb3RvMw==")); |
||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, |
||||
new pbr::FileDescriptor[] { }, |
||||
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { |
||||
new pbr::GeneratedClrTypeInfo(typeof(global::Benchmarks.BenchmarkDataset), global::Benchmarks.BenchmarkDataset.Parser, new[]{ "Name", "MessageName", "Payload" }, null, null, null, null) |
||||
})); |
||||
} |
||||
#endregion |
||||
|
||||
} |
||||
#region Messages |
||||
public sealed partial class BenchmarkDataset : pb::IMessage<BenchmarkDataset> { |
||||
private static readonly pb::MessageParser<BenchmarkDataset> _parser = new pb::MessageParser<BenchmarkDataset>(() => new BenchmarkDataset()); |
||||
private pb::UnknownFieldSet _unknownFields; |
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] |
||||
public static pb::MessageParser<BenchmarkDataset> Parser { get { return _parser; } } |
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] |
||||
public static pbr::MessageDescriptor Descriptor { |
||||
get { return global::Benchmarks.BenchmarksReflection.Descriptor.MessageTypes[0]; } |
||||
} |
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] |
||||
pbr::MessageDescriptor pb::IMessage.Descriptor { |
||||
get { return Descriptor; } |
||||
} |
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] |
||||
public BenchmarkDataset() { |
||||
OnConstruction(); |
||||
} |
||||
|
||||
partial void OnConstruction(); |
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] |
||||
public BenchmarkDataset(BenchmarkDataset other) : this() { |
||||
name_ = other.name_; |
||||
messageName_ = other.messageName_; |
||||
payload_ = other.payload_.Clone(); |
||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); |
||||
} |
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] |
||||
public BenchmarkDataset Clone() { |
||||
return new BenchmarkDataset(this); |
||||
} |
||||
|
||||
/// <summary>Field number for the "name" field.</summary> |
||||
public const int NameFieldNumber = 1; |
||||
private string name_ = ""; |
||||
/// <summary> |
||||
/// Name of the benchmark dataset. This should be unique across all datasets. |
||||
/// Should only contain word characters: [a-zA-Z0-9_] |
||||
/// </summary> |
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] |
||||
public string Name { |
||||
get { return name_; } |
||||
set { |
||||
name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); |
||||
} |
||||
} |
||||
|
||||
/// <summary>Field number for the "message_name" field.</summary> |
||||
public const int MessageNameFieldNumber = 2; |
||||
private string messageName_ = ""; |
||||
/// <summary> |
||||
/// Fully-qualified name of the protobuf message for this dataset. |
||||
/// It will be one of the messages defined benchmark_messages_proto2.proto |
||||
/// or benchmark_messages_proto3.proto. |
||||
/// |
||||
/// Implementations that do not support reflection can implement this with |
||||
/// an explicit "if/else" chain that lists every known message defined |
||||
/// in those files. |
||||
/// </summary> |
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] |
||||
public string MessageName { |
||||
get { return messageName_; } |
||||
set { |
||||
messageName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); |
||||
} |
||||
} |
||||
|
||||
/// <summary>Field number for the "payload" field.</summary> |
||||
public const int PayloadFieldNumber = 3; |
||||
private static readonly pb::FieldCodec<pb::ByteString> _repeated_payload_codec |
||||
= pb::FieldCodec.ForBytes(26); |
||||
private readonly pbc::RepeatedField<pb::ByteString> payload_ = new pbc::RepeatedField<pb::ByteString>(); |
||||
/// <summary> |
||||
/// The payload(s) for this dataset. They should be parsed or serialized |
||||
/// in sequence, in a loop, ie. |
||||
/// |
||||
/// while (!benchmarkDone) { // Benchmark runner decides when to exit. |
||||
/// for (i = 0; i < benchmark.payload.length; i++) { |
||||
/// parse(benchmark.payload[i]) |
||||
/// } |
||||
/// } |
||||
/// |
||||
/// This is intended to let datasets include a variety of data to provide |
||||
/// potentially more realistic results than just parsing the same message |
||||
/// over and over. A single message parsed repeatedly could yield unusually |
||||
/// good branch prediction performance. |
||||
/// </summary> |
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] |
||||
public pbc::RepeatedField<pb::ByteString> Payload { |
||||
get { return payload_; } |
||||
} |
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] |
||||
public override bool Equals(object other) { |
||||
return Equals(other as BenchmarkDataset); |
||||
} |
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] |
||||
public bool Equals(BenchmarkDataset other) { |
||||
if (ReferenceEquals(other, null)) { |
||||
return false; |
||||
} |
||||
if (ReferenceEquals(other, this)) { |
||||
return true; |
||||
} |
||||
if (Name != other.Name) return false; |
||||
if (MessageName != other.MessageName) return false; |
||||
if(!payload_.Equals(other.payload_)) return false; |
||||
return Equals(_unknownFields, other._unknownFields); |
||||
} |
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] |
||||
public override int GetHashCode() { |
||||
int hash = 1; |
||||
if (Name.Length != 0) hash ^= Name.GetHashCode(); |
||||
if (MessageName.Length != 0) hash ^= MessageName.GetHashCode(); |
||||
hash ^= payload_.GetHashCode(); |
||||
if (_unknownFields != null) { |
||||
hash ^= _unknownFields.GetHashCode(); |
||||
} |
||||
return hash; |
||||
} |
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] |
||||
public override string ToString() { |
||||
return pb::JsonFormatter.ToDiagnosticString(this); |
||||
} |
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] |
||||
public void WriteTo(pb::CodedOutputStream output) { |
||||
if (Name.Length != 0) { |
||||
output.WriteRawTag(10); |
||||
output.WriteString(Name); |
||||
} |
||||
if (MessageName.Length != 0) { |
||||
output.WriteRawTag(18); |
||||
output.WriteString(MessageName); |
||||
} |
||||
payload_.WriteTo(output, _repeated_payload_codec); |
||||
if (_unknownFields != null) { |
||||
_unknownFields.WriteTo(output); |
||||
} |
||||
} |
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] |
||||
public int CalculateSize() { |
||||
int size = 0; |
||||
if (Name.Length != 0) { |
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); |
||||
} |
||||
if (MessageName.Length != 0) { |
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(MessageName); |
||||
} |
||||
size += payload_.CalculateSize(_repeated_payload_codec); |
||||
if (_unknownFields != null) { |
||||
size += _unknownFields.CalculateSize(); |
||||
} |
||||
return size; |
||||
} |
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] |
||||
public void MergeFrom(BenchmarkDataset other) { |
||||
if (other == null) { |
||||
return; |
||||
} |
||||
if (other.Name.Length != 0) { |
||||
Name = other.Name; |
||||
} |
||||
if (other.MessageName.Length != 0) { |
||||
MessageName = other.MessageName; |
||||
} |
||||
payload_.Add(other.payload_); |
||||
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); |
||||
} |
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] |
||||
public void MergeFrom(pb::CodedInputStream input) { |
||||
uint tag; |
||||
while ((tag = input.ReadTag()) != 0) { |
||||
switch(tag) { |
||||
default: |
||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); |
||||
break; |
||||
case 10: { |
||||
Name = input.ReadString(); |
||||
break; |
||||
} |
||||
case 18: { |
||||
MessageName = input.ReadString(); |
||||
break; |
||||
} |
||||
case 26: { |
||||
payload_.AddEntriesFrom(input, _repeated_payload_codec); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
#endregion |
||||
|
||||
} |
||||
|
||||
#endregion Designer generated code |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue