DAML-LF1 and Dev protos cause name conflict for C# generated classes
See original GitHub issueWhen using the C# plugin for protoc to generate .Net code from the DAML-LF protos, the resulting code doesn’t compile due to two name clashes. Proto oneof types in C# are generated as enum
s with a default case named None
: https://developers.google.com/protocol-buffers/docs/reference/csharp-generated#oneof
So any case that’s also named none
in the source proto file will be generated as a duplicate case None
on the resulting enum. The two cases where this happens are:
message Expr {
...
oneof Sum {
..
// empty optional valye ('ExpNone')
// *Available since version 1.1*
None none = 26; <= clash
..
}
...
}
...
message CaseAlt {
...
oneof Sum {
...
Unit none = 7; // * Available since version 1* <= clash
...
}
...
}
A simple solution is to rename the cases above into:
None nothing;
respectively
Unit nothing;
The issue is present in both daml_lf_1.proto
and daml_lf_dev.proto
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
C# codegen support #1332 - digital-asset/daml - GitHub
GeorgSchneider mentioned this issue on Jun 19, 2019. DAML-LF1 and Dev protos cause name conflict for C# generated classes #95.
Read more >Protocol Buffers for (Coding) Dummies - GitHub Pages
proto file to place a protocal buffer message into a particular package. Packages help to prevent name conflicts, just like C++ namespaces (...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Bummer - fixing this issue means that my beautiful solution using sed scripts is not needed anymore 😦
e.g.
<Target Name="ModifyGeneratedProtoSources" BeforeTargets="CoreCompile"> <Exec Command="sed -ri "/enum SumOneofCase \{$/{N; s/(enum SumOneofCase \{)\n([ ]*)(None = 0)/\1\n\2_\3/}" $(MSBuildProjectDirectory)\$(IntermediateOutputPath)*.cs" /> <Exec Command="sed -ri "s/(SumOneofCase.)(None)/\1_\2/" $(MSBuildProjectDirectory)\$(IntermediateOutputPath)\*.cs" /> <Exec Command="del $(MSBuildProjectDirectory)\sed*" /> </Target>
converts all the generated None enums to _None, which is fair enough as it is compiler generated so should look like a non-standard symbol…
I’ll take care of this today then.