简体   繁体   English

Protobuf-net 和 StringValue 类型

[英]Protobuf-net and StringValue types

I have some protobuf definitions with a lot of google.protobuf.StringValue and google.protobuf.Int32Value types referenced.我有一些 protobuf 定义,其中引用了很多 google.protobuf.StringValue 和 google.protobuf.Int32Value 类型。 I am guessing that the first should be just a string in c# but without a default value and the second a int?.我猜第一个应该只是 c# 中的一个字符串,但没有默认值,第二个是 int?。 Is that right?那正确吗?

This particular event is very large with lots of levels.这个特殊的事件非常大,有很多级别。 When the C# class is generated it is generating Google.Protobuf.WellKnownTypes.StringValue types for which I get a message that there is no serializer.当生成 C# class 时,它正在生成 Google.Protobuf.WellKnownTypes.StringValue 类型,我收到一条消息,指出没有序列化程序。 According the Microsoft's documentation that would be a straight string.根据微软的文档,这将是一个直字符串。 I understand that all these Value types like StringValue and Int32Value are wrappers to make nullable types.我知道所有这些值类型,如 StringValue 和 Int32Value 都是用于制作可空类型的包装器。

If you are (tags) talking about protobuf-net: protobuf-net doesn't currently do anything special with those well-known types.如果您(标签)在谈论 protobuf-net:protobuf-net 目前对那些众所周知的类型没有做任何特别的事情。 It could, in principle, if we added:原则上,如果我们添加:

  • recognition to the code-gen tooling (protogen)识别代码生成工具(protogen)
  • handling to.the library, to silently add/remove the extra layer of message wrapper处理 to.the 库,以静默方式添加/删除额外的消息包装层

But today : those things do not exist.但是今天:那些东西不存在了。 If you think it warrants special treatment, it would be best discussed on GitHub.如果您认为需要特殊处理,最好在 GitHub 上讨论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM