C# and .NET

Florian Rappl, MVP Visual C#

C# and .NET

Current and future developments

Future .NET

Florian Rappl

Writer and consultant

  • Microsoft C# MVP and CodeProject MVP
  • Active contributions to open-source projects
  • Company workshops, talks and IT consulting

Languages and technologies

  • C#, JavaScript and C/C++
  • Full web stack (client and server)
  • High Performance and Embedded Computing


  1. The .NET-Framework 4.5.1
  2. A glance at the Roslyn project
  3. The next version of C#
  4. Predictions and speculations
Here Now Sign

A little .NET history

  • 1.0 Initial release, 2002
  • 2.0 CLR update (Generics, x64), 2005
  • 3.5 LINQ, 2007
  • 4.0 CLR update (DLR) and TPL, 2010
  • 4.5 Windows Store apps and async/await, 2012

The .NET components

.NET components

.NET-Framework 4.5.1

  • Responsible for more productivity in VS 2013
  • Many implicit performance improvements
  • No new assemblies, one additional type
  • Two more interfaces
  • Many modifications and some new methods

Large Object Heap (LOH)

  • The GC distinguishes between large and small objects
  • A large object is bigger than 85000 bytes
  • The heap for large objects is not compactified by default
  • Therefore at some stage we could have unusable memory
  • With .NET 4.5.1 we can instruct the GC to compact the LOH

LOH scheme

Windows Store improvements

  • Streams can now be converted
  • Extension method AsRandomAccessStream available
  • WinRT nullable types in structures are now possible (WME1060)
  • Improved exception messages
  • Also many Visual Studio enhancements

AsRandomAccessStream (Windows 8.1)

// using System.IO.WindowsRuntimeStreamExtensions
var client = new HttpClient();
var stream = await client.GetStreamAsync(imageUrl);
var memStream = new MemoryStream();
await stream.CopyToAsync(memStream);
memStream.Position = 0;
var bitmap = new BitmapImage();
image.Source = bitmap;

Further enhancements

  • ASP.NET app suspension (new default mode)
  • Framework startup is faster
  • Improved memory management
  • JIT is better (especially for multi-core)
  • Finally: x64 edit is now possible in VS
  • Also return value inspection is now included

New ASP.NET app suspension

ASP.NET app Suspension

Example: DotNetNuke startup in seconds

Multi-Core JIT Performance

What is Roslyn?

  • Idea: Open the compiler
  • Instead of having a black box, we have an API
  • Build tooling and services upon this API
  • Roslyn is written entirely in C#
  • Prototyping new features should be faster

Roslyn overview

Roslyn Overview

Why this is a good thing

  • As developers we should care about this project
  • Much easier to create DSL, language services, ...
  • Also the C# compiler will be more robust and open
  • Finally we could use the API for rich interaction

The Roslyn SDK

  • Visual Studio 2012
  • Visual Studio 2012 SDK (here)
  • Roslyn September 2012 CTP SDK (here)

More information

The NuGet packages

  • Much easier to install
  • Cannot be used for writing VS extensions
  • Very useful for compiler services
  • Pretty much a portable compiler

Roslyn information tree

Roslyn Hierarchy


  • The CTP is already outdated
  • It should not be used for production code
  • Very useful for a first look
  • The API already changed a lot
  • Expect another CTP soon enough


  • Using C# as a scripting language is not new
  • However, scriptcs does this in a particular manner
    1. Using Roslyn for the job (very efficient)
    2. Providing an event loop like JavaScript (e.g. V8)
  • Together with e.g. Nancy we have similar abilities to node.js
  • It is very modular and using NuGet for resolving dependencies

Using scriptcs with chocolatey

  • A package manager for windows
  • Uses powershell / command line
  • Enables automated installations
  • chocolatey.org
  • Installing libraries
  • Referencing libraries
  • Including other sources
  • scriptcs.net
Next Sign


  • We will not see life changing features like await/async
  • However, subtle changes will improve the workflow
  • Some are inspired from other languages (Java, C++, ...)
  • Some changes are just great additions
  • The standard is still in movement

Property initializer

  • Before we could not use use a single get auto property
  • With property initializers this is now possible
  • Also other auto-properties can now be initialized very quickly
				public int AnswerToEverything { get; } = 42;

Primary constructor

  • Too often we need to write too much code
  • An example: Constructor that takes some parameters to set fields with the same name
  • C# will help us to write this with no effort
				class Point(int x, int y) {
					public int X { get { return x; } }

Enumerable parameters

  • The params keyword is great, but ...
  • ... it can only be used with arrays!
  • Therefore we cannot pass in LINQ queries - only results
  • Now we can also have params IEnumerable<T> constructs
				void Foo(params IEnumerable<int> numbers);

Using static methods

  • In Java we can import static methods of a given type
  • These methods behave as if they are defined in the current context
  • Now we can do the same, e.g.
				using System.Math;
				double Foo() {
					return Sin(PI);

Monadic null checking

  • Replace the member operator by another operator
  • Reason: Avoid nesting many null checks
  • Design problem: Result of chain?
  • Also we need a way for structures
  • For example they could be nullable<T>
				var d = a?.b?.c();

More features (?!)

  • Declare variables directly for out parameters
  • Generic class type inference
  • Derived property expressions
  • Method expressions
Future Sign


  • A complete new JIT compiler has been created
  • Goal: Improved performance, better architecture
  • Especially mobile (ARM) have been powered up
  • We get a better performance for free

Performance speedup with RyuJIT

RyuJIT Performance

Cross platform (Xamarin)

  • Microsoft is shifting towards cross platform
  • .NET will be the major platform for this
  • To support this .NET has to become native
  • Xamarin is doing a great job (MonoTouch, MonoDroid)
  • Likely to see a future merge of opportunities

What's the benefit?

Xamarin Cross-Platform


  • Starting with VS 2013 a Microsoft feed has been included
  • Future releases in form of NuGet packages
  • We select the libraries (incl. version) to our needs
  • Already present, e.g. AsyncTargetingPack for .NET 4
  • Other examples include TPL Dataflow, MEF
  • The role of NuGet will be crucial

The official .NET feed

NuGet .NET feed

Roslyn and C# vNext

  • Probably everything will ship in the next VS
  • C# vNext is coupled to Roslyn
  • Next VS release date is still unknown
  • Much faster and more reliable release cycles

Thanks for your attention

  • Feel free to contact me any time: