寻找用于跨平台开发的最佳 PCL 配置文件 [英] Searching for the best PCL profile for cross-platform development

查看:33
本文介绍了寻找用于跨平台开发的最佳 PCL 配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的应用程序扩展支持的平台数量,它曾经支持 .NET4/Windows Store/Windows Phone,但我希望也涵盖适用于 Android 和 iOS 的 Mono.我已经将所有业务逻辑、模型和视图模型都放到了可移植类库 (PCL) 中,但是我应该针对哪些平台子集是一个很大的难题.每种组合都会导致某些事情失败.以下是我可能使用的 4 个平台的结果:

I am working on extending number of supported platforms for my app, it used to support .NET4/Windows Store/Windows Phone, but I hope to also cover Mono for Android and iOS. I've put all business logic, models and view models to portable class libraries (PCL) but it's a big dilemma what subset of platforms I should target. Each combination causes something to fail. Here are the results for 4 platforms that I might use:

Profile 78 (NET45+WP8+Store):TPL 没有问题,await/async 并支持 CallerMemberName 属性(用于 BindableBase 视图模型基类).但是引用此类库的 Mono.Android 项目无法构建抱怨不存在的 System.Runtime.dll 应该被引用.

Profile 78 (NET45+WP8+Store): no problem with TPL,await/async and support for CallerMemberName attribute (used in BindableBase view model base class). But the Mono.Android project that refers such library fails to build complaining about non-present System.Runtime.dll that should be referenced.

Profile 104 (NET45+SL4+WP75+Store):await/async 不起作用,CallerMember 名称未找到,但如果我删除对它们的所有引用,Android 项目构建正常.

Profile 104 (NET45+SL4+WP75+Store): await/async don't work, CallerMember name not found, but if I remove all references to them, Android project builds fine.

Profile 147 (NET403+SL5+WP8+Store):await/async 不起作用,找不到 CallerMember 名称,但如果我删除对它们的所有引用,Android 项目就可以正常构建.

Profile 147 (NET403+SL5+WP8+Store): await/async don't work, CallerMember name not found, but if I remove all references to them, Android project builds fine.

Profile 158 (NET45+SL5+WP8+Store):await/async 不起作用,找不到 CallerMember 名称,但如果我删除对它们的所有引用,Android 项目构建正常.

Profile 158 (NET45+SL5+WP8+Store): await/async don't work, CallerMember name not found, but if I remove all references to them, Android project builds fine.

所以我不确定该选择什么.配置文件 78、104、147 是有限的,配置文件 78 是唯一同时支持等待/异步和 CallerMemberName 使用 BindableBase 的配置文件,但它在 Android 上失败并抱怨 System.Runtime.dll.因此,如果您了解哪种 PCL 配置文件最适合针对 Mono 的 PCL,请分享您的想法.

So I am not really sure what to choose. Profiles 78, 104, 147 are limited, profile 78 is the only one that supports both await/async and CallerMemberName used BindableBase, but it fails on Android complaining about System.Runtime.dll. So if you have an experience with what PCL profile is the best match for PCL targeting Mono, please share your thoughts.

推荐答案

考虑个人资料编号很难 - 我更喜欢从平台的角度考虑.

Thinking about profile numbers is hard - I prefer to think in terms of the platforms.

理想情况下,我希望我的项目能够得到支持:

Ideally I'd love my projects to support:

  • .Net 3.5 及更高版本
  • SL3 及更高版本
  • WP7.x 手机及更高版本
  • MonoDroid 1.6 及更高版本
  • MonoTouch iOS6 及更高版本
  • (Mac 桌面 OSX Lion)

我支持的主要 PCL 项目是 MvvmCross - 它需要像 ICommand 这样的 Mvvm '设施'.这些工具仅在 .Net 4.5 及更高版本的平台中可用...这是一个硬性限制 - 我对此无能为力 - 所以我的需求更改为:

The main PCL project I support is MvvmCross - which requires Mvvm 'facilities' like ICommand. These facilities are only available in platforms for .Net 4.5 and higher... that's a hard limit - nothing I can do about it - so changes my needs to:

  • .Net 3.5 及更高版本.Net 4.5
  • SL3 及以上SL4 及以上
  • WP7.x 手机及更高版本
  • MonoDroid 1.6 及更高版本
  • MonoTouch iOS6 及更高版本
  • (Mac 桌面 OSX Lion)
  • .Net 3.5 and higher .Net 4.5
  • SL3 and higher SL4 and higher
  • WP7.x phone and higher
  • MonoDroid 1.6 and higher
  • MonoTouch iOS6 and higher
  • (Mac desktop OSX Lion)

有了这个选择,然后这将我带到一个个人资料编号 - 104(不知道平台是如何决定这个的......很久以前就放弃了!)

With this selection in place, then this leads me to a profile number - 104 (no idea how the platform decided this... gave up asking a long time ago!)

所以我已经将 MvvmCross 定位在配置文件 104 - 并且在仍然需要 WP7.x 支持时它会保留在那里.

So I've targeted MvvmCross at profile 104 - and it will stay there while WP7.x support is still needed.

这个选择确实意味着 MvvmCross 不能开箱即用地支持 async/awaitCallerMemberName 之类的东西 - 但这是我们决定做出妥协 - 我们的用户需要 WP7.

This selection does mean that MvvmCross cannot out-of-the-box support things like async/await and CallerMemberName - but this is a compromise we've decided to make - we have users who need WP7.

但是,有些人在询问 await/async...

However, some people are asking about await/async...

要使用这些新功能,有一些 BCL.Async Nuget hack 可以让它们在配置文件 104 中工作......或者这些用户可以将他们的应用程序定位到更新的配置文件(不支持 WP7.x 和 SL4 的配置文件)) - 这导致他们在配置文件 78 中构建他们的应用程序,但添加对我的配置文件 104 程序集的引用.

To use these new features, there are some BCL.Async Nuget hacks to make them work in profile 104... or these users can target their apps at a newer profile (one that doesn't support WP7.x and SL4) - this leads them to build their apps in profile 78, but to add references to my profile 104 assemblies.

目前,这些解决方案都不适用于 Xamarin 双胞胎 - 例如.您遇到了诸如缺少 System.Runtime.dll 程序集之类的问题.但是,我预计当 Xamarin 正式支持 PCL(并经过一些 alpha/beta 测试后)时,这些问题将得到解决.这个官方支持现在很快就会到期 - 这就是为什么我不会花费太多时间来思考这些问题......

Neither of these sets of solutions works very well with the Xamarin twins at present - e.g. you hit issues like the missing System.Runtime.dll assembly. However, I anticipate that when Xamarin officially supports PCLs (and after some alpha/beta testing) then these problems will be resolved. This official support is due very soon now - which is why I don't bother expending too much of my time thinking about these problems...

我预计 MvvmCross 将在中期内放弃对 WP7.x 和 SL4 的支持.当这种情况发生时,我们也可以将核心库移动到配置文件 78.

I expect in the medium term that MvvmCross will drop support for WP7.x and SL4. When that happens, we may also move the core libraries to profile 78.

我知道的唯一一个已经开始支持 PCL 的大型平台是 ReactiveUI.我相信这个平台必须使用配置文件 78,因为 Microsoft 的 Reactive 的 PCL 版本的目标是 78.

The only other large platform I know that has started PCL support is ReactiveUI. I believe this platform must use profile 78 because the PCL version of Reactive from Microsoft is targeting 78.

这篇关于寻找用于跨平台开发的最佳 PCL 配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