tags:

views:

9

answers:

1

I am using the latest version of protobuf-net with VS2008 integration. I have created 2 messages (Message1 and Message2), 1 message in 1 proto file. When I try to reference Message2 in Message1 the code generator tool gives me error "Message2" is not defined and won't generate the code file. The package for both messages is same.
It look like that because of the integration of the tool with VS2008 it expects all the messages in same .proto file to compile. Currently I have to paste an empty message with same name in Message1.proto file, like this:

message Message1 {
 optional Message2 message2 = 1;
}

message Message2 {
}

And then later on remove the declaration of class Message2 from Message1.cs. Are there any settings that I need to do so to avoid this error, or is providing an empty declaration the only way? Or if there isn't then I suggest that you (Marc Gravell) include a keyword like "extern" to tell the compiler that the definition of this type is available in another class

+1  A: 

I have:

(File1.proto)

import "File2.proto";
message Message1 {
 optional Message2 message2 = 1;
}

(File2.proto)

message Message2 {
}

Each decorated (in the IDE) with the custom tool (ProtoBufTool) and it is working fine. Two .cs files are generated, one each nested under the File*.proto files, with the necessary generated types in each.

Have I missed something? I guess I could make the first file (alone) generate the types from the imported files, but to do that I'd actually need to write a parser from scratch (at the moment it uses google's .proto parser under the hood).

Re changing the language - that isn't up to me; but do you simply mean the (existing) import declaration?

Marc Gravell
no, i was missing something
cornerback84