From 5c6c86858876e95230c9a2962dd709bb788a041a Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 25 Oct 2022 16:13:27 +0100 Subject: [PATCH] Rename C# files to indicate generated code (#10801) * Change C# generation script to use .pb.cs extension * Rename generated C# files This was performed by running generate_protos.sh and then removing the old files. Notes: - This does not change the conformance test generated C# code - This does not change the compatibility C# code - There's currently no clean-up operation in generate_protos.sh to remove old .pb.cs files (which would now be feasible) - The changes to TestMessagesProto2.pb.cs are just due to formatting and a new Objective-C option * Fix well-known type source files for C# Bazel build --- csharp/.gitignore | 5 +++++ csharp/BUILD.bazel | 22 +++++++++---------- csharp/generate_protos.sh | 3 +++ .../{Addressbook.cs => Addressbook.pb.cs} | 0 ...ttestProto3.cs => MapUnittestProto3.pb.cs} | 0 ...agesProto2.cs => TestMessagesProto2.pb.cs} | 0 ...agesProto3.cs => TestMessagesProto3.pb.cs} | 0 .../{Unittest.cs => Unittest.pb.cs} | 0 ...3.cs => UnittestCustomOptionsProto3.pb.cs} | 0 ...UnittestImport.cs => UnittestImport.pb.cs} | 0 ...rtProto3.cs => UnittestImportProto3.pb.cs} | 0 ...rtPublic.cs => UnittestImportPublic.pb.cs} | 0 ...o3.cs => UnittestImportPublicProto3.pb.cs} | 0 ...Issue6936A.cs => UnittestIssue6936A.pb.cs} | 0 ...Issue6936B.cs => UnittestIssue6936B.pb.cs} | 0 ...Issue6936C.cs => UnittestIssue6936C.pb.cs} | 0 ...UnittestIssues.cs => UnittestIssues.pb.cs} | 0 ...UnittestProto3.cs => UnittestProto3.pb.cs} | 0 ...tional.cs => UnittestProto3Optional.pb.cs} | 0 ...s => UnittestSelfreferentialOptions.pb.cs} | 0 ...nTypes.cs => UnittestWellKnownTypes.pb.cs} | 0 .../Compiler/{Plugin.cs => Plugin.pb.cs} | 0 .../{Descriptor.cs => Descriptor.pb.cs} | 0 .../WellKnownTypes/{Any.cs => Any.pb.cs} | 0 .../WellKnownTypes/{Api.cs => Api.pb.cs} | 0 .../{Duration.cs => Duration.pb.cs} | 0 .../WellKnownTypes/{Empty.cs => Empty.pb.cs} | 0 .../{FieldMask.cs => FieldMask.pb.cs} | 0 .../{SourceContext.cs => SourceContext.pb.cs} | 0 .../{Struct.cs => Struct.pb.cs} | 0 .../{Timestamp.cs => Timestamp.pb.cs} | 0 .../WellKnownTypes/{Type.cs => Type.pb.cs} | 0 .../{Wrappers.cs => Wrappers.pb.cs} | 0 33 files changed, 19 insertions(+), 11 deletions(-) rename csharp/src/AddressBook/{Addressbook.cs => Addressbook.pb.cs} (100%) rename csharp/src/Google.Protobuf.Test.TestProtos/{MapUnittestProto3.cs => MapUnittestProto3.pb.cs} (100%) rename csharp/src/Google.Protobuf.Test.TestProtos/{TestMessagesProto2.cs => TestMessagesProto2.pb.cs} (100%) rename csharp/src/Google.Protobuf.Test.TestProtos/{TestMessagesProto3.cs => TestMessagesProto3.pb.cs} (100%) rename csharp/src/Google.Protobuf.Test.TestProtos/{Unittest.cs => Unittest.pb.cs} (100%) rename csharp/src/Google.Protobuf.Test.TestProtos/{UnittestCustomOptionsProto3.cs => UnittestCustomOptionsProto3.pb.cs} (100%) rename csharp/src/Google.Protobuf.Test.TestProtos/{UnittestImport.cs => UnittestImport.pb.cs} (100%) rename csharp/src/Google.Protobuf.Test.TestProtos/{UnittestImportProto3.cs => UnittestImportProto3.pb.cs} (100%) rename csharp/src/Google.Protobuf.Test.TestProtos/{UnittestImportPublic.cs => UnittestImportPublic.pb.cs} (100%) rename csharp/src/Google.Protobuf.Test.TestProtos/{UnittestImportPublicProto3.cs => UnittestImportPublicProto3.pb.cs} (100%) rename csharp/src/Google.Protobuf.Test.TestProtos/{UnittestIssue6936A.cs => UnittestIssue6936A.pb.cs} (100%) rename csharp/src/Google.Protobuf.Test.TestProtos/{UnittestIssue6936B.cs => UnittestIssue6936B.pb.cs} (100%) rename csharp/src/Google.Protobuf.Test.TestProtos/{UnittestIssue6936C.cs => UnittestIssue6936C.pb.cs} (100%) rename csharp/src/Google.Protobuf.Test.TestProtos/{UnittestIssues.cs => UnittestIssues.pb.cs} (100%) rename csharp/src/Google.Protobuf.Test.TestProtos/{UnittestProto3.cs => UnittestProto3.pb.cs} (100%) rename csharp/src/Google.Protobuf.Test.TestProtos/{UnittestProto3Optional.cs => UnittestProto3Optional.pb.cs} (100%) rename csharp/src/Google.Protobuf.Test.TestProtos/{UnittestSelfreferentialOptions.cs => UnittestSelfreferentialOptions.pb.cs} (100%) rename csharp/src/Google.Protobuf.Test.TestProtos/{UnittestWellKnownTypes.cs => UnittestWellKnownTypes.pb.cs} (100%) rename csharp/src/Google.Protobuf/Compiler/{Plugin.cs => Plugin.pb.cs} (100%) rename csharp/src/Google.Protobuf/Reflection/{Descriptor.cs => Descriptor.pb.cs} (100%) rename csharp/src/Google.Protobuf/WellKnownTypes/{Any.cs => Any.pb.cs} (100%) rename csharp/src/Google.Protobuf/WellKnownTypes/{Api.cs => Api.pb.cs} (100%) rename csharp/src/Google.Protobuf/WellKnownTypes/{Duration.cs => Duration.pb.cs} (100%) rename csharp/src/Google.Protobuf/WellKnownTypes/{Empty.cs => Empty.pb.cs} (100%) rename csharp/src/Google.Protobuf/WellKnownTypes/{FieldMask.cs => FieldMask.pb.cs} (100%) rename csharp/src/Google.Protobuf/WellKnownTypes/{SourceContext.cs => SourceContext.pb.cs} (100%) rename csharp/src/Google.Protobuf/WellKnownTypes/{Struct.cs => Struct.pb.cs} (100%) rename csharp/src/Google.Protobuf/WellKnownTypes/{Timestamp.cs => Timestamp.pb.cs} (100%) rename csharp/src/Google.Protobuf/WellKnownTypes/{Type.cs => Type.pb.cs} (100%) rename csharp/src/Google.Protobuf/WellKnownTypes/{Wrappers.cs => Wrappers.pb.cs} (100%) diff --git a/csharp/.gitignore b/csharp/.gitignore index 62c96383ce..56ac1494d6 100644 --- a/csharp/.gitignore +++ b/csharp/.gitignore @@ -33,3 +33,8 @@ lib/protoc.exe # Benchmark output BenchmarkDotNet.Artifacts/ + +# Reinstate generated code for test files +!any_test.pb.* +!map*unittest.pb.* +!unittest*.pb.* diff --git a/csharp/BUILD.bazel b/csharp/BUILD.bazel index 9f9e83a511..23fbe411f9 100644 --- a/csharp/BUILD.bazel +++ b/csharp/BUILD.bazel @@ -45,17 +45,17 @@ filegroup( filegroup( name = "wkt_cs_srcs", srcs = [ - "src/Google.Protobuf/Reflection/Descriptor.cs", - "src/Google.Protobuf/WellKnownTypes/Any.cs", - "src/Google.Protobuf/WellKnownTypes/Api.cs", - "src/Google.Protobuf/WellKnownTypes/Duration.cs", - "src/Google.Protobuf/WellKnownTypes/Empty.cs", - "src/Google.Protobuf/WellKnownTypes/FieldMask.cs", - "src/Google.Protobuf/WellKnownTypes/SourceContext.cs", - "src/Google.Protobuf/WellKnownTypes/Struct.cs", - "src/Google.Protobuf/WellKnownTypes/Timestamp.cs", - "src/Google.Protobuf/WellKnownTypes/Type.cs", - "src/Google.Protobuf/WellKnownTypes/Wrappers.cs", + "src/Google.Protobuf/Reflection/Descriptor.pb.cs", + "src/Google.Protobuf/WellKnownTypes/Any.pb.cs", + "src/Google.Protobuf/WellKnownTypes/Api.pb.cs", + "src/Google.Protobuf/WellKnownTypes/Duration.pb.cs", + "src/Google.Protobuf/WellKnownTypes/Empty.pb.cs", + "src/Google.Protobuf/WellKnownTypes/FieldMask.pb.cs", + "src/Google.Protobuf/WellKnownTypes/SourceContext.pb.cs", + "src/Google.Protobuf/WellKnownTypes/Struct.pb.cs", + "src/Google.Protobuf/WellKnownTypes/Timestamp.pb.cs", + "src/Google.Protobuf/WellKnownTypes/Type.pb.cs", + "src/Google.Protobuf/WellKnownTypes/Wrappers.pb.cs", ], visibility = ["//src/google/protobuf/compiler/csharp:__pkg__"], ) diff --git a/csharp/generate_protos.sh b/csharp/generate_protos.sh index cfd6082708..8be4428405 100755 --- a/csharp/generate_protos.sh +++ b/csharp/generate_protos.sh @@ -32,6 +32,7 @@ fi # descriptor.proto and well-known types $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \ --csharp_opt=base_namespace=Google.Protobuf \ + --csharp_opt=file_extension=.pb.cs \ src/google/protobuf/descriptor.proto \ src/google/protobuf/any.proto \ src/google/protobuf/api.proto \ @@ -52,6 +53,7 @@ $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \ $PROTOC -Isrc -Icsharp/protos \ --experimental_allow_proto3_optional \ --csharp_out=csharp/src/Google.Protobuf.Test.TestProtos \ + --csharp_opt=file_extension=.pb.cs \ --descriptor_set_out=csharp/src/Google.Protobuf.Test/testprotos.pb \ --include_source_info \ --include_imports \ @@ -75,4 +77,5 @@ $PROTOC -Isrc -Icsharp/protos \ # AddressBook sample protos $PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \ + --csharp_opt=file_extension=.pb.cs \ examples/addressbook.proto diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.pb.cs similarity index 100% rename from csharp/src/AddressBook/Addressbook.cs rename to csharp/src/AddressBook/Addressbook.pb.cs diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/MapUnittestProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/MapUnittestProto3.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf.Test.TestProtos/MapUnittestProto3.cs rename to csharp/src/Google.Protobuf.Test.TestProtos/MapUnittestProto3.pb.cs diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto2.cs b/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto2.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto2.cs rename to csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto2.pb.cs diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.cs rename to csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.pb.cs diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs b/csharp/src/Google.Protobuf.Test.TestProtos/Unittest.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs rename to csharp/src/Google.Protobuf.Test.TestProtos/Unittest.pb.cs diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestCustomOptionsProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestCustomOptionsProto3.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf.Test.TestProtos/UnittestCustomOptionsProto3.cs rename to csharp/src/Google.Protobuf.Test.TestProtos/UnittestCustomOptionsProto3.pb.cs diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImport.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImport.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf.Test.TestProtos/UnittestImport.cs rename to csharp/src/Google.Protobuf.Test.TestProtos/UnittestImport.pb.cs diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportProto3.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportProto3.cs rename to csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportProto3.pb.cs diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublic.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublic.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublic.cs rename to csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublic.pb.cs diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublicProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublicProto3.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublicProto3.cs rename to csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublicProto3.pb.cs diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936A.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936A.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936A.cs rename to csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936A.pb.cs diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936B.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936B.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936B.cs rename to csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936B.pb.cs diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936C.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936C.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936C.cs rename to csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936C.pb.cs diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.cs rename to csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.pb.cs diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3.cs rename to csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3.pb.cs diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.cs rename to csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.pb.cs diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestSelfreferentialOptions.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestSelfreferentialOptions.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf.Test.TestProtos/UnittestSelfreferentialOptions.cs rename to csharp/src/Google.Protobuf.Test.TestProtos/UnittestSelfreferentialOptions.pb.cs diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestWellKnownTypes.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestWellKnownTypes.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf.Test.TestProtos/UnittestWellKnownTypes.cs rename to csharp/src/Google.Protobuf.Test.TestProtos/UnittestWellKnownTypes.pb.cs diff --git a/csharp/src/Google.Protobuf/Compiler/Plugin.cs b/csharp/src/Google.Protobuf/Compiler/Plugin.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf/Compiler/Plugin.cs rename to csharp/src/Google.Protobuf/Compiler/Plugin.pb.cs diff --git a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs b/csharp/src/Google.Protobuf/Reflection/Descriptor.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf/Reflection/Descriptor.cs rename to csharp/src/Google.Protobuf/Reflection/Descriptor.pb.cs diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Any.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf/WellKnownTypes/Any.cs rename to csharp/src/Google.Protobuf/WellKnownTypes/Any.pb.cs diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Api.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf/WellKnownTypes/Api.cs rename to csharp/src/Google.Protobuf/WellKnownTypes/Api.pb.cs diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs rename to csharp/src/Google.Protobuf/WellKnownTypes/Duration.pb.cs diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs rename to csharp/src/Google.Protobuf/WellKnownTypes/Empty.pb.cs diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs rename to csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.pb.cs diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs rename to csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.pb.cs diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs rename to csharp/src/Google.Protobuf/WellKnownTypes/Struct.pb.cs diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs rename to csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.pb.cs diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Type.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf/WellKnownTypes/Type.cs rename to csharp/src/Google.Protobuf/WellKnownTypes/Type.pb.cs diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.pb.cs similarity index 100% rename from csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs rename to csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.pb.cs