简体   繁体   English

UWP / .NET Native和iOS上的Protobuf-net

[英]Protobuf-net on UWP/.NET Native and iOS

I have a Xamarin.Forms App based on .NET Standard 1.4 that uses protobuf-net to store objects in the database that will be sent to a WCF service at a later time. 我有一个基于.NET Standard 1.4的Xamarin.Forms应用程序,该应用程序使用protobuf-net在数据库中存储将在稍后发送到WCF服务的对象。

On Android and UWP "managed" everything works fine but - after searching through repositories, articles and blogposts that can no longer be accessed, and also after trying to get the precompilation tool to work, but failing at that - I have one simple (probably not) question: How do I get protobuf-net to work in "restricted" environments like UWP/.NET Native and iOS/Xamarin? 在Android和UWP上“托管”一切正常但是 - 在搜索了无法再访问的存储库,文章和博客文章之后,以及在尝试使预编译工具工作之后,但是失败了 - 我有一个简单的(可能)问题:如何让protobuf-net在UWP / .NET Native和iOS / Xamarin等“受限”环境中工作?

Right now I don't have a great solution for this scenario. 现在我没有一个很好的解决方案。 I know some people have made it work, but I'm not expert enough in UWP / Native / iOS to give you reliable "here's the path to success" instructions. 我知道有些人已经让它成功了,但我在UWP / Native / iOS方面不够专业,无法为您提供可靠的“这里是成功之路”的指示。

UWP / .NET Native and iOS share (as you know) a common issue: lack of full runtime emit. UWP / .NET Native和iOS共享(如您所知)一个常见问题:缺少完整的运行时发射。 I understand why this is . 我明白为什么会这样 It is just: tricky. 这只是:棘手。

Historically, protobuf-net has tried to solve this problem via a build tool that repeated the existing IL-emit usually done at runtime - as a build-time tool. 从历史上看,protobuf-net试图通过构建工具来解决这个问题,该构建工具重复通常在运行时完成的现有IL发射 - 作为构建时工具。 This was ugly and nasty, but it worked . 这是丑陋和令人讨厌的,但它的确有效 Kind of. 的种类。 To hack around some platform restrictions, protobuf-net used some of the IKVM tooling to help with this, but as the .NET framework scene has continued to expand this is basically not viable. 为了解决一些平台限制问题,protobuf-net使用了一些IKVM工具来帮助解决这个问题,但随着.NET框架场景不断扩展,这基本上不可行。 Plus: the IKVM tool is now abandoned and won't be being maintained. 另外:IKVM工具现已放弃,不会被维护。

In parallel with this , there is increasing impetus to investigate some newer concepts: 与此同时,研究一些新概念的动力越来越大:

  • full async / await for asynchronous IO sources: note that this is extremely unfriendly to IL emit, but is almost embarrassingly easy to implement in C# 完全async / await异步IO源:请注意,这对IL发射非常不友好,但在C#中实现起来几乎非常容易实现
  • "pipelines" / "channels" / "streams 2" - whatever it is being called this week; “管道”/“渠道”/“流2” - 无论本周被称为什么; but: the new allocation-free IO concept that is being used in Kestrel (I helped kick this ball around a little bit when it was in the early stages, so I'm familiar with what needs doing) - note that this also ties into async / await 但是:在Kestrel中使用的新的无分配IO概念(我在早期阶段帮助将这个球放了一点,所以我很熟悉需要做什么) - 请注意,这async / await
  • and of course: how all of the above relates to pre-generation 当然:以上所有与上一代有关

Right now, I'm very much of the opinion that the best route forward is for the pre-gen scenario to switch to emitting C# via build-time tooling. 现在,我非常认为最好的前进方向是通过构建时工具切换到发布C#。 I have repeatedly petitioned MS for improved automated C# emit based on Roslyn, but so far: no joy (vexingly: the asp.net stuff even had a fully working proof-of-concept, but it is shelved). 我一再请求MS改进基于Roslyn的自动化C#发射,但到目前为止:没有快乐(令人烦恼:asp.net的东西甚至有一个完全可用的概念验证,但它被搁置)。 So right now I'm thinking: we need to assume that isn't going to happen, and basically write it independently. 所以现在我想:我们需要假定这是不会发生的,基本上独立写。 This isn't necessarily as complex as it sounds (and: codegen of various forms is very familiar to me). 不一定像听起来那么复杂(并且:各种形式的codegen对我来说非常熟悉)。 The advantage of C# emit here is that I don't need to fight the intricacies of every framework - I just need to make it compile (well, and run, obviously). 这里C#emit的优势在于我不需要对抗每个框架的复杂性 - 我只需要编译它(好吧,然后运行,显然)。

So: what's holding me back? 那么:什么阻碍了我? In theory: nothing. 理论上:没什么。 I just need to get this stuff written and deployed. 我只需要编写和部署这些东西。 In reality: life, time, etc. I am guilty of prioritising things that impact me daily , and the reality is that I'm not really a daily user of those platforms, which means I'm not feeling the pain that you're feeling. 在现实中:生活,时间等等。 我每天都会对影响我的事物进行优先排序,而现实是我不是那些平台的日常用户,这意味着我感觉不到你的痛苦感觉。 But: I hear you loud and clear, and I am trying to ramp up the v3 work that should address these points. 但是:我清楚地听到你的声音,我正在努力提高应该解决这些问题的v3工作。 I genuinely want to have a good story for those things - and my aim is that by moving to a C#-emit model (for pre-gen, at least): it helps me . 我真的希望一个关于这些事情的好故事 - 我的目标是通过转向C#-emit模型(至少对于pre-gen):它对帮助 And if it helps me I know it won't be the forgotten toy in the attic / basement that I know is there but which it is hard to find the motivation to go to the trouble of finding. 如果它可以帮助我,我知道这不会是阁楼/地下室,我知道被遗忘的玩具是有 ,但它是很难找到的动机去寻找的麻烦。

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

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