自定义工具错误:Command.proto:11:18:“Message2”没有定义
我正在使用最新版本的 protobuf-net 与 VS2008 集成。我创建了 2 条消息(Message1 和 Message2),1 条消息位于 1 个原始文件中。当我尝试在 Message1 中引用 Message2 时,代码生成器工具给出错误“Message2”未定义,并且不会生成代码文件。两条消息的包是相同的。
看起来是这样,因为该工具与 VS2008 集成,它希望编译同一 .proto 文件中的所有消息。目前,我必须在 Message1.proto 文件中粘贴一条具有相同名称的空消息,如下所示:
message Message1 {
optional Message2 message2 = 1;
}
message Message2 {
}
然后稍后从 Message1.cs
中删除 class Message2
的声明。 我是否需要进行任何设置以避免此错误,或者提供空声明是唯一的方法? 或者,如果没有,那么我建议您(Marc Gravell)包含一个像“extern”这样的关键字来告诉编译器该类型的定义在另一个类中可用
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我有:
(
File1.proto
)(
File2.proto
)每个都用自定义工具 (
ProtoBufTool
) 装饰(在 IDE 中)并且它工作正常。生成两个.cs
文件,每个文件嵌套在File*.proto
文件下,每个文件中都包含必要的生成类型。我错过了什么吗?我猜我可以让第一个文件(单独)从导入的文件中生成类型,但要做到这一点,我实际上需要从头开始编写一个解析器(目前它使用谷歌的 .proto引擎盖下的解析器)。
重新改变语言——这不取决于我;但您只是指(现有的)
import
声明吗?I have:
(
File1.proto
)(
File2.proto
)Each decorated (in the IDE) with the custom tool (
ProtoBufTool
) and it is working fine. Two.cs
files are generated, one each nested under theFile*.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?