搜索最佳PCL配置文件以进行跨平台开发 [英] Searching for the best PCL profile for cross-platform development

查看:88
本文介绍了搜索最佳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:

配置文件78(NET45 + WP8 + Store):TPL,等待/异步和对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.

配置文件104(NET45 + SL4 + WP75 + Store):等待/异步不起作用,找不到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.

配置文件147(NET403 + SL5 + WP8 + Store):等待/异步不起作用,找不到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.

配置文件158(NET45 + SL5 + WP8 + Store):等待/异步不起作用,找不到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是唯一支持await/async和使用BindableBase的CallerMemberName的配置文件,但是在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.

但是,有些人问有关等待/异步...

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

要使用这些新功能,有一些BCL.可以通过异步Nuget骇客使其在配置文件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的PCL版本的Reactive的目标是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天全站免登陆