• ## „Compiler crashed with code 1“ on Mono

Update:
I opened a bug ticket for the described issue and it got fixed within the week.

Original post:
At work we recently stumbled across an interesting problem: While compilation of our C# 6 code base would work fine on Windows, a guy that works on OSX using Xamarin Studio suddenly was unable to compile the code, because „Error: Compiler crashed with code 1“. No line number, no nothing, only that.

After a run through git bisect we eventually were able to track down the commit where I found the error to lie within an await happening in a string interpolation. Sadly, this problem was introduced by simply (and automatically) refactoring all occurrences of String.Format() in the file.

I was able to reproduce the problem with the following simple code:

private async Task<int> Foo()
{
Console.WriteLine($"Something {await Foo()}"); }  Apparently, the mono compiler doesn’t like that too much. The solution to this is simple: Don’t await within the interpolated string. Instead, do it outside: private async Task Bar() { var foo = await Foo(); Console.WriteLine($"Something {foo}");