Internal Code Change

PiperOrigin-RevId: 513928860
pull/12142/head
Mike Kruskal 2 years ago committed by Copybara-Service
parent cb405967c3
commit 63895855d7
  1. 17
      conformance/conformance_test.cc
  2. 15
      src/google/protobuf/compiler/ruby/ruby_generator.cc

@ -162,12 +162,19 @@ ConformanceTestSuite::ConformanceRequestSetting::NewTestMessage() const {
}
string ConformanceTestSuite::ConformanceRequestSetting::GetTestName() const {
string rname = prototype_message_.GetDescriptor()->file()->syntax() ==
FileDescriptor::SYNTAX_PROTO3
? "Proto3"
: "Proto2";
string rname;
switch (prototype_message_.GetDescriptor()->file()->syntax()) {
case FileDescriptor::SYNTAX_PROTO3:
rname = ".Proto3.";
break;
case FileDescriptor::SYNTAX_PROTO2:
rname = ".Proto2.";
break;
default:
break;
}
return absl::StrCat(ConformanceLevelToString(level_), ".", rname, ".",
return absl::StrCat(ConformanceLevelToString(level_), rname,
InputFormatString(input_format_), ".", test_name_, ".",
OutputFormatString(output_format_));
}

@ -79,8 +79,7 @@ std::string GetOutputFilename(absl::string_view proto_file) {
}
std::string LabelForField(const FieldDescriptor* field) {
if (field->has_optional_keyword() &&
field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) {
if (field->has_optional_keyword() && field->containing_oneof() != nullptr) {
return "proto3_optional";
}
switch (field->label()) {
@ -520,11 +519,9 @@ bool GenerateFile(const FileDescriptor* file, io::Printer* printer,
printer->Print("\n");
}
// TODO: Remove this when ruby supports extensions for proto2 syntax.
if (file->syntax() == FileDescriptor::SYNTAX_PROTO2 &&
file->extension_count() > 0) {
ABSL_LOG(WARNING)
<< "Extensions are not yet supported for proto2 .proto files.";
// TODO: Remove this when ruby supports extensions.
if (file->extension_count() > 0) {
ABSL_LOG(WARNING) << "Extensions are not yet supported in Ruby.";
}
bool use_raw_descriptor = file->name() == "google/protobuf/descriptor.proto";
@ -560,9 +557,7 @@ bool Generator::Generate(
const std::string& parameter,
GeneratorContext* generator_context,
std::string* error) const {
if (file->syntax() != FileDescriptor::SYNTAX_PROTO3 &&
file->syntax() != FileDescriptor::SYNTAX_PROTO2) {
if (file->syntax() == FileDescriptor::SYNTAX_UNKNOWN) {
*error = "Invalid or unsupported proto syntax";
return false;
}

Loading…
Cancel
Save