prost icon indicating copy to clipboard operation
prost copied to clipboard

prost automatic naming convention causes build failure on valid protobuf

Open gen-xu opened this issue 2 years ago • 8 comments

Minimum re-produceable example of protobuf

syntax = "proto3";
package foobar;
enum Fb { 
    Fb1 = 0;
}
enum FB {
    FB2 = 0;
}

Since prost rename FB into Fb and it generates conflicts definitions like following and causes compiling failure in some cases

Is there any way to enforce naming convention in prost? I think it relates with this issue https://github.com/tokio-rs/prost/issues/593

But since this causes compiling failure only in prost but works with other languages with protoc I would deem this as a bug.

#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Fb {
    Fb1 = 0,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Fb {
    Fb2 = 0,
}

gen-xu avatar Jun 12 '22 08:06 gen-xu

This seems like an interesting corner case, I don't see how we can fix this without exposing more fine grained controls which I am not super happy about. That said, I want to say this goes against protobuf naming conventions so I am not sure how much I want to support that.

LucioFranco avatar Jun 15 '22 15:06 LucioFranco

@LucioFranco yes I agree it goes against naming convention. But sometime I think there are needs for that. For example XML, GPIO are very commonly used abbreviations together as all capitals cases. Also I am not sure if this is a bug of heck that does the naming conversion in Prost. As to me I think the upper camel cases applied on FB should still lead into FB.

gen-xu avatar Jun 15 '22 19:06 gen-xu