从.proto rpc条目生成FaultContract属性
我在我正在处理的数据合约项目中使用 protobuf-net,手动创建 .proto 文件,并让自定义工具输出它正在执行的 C# 代码。 我也开始将它用于服务合同,并且服务接口也创建得很好。
为了连接到某些系统,我正在使用 WCF,因此我启用了 datacontracts 生成器选项,尽管存在 System.ServiceModel 属性,但似乎没有任何我可以声明该服务可能引发的具体错误的方式。
所以我的问题基本上是:
- Protocol Buffers 语言似乎没有任何异常/错误的构造。
- 我看不到任何用于生成FaultContract 属性的protobuf-net 选项。
- protobuf-net 生成的接口未声明为部分的,因此我无法扩充生成的代码。
有没有办法在 protobuf-net 中声明服务 WCF 操作错误,或者我必须等待版本 2?
非常感谢。
I am using protobuf-net on the project I am working on for the data contracts, creating the .proto
files by hand and having the custom tool spew forth the C# code which it is duly doing.
I have also started using it for service contracts and the service interfaces are also created just fine.
For connectivity to some systems I am using WCF so I have enabled the datacontracts
generator option and, although the the System.ServiceModel
attributes are present, there does not appear to be any way for me to declare the specific faults the service may raise.
So my problem is basically:
- Protocol Buffers language does not appear to have any constructs for exceptions/faults.
- I cannot see any protobuf-net options for generating FaultContract attributes.
- The interface generated by protobuf-net is not declared partial so I cannot augment the generated code.
Is there any way to declare service WCF operation faults in protobuf-net or is this something that I would have to wait for version 2 for?
Many thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道为什么我不将其声明为部分接口,因为这在 C# 2.0 中似乎非常满意;当我有时间时我会进行更改,但请注意,您可以在本地应用手动更改 - 只需编辑 csharp.xslt 文件即可。现在,xslt 并不是每个人都喜欢的,但它应该是 1 行更改(靠近单词
interface
) - 事实上,它可能是添加了partial 此处:
由于 xslt 是可调整的,因此您应该能够应用您需要的任何其他更改。
I'm not sure why I don't declare that as
partial interface
, since that seems perfectly happy in C# 2.0; I'll get that changed when I get a second, but note that you can apply a manual change locally - simply by editing the csharp.xslt file. Now, xslt isn't everyone's cup of tea, but it should be a 1-line change (near to the wordinterface
) - in fact, it is probably the addition ofpartial
here:Since the the xslt is tweakable, you should be able to apply any other changes you require.
这并不能直接回答您的问题,但无论如何可能是合适的
protobuf-net 不需要 .proto 文件才能工作,因此只需编写 C# 类并使用 WCF 属性(和您的 FaultContract 属性)装饰它们与(手动)为为了生成 C# 类。
this doesnt directly answer your question but may be appropriate anyway
protobuf-net doesn't need .proto files to work, so it would be the same amount of effort to just write your C# classes and decorate them with the WCF attributes (and your FaultContract attributes) than create the proto's (manually) for the sake of generating C# classes.