Skip to content
New issue

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

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

Already on GitHub? # to your account

fix(build): Fix service and rpc name conflict #92

Merged
merged 4 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ members = [
"tonic-build",
"tonic-examples",
"tonic-interop",

"tests/same_name",
"tests/wellknown",
]
16 changes: 16 additions & 0 deletions tests/same_name/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "same_name"
version = "0.1.0"
authors = ["Lucio Franco <luciofranco14@gmail.com>"]
edition = "2018"
publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tonic = { path = "../../tonic" }
bytes = "0.4"
prost = "0.5"

[build-dependencies]
tonic-build = { path = "../../tonic-build" }
3 changes: 3 additions & 0 deletions tests/same_name/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
tonic_build::compile_protos("proto/foo.proto").unwrap();
}
11 changes: 11 additions & 0 deletions tests/same_name/proto/foo.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";

package foo;

service Foo {
rpc Foo(stream FooRequest) returns (stream FooResponse) {}
}

message FooRequest {}

message FooResponse {}
3 changes: 3 additions & 0 deletions tests/same_name/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod pb {
tonic::include_proto!("foo");
}
17 changes: 17 additions & 0 deletions tests/wellknown/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "wellknown"
version = "0.1.0"
authors = ["Lucio Franco <luciofranco14@gmail.com>"]
edition = "2018"
publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tonic = { path = "../../tonic" }
bytes = "0.4"
prost = "0.5"
prost-types = "0.5"

[build-dependencies]
tonic-build = { path = "../../tonic-build" }
3 changes: 3 additions & 0 deletions tests/wellknown/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
tonic_build::compile_protos("proto/wellknown.proto").unwrap();
}
3 changes: 3 additions & 0 deletions tests/wellknown/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod pb {
tonic::include_proto!("wellknown");
}
8 changes: 4 additions & 4 deletions tonic-build/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ fn generate_unary(
proto_path: &str,
server_trait: Ident,
) -> TokenStream {
let service_ident = Ident::new(&method.proto_name, Span::call_site());
let service_ident = quote::format_ident!("{}Svc", method.proto_name);

let (request, response) = crate::replace_wellknown(proto_path, &method);

Expand Down Expand Up @@ -262,7 +262,7 @@ fn generate_server_streaming(
proto_path: &str,
server_trait: Ident,
) -> TokenStream {
let service_ident = Ident::new(&method.proto_name, Span::call_site());
let service_ident = quote::format_ident!("{}Svc", method.proto_name);

let (request, response) = crate::replace_wellknown(proto_path, &method);

Expand Down Expand Up @@ -305,7 +305,7 @@ fn generate_client_streaming(
proto_path: &str,
server_trait: Ident,
) -> TokenStream {
let service_ident = Ident::new(&method.proto_name, Span::call_site());
let service_ident = quote::format_ident!("{}Svc", method.proto_name);

let (request, response) = crate::replace_wellknown(proto_path, &method);

Expand Down Expand Up @@ -346,7 +346,7 @@ fn generate_streaming(
proto_path: &str,
server_trait: Ident,
) -> TokenStream {
let service_ident = Ident::new(&method.proto_name, Span::call_site());
let service_ident = quote::format_ident!("{}Svc", method.proto_name);

let (request, response) = crate::replace_wellknown(proto_path, &method);

Expand Down
12 changes: 0 additions & 12 deletions tonic-build/tests/wellknown.rs

This file was deleted.