首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用时可以省略"protobuf package“吗?

使用时可以省略"protobuf package“吗?
EN

Stack Overflow用户
提问于 2019-06-21 09:59:05
回答 1查看 170关注 0票数 0

我有以下的protobuf文件,我想使用“protobuf-gen”将它们编译成C#。我发现"chassis.proto“可以成功,但"perception_lane.proto”不能。我猜原因是"common.Header",应该是"apollo.common.Header":

我用C++编译了bazel,他们没有这个问题。可以使用protoc将Aslo编译成python。问题是protobuf本身是否支持这种用法?或者“protobuf-net”不能识别这样的用法?

header.proto

代码语言:javascript
复制
syntax = "proto2";

package apollo.common;

import "modules/common/proto/error_code.proto";

message Header {

  optional double timestamp_sec = 1;
  ...
}

chassis.proto

代码语言:javascript
复制
syntax = "proto2";

package apollo.canbus;

import "modules/common/proto/header.proto";

message Chassis {
  optional apollo.common.Header header = 19;
}

perception_lane.proto

代码语言:javascript
复制
syntax = "proto2";

package apollo.perception;

import "modules/common/proto/header.proto";


message PerceptionLanes {
    optional common.Header header = 1;
}

我得到的错误信息如下:

代码语言:javascript
复制
C:\01code\protobuf-net-2.3.16\src\protogen\bin\Release\net462>protogen.exe --proto_path=../net462 --csharp_out=gen +names=original +langver=3 modules/perception/proto/perception_lane.proto
modules/perception/proto/perception_lane.proto(9,14,9,27): error: type not found: 'common.Header'
modules/perception/proto/perception_lane.proto(11,14,11,36): error: type not found: 'camera.CameraErrorCode'
modules/perception/proto/perception_lane.proto(12,14,12,37): error: type not found: 'camera.CameraCalibrator'
modules/perception/proto/perception_lane.proto(13,14,13,35): error: type not found: 'camera.CameraLaneLine'
modules/perception/proto/perception_camera.proto(50,14,50,28): error: type not found: 'common.Point2D'
modules/perception/proto/perception_camera.proto(51,14,51,28): error: type not found: 'common.Point2D'
modules/perception/proto/perception_camera.proto(62,14,62,28): error: type not found: 'common.Point3D'
modules/perception/proto/perception_camera.proto(64,14,64,28): error: type not found: 'common.Point2D'
modules/perception/proto/perception_camera.proto(96,14,96,28): error: type not found: 'common.Point2D'
modules/perception/proto/perception_camera.proto(97,14,97,28): error: type not found: 'common.Point2D'
modules/perception/proto/perception_camera.proto(98,14,98,28): error: type not found: 'common.Point2D'
modules/perception/proto/perception_camera.proto(104,14,104,27): error: type not found: 'common.Header'
modules/perception/proto/perception_obstacle.proto(30,12,30,26): error: type not found: 'common.Point3D'
modules/perception/proto/perception_obstacle.proto(36,12,36,26): error: type not found: 'common.Point3D'
modules/perception/proto/perception_obstacle.proto(48,12,48,26): error: type not found: 'common.Point3D'
modules/perception/proto/perception_obstacle.proto(51,12,51,26): error: type not found: 'common.Point3D'
modules/perception/proto/perception_obstacle.proto(58,12,58,26): error: type not found: 'common.Point3D'
modules/perception/proto/perception_obstacle.proto(86,12,86,26): error: type not found: 'common.Point3D'
modules/perception/proto/perception_obstacle.proto(89,12,89,26): error: type not found: 'common.Point3D'
modules/perception/proto/perception_obstacle.proto(93,12,93,26): error: type not found: 'common.Point3D'
modules/perception/proto/perception_obstacle.proto(157,12,157,25): error: type not found: 'common.Header'
modules/perception/proto/perception_obstacle.proto(158,12,158,28): error: type not found: 'common.ErrorCode'
modules/perception/proto/perception_lane.proto(5,8,5,41): warning: import not used: 'modules/common/proto/header.proto'
modules/perception/proto/perception_lane.proto(6,8,6,56): warning: import not used: 'modules/perception/proto/perception_camera.proto'
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-06-21 13:02:17

这听起来很像protobuf-net.Reflect中名称解析的错误;最好登录GitHub并提供足够的信息来重现它(理想情况下是最小的!)。或者更好:您可以使用fork、fix和PR :)

作为一种变通办法,您可以尝试在模式中使用完全限定名称(从.开始)。例如,Empty.google.protobuf.Empty IIRC。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56695946

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档