question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DAML-LF1 and Dev protos cause name conflict for C# generated classes

See original GitHub issue

When 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 enums 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:closed
  • Created 5 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
AndrewDCDrummondcommented, Jun 26, 2019

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 &quot;/enum SumOneofCase \{$/{N; s/(enum SumOneofCase \{)\n([ ]*)(None = 0)/\1\n\2_\3/}&quot; $(MSBuildProjectDirectory)\$(IntermediateOutputPath)*.cs" /> <Exec Command="sed -ri &quot;s/(SumOneofCase.)(None)/\1_\2/&quot; $(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…

1reaction
hurryabitcommented, Jun 21, 2019

I’ll take care of this today then.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found