Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird capitlization: Point2d -> Point2D #19

Closed
mattoni opened this issue Apr 21, 2022 · 4 comments · Fixed by #22
Closed

Weird capitlization: Point2d -> Point2D #19

mattoni opened this issue Apr 21, 2022 · 4 comments · Fixed by #22

Comments

@mattoni
Copy link

mattoni commented Apr 21, 2022

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) } } } ;
@mattoni
Copy link
Author

mattoni commented Apr 21, 2022

It appears to come from this line which is taking Point2d and converting it to Point2D.

@fdeantoni
Copy link
Owner

This should now have been addressed by commit 4dc9f0e. This commit makes prost-wkt make use of the same package name capitalization as Prost.

@mattoni
Copy link
Author

mattoni commented Jul 5, 2022

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)

image

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);
}

@mattoni
Copy link
Author

mattoni commented Jul 5, 2022

The path doing the conversion I referenced above is still explicitly mentioning PascalCase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants