New in Mono 3.0

Release date: 19 Oct 2012

Mono 3.0 is a portable and open source implementation of the .NET framework for Unix, Windows, MacOS and other operating systems.

Mono 3.0 is an update to Mono 2.10 based on the master branch of github, it is not a minor upgrade to 2.10. Mono 3.0 was released on October 18th 2012.

We will continue to bug fix and update Mono 2.10 for another six months for users that can not upgrade to Mono 3.0.

Major Highlights

C# Compiler

Mono now has a complete C# 5.0 compiler with asynchronous programming support.

Our C# compiler has now completed its migration from using System.Reflection.Emit as its code generation backend to use the IKVM.Reflection API. This functionality was previewed in Mono 2.10 and is now the default. With this functionality, developers can use any mscorlib that they want (for example the MicroFramework one, or a custom one) without having to build a custom compiler. We were able to eliminate the multiple executables for the compiler, and unify all the compilers into one as well as reducing our build times significantly.

gmcs, dmcs and smcs are now merely aliases to call the mcs compiler with the proper -sdk flag.

Tool/Library

Purpose

Profile

New Backend

2.10 Backend

gmcs

C# Compiler

2.0

IKVM.Reflection

System.Reflection 2.0

dmcs

C# compiler

4.0

IVKM.Reflection

System.Reflection 4.0

smcs

C# Compiler

2.1 (Silverlight, MonoTouch, MonoDroid)

IKVM.Reflection

System.Reflection 2.0

mcs

C# Compiler

Any profile, any mscorlib

IKVM.Reflection

IKVM.Reflection

csharp

Interactive C# Shell/REPL

4.5

System.Reflection 4.5

System.Reflection 4.0

Mono.CSharp

C# Compiler as a Service

2.0, 2.1 and 4.0.

System.Reflection 4.0

System.Reflection

System.Reflection is still used as a backend for the compiler as a service and the C# interactive shell.

Evaluation can now Compile Types

The Evaluator.Eval () API is no longer limited to expressions and statements, you can now pass entire namespace, class, interface, struct definitions as a string and have the result get compiled.

This extends to the csharp command:

csharp> class X { public int a; }
csharp> var t = new X () { a = 1 };
csharp> print (t.a);
1
csharp>

Instance API

The compiler as a service exposed by the Mono.CSharp library is no longer limited to be a global compiler, now you can instantiate multiple scopes for the compiler, each having its own set of localized types and global variables.

For example, the following sample assigns a string in one context and an int in another one:

using System;
using Mono.CSharp;
 
class MyWorld {
       public Evaluator Evaluator;
 
       public MyWorld (string [] args)
       {
               var r = new Report (new ConsoleReportPrinter ());
               var cmd = new CommandLineParser (r);
 
               var settings = cmd.ParseArguments (args);
               if (settings == null || r.Errors > 0)
                       Environment.Exit (1);
 
               Evaluator = new Evaluator (settings, r);
       }
}
 
class X {
       static int Main (string [] args)
       {
               var first = new MyWorld (args);
               var second = new MyWorld (args);
 
               first.Evaluator.Run ("var Demo = \"hello, world\";");
               second.Evaluator.Run ("var Demo = 1;");
               first.Evaluator.Run ("print (Demo);");
               second.Evaluator.Run ("print (Demo);");
               return 0;
       }
}

C# Interactive Shell

New convenience function print, can be used instead of Console.WriteLine

Additionally, the C# interactive shell will by default use a terse syntax that does not require a semicolon at the end of an expression, for example:

csharp> 1 + 2
3
csharp>

4.5 Profile

The 4.5 Profile is a strict superset of the 4.0 API and is now the default profile.

Because 4.5 API is a strict superset of 4.0 API they both share the same assembly version number, so we actually install the 4.5 library into the GAC.

Some of the changes in the 4.5 API family include:

  • New Async methods
  • WinRT compatibility API
  • Newly introduced assemblies (System.Net.Http, System.Threading.Tasks.Dataflow)

New Microsoft Open Source Stacks

We now include the following assemblies as part of Mono from Microsoft’s ASP.NET WebStack:

  • System.Net.Http.Formatting.dll
  • System.Web.Http.dll
  • System.Web.Razor.dll
  • System.Web.WebPages.Deployment.dll
  • System.Web.WebPages.Razor.dll
  • System.Web.WebPages.dll
  • System.Web.Mvc.dll
  • System.Json.dll (Previously available in Mono, but now replaced with Microsoft’s implementation)

We also bundle the recently open sourced Entity Framework and

  • EntityFramework.dll

Garbage Collector

SGen now has a new task management system that allows it to easily scale new GC-related tasks across multiple CPUs if available:

  • SGen on SMP systems is able to distribute more work across the worker threads. Previously only the mark phase was distributed.
  • SGen is now able to perform parallel collection in the nursery.
  • SGen has been ported to Win32
  • SGen has been ported to the MIPS platform
  • Precise stack scanning has been improved considerably, and it is now supported on x86 and ARM.
  • On OSX, SGen now uses Mach APIs directly to speedup some tasks in the garbage collector.

Runtime Optimizations

Implemented fast version of ThreadLocal<T> (it is now a low-level intrinstic operation)

List<T> optimizations

Support for new attributes to force inlining.

Major change in Mono to support the full table of Unicode surrogate characters. This code was written by Damien Diederen and David Mitchell from Logos software.

Runtime supports deferred attaching to the process (when using suspend=n,server=y the runtime collects metadata until a debugger is attached).

Implement tail call optimizations on PowerPC for F# (Bug #664631)

New profiler that can be used with Intel’s VTune Amplifier Profiler.

Support for System.Net.NetworkInformation.NetworkChanged events on Linux.

New tool: crlupdate this is the Mono Certficate Revocation List Downloader and Updater and can be used to download of new, or update of existing, Certficate Revocation List (CRL) associated with the certificates present in the user (default) or machine stores. The CRL present in the stores are used to determine the validity of unexpired, trusted X.509 certificates.

ASP.NET

Bring the error page to the new millenium.

CodeContracts

Alexander Chebaturkin has implemented initial version of static Code Contract analyser as part of SoC 2011.

Smaller Updates

Partial support for Portable Class Libraries (details)

Updated Unicode tables, fixes long-standing 480178

MacOS X

We continue to expand significantly our support for MacOS X and iOS.

Mono can now be compiled by users as a 64-bit binary. Mono still ships as a 32-bit binary, as most libraries that exist today for Mono run only in 32 bits.

DriveInfo now returns correct information on OSX.

Mono.Data.Sqlite

It is now possible to configure the threading model for SQLite using the SetConfig method in the SQLiteConnection class.

Supports iOS crypto APIs.

C5 Library

We have updated the venerable C5 library to the latest version.

Breaking Changes Since Mono 2.10

In order to be compatible with Microsoft .NET’s behavior, exceptions thrown in object finalizers now cause a full runtime abort. This behavior was already present for thread pool threads, but hadn’t been enabled for the finalizer thread yet.

Generally, one should avoid exceptions in finalizers entirely. If you must use them, catch them so that they do not terminate the application.

GDB

  • GDB support has been extended with a new gdb hook that is aware of the SGenGC internals.
  • Added pretty printers for more runtime data structures like MonoVTable to the mono gdb mode.

MIPS port

The MIPS port is now complete, it can do a full bootstrap, and run the runtime/corlib test suites.

Soft Debugger

  • Single stepping is now implemented using breakpoints in most cases, speeding it up considerably.
  • Calls to System.Diagnostics.Debugger:Log()/Break () are now routed to the debugger using new UserLog/UserBreak event types.
  • S390x is now supported (Neale Ferguson).
  • MIPS is now supported.
  • Added new methods to Mono.Debugger.Soft and the runtime to decrease the amount of packets transmitted between the debugger and the debuggee. This significantly improves performance over high latency connections like USB.
  • Many bug fixes.

Static Compiler (AOT)

Made changes to some AOT data structures to reduce their size, especially when using generics. This reduces the size of an mscorlib AOT image by about 1-2%.

Many changes to the class libraries allow more core Generics code to run on systems that do not support JIT compilation.

Installing Mono 3.0

Binary Packages and Source Code Downloads:

Source code and pre-compiled packages for Linux, Solaris,
MacOS X and Windows are available from our web site from
the Downloads section.

Quick source code installation:

If we have no packages for your platform, installing from
source code is very simple.

Compile libgdiplus to support System.Drawing:

    $ tar xjvf libgdiplus-3.0.tar.bz2
    $ cd libgdiplus-3.0
    $ ./configure
    $ make
    $ make install

Then compile Mono itself:

    $ tar xjvf mono-3.0.tar.bz2
    $ cd mono-3.0
    $ ./configure
    $ make
    $ make install

Bug Fixes

  • mdoc update has been fixed so that -fno-assembly-versions and –delete interact properly, and delete XML types and members which do not exist in the target assembly. This allows copying e.g. corlib/Documentation/en, processing en against the Silverlight-profile mscorlib.dll, and removing all types and members which don’t exist in the Silverlight profile.