js codegen does not produce helper functions for Any when using closure imports
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript
- Ambito
- compilers
Direzione di ricerca
Inizia da src/google/protobuf/compiler/js/js_generator.cc, in particolare dalla logica di GenerateFile e output-mode indicata, e confronta closure-generated any.js con commonjs any_pb.js della riproduzione. Il lavoro è completato quando l'output in stile Closure include gli helper Any pack/unpack previsti senza introdurre regressioni nell'output commonjs.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What version of protobuf and what language are you using?
Version: v3.6.1 (binary downloaded from official releases)
Language: Javascript, when closure styled imports
What operating system (Linux, Windows, ...) and version?
Linux x86_64
What runtime / compiler are you using (e.g., python version or gcc version)
NA
What did you do?
Steps to reproduce the behavior:
root@ec834298ad98:/github/grpc-web-base/third_party/grpc/third_party/protobuf# mkdir -p /tmp/proto_out/closure /tmp/proto_out/commonjs
root@ec834298ad98:/github/grpc-web-base/third_party/grpc/third_party/protobuf# /tmp/bin/protoc -I /github/grpc-web-base/third_party/grpc/third_party/protobuf --js_out=import_style=closure,binary:/tmp/proto_out/closure google/protobuf/any.proto
root@ec834298ad98:/github/grpc-web-base/third_party/grpc/third_party/protobuf# /tmp/bin/protoc -I /github/grpc-web-base/third_party/grpc/third_party/protobuf --js_out=import_style=commonjs,binary:/tmp/proto_out/commonjs/ google/protobuf/any.proto
root@ec834298ad98:/github/grpc-web-base/third_party/grpc/third_party/protobuf# find /tmp/proto_out/ -type f
/tmp/proto_out/commonjs/google/protobuf/any_pb.js
/tmp/proto_out/closure/any.js
root@ec834298ad98:/github/grpc-web-base/third_party/grpc/third_party/protobuf# grep -rHin -C 5 unpack /tmp/proto_out/
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-240-};
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-241-
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-242-
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-243-/**
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-244- * @template T
/tmp/proto_out/commonjs/google/protobuf/any_pb.js:245: * Unpacks this Any into the given message object.
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-246- * @param {function(Uint8Array):T} deserialize Function that will deserialize
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-247- * the binary data properly.
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-248- * @param {string} name The expected type name of this message object.
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-249- * @return {?T} If the name matched the expected name, returns the deserialized
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-250- * object, otherwise returns null.
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-251- */
/tmp/proto_out/commonjs/google/protobuf/any_pb.js:252:proto.google.protobuf.Any.prototype.unpack = function(deserialize, name) {
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-253- if (this.getTypeName() == name) {
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-254- return deserialize(this.getValue_asU8());
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-255- } else {
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-256- return null;
/tmp/proto_out/commonjs/google/protobuf/any_pb.js-257- }
What did you expect to see
I expect to see pack/unpack functions for closure import code output
What did you see instead?
I do not see pack/unpack. However, when I use commonjs outputs, I see pack/unpack as demonstrated in the repro steps.
Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).
Anything else we should know about your project / environment
@TeBoring had some investigation into the root cause:
https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/compiler/js/js_generator.cc#L3682
This line is only called in GenerateFile.
https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/compiler/js/js_generator.cc#L3515
When you specify closure style, options.output_mode() == GeneratorOptions::kOneOutputFilePerType, and GenerateFile is not called.
- Lingua principale
- JavaScript
- Stelle
- 471
- Fork
- 91
- Merge medio
- 3h 57m
- PR unite (30g)
- 2
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di protocolbuffers/protobuf-javascript
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
protocolbuffers/protobuf-javascript#248 · 1 commento · 13 reazioni ·
-
question
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
protocolbuffers/protobuf-javascript#222 · 9 commenti ·
-
Why map.js sort keys? Apertaenhancement port-fix triaged
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
protocolbuffers/protobuf-javascript#185 · 1 commento ·
-
enhancement port-fix triaged
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
protocolbuffers/protobuf-javascript#182 · 3 commenti · 1 reazione ·
Tutte le issue di protocolbuffers/protobuf-javascript
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
avniproject/avni-client#2135 ·
-
automated broken-link
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
agent/security hive/hosted-available-lke648397-260827-5n31 security
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
babalae/bettergi-scripts-list#3674 ·
-
A-Release-Notes C-Editing D-Modest S-Ready-For-Implementation
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
bevyengine/bevy-website#2595 ·