Runar Ovesen Hjerpbakk

Software Philosopher

What’s New in C# 6 and Visual Basic 14

Everybody loves Mads and Dustin. The line was forming even 30 minutes before the session. The first session of the day.

A big year. Began talking publicly about C# 6, released and open sourced Roslyn, released .Net Core libraries and runtime as OSS on GitHub. OSS all the things!

Visual Studio 2015

The C# stack in Visual Studio 2015 has been completely rebuilt. Everything is a little bit better. And shinier. The IDE has stolen most of ReSharper best features and made them available out of the box. This is a good thing and I’m writing these words wearing a ReSharper t-shirt.

Code actions will show previews before you complete them. An improvement over ReSharper’s implementation. Potential conflicts that would come as result of the actions are visualized. Modal dialogues are also used less.

Refactoring preview in action. Refactoring preview in action.

Anyone can build code analyzers, and they can even be shipped together with the code the should analyze. For instance, ship analyzers for ImmutableArrays together with Immutable Collections nuget packages.

Language features

Static usings simplify access to static members. Console WriteLine can be called as WriteLine with using static System.Console.

Immutable types are awesome. Auto properties can now be readonly, same as with normal member variables. Only declare getters and you’re set. They can even be initialized directly.

Expression bodied members can skip the return statement and curly brackets, using the lambda arrow instead. Makes for more readable code when dealing with small methods. Thanks for the inspiration F#!

Simplify all the things! Simplify all the things!

String.Format can be converted to an interpolated string. Prefix the string with an $ and write your format string. Expressions can be used, not just values.

nameof(whatever) gives you the name of the variable. Useful when creating argument exceptions or in databinding.

Null conditional checks can be written with ?., an inline null check. It even supports indexers. No more foo == null boilerplate!

Object initializers can now initialize to an index, not only members.

Focus on the important bits, less cruft. Focus on the important bits, less cruft.

The team became smarter with time, an await can now be used inside catch and finally blocks. It just works!

Exception filtering is supported using the when keyword. Less logic in the catch block.

Debugging experience

Edit and continue is back and works even if you use new language features. You can code freely while stopped at a breakpoint, even create new types. Visual Studio 2015 still gives you Intellisense and the code actions and refactorings works!

Lambdas and LINQ can be used in the watch and immediate windows. Impressive, the language is even useful during debugging.

The C# Essentials is a useful extension, helping you use the new languate features.

Future stuff

A playground without equipment. A playground without equipment.

C# interactive window will be back with full Intellisense. Xamarin and Swift, you’re not alone! Not as feature rich as the Playgrounds of other languages, yet at least. Roadmap is available on GitHub. Though a REPL is still useful without visualizations.

The design notes of C# 7 is on Github. They’re issues tagged as Design Notes. Modern languages have greater potential to help the programmers being more productive and less error prone, such as nullability tracking or tuple types.

I love the new open Microsoft. I love the new open Microsoft.