Closed mgrojo closed 2 years ago
Surprisingly, this fails for Java:
enum Result {
NONE = 0;
OK = 1;
WARNING = 2;
ERROR = 3;
type = 4;
switch = 5;
class = 6;
}
Using
$ protoc --version
libprotoc 3.15.2
I had expected that something would be foreseen for these cases, but maybe one is supposed to adjust the proto file for the languages that one is using That's strange to me. I've used CORBA IDL and each language mapping defined a prefix for names matching a target language keyword. In C, Java and the like, case sensitivity could made this problem less prevalent, but it feels like buggy behaviour nevertheless.
Update: In fact, the official generators are full of issues like this but they seem to consider them bugs, I've found these related issues: https://github.com/protocolbuffers/protobuf/issues/8837 https://github.com/protocolbuffers/protobuf/issues/9058 https://github.com/protocolbuffers/protobuf/issues/4833 https://github.com/protocolbuffers/protobuf/issues/4363
The first problem is that it takes the proto file name as Ada identifier, but my file contains hyphens. It is adding underscores, but it is not removing the hyphens, so the generated result is not directly compilable.
Example: file
test-file-with-hyphens.proto
generates packageTestpkg.Test_-file_-with_-hyphens
in files:testpkg-test_-file_-with_-hyphens.adb testpkg-test_-file_-with_-hyphens.ads
The second problem is when the proto files contains names that match Ada keywords. The name is directly translated to the generated Ada source code, making the result invalid Ada. I suppose the generators for other languages have this into account and adjust the name adding a prefix or similar.
For example, this NULL value used in the proto file:
Originally posted by @mgrojo in https://github.com/reznikmm/protobuf/issues/4#issuecomment-949491108