Comments (4)
Actually, based on what Prost is doing with identifiers, maybe you could change the identifier to __
(double underscore), which would be a valid identifier, at least?: https://github.com/tokio-rs/prost/blob/e3deaa200b3a5500bf0403325d02716973b7296a/prost-build/src/ident.rs#L23. However, __
is a valid Protobuf package name too, so you'd potentially conflict with that package 😃.
from protoc-gen-prost.
Also:
// File: test1.proto
syntax = "proto3";
package _;
message Test {}
// File: test2.proto
syntax = "proto3";
message Test {}
# buf.gen.yaml
version: v1
plugins:
- plugin: buf.build/community/neoeinstein-prost
out: gen/src
Running buf generate .
creates two files, named _
and _.rs
, both containing:
// @generated
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Test {
}
// @@protoc_insertion_point(module)
Again, not sure the answer, but it doesn't seem like generating a file named _
is desirable.
from protoc-gen-prost.
I'll start off by noting that _
is not a valid package name in the Protobuf spec either. The package line must follow the following grammar (which I've grabbed excerpts from):
package = "package" fullIdent ";"
fullIdent = ident { "." ident }
ident = letter { letter | decimalDigit | "_" }
letter = "A" ... "Z" | "a" ... "z"
decimalDigit = "0" ... "9"
As the grammar requires that an ident
start with a letter
, _
alone is not a valid Protobuf identifier. We don't do any special detection around that, but since it's not considered a valid ident, I don't think it's something that I'd take special care to handle.
Let me know if you have additional information that should cause me to reconsider, but that would also likely require coordination and changes to the underlying Prost library as well. The most likely change would be to more explicitly reject a _
package name rather than work around it.
from protoc-gen-prost.
Yeah, unfortunately I think the spec linked above is slightly off. In the Buf version of the spec, _
is included in the letter
character class, meaning that package _;
is (unfortunately) valid. And protoc
seems to agree with that:
// test-underscore.proto
syntax = "proto3";
package _;
message Test {}
$ protoc --version
libprotoc 25.0
$ protoc --descriptor_set_out=underscore.binpb test-underscore.proto # passes
versus an invalid package -;
:
// test-dash.proto
syntax = "proto3";
package -;
message Test {}
$ protoc --descriptor_set_out=dash.binpb test-dash.proto
test-dash.proto:3:9: Expected identifier.
I think the upstream spec should be fixed, heh. Anyway, happy to leave this closed; it's terribly niche.
from protoc-gen-prost.
Related Issues (20)
- protoc-gen-prost-serde: doesn't generate .serde.rs for module with "type" in its name HOT 2
- Failure when compiling with file_descriptor_set HOT 3
- How to properly use protoc-gen-prost-crate
- Failure with tonic when a proto file has only service definitions HOT 6
- Release a new version of protoc-gen-prost-crate HOT 1
- Add example for how to use well known types with buf HOT 1
- add max message size configuration to generated service HOT 1
- More verbose error message when compilation fails HOT 1
- Bug: Protos with duplicate package names fail to generate any files
- Missing tags on latest release HOT 1
- File generated by tonic cannot compile directly HOT 1
- Update generation to prost 0.12 HOT 4
- Failure: plugin prost-crate: could not find protoc plugin for name prost-crate - please make sure protoc-gen-prost-crate is installed and present on your $PATH HOT 4
- Support `axum-connect` code gen HOT 2
- Missing support for option json_name HOT 1
- `exclude` option not supported in protoc-gen-prost-serde
- How to replace include!("v1.account.rs") on #[path = "v1.account.rs"] ?
- Suggestion: support the `prost_build::Config::include_file` option HOT 4
- question: added packaging for aur HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protoc-gen-prost.