-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--csharp_opt=file_extension= is not supported in the C# tooling #25930
Comments
By the way, if this is too much of a hassle to support, it's not that an issue for me (as my initial goal of preventing these generated files to be analyzed by SonarQube is already covered by the fact they live under |
It is not feasible to track every option being passed to the protoc by attributes that allow arbitrary options (such as What is the reason why you need to override the file extension? (there seems to be no point when you're using automatic protoc codegen integration). Feel free to suggest an update to the documentation: https://github.com/grpc/grpc/blob/master/src/csharp/BUILD-INTEGRATION.md |
Thanks for the reply. About my initial requirement: before using However, because the files generated by So I'm closing this and when I find time, I may indeed propose a documentation update as you suggested. |
I have the same need as @odalet - without one of the common conventions for identifying these as code generated, they show up as "not covered" by coverage analsys tools that use compiled type information (in my case coverlet is used by our build pipelines, the results of which feed sonarcloud). In my case I dont even get an error. The options are not even getting passed along as arguments to protoc.exe and the file extension is always
@jtattermusch - what is the scope of possible options that MSBuild would be passing along? I can only find two. Two seems feasable, and otherwise necessary in the case of the |
As mentioned on #25950 , I think the issue might be caused by CSharpGeneratorServices.GetPossibleOutputs expecting a ".cs" extension and thus the |
That is correct. I think GetPossibleOutputs needing to check what value of @StingyJack you mentioned that the reason why you need this is because the generated code doesn't comply with "common conventions for identifying these as code generated". If that's all that's needed, than adding an extra header/line at the beginning of the generated files would be much easier that messing with the GetPossibleOutputs logic. |
@StingyJack is this what you had in mind? |
@jtattermusch the Generated code attribute is the better choice over the filename, because that will be available to both source readers and compiled output readers. |
What version of gRPC and what language are you using?
This affects Grpc.Tools v2.37 (C#)
What operating system (Linux, Windows,...) and version?
On Windows, but most probably not dependent on the OS (this is somewhere in the MSBuild tooling)
What runtime / compiler are you using (e.g. python version or version of gcc)
VS2019 16.9.1 (targeting .NET Standard 2.0)
What did you do?
In my csproj, I have something like this (taking advantage of the
AdditionalProtocArguments
introduced in v2.37):What did you expect to see?
The project compiles successfully
What did you see instead?
The project does not compile and complains it can't find the definition of protobuf-generated code
Anything else we should know about your project / environment?
The actual behavior is kind of expected:
My
csharp_opt
is indeed honored byprotoc
and the generated files are calledfoo.g.cs
somewhere in theobj\
directory. However, it seems the msbuild task expects the file to be namedfoo.cs
(and by the way, a 0-sizedfoo.cs
file gets created). This explains why the compilation subsequently fails:foo.cs
is part of the files to compile, but notfoo.g.cs
.The task should be clever enough to not assume the file name to be
foo.cs
as this can be changed withcsharp_opt=file_extension
...The text was updated successfully, but these errors were encountered: