-
Notifications
You must be signed in to change notification settings - Fork 16.1k
Discuss adding an option to preserve file names in C# codegen #3843
Description
This is related to grpc/grpc#13207. When automating the build process, it is necessary to know the exact names of the files generated by protoc. In the build process I am trying to introduce for .NET Core and Visual Studio, the generated outputs files are considered transient (just like .o files would be for a C++ compilation). The problem is the filenames need to be known ahead to the build process, and they are currently camelized (and, well, deunderscored?..)
What I would like to do is add an option preserve_filename for the C# codegen plugins (both proto and gRPC) so that the generated file has the same name as the input, e. g. one_two.proto would produce one_two.cs (and one_twoGrpc.cs in the gRPC codegen). Are there any issues with that? Would such a change be acceptable?
On the same note, the function GetOutputFile in csharp_names.h would have to change. It is marked LIBPROTOC_EXPORT but is not actually used by gRPC codegen. Would it be ok to change it? Un-export and move the declaration to csharp_helpers.h? Or keep the existing API for compatibility with something else? I am thinking of passing it a const pointer to struct Options instead of the 3 last parameters, as it contains all codegen plugin options already (and will need more).
If the decision is to go ahead with this, unit tests for name generation are on me. There are currently none at all, and I would not start changing anything without them in place first.
/cc @jtattermusch, @jskeet