Weird capitlization: Point2d -> Point2D
mattoni opened this issue · 4 comments
Unsure how this is happening, but I have a type, Point2d
, that is getting some generated code from prost-wkt referring to it as Point2D
with the capital D. Point2D
does not appear anywhere in my idl files or in my code. I'm unsure where this is coming from.
# [allow (dead_code)] const IMPL_MESSAGE_SERDE_FOR_POINT_2_D : () = { use :: prost_wkt :: typetag ; # [typetag :: serde (name = "type.googleapis.com/atp.pb.Point2d")] impl :: prost_wkt :: MessageSerde for Point2D { fn package_name (& self) -> & 'static str { "atp.pb" } fn message_name (& self) -> & 'static str { "Point2d" } fn type_url (& self) -> & 'static str { "type.googleapis.com/atp.pb.Point2d" } fn new_instance (& self , data : Vec < u8 >) -> Result < Box < dyn :: prost_wkt :: MessageSerde > , :: prost :: DecodeError > { let mut target = Self :: default () ; :: prost :: Message :: merge (& mut target , data . as_slice ()) ? ; let erased : Box < dyn :: prost_wkt :: MessageSerde > = Box :: new (target) ; Ok (erased) } fn encoded (& self) -> Vec < u8 > { let mut buf = Vec :: new () ; buf . reserve (:: prost :: Message :: encoded_len (self)) ; :: prost :: Message :: encode (self , & mut buf) . expect ("Failed to encode message") ; buf } fn try_encoded (& self) -> Result < Vec < u8 > , :: prost :: EncodeError > { let mut buf = Vec :: new () ; buf . reserve (:: prost :: Message :: encoded_len (self)) ; :: prost :: Message :: encode (self , & mut buf) ? ; Ok (buf) } } } ;
It appears to come from this line which is taking Point2d
and converting it to Point2D
.
This should now have been addressed by commit 4dc9f0e. This commit makes prost-wkt
make use of the same package name capitalization as Prost.
Hmm... I've updated to the latest version (0.3.2) and I'm still hitting this snag. If it helps at all, I'm using tonic-build (which uses prost under the hood/same API)
Here's my build script:
use prost_wkt_build::*;
use std::{env, path::PathBuf};
fn main() {
let out = PathBuf::from("./compiled");
let descriptor_file = out.join("descriptors.bin");
tonic_build::configure()
.type_attribute(
".",
"#[derive(serde::Serialize,serde::Deserialize)]"
)
.out_dir("./compiled")
.extern_path(
".google.protobuf.Any",
"::prost_wkt_types::Any"
)
.extern_path(
".google.protobuf.Timestamp",
"::prost_wkt_types::Timestamp"
)
.extern_path(
".google.protobuf.Value",
"::prost_wkt_types::Value"
)
.extern_path(
".google.protobuf.Duration",
"::prost_wkt_types::Duration"
)
.file_descriptor_set_path(&descriptor_file)
.compile(
&[
"../idl/grpc/aero.joby/atp/marketplace/marketplace.proto",
"../idl/grpc/aero.joby/atp/core.proto",
],
&["../idl/grpc/aero.joby"],
)
.unwrap();
// TODO - https://github.com/fdeantoni/prost-wkt/issues/19
let descriptor_bytes = std::fs::read(descriptor_file).unwrap();
let descriptor = FileDescriptorSet::decode(&descriptor_bytes[..]).unwrap();
prost_wkt_build::add_serde(out, descriptor);
}
The path doing the conversion I referenced above is still explicitly mentioning PascalCase.