What do you guys think?
I think “Roslyn” requires .NET Framework 4.5 and Unity’s Mono is restricted to .NET Framework 2.0/3.5. … yes ?
I imagine this will lead to some discontent with Unity because C# 6.0 has some great features in development.
I hope, due to the cooperation between Microsoft and Mono to make the .NET Framework open source, that with Unity 6 or so the latest version of .NET will be implemented. Fingers crossed.
I think C# 6.0 is awesome, just like I thought C# 5.0 was awesome and C# 4.0 was awesome, but unfortunately Unity is still on the decade-old C# 3.0, and not even a full implementation at that.
Yeah I think 6.0 has some great new features. I really like the is null operator (?). Gonna make things much nicer.
Once IL2CPP is really ready for prime time and being used for all platforms we will almost certainly see a major .net version upgrade. However, mono is still necessarily currently to allow the editor to work on platforms like IOS. So, with mono always being behind, c# 6 features are highly unlikely anytime in the foreseeable future.
Mono’s nowhere near as far behind as Unity always is. Mono already has a preview C# 6 compiler available. Keep in mind Microsoft’s own C# 6 compiler hasn’t officially released yet either.
[FREE TRIAL] Unity C# 6.0 Compiler - Community Showcases - Unity Discussions no?
Or am I missing something - this is about official support? is it? or just getting it however…
I read all the posts, as usual, this only helped so much ![]()
Evidently not as far as it used to be. I haven’t kept up as much on mono news.
Hmmmm, interesting. I’d be really hesitant to have my entire codebase reliant on an Asset Store plugin but I’d check it out. It’s still not quite as good as having an actual Mono upgrade since it has to convert everything to .NET 2 IL, so it wouldn’t be able to support async or dynamic. It would also be a pain getting Resharper to understand which parts of C# 6 were available and which weren’t. But it’s a good idea; I hope they succeed.
Hi everyone, I’m the developer of C# 6 compiler for Unity.
I’ll try to answer some questions.
We’re using Microsoft Roslyn compiler, and it runs independently from Unity (it’s a standalone application). It’s not bound to Unity’s Mono platform. Roslyn is capable of producing .NET 3.5 code.
It’s possible to use C# 6.0 in Unity, because language version is mainly independent from the runtime version. Almost all features of C# 6.0 are supported, except for Caller Information.
Mono MCS compiler doesn’t yet support all of C# 6 features, that’s why Roslyn is used in our tool.
Resharper support - we use Resharper for all of our development in-house. It works flawlessly with C# 6.0, we haven’t yet encountered any issues. The compiler tool has also been extensively tested, and is able to compile huge codebases without any issues.
The tool doesn’t interfere with the compilation process in any way. It simply redirects compilation requests from Unity to Roslyn, and adds a few command line arguments to target .NET 3.5.
We’re offering a few free licenses of the tool this week, send me a PM for a free copy.
nice try, aprils fool ![]()
No he’s serious. He posted a thread about it.
I’m already using it, enjoying string interpolation, nameof and “Elvis operator” ?. for null propagation in monadic way. However, no dynamic via DLR; and no async/await since we’re restricted to .NET 3.5.
But language C# 6.0 itself is NOT restricted to .NET vNext! You can target .NET 3.5; generated code is compatible with ancient CLR. You can decompile it with dotPeek and see, how actually C# 6.0 syntax sugar can be expressed in C# 3.0 terms. Except dynamic of course, and new classes in standard library.
Unfortunately, Unity Editor is stuck with old language and runtime. So we need to precompile our logic code to assembly and then use it as usual managed plugin. On the other hand, this separation gives as possibility to develop Unity agnostic library for core game logic and use it in context with not Unity at all: e.g. server side, or console runner, or automatic tests.
Not entirely true
The tool we have developed enables developers to use C# 6.0 right within Unity, without resorting to third-party compilers.
no dynamic - true
no async/await - false
no caller information attributes - false
Async/await is a syntax sugar, a C# 5.0 compiler feature, not the CLR 4 feature. It just relies on some types that come with .Net Framework 4/4.5 base class library. However, these types are available under CLR 2.0 as well. Have a look at AsyncBridge, it’s been there for three years already.
The same is true for caller information attributes and these attribute types are also included in AsyncBridge.
It looks like both async/await and caller information attributes work fine in Unity. I checked it yesterday using the standard MS C# 5.0 compiler.
The only restriction we have - we have to use CLR 2.0. I have no idea why Unity is stuck to the old Mono’s compiler, while the modern Mono’s C# compiler supports all the fancy language features and still can target CLR 2.0.
One word…
Xamarin
Thanks for the idea, I’ll take a look at the AsyncBridge project, and will see if it’s possible to integrate it into our Unity C# 6.0 compiler.
As for the older CLR used by Unity - looks like they’re having some licensing issues with Xamarin. They have a license for the old version of Mono. Another difficulty with upgrading to a newer CLR lies in Unity using a custom version of Mono. It is not possible to simply swap the older version of Mono runtime with the newer one - Unity made lots of changes to the CLR. Theoretically it should be possible to merge the changes made by Unity into the newest Mono runtime (the sources are open, and available on GitHub), however this would require a tremendous amount of work.
There’s no integration needed. It’s just a couple of libraries you drop in your project and async/await and caller information attributes start working, if you use a decent compiler of course.
Unity already has a compiler that supports C# 5.0. It just doesn’t use it.
H:\Program Files\Unity\Editor\Data\MonoBleedingEdge\lib\mono\4.5>mcs.exe -?
Mono C# compiler, Copyright 2001-2011 Novell, Inc., Copyright 2011-2012 Xamarin, Inc
mcs [options] source-files
--about About the Mono C# compiler
...
-langversion:TEXT Specifies language version: ISO-1, ISO-2, 3, 4, 5, Default or Future
...
-sdk:VERSION Specifies SDK version of referenced assemblies
VERSION can be one of: 2, 4, 4.5 (default) or a custom value
...
Yeah, and why doesn’t it use it?
Xamarin, the company that licenses Mono, charges to use it on embedded systems and other things (which unity wants to support):
http://xamarin.com/licensing
Xamarin wants more money than Unity is willing to pay to upgrade their license to the latest version.