使用自动生成时如何在.proto文件中包括服务(Serializer.GetProto <>())

问题描述 投票:0回答:1

因此,我需要使用服务和消息创建完整的.proto文件,以充分描述我将要使用的服务之一。我已经发现this post提到了string proto = Serializer.GetProto<YourType>();但是可悲的是,当在我的服务上使用它时,它只是生成一个带有以我的服务命名的“消息”的原型文件。

与我在下面给出的具体文件示例进行对话,有没有办法从IExampleService.cs获取Example.proto?

[ServiceContract]
public interface IExampleService
{
    Task<ExampleReply> ExampleMethod(ExampleRequest request);
}

[ProtoContract]
public class ExampleRequest
{
    [ProtoMember(1)]
    public string Prop1 { get; set; }

    [ProtoMember(2, DataFormat = DataFormat.WellKnown)]
    public DateTime TimeProp2 { get; set; }
}

[ProtoContract]
public class ExampleReply
{
    [ProtoMember(1)]
    public string Prop1 { get; set; }
}

Example.proto文件

service IExampleService {
    rpc ExampleMethod (ExampleRequest) returns (ExampleReply) {}
}

message ExampleRequest{
   string Prop1 = 1;
   .google.protobuf.Timestamp TimeProp2 = 2;
 }

message ExampleReply {
  string message = 1;
}
.net serialization protocol-buffers grpc protobuf-net
1个回答
0
投票

目前尚未编写执行此操作的代码。有一个开放的github票证,但是需要一些时间。目前,您可能需要手动修改它。

© www.soinside.com 2019 - 2024. All rights reserved.