bufbuild / buf

The best way of working with Protocol Buffers.

Home Page:https://buf.build

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

csharp plugin fails in managed mode with same filename in different versions

noahseger opened this issue · comments

Given a project structure like in managed mode:

  • proto/foo/v1/bar.ts
  • proto/foo/v2/bar.ts

buf generate will fail to generate CSharp with an error like this:

Failure: file "target/proto/csharp/Bar.cs" was generated multiple times: once by plugin "buf.build/protocolbuffers/csharp:v25.2" and again by plugin "buf.build/protocolbuffers/csharp:v25.2"

Nice if it was handled by some managed mode option, but is there another way csharp folks are managing versioned APIs?

Okay, I found the solution in the Buf Slack from @timostamm, thanks!

[...] the C# plugin is a bit odd in this regard. You have to set the option base_namespace= to tell the plugin to generate files in a directory hierarchy matching the class namespace. See here and here for examples, and here for the documentation.