Has the Roslyn compiler been integrated into the Mono project? - c#

I've been rather interested in C# and Mono since Microsoft announced that it was open sourcing .Net. I was wondering how much influence this decision has had over the Mono project? I'm assuming it now means there isn't any potential danger of Microsoft trying to shut down the project anymore (if they had wanted)?

Yes Roslyn has been integrated.
From the article Mono and Roslyn, which was written by one of the Mono maintainers:
At BUILD, we showed Roslyn running on Mono. If you want to run your own copy of Roslyn today, you need to use both a fresh version of Mono, and apply a handful of patches to Roslyn.
...
Our goal is to keep track of Roslyn as it is being developed, and when it is officially released, to bundle Roslyn's compilers with Mono.

Related

Xamarin - Compile AOT in Community edition?

I wanted to obfuscate my application, but I couldn't find a free obfuscator for commercial use. I saw that mono supports AOT compilation, so is there a was to compile my app ahead of time using the community version of Xamarin?
If not: is there a free obfuscator for C#(xamarin) for commercial use?
NOTE:
I'm targeting Android
I want to clarify the licensing restrictions that come with Dotfuscator Community Edition (CE). UUioP writes "I know about Dotfuscator, but I was actually looking for a free obfuscator for commercial use." Dotfuscator CE most certainly comes with license restrictions that preclude most commercial use scenarios, but there is one exception (granted - it is a very narrow exception, but one that might work for some). Dotfuscator CE can be used to release commercial software if the code being obfuscated is written and owned by the Dotfuscator CE user. In other words, if you develop your own app (and it's your app - not your employer's), you can use Dotfuscator CE to obfuscate your app - even if it is for sale or other "commercial/production" use. See (Re) Introducing Dotfuscator CE - the licensing terms are explained towards the end of the post.
The AOT Compilation option requires an Enterprise license or higher. AOT compilation is available only when the project is configured for Release mode, and it is disabled by default.
Source: https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/publishing_an_application/part_1_-_preparing_an_application_for_release/#AOT_Compilation
As for obfuscation, Xamarin.Android does not support obfuscation out of the box. You will need to use a third party obfuscation tool like Dotfuscator. They have a tutorial on this here.
Many people think Proguard will obfuscate their code in a Xamarin.Android project, but it only works on the Java end.
The Xamarin.Android ProGuard configuration does not obfuscate the APK, and it is not possible to enable obfuscation through ProGuard, even with custom configuration files. If you wish to use obfuscation, please see Application Protection with Dotfuscator.
Source:
https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/publishing_an_application/part_1_-_preparing_an_application_for_release/#ProGuard
AOT in Xamarin:
It depends whether you are targeting Android or iOS.
As #Jon Douglas states in his answer, Android AOT in Xamarin is unfortunately currently limited to Enterprise licenses. (tip: You can test out this Enterprise feature using a limited-time Enterprise license trial.)
iOS AOT in Xamarin, on the other hand, is part of every iOS build, so you get it with the Community license for free. Note however, that the full .Net assemblies are still included in iOS release builds, so that defeats the purpose of AOT "obfuscation" in iOS. :/
Obfuscation:
ConfuserEx is a great .Net open-source obfuscator with an MIT License:
https://github.com/yck1509/ConfuserEx/
I still haven't tested ConfuserEx end-to-end in a Xamarin app, but it looks promising so far... (Beware, as many people point out, ConfuserEx is a little "confusing" to use...)

Manually adding .NET 4.5 scripts to Unity: Potential issues?

I've recently had to some work in Unity that required classes only available in the later versions of .NET, which Unity does not yet support. I managed to download the very few scripts that I was missing and added it to my project and it seems to work fine. What I wanted to know is why can I not just take the entire .NET source and shove it into my projects? What are the implications of doing something like that?
EDIT: The scripts that I have added so far was the generic version of WeakReference as well as any dependencies that it needed (Contract in System.Diagnostics.Contract).
EDIT EDIT: I basically want to know why I can't simply just the C# class files found in the later versions of .NET to Unity, which uses an older version of .NET. Is it a software issue? Is it a hardware issue? Is it because Unity's system components were built in correspondence with the earlier version of .NET?
SHORT ANSWER:
Install the Visual Studio Tools for Unity (it should automatically get installed when you install Unity), when you do you can tell your .csproj in the "target framework" drop-down to target the special version of .NET Unity uses and you will only be able to compile dll's that have methods and types that Unity supports.
LONG ANSWER:
It is because Unity does not use the installed version of .NET on your computer. Unity uses Mono, and a very old version at that. This allows unity to be ran on multiple platforms and OSes. Because of that you can only use features that are in the supported version of Mono.
However, if you look at their roadmap the alpha build you will see
Scripting: C# Compiler Upgrade
Upgrade Mono C# compiler against our
current .Net 2.0 and 2.0 Subset profiles. Note that this is an upgrade
of the C# compiler only, not the full Mono runtime
Then further on in the "research" phase
Scripting: .NET Profile Upgrade
Upgrade .Net profile to 4.6 enabling access to the latest .Net functionality and APIs.
UPDATE:
You can get a experimental build that uses the 4.6 profile from the stickied post here.
Here are the notes for the 5.6.0b5 beta release
For this release, the Editor and the following players should be working:
Windows, OSX, Linux standalone
iOS with IL2CPP
Android with IL2CPP and Mono
Other platforms are known to not work yet, and are probably not worth installing.
Managed debugging via Visual Studio Tools for Unity or MonoDevelop is not supported in this release. If you want to use VSTU for
editing please use the special build linked at the bottom of this
post.
The compiler targets the C# 6 language.
The compiler by default will still target the .Net 4.6 framework profile.
Known issues
The Android/Mono build does not work properly with managed code stripping. Please disable managed code stripping for now.
For some projects, the Windows standalone player can crash on Windows 8.1. This is intermittent, so we would love to see any crash
reports or data about this
A similar question was answered before here. Like I described in your other question, you can "inject" newer stuff and use them, but sooner or later they'll backfire (e.g. can't compile to particular systems, can compile but cannot be published in whatever mobile store, surprisingly slow execution, huge builds, etc. Worst case your project will be compromised).
If you really cannot refactor the project you are working on and you feel you must use 'up-to-date technology', bear in mind the injected classes code must be data objects, means, not at all related to GameObjects.It is also adviced to derive from ScriptableObject when and where possible.EDIT: But I'd recommend what I told you earlier (refactor) or what the linked answer describes ('export' the code incompatible with mono/.net2.0 to an external dll and use it from there)

Using async-await on .net 4

I'm currently starting to create an application that would profit a lot from C# 5's async-await feature. But I'm not sure which version of VS and of the async runtime to use.
Looking at OS popularity charts, I'll need to support Windows XP for another three years or so. It looks like .net 4.5 runs only on newer versions of Windows, so I need to target .net 4.0. The development machines use Windows 7, so using a newer version of VS is not a problem.
Now I need to first choose a compiler for doing this:
VS2010 with AsyncCTP
VS2012 Preview (and final once it arrives), setting the target to .net 4.0
Mono (Looks like 2.12 has async-await, I prefer/am used to VS over MonoDevelop as IDE)
Which one has fewer code-gen bugs? Looking at Jon Skeet's blog the VS2012 Preview uses a never code-generator than the CTP.
And more importantly which runtime to use?
Does VS2012 contain a redistributable async runtime for use with .net 4?
I managed to compile code, with the preview, by referencing the AsyncCTP runtime. But since the CTP has strange licensing conditions, that doesn't look like a good long term solution.
Or should I use a third party implementation? Perhaps mono has one?
For distributing the library I prefer simply putting the dll in the same directory as the application, instead of some kind of installer.
I'd also like it if my binaries would work without changes on mono+Linux/MacOS. So the runtime should either be compatible with whatever mono (2.12 probably) has built in, or allow use on non windows OSs.
Microsoft released the Async Targeting Pack (Microsoft.Bcl.Async) through Nuget as a replacement for the AsyncCTP.
You can read more about it here: http://blogs.msdn.com/b/bclteam/archive/2013/04/17/microsoft-bcl-async-is-now-stable.aspx.
You can read about the previous version here: http://blogs.msdn.com/b/lucian/archive/2012/04/24/async-targeting-pack.aspx.
As this pack is officially supported, I now believe the best option for targeting XP + async would be using Visual Studio 2012 + C#5 + Async Targeting Pack.
If you feel the need to target .NET 3.5 though, you can still use (my) AsyncBridge for .NET 3.5.
If you are open to considering other .Net languages, F# can solve your problem. It has had the async{} computation expression for years, and is backwards compatible even with .Net 2.0. Minimum requirement is Windows XP SP3. The runtime can be downloaded here.
It's possible to use the VS 12 beta to target .NET 4.0 using async/await.
You need to copy some code into your project that provides the types that the compiler relies on.
Details here
Edit: we've taken this technique and turned it into a open source library called AsyncBridge:
https://nuget.org/packages/AsyncBridge
If you want to be able to distribute your software, I think that the Mono solution is really your only option right now. You also say that you want the end result to run on Mono over Linux and OS X. Targeting Mono to begin with seems like the natural solution.
Your next issue is the IDE. MonoDevelop would obviously work well but you say you prefer Visual Studio.
Greg Hurlman created a profile to code against Mono 2.8 from Visual Studio. If you follow-up with him, he might be able to point you in the right direction for developing against Mono 2.11/2.12 in Visual Studio.
Of course, there is also Mono Tools for Visual Studio which is a commercial product. I assume that it is still being offered by Xamarin.
You might also be able to run the required 4.5 profile assemblies from Mono on top of .NET but I have not tried that. The 4.5 profile is a strict super-set of the 4.0 API. Perhaps give it a shot and report back.
EDIT: It looks like perhaps you can use the Visual Studio Async CTP in production now
Here is what it says on the download page:
Includes a new EULA for production use. Note - This license does not
constitute encouragement for you to use the CTP for your production
code. The CTP remains an unsupported and use-at-your-own-risk
Technology Preview. However, we’ve received many requests from
developers to use the CTP for production code, and so have changed the
license to allow that.
If you want to start distributing your software after MS releases C# 5.0, then you can start developing using AsycnCTP.
Otherwise I wouldn't recommend you to use it, as it is just CTP, not even a beta. It can be changed a lot close to the beta stage and to the release. It may be unstable, etc.
If you want to introduce easy async operations in your application I would recommend you to use Reactive Extensions and stuff built on top (Reactive UI, etc), it is just beautiul.
As for VS2012, it also contains the same Async CTP as far as I remember from my //Build/ tablet MS gave me on that conference.

