silentorbit / protobuf

C# code generator for reading and writing the protocol buffers format
https://silentorbit.com/protobuf/
MIT License
307 stars 105 forks source link

Import/Include path #43

Closed zeroZshadow closed 2 years ago

zeroZshadow commented 9 years ago

Im having an issue where i import a file using import "somefile.proto"; In protoc i can provide the -I someincludedir to tell it where it can look for imports, but CodeGenerator does not have this.

hultqvist commented 9 years ago

This should be quite easy to add.

zeroZshadow commented 9 years ago

I've had a quick jab at this feature on my fork, but the issue is a bit less trivial then though. As you are generating code for the imported message class.

Say i have a Info message which i import in 2 different proto files, then i run the code generator twice to create the files for these 2 messages. Both generated files will now have a partial class of Info, causing the compiler to complain.

hultqvist commented 9 years ago

Can you run the code generator only once? Try give both proto files as argument.

zeroZshadow commented 9 years ago

I can try in a bit. In my case both proto files are in different directories and packages, so generating this list before running CodeGenerator.exe instead of my current for loop will be much more work (on windows).

hultqvist commented 9 years ago

I see it's not so easy.

It looks like we also need a way import without generating code for the imported files.

It's doable.

My only concern is that using the tool like this put a lot of responsibility on the user to call the tool on every imported .proto.

hultqvist commented 9 years ago

Let me know how this works.

gyf19 commented 8 years ago

+1