diff --git a/src/google/protobuf/compiler/csharp/BUILD.bazel b/src/google/protobuf/compiler/csharp/BUILD.bazel index 96b8dcbc0e..414dd0ffd6 100644 --- a/src/google/protobuf/compiler/csharp/BUILD.bazel +++ b/src/google/protobuf/compiler/csharp/BUILD.bazel @@ -8,8 +8,8 @@ load("//build_defs:cpp_opts.bzl", "COPTS") cc_library( name = "names", - hdrs = ["names.h"], srcs = ["names.cc"], + hdrs = ["names.h"], copts = COPTS, include_prefix = "google/protobuf/compiler/csharp", visibility = ["//visibility:public"], @@ -71,6 +71,7 @@ cc_library( ":names", "//src/google/protobuf:protobuf_nowkt", "//src/google/protobuf/compiler:code_generator", + "//src/google/protobuf/compiler:retention", "@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/strings", ], @@ -125,9 +126,12 @@ pkg_files( filegroup( name = "test_srcs", - srcs = glob([ - "*_test.cc", - "*unittest.cc", - ], allow_empty = True), + srcs = glob( + [ + "*_test.cc", + "*unittest.cc", + ], + allow_empty = True, + ), visibility = ["//src/google/protobuf/compiler:__pkg__"], ) diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index a08c1be084..2db328bc77 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -56,6 +56,7 @@ #include "google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h" #include "google/protobuf/compiler/csharp/csharp_wrapper_field.h" #include "google/protobuf/compiler/csharp/names.h" +#include "google/protobuf/compiler/retention.h" #include "google/protobuf/descriptor.pb.h" // Must be last. @@ -380,8 +381,7 @@ std::string StringToBase64(absl::string_view input) { std::string FileDescriptorToBase64(const FileDescriptor* descriptor) { std::string fdp_bytes; - FileDescriptorProto fdp; - descriptor->CopyTo(&fdp); + FileDescriptorProto fdp = StripSourceRetentionOptions(*descriptor); fdp.SerializeToString(&fdp_bytes); return StringToBase64(fdp_bytes); } diff --git a/src/google/protobuf/unittest_retention.proto b/src/google/protobuf/unittest_retention.proto index e157bc452e..643cc35982 100644 --- a/src/google/protobuf/unittest_retention.proto +++ b/src/google/protobuf/unittest_retention.proto @@ -34,6 +34,7 @@ package protobuf_unittest; import "google/protobuf/descriptor.proto"; +option csharp_namespace = "ProtobufUnittest"; // Retention attributes set directly on custom options extend google.protobuf.FileOptions {