MonoDevelop in windows

Is there a version of Monodevelop that runs on Windows? If so where can I get it?
MonoDevelop officially supports Windows since 2.2. You can check the what's new in Monodevelop 2.2 or download the last release.
Windows Support
Windows now Officially Supported
Windows is now an officially supported
platform for running MonoDevelop. Many
Windows specific issues have been
fixed, and some add-ins such as
debugging and subversion support have
been written specifically for Windows.
Windows Installer
We are releasing a new Windows
Installer which includes almost all
you need to run MonoDevelop. The only
external dependency is gtk#, which is
provided in a separate installer.
It looks like you can build it and run it on Windows, but I don't think there is a binary download available yet. From the docs, here:
Does MonoDevelop work on Windows?
Yes. MonoDevelop can be built and run
on Mono on Windows, although it is
still unstable and some features may
not be available. We are currently
working on a Windows installer that
will be soon be available.
There are no precompiled binaries, so you'd have to build from source. Even then, there seems to be some stability issues running MonoDevelop on Windows (see here).
Some alternatives would be SharpDevelop and/or Visual Studio Express.
Update: MonoDevelop version 2.2 and higher officially supports Windows. You can get the latest version here: http://monodevelop.com/Download
There is currently no official release of Monodevelop for windows. After researching it a little bit, it seems that MonoDevelop was started as a port of SharpDevelop which is an open source .Net IDE for windows. Perhaps you may want to look into SharpDevelop and see if it meets your needs.
You can find out more information at the SharpDevelop website:
http://www.icsharpcode.net/OpenSource/SD/
You can specifically target the Mono framework when writing apps in SharpDevelop (something you can't do with Visual Studio Express). I should have pointed this out in my answer above. From the website:
SharpDevelop has the ability to
compile your code against previous
versions of Microsoft's .NET
Framework, Microsoft's Compact
Framework or Mono (an open source
implementation of the .NET Framework
sponsored by Novell) if they are
installed.
The easiest way now to get MonoDevelop is running openSUSE Linux under VirtualBox. It's really no so hard. You will get "real" linux system with Mono & MonoDevelop running on it without any issues. Hope this helps.
There is not currently binaries available for MonoDevelop for Windows. This is because it has not been tested and is extremely buggy. Ie: you will probably not get more a minute or two of use before it crashes. Hopefully with MD 2.0 now out, this is something we will soon have time to address.
Note that you do not need MonoDevelop to use Mono. You can use the same binaries produced from Visual Studio or SharpDevelop on Mono.

Feasibility of C# development with Mono

Recently, I came across Mono and MonoDevelop packages in Ubuntu linux. They claim to have a .NET runtime in accordance with CLI. Before installing the packages myself, I would like to know the following:
How powerful is Mono?
Can I develop GUI application for
linux like developing WinForm
applications for Windows.
Is MonoDevelop IDE compatible with Visual Studio IDE. Can I import VS 2008 solutions to MonoDevelop and work?
Does it support .NET 2.0 and above?
EDIT: Adding one more doubt
Is there any way to run the .NET exe (of a winform app) in Linux without building the cod e in linux? In fact I don't have the code for some of the small utilities I developed earlier and would like to run them in linux.
(Strange, markdown starts the enumeration with one, even though I began with 2...)
Yes, you can, but you're limited with 3rd-party components, because the internal implementation is different, and last time I checked (not very long ago), the Mono WinForms implementation made my test app look rather strange (owner-drawn list view). It is not really recommended, though Mono claims that it's now completely WinForms-2.0-compatible.
MonoDevelop is/was a SharpDevelop branch, with the latter having solution support. I don't know if MonoDevelop has. But the cool thing is, you can just develop with Visual Studio and run your compiled apps on Mono. And Mono is, by the way, also available for Windows.
Yes, it does, as far as the CLR goes. As Marc Gravell already wrote, the Windows Foundation libraries are missing, as are a few other (System.Management, for example). But things should mostly work, including ASP.NET 2.0. Mono's application portability guidelines are a good read on this.
1: pretty good, actually. Not all the full framework is there, so if you are writing code that should build on both MS .NET and mono, you need to build and test early against both platforms
4: yes - although things like WPF/WCF/WF (3.0) are missing or slimmed down
I don't know much about the development environment, since I use VSTS (on Windows) and just use a NANT script to do the build on mono...
Define "powerful".
Mono has a WinForms implementation to allow for some level of source compatibility. However, depending on your needs, you might want to use one of the Mono bindings for a Linux native framework, like Gtk# or Qyoto
Wouldn't know.
Depends on what parts of .NET you mean. C# the language seems to be pretty current, things get fuzzier the closer you get to the enterprisey features as was already mentioned.
To sum things up, if you'll be using Mono as a separate target platform, you're likely to have good results. If you want a no-code-changes-required .NET compatibility layer, less so.
Very powerful. There are no major bugs in the core implementation. It is not a science project. The deficiencies are mostly where you would expect, the newest APIs (Microsoft inherently has a first-mover advantage there).
Yes. We just finished a project where most of the GUI code was developed in WinForms on Windows. I was able to work on it using Ubuntu without major headaches. That said, this is one of the hardest parts of the API, and there are still issues. See http://mono-project.com/WinForms for details.
Don't know, as I don't use it.
Yes, though again, there may be some missing APIs in the runtime.
Note, I use Ubuntu Hardy (8.04).
Mono is mighty powerful. It has all the .Net muscle on a very strong open source skeleton.
When you say "develop GUI application for linux like developing WinForm applications for Windows" I understand that you are asking about a visual designer that will allow you to quickly create the UI. Yes, it is possible. MonoDevelop has Stetic - a built-in visual designer for Gtk#. There is also QyotoDevelop which enables QT support in MonoDevelop.
Yes, MonoDevelop natively supports VS project/solution file format. You can use the same code base to compile your app with VS in .Net on Windows and win MD in Mono on Linux.
Currently Mono supports C# 3.0 with some stuff beyond that already implemented and a lot in the pipeline.
Yes, in many cases it is possible to run a .Net compiled app in Mono, however with MonoDevelop's support for VS solutions it doesn't really matter. It takes as much as pressing F7 to rebuild the whole project, so the effort is really negligible. The best tool for checking if your application can run in Mono is MoMA.
Mono is very powerfull, sometimes even more powerfull than Microsoft's implementation. link text
Yes you can. Winforms 2.0 is supported
I believe so.
Yes it does. C# 3 is supported and just look at winforms and the asp.net implementation to see how much is supported from each of the projects. Look at http://mono-project.com
I use WinForms in mono. The 2.x releases are very good.
I develop forms in visual-studio on windows, and run them in Linux, with zero code changes. Yes, forms look a little different than on XP, but then again, an XP-themed GUI would look kind of strange in GNOME.
If you are just getting started, stick with WinForms, while you get comfortable with Mono/Linux. However at some point you might want to investigate GTK.

Categories

Resources