Existing C# 6 users

Hello Unity, just wanted to make sure you all were aware of alexzzzz’s existing wrapper for the Roslyn compiler:

https://bitbucket.org/alexzzzz/unity-c-5.0-and-6.0-integration/src

and SaladLab’s Unity C# 6 incremental compiler:

https://github.com/SaladLab/Unity3D.IncrementalCompiler

I have not used the incremental one but I’ve been using alexzzzz’s wrapper for a few months now and have had no issues with it. FYI, both Visual Studio and Resharper can currently be set to use C# 6 but target .NET 3 without any issues.

I hope Unity gives Roslyn some serious consideration… I know you guys like to make custom versions of everything but it’s good to leverage existing solutions where possible. I still don’t really understand why you need to write your own .NET compiler when IL2CPP is supposed to handle IL (it’s in the name!) and so should be compiler-agnostic.

1 Like

@makeshiftwings

Thanks for the information. We’ve actually looked those projects a bit - they look pretty nice.

To clarify, we’re not shipping a custom C# compiler. We ship the Mono C# compiler, and in fact we’re upgrading to the latest Mono compiler (the one released with Mono 4.4) for the next version of Unity. You can try out that compiler with a 5.3.5p8-compatible build of Unity here:

Although that compiler has full C# 6 support, we’ve not enabled it yet since some other tools in the Unity ecosystem can’t handle C# 6. We’re working to update those tools, and we plan to support C# 6 when everything is ready.

Indeed, IL2CPP is C#-compiler agnostic, so it really doesn’t have any impact on the C# compiler upgrade.

3 Likes

And I’ve just realized this thread was posted in the experimental scripting previews section already, so hopefully I did not just restart what Jonathan has already mentioned.

@makeshiftwings Let me know if I’ve totally missed the point of your comments, sorry about that.

Ah ok, I got the impression you were making a branch of the Mono C# compiler specific to Unity. Though still, it sounds like the Mono C# Compiler is not going to be around for much longer, since Mono has been working to adopt Roslyn and will be dumping their own compiler eventually:

http://tirania.org/blog/archive/2015/Jul-21.html

Roslyn already works pretty well with the Mono runtime and it’s going to be the main C# compiler for all platforms in the not too distant future, so it would seem wise to try to integrate Roslyn rather than the Mono compiler. Though I’m sure there are other factors that I might not be aware of.

1 Like

@makeshiftwings

Actually, we are planning to use the Roslyn compiler, via the Mono project! So as Mono moves to Roslyn for its C# compiler, at some point a stable version on Mono will be released that uses Roslyn. We plan to upgrade to that version of Mono (and future versions in general, not just that version), so Unity will get the Roslyn compiler.

Internally, we’ve done some early testing with Roslyn, and the results are good. The various .NET runtimes Unity uses all seem to work with it (at least with our test cases).

6 Likes

Perfect! Thanks for the info. :slight_smile: That’s the direction I was hoping for.

Really glad to hear the progress! Well done!

Just curious, why not go directly with Roslyn then?

1 Like

There’s at least one problem with Roslyn. It can’t generate .mdb/.pdb debug information files on MacOS. .Mdb is not supported and .pdb is tied to Windows only.

Roslyn can write “portable pdb” on Macs but it’s a pretty new standard that is not compatible with the current tool chain. So, you can compile C# with Roslyn on MacOS if you want, but can not debug it.

4 Likes

@00christian00

Besides what @alexzzzz mentioned about portable pdbs, it was simply easier to integrate the new Mono compiler, as we already have an existing Mono compiler integration. That allowed us to focus on issues related to the actual compiler more so than the integration tasks, and get something shipped earlier.

With that said, we’re looking closely at C# 7 (and working with Microsoft on a few design issues). So depending on the time lines, we might see Roslyn integrated directly. But it is too early to talk about anything real now.

2 Likes

While I wait for this to become license unrestricted I tried the one above with incremental build and it’s saving a ton of time in compilation time, while there wasn’t that much difference with normal roslyn.
Can Mono also enable incremental builds?
And Is this something that could be implemented also:
https://www.infoq.com/news/2011/12/Mono-for-Android-4
Uploading only a delta to the device would speed up testing A LOT!

@00christian00

The version of the Mono C# compiler we’re shipping now doesn’t have the same incremental capability that Roslyn does, so we can’t ship that. But it is certainly something we’re looking at. Likewise the partial package stuff for Android is pretty cool. It is not a current target for us, but I think as we move to the new Mono, this kind of thing will be much easier to integrate.

1 Like

Is there any link that i can learn what benefits c# 6 will bring to us ?

3 Likes

Is there any update on C# 6+ from Unity Tech?

Are we getting closer? This is 2017 now :slight_smile:

@Xtro

You can use C# in the Editor using the latest preview build with the new Mono runtime:

We’re currently working to prepare a new preview build with a number of fixes and support for players as well. We’ll post in this forum section when that is ready.

1 Like

I think you meant “you can use C# 6+”.

Well, that’s great news. Thank you :slight_smile:

Yes, C#6 is what I meant, thanks!

1 Like

OMG wait!! This is not just C# update. This is .NET upgrade!!! Can’t belive this!!!

I have been using C# 6 in Unity via pre-build dll’s for a long time but now having the option of .NET 4.6!!! Can’t belive it !!!

1 Like