From e8e1dab03f8cdd473a3504c4efbe6920eb2c2612 Mon Sep 17 00:00:00 2001 From: csharptest Date: Fri, 3 Sep 2010 16:36:50 -0500 Subject: [PATCH] Completed the following changes & testing, see todo.txt for more information 1 - Add a way to specify the output directory 2 - Added an option "file_extension" to control the suffix for cs files generated, defaults to ".cs" 3 - Added the option for "umbrella_namespace" used when nest_classes=false and having name conflicts 4 - Optionally remove dependencies to csharp options 5 - Investigate command line parsing library 6 - Investigate calling protoc directly 7 - Unable to resolve dependencies correctly 8 - Added several (20) nunits to automate the command-line invocation of each option --- .gitignore | 2 + protos/google/protobuf/csharp_options.proto | 17 + src/ProtoGen.Test/ProtoGen.Test.csproj | 18 + src/ProtoGen.Test/TempFile.cs | 48 ++ src/ProtoGen.Test/TestPreprocessing.cs | 600 ++++++++++++++++++ src/ProtoGen/DescriptorUtil.cs | 16 +- src/ProtoGen/Generator.cs | 70 +- src/ProtoGen/GeneratorOptions.cs | 190 +++++- src/ProtoGen/Program.cs | 9 +- src/ProtoGen/ProgramPreprocess.cs | 150 +++++ src/ProtoGen/ProtoGen.csproj | 2 + src/ProtoGen/ServiceGenerator.cs | 2 +- src/ProtoGen/UmbrellaClassGenerator.cs | 17 +- src/ProtocolBuffers.sln | 8 + .../DescriptorProtos/CSharpOptions.cs | 186 +++++- .../Descriptors/FileDescriptor.cs | 62 +- todo.txt | 47 +- 17 files changed, 1393 insertions(+), 51 deletions(-) create mode 100644 src/ProtoGen.Test/TempFile.cs create mode 100644 src/ProtoGen.Test/TestPreprocessing.cs create mode 100644 src/ProtoGen/ProgramPreprocess.cs diff --git a/.gitignore b/.gitignore index 1382b2b591..f37fd25626 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,5 @@ mono/TestResult.xml mono/.libs mono/*.exe mono/*.dll + +src/ProtocolBuffers/objCF \ No newline at end of file diff --git a/protos/google/protobuf/csharp_options.proto b/protos/google/protobuf/csharp_options.proto index 184eef2000..3844578923 100644 --- a/protos/google/protobuf/csharp_options.proto +++ b/protos/google/protobuf/csharp_options.proto @@ -38,6 +38,23 @@ message CSharpFileOptions { // Generate attributes indicating non-CLS-compliance optional bool cls_compliance = 8 [default = true]; + + // ROK - 2010-09-03 additions to csoptions ... + // The extension that should be appended to the umbrella_classname when creating files. + optional string file_extension = 221 [default = ".cs"]; + + // A nested namespace for the umbrella class. Helpful for name collisions caused by + // umbrella_classname conflicting with an existing type. This will be automatically + // set to 'Proto' if a collision is detected with types being generated. This value + // is ignored when nest_classes == true + optional string umbrella_namespace = 222; + + // The output path for the source file(s) generated + optional string output_directory = 223 [default = "."]; + + // Will ignore the type generations and remove dependencies for the descriptor proto + // files that declare their package to be "google.protobuf" + optional bool ignore_google_protobuf = 224 [default = false]; } extend FileOptions { diff --git a/src/ProtoGen.Test/ProtoGen.Test.csproj b/src/ProtoGen.Test/ProtoGen.Test.csproj index f08495e58f..2ac2cb118f 100644 --- a/src/ProtoGen.Test/ProtoGen.Test.csproj +++ b/src/ProtoGen.Test/ProtoGen.Test.csproj @@ -50,10 +50,14 @@ ..\..\lib\Rhino.Mocks.dll + + + + @@ -68,6 +72,20 @@ + + + protoc.exe + Always + + + google\protobuf\csharp_options.proto + Always + + + google\protobuf\descriptor.proto + Always + +