[FREE TRIAL] Unity C# 6.0 Compiler

NO LONGER A SUPPORTED PRODUCT

edited by moderators.

We believe that Unity developers deserve to have access to the newest development tools. That’s why our team worked hard on integrating the newest Microsoft Roslyn compiler into Unity.

C# 6.0 brings developers many new and exciting features. Another added benefit is improved compilation time provided by the newest C# compiler.

This tool works by redirecting compilation requests from within Unity to the newest Microsoft Roslyn compiler. Compiled code is compatible with .NET 3.5 and is guaranteed to work on most platforms.

Supported deployment platforms:
Windows, Mac, Android, iOS. Webplayer is currently not supported. Other platforms may be supported, but weren’t yet tested.

Although produced binaries will run on the above mentioned platforms, current version of this tool works only on Windows. C# 6.0 code won’t currently compile on Mac OS.

Supported new language features:

String interpolation:

$"GameObject name: {gameObject.name}"

Expression-bodied members:

public string FullName => $"{FirstName} {LastName}"

Default values of auto properties:

public string FirstName {get; set;} = "John"

Null-conditional ?. operator:
Partially supported, currently not supported with components inherited from Object as it overrides the equality (==) operator. Regular C# types are supported.

material?.Shader?.Name?.Length

Using static classes:

using static Math;
...
float sin90 = Sin(90f);

nameof expressions:

Debug.Log($"name of variable is {nameof(someVar)}")

Dictionary initializers

public Dictionary<string, string> CountriesList = new Dictionary<string, string>
                             {
                               ["ca"] = "Canada",
                               ["us"] = "United States",
                               ["uk"] = "United Kingdom",
                               ["ch"] = "China"
                             };

Features not supported:
Async/Await
Dynamic data types

Current version is 1.07 (released on April 10th 2015):

  • Improved logging

  • Fixed concurrency issues

  • Fixed uninstallation bug

  • Fixed missing debug information bug

The tool can be purchased at: http://www.unityninjas.com/downloads/unity-c-6-0-compiler/
The price is $25.

__**A free fully-featured 30-day trial is now available at: http://bit.ly/CS6TRIAL**__

Please send bug reports to goldenzebrasoftware@gmail.com instead of posting them in this thread. This will help us to fix the bug faster, and will make the forum thread easier to read. Thank you!

14 Likes

I’ll answer a few questions about the tool:

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.

Can you give us a preview of the price? :slight_smile:

Missing ETA and price. :smile:

this looks quiet interesting. Any link for the assets store?

Thank you! This is awesome. Is Mac support planned for the (near) future?

I’m also wondering about Mac support.

Thanks for the codes, claimed one. I’ll be happy if it eventually gets async and await support since those are some my most used newer .net features not available in 3.5

Cool, very interesting to see it in action. :slight_smile:

Yes, I’m planning to add Mac support as soon as Mono updates their MCS compiler. Current version doesn’t support all of C# 6.0 features: c# 6.0 - C# 6.0 String Interpolation in Mono MCS - Stack Overflow

1 Like

I saw your post in the other thread discussing C# 6. I just used a code to download it and see how it goes!

sweet and thanks for the free key that i can use to play with… :slight_smile:

if its checks out i’ll be happy to buy a key when it hits the unity asset store!

cheers!

I’m very impressed! Yesterday it worked flawlessly all day; though I have hit a bug this morning. Unity crashed saying that mono.exe had crashed, now any time I open my project I get this error:

(Edit: This bug was later fixed)

I tried deleting that settings.xml file and it recreated it but it still gets the error. It also seems that while I have this error, it is unable to compile my Plugins and Plugins/Editor projects, so the assets in those folders aren’t working.

I tried uninstalling the compiler in order to reinstall, but the uninstall fails with this error:

Though, looking in my Unity folder, smcs.orig.exe is actually there, so I’m not sure why it can’t find it. Reinstalling without uninstalling didn’t fix anything.

Edit: Some more info - I tried importing into a different Unity project and it worked fine, so something became corrupted in this project. I tried deleting the entire Library folder and rebuilding it but that didn’t fix it. I’m guessing that that error message about being unable to access the settings.xml is actually a false error, since other projects can access that file fine, and the file does get recerated if I delete it. I think what’s actually happening is that it’s crashing when trying to build the CSharp.Plugins.Editor project, because the log shows that it builds CSharp.FirstPass and CSharp but then stops. I don’t know what would have suddenly corrupted it because I haven’t changed anything in the Plugins folder all day and it just crashed suddenly while I was working on a cs file in the regular CSharp project.

Edit: One last edit. I was right and it was the Plugins/Editor project failing to compile. Finally fixed it by temporarily removing the Plugins/Editor and StandardAssets/Editor folders. That caused it to wake up and finally try compiling again, getting errors of course that the editor files were missing. Then I copied the Plugins/Editor and Standard Assets/Editor folders back in, and this time it recompiled with no error. Very strange.

The error above happened twice more, and with the same solution… the Plugins/Editor project would not compile until I removed all the Plugins/Editor folders, let it recompile, and then moved them all back in again.

One other thing I noticed that there may not be a way to fix: null propagation doesn’t work with Unity components or MonoBehaviours. This is because Unity actually overloads the == operator on all components so that when you do (something == null) it actually checks to see if it’s been assigned in the editor instead, since the values are never actually null. Apparently null propagation checks for null some other way, so it will just throw a “You must assign this value in the editor” exception when the component is null (or fake-null as it may be). Example:

public class SomeClass : MonoBehaviour {
    public MeshRenderer foo;

    public void Start() {
        foo?.DoSomething();  //throws exception if foo is "null", not assigned in the editor
    }
}

Damn, missed out!

The Sharing violation error is happening a whole lot, on both settings.xml and the log file. I figured out I can fix it by just forcing it to recompile a bunch of times by changing files, but it’s suuuuper annoying. I changed my mind about it being specifically related to Plugins/Editor and I think rather it’s just related to how long it takes to compile everything. I’m guessing maybe you guys are trying to read/write to the settings and log files from multiple threads at the same time? That’s a bad idea. :wink:

It seems I no longer get file names and line numbers reported in stack traces (in the Console window). To get some debugging done, I tried to uninstall the CS6 plugin and ran into the same “Compiler backup not found” error that makeshiftwings had, even though the file was indeed there. I manually restored the backup smcs and gmcs files and everything seems to be back to normal.

So, bug report:

  • Stack traces are missing from console log, presumably because debug information is missing?
  • Uninstall of CS6 plugin fails with Exception: System.InvalidProgramException: Compiler backup not found at path ‘Editor\Data\Mono\lib\mono\unity\smcs.orig.exe’

I’m running with Unity 5.0.1f1 and Visual Studio 2015 Tools for Unity 1.9.8.0 on Windows 7 x64.

[ EDIT: Bugs are fixed now. ]

All of the mentioned bugs have been fixed. Send me a PM/email to get the newest version (1.06).

I can confirm all my issues were fixed with the v1.07 update. Thanks!

The locked file bug seems to be fixed with the newest update. Thank you!