nikhilk / scriptsharp

Script# Project - a C# to JavaScript compiler, to power your HTML5 and Node.js web development.

Home Page:http://scriptsharp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ScriptSharp as a PCL Target

TheXenocide opened this issue · comments

I'm not fully familiar with the implementation behind ScriptSharp to know well enough how much of the .NET framework is compatible with it, but it would still be extremely useful for multi-targeting code if ScriptSharp could be a build target for PCL libraries. Enabling code sharing on this level could empower several mechanisms for cross-platforming between native mobile, desktop, and web based applications. Even if it wasn't quite powerful enough to run a whole ton it could be backed by remoting using SignalR or even as a means of sharing service contracts and DTO definitions between client and server without requiring both ends to use ScriptSharp (i.e. C# Mobile Client -> C# Node.js backend, etc.)

I should also like to note, as a grander goal, it would be really cool to see deeper Xamarin integration.

Its worth an idea to evaluate ... that said, I think even the mscorlib associated with PCLs has too large of a surface area to support from script. The mscorlib APIs in script# are much more constrained to match what is available in script, and also contain APIs that don't exist in .net that do exist in script.

Does xamarin support msbuild projects, nuget etc. If so, the only remaining bit is templates, which in vs are installed via a vsix. Presumably there is a xamarin equivalent.

Xamarin does indeed support MSBuild (and other Visual Studio solution file support) as well as NuGet. Apart from Xamarin Studio they also provide some great Visual Studio integration, so they can both live in the same IDE today, it's more the sharing of contracts I was hoping for. The mscorlib concern seems fairly real, although I believe it might be possible to set a new "minimum" in the foundation PCLs provide, since the target is defined by the lowest common denominator, in a manner of speaking. Several PCLs in my world only utilize primitive types, near-primitive immutable types (string, DateTime), and basic collection interfaces (IDictionary<K,V>, IEnumerable<T>, T[]), along with references to the classes contained within the same PCL. A couple more I see as feasible targets additionally reference concrete collection implementations (List<T>, Dictionary<K,V>). That said, I also recall having read something about PCLs not being supported by Micro Framework either (although I feel like that was a runtime thing, much like SQL Server can't use PCLs).

Ultimately, I'd really like to use many of these technologies together, and there are other barriers, but I think a reasonable goal for the lot of the following projects would be a single application that combines them all: Xamarin, Owin, SignalR, and ScriptSharp. ScriptSharp JS outputs can definitely be packaged in a Xamarin application, but I wonder if it would be feasible to link ScriptSharp to the backend using SignalR in a type-safe way (instead of the dynamic keyword, which SignalR can also make use of to call methods on the client-side) and, if so, if they could share contracts in a lowest-common-denominator targeted library. There is still the option of just having multiple libraries and sharing the code using Linked Files, but idealistically speaking I'd like it if that weren't necessary (especially considering absolutely no difference in implementation).

Closing this ticket to get it out of my GitHub issues list and since I'm off into the wonderful world of the Web Assembly runtime now; thanks for the early days of C# in the browser :)