What’s new in ASP.NET Core and C# 6.0

What’s new in ASP.NET Core and C# 6.0 150 150 Tom Kington

Wow, what a year Microsoft have had already. They are now shipping Xamarin with all editions of Visual Studio, shipping hardware for HoloLens and have announced the next major update for Windows 10 (which has already enjoyed widespread adoption with over 270 million active devices using it). But the one thing which really caught my eye at DevWeek was the new .NET Core and ASP.NET Core framework (formerly known as .NET 5 and ASP.NET 5). In a nutshell, .NET Core is a subset of the standard .NET framework; it is designed to be lightweight, portable, open source, multi-platform and modular. So let’s explore the reasons behind this in a bit more detail.

Features of new ASP.NET Core

  • Lightweight – with the heavy adoption of the cloud, Microsoft have realised that the standard .NET framework, while mature and stable, was quite resource intensive for most applications and carried a large overhead. By reducing the size and number of libraries included the footprint of the .NET framework has been dramatically reduced which in turn provides performance improvements for all .NET based applications
  • Portable – Since the .NET framework is now more compact, applications can be transferred and deployed more easily and in less time
  • Open Source – Microsoft has finally got on the open source bandwagon and made .NET Core open source, this gives developers real flexibility with to regards to which parts of the framework they wish to use
  • Multi-platform – Microsoft have accepted that not everyone uses Windows and as such have designed .NET Core to run on all manner of platforms including Linux and OSX. This ties in nicely with their new IDE (Integrated Development Environment) Visual Studio Code which allows developers to use Visual Studio on their platform of choice.
  • Modular – all .NET framework libraries are now installed as NuGet packages which means you only install the ones you want and need

Features of C# 6.0 release

To complement this new edition of the .NET framework, Microsoft has released a new version of the C# programming language – C# 6.0 (already available with .NET 4.6). This version of the language boasts a whole host of features which will make our lives as developers easier and allow us to deliver solutions more efficiently. Some of the more noteworthy features include:

  • Initializers for Auto-Properties – we can now declare and initialise an auto-property with one line of code
  • Null-Conditional Operator – often developers have to scatter their code with null checking to ensure an error is now thrown if we attempt to access a property on a null object. This is no longer necessary as this operator ensures we can only access the members and elements when the receiver is not null (otherwise just return null)
  • String Interpolation – formatting a string using the “String.Format” method was often unwieldy and made code difficult to read if the string was long and had many parameters. This syntax has been cut down to make code more readable
  • Exception Filters – when catching an exception we can now evaluate an expression related to the exception and deal with it in a certain way, in the past we just had to catch the exception and then drill down in it within our catch statement

In addition to Roslyn (the C# compiler we already know and love) developers can now use .NET Native to precompile their applications, this new technology uses the same back end as the C++ compiler and as such provides the following benefits – fast execution times (up to 60{7465c2450dcd042996416963879c72771606ba211532680daeb6e67dd6282842} faster), consistently speedy application start-up and optimised application memory usage. .NET Native also includes a refactored runtime whereby the specific libraries required by your App are embedded into your App so you don’t have to worry about whether the client machine has the correct version of the .NET framework installed or not. Furthermore Roslyn has had a bit of a facelift with GC (Garbage Collection) improvements being added, this is in addition to a new feature which allows developers to instruct the GC to wait before executing (this is especially useful if you have a segment of code which is resource intensive and you would like it to run without being interrupted by the GC).

Visual Studio 15 available for preview

Finally Visual Studio 15 (not to be confused with Visual Studio 2015) is on the way with the preview now available. Apart from breaking the convention of versions based on years (2010, 2015 etc), there are a number of new features including –

  • First launch up to 30-35{7465c2450dcd042996416963879c72771606ba211532680daeb6e67dd6282842} faster
  • Better tools and support for Universal Windows Apps
  • Configurable code style analysis – to allow you to enforce the coding standards used by your team
  • Updates to Application Insights for improved diagnostics and tracing
  • Improved SQL Server Data Tools with better support for Azure SQL Database and SQL Server 2016

While the Visual Studio team are keeping the RTM date close to their chest we should see this sometime in 2016 Q3/Q4.

So all in the all the changes are positive, Microsoft has listened to the developers, consumers, businesses (both large and small) as well as the wider population and is adapting to changing landscape of software, hardware, business needs and attitudes towards technology.

Discover our full range of technology experience. If you need help with your technology challenges, get in touch with an expert today.