.NET Standard and .NET Core – What and Why?
Unless you have been living under a rock, you must have heard about .NET Standard and .NET Core by now.
.NET Standard (https://www.dotnetcurry.com/dotnet/1377/dotnet-standard-2-xaml-standard) is a formal specification of .NET API’s that a Framework must implement to be .NET Standard compliant. This specification is important because it establishes a uniformity in the .NET ecosystem.
As of this writing, there are four .NET implementations that are .NET Standard 2 compliant:
- .NET Framework
- .NET Core
- Xamarin and
In the near future, Universal Windows Platform (UWP) vNext will also implement the .NET Standard spec.
The .NET Standard makes it easy to write .NET code that can be shared across all these .NET implementations. So as a developer, if your write a .NET Standard Class Library, you can be rest assured that it will work on all the four .NET implementations listed above, as well as the new ones implemented in the future.
Are you keeping up with new developer technologies? Advance your IT career with our Free Developer magazines covering C#, Patterns, .NET Core, MVC, Azure, Angular, React, and more. Subscribe to the DotNetCurry (DNC) Magazine for FREE and download all previous, current and upcoming editions.
In November 2016, .NET Core 1.1 was released at the Connect() event. This was the first new minor version of .NET Core - a cross-platform, open source, and modular .NET platform for creating modern .NET applications. Unlike the LTS (Long Term Support) version 1.0, .NET Core 1.1 was categorized as a “Current” release.
While LTS releases have a 3-year support period from the original release, or 1 year from the next LTS release; the “Current” releases are only eligible for support as long as their parent LTS release support period or 3 months after the next “Current” release, whichever comes first.
The two versions can safely be installed side-by-side, so that individual applications on the same machine can use either one.
The focus of this release was performance.
The big news was that ASP.NET Core is now included in the TechEmpower web framework benchmarks, and is the fastest mainstream full stack framework in the Plaintext category.
Several new features were added to ASP.NET Core 1.1 as well:
- With MVC filters, you can apply middleware only to specific controllers or actions.
- Two new middleware were included: URL rewriting and response caching.
- Web Listener Server for Windows is available as an alternative to Kestrel. With it, you can take advantage of Windows specific features, such as Windows authentication, HTTP/2 over TLS, and others.
- Compiling views during the publish process is supported.
Editorial Note: You may want to read https://www.dotnetcurry.com/aspnet/1329/aspnet-core-11-what-is-new to learn more on ASP.NET Core 1.1.
Entity Framework Core 1.1 has built-in support for connection resiliency and SQL Server memory-optimized tables. Thanks to improved LINQ translation, the database engines can successfully execute more queries than before. New APIs were added for explicit loading, mapping to fields and a few other features.
Editorial Note: To learn more about the current state of Entity Framework Core, read this tutorial https://www.dotnetcurry.com/entityframework/1389/ef-core-past-present-future
Final version of MSBuild tooling for .NET Core was released in March 2017 as part of Visual Studio 2017. This means that standard .csproj project files can be used instead of project.json. To better align the two formats, MSBuild now supports wildcard-based inclusion of files for folder based projects, and direct NuGet package references. A wizard for migrating project.json projects to .csproj is available as well.
.NET Core 2.0
In May 2017, .NET Core 2.0 Preview was released at Build 2017 event. Three months later, on August 14th, .NET Core 2.0.0 final version was made available.
The main focus of this first new major version of .NET Core is increased source level compatibility with the full .NET framework. To achieve that, the team added over 20000 APIs from .NET framework, which were missing in .NET Core 1.1.
At the same time it introduced .NET Standard 2.0, which will be implemented by both .NET Framework and .NET Core 2.0 and will allow compatible .NET framework libraries to be used directly from .NET Core 2.0. You can read more about .NET Standard 2.0 in my article about it for Dot Net Curry (DNC) magazine.
.NET Core 2.0 is also accompanied by Entity Framework Core 2.0 and ASP.NET Core 2.0.
Entity Framework Core 2.0 is mostly about improvements to LINQ implementation and reduced functionality gap between Entity Framework 6 and Entity Framework Core. ASP.NET Core 2.0 is reintroducing Razor pages and features simplified startup code.
Support for C# and F#
Both C# and F# are fully supported for .NET Core 2.0 development. The same project templates are available for both languages, however Visual Studio 2017 is not yet fully compatible with .NET Core development in F#. While projects can be built and debugged, IntelliSense does not yet work correctly for F# and will be fixed in one of the future Visual Studio updates.
For the time being, Visual Studio Code (https://www.dotnetcurry.com/visualstudio/1340/visual-studio-code-tutorial) is a better alternative – Ionide-FSharp extension has full IntelliSense support, while the C# extension provides the .NET Core debugger.
Visual Basic support is also being added to .NET Core: it can be used for developing .NET Core based class libraries and console applications.
Editorial Note: Are you a C# developer who wants to get started with F#? Read this https://www.dotnetcurry.com/csharp/1384/functional-programming-fsharp-for-csharp-developers
Visual Studio 2017
In March Visual Studio 2017 was released at a dedicated launch event. The new version comes with many productivity improvements:
- better filtering and default suggestions in IntelliSense dialogs,
- easier navigation with redesigned Find All References and Go To functionalities,
- new Exception Helper dialog with more information and support for filtering exceptions by the assembly they originate from,
- quick reattaching with Reattach to Process command and filtering by process name in the Attach to Process dialog,
- continuous running of tests and coverage information for individual code lines with Live Unit Testing (only available in Enterprise edition),
Figure 1: Live Unit Testing in action
- additional code refactorings,
- configurable code style, and more.
Better performance is also a high priority: Visual Studio 2017 starts faster, has shorter load times for solutions, and a faster, more componentized installer. To further speed-up initial loading of large solutions, lightweight solution loading can be enabled for them, which defers the full loading of projects to a later time when they are first needed.
Editorial Note: You can read more about VS 2017 in our tutorials at https://www.dotnetcurry.com/tutorials/visualstudio
Extensions can also largely affect the overall responsiveness of Visual Studio. The new performance-monitoring feature will now warn the user about extensions which slow down Visual Studio.
Other improvements to extensions include:
- batched installs and updates,
- built-in roaming extension manager, and
- support for extensions to detect missing dependencies and trigger their installation in Visual Studio.
A few other noteworthy features in Visual Studio 2017 are:
- New versions of C# and Visual Basic provide many new language features, as described in my previous article on C# 7.0 for Dot Net Curry (DNC) magazine.
- A new Service Capabilities page is now the centralized location for adding cloud service dependencies to a project.
- You can record tests for mobile applications using the new mobile test recorder and upload them directly to Xamarin Test Cloud.
- Visual Studio Tools for Unity are now available as a part of a separate Unity workload in the Visual Studio installer. Among other improvements, the code editor now features full syntax coloring and IntelliSense support for Unity event functions.
With Visual Studio 2017 the release rhythm of updates has also changed. Since the initial release in March, three updates (15.1, 15.2 and 15.3) have already been released, bringing several improvements to Visual Studio, most notably:
- support for .NET Core 2.0,
- Windows 10 Creators Update SDK for UWP applications,
- Redgate Data Tools in Visual Studio Enterprise,
- updated TypeScript support, and
- a new Data Science and analytics workload.
C# 7.x and 8.0
With the release of C# 7.0 as part of Visual Studio 2017, the planned release cadence for new language versions has changed. Between the major versions, several new minor versions will be released, which will allow smaller features to be released sooner, not having to wait for a new major language version to be ready.
According to this new policy, Visual Studio 2017 update 15.3 introduces C# 7.1 with several new features: asynchronous Main method, default literal, inferred tuple names and pattern matching with generics. Other small features are already planned for C# 7.2, such as read-only by-reference argument passing and named arguments in non-trailing positions.
The next major version, C# 8.0, is currently planned to support safe nullable reference types and default interface methods, which promise to bring trait-like behavior to C#.
Editorial Note: A good article with an overview of what's new and upcoming in C# 7.1, 7.2 and 8.0 can be found here www.dotnetcurry.com/csharp/1401/csharp-7-1-csharp-8-new-features .
Visual Studio for Mac
The Visual Studio product family got a new member: Visual Studio for Mac.
The application is an evolved version of Xamarin Studio, more closely aligned to the Visual Studio experience on Windows. It supports development of Xamarin based mobile applications, and their cloud backends in .NET Core, using either C# or F#. It features the same Roslyn powered compiler, IntelliSense code completion and refactoring experience as Visual Studio. The same MSBuild project format allows for seamless sharing of projects between Visual Studio on Windows and Mac.
There’s also a preview of the next release available for download. It adds support for Unity development, publishing ASP.NET Core applications to Docker and development of Azure Functions.
Mobile Development with Xamarin
The Xamarin team recently released stable versions of several new tools.
Xamarin Inspector is an extension for Visual Studio and Xamarin Studio, which can attach to a running iOS, Android, Mac or WPF application. It provides a structured look into the current view of the attached application, without pausing its execution with a debugger. You can even modify its properties via a graphical user interface or by executing custom C# code in the application context.
Xamarin Workbooks is an editor and viewer for interactive documents, consisting of rich formatted documentation with live runnable code. This makes it very useful for creating and consuming learning materials, guides and teaching aids. A large selection of workbooks on different Microsoft technologies is already available for download.
Figure 2: C# 6 workbook in Xamarin Workbooks
Remoted iOS Simulator for Windows provides a convenient way for testing and debugging iOS applications from Visual Studio on Windows. Although the simulator still requires a connected Mac machine where the simulator is actually running, you can fully interact with it directly from Windows. It even provides full touchscreen support, including Apple Pencil simulation using a stylus – that is if you have a touchscreen connected to your Windows machine. The simulator does not support Apple Watch devices yet.
Xamarin Profiler is everything you would expect from a profiler for Xamarin based applications. Its three main views allow tracking of memory allocations and footprint, performance tracking with method execution sampling, and tracking of memory cycles that cannot be released and cause memory leaks.
Remoted iOS Simulator and Xamarin Profiler are only available to owners of Visual Studio Enterprise license.
Editorial Note: To learn more about Xamarin, visit our tutorials at https://www.dotnetcurry.com/tutorials/xamarin
At Build 2017 event, another new Xamarin tool was announced to be available in preview: Xamarin Live Player. It comes with an accompanying mobile application for iOS and Android. With some limitations, it allows direct deployment of Xamarin applications from the IDE to your device without having to create and deploy the full package for every change.
Another large Xamarin related product in preview is Visual Studio Mobile Center. It is the successor to HockeyApp and Xamarin Test Cloud, an integrated cloud service for the complete lifecycle of your mobile applications, providing a wide spectrum of functionalities:
- continuous integration and release management,
- automated testing on devices using Xamarin.UITest, Calabash, Appium, XCUITest or Espresso,
- application distribution to your test users and enterprise users,
- crash reporting and usage metrics,
- backend services for authentication, data storage and push notifications, with more coming in the future.
It currently supports UWP, iOS and Android applications written in C#, Objective-C, Swift, Java, Xamarin or Reactive Native. Support for Cordova applications has been announced.
Direct deployment to Google Play store is already available, support for App Store, Windows Store and Intune has also been announced.
Visual Studio Tools for Tizen - Samsung's Linux based OS
Tizen is Samsung’s Linux-based open source operating system, used in over 50 million of their devices: smart TVs, wearables, smartphones and IoT devices. At Connect() in November 2016, Samsung announced its intention on collaborating with Microsoft to bring .NET Core to ARM devices, and add Tizen support to Xamarin.Forms.
Since then Samsung has released four preview versions of Visual Studio Tools for Tizen. They provide an alternative to existing C and HTML 5 based programming models for Tizen.
Mobile and TV application development is already supported. Support for other types of devices will follow in the future. All the development is done in C# with .NET Core (2.0 Preview is already supported), Xamarin.Forms for the user interface, and wrappers for many native APIs to access device specific functionalities - everything with full IntelliSense support.
Debugging takes advantage of device emulators, which are included in the download.
The official release is planned for the end of 2017 as part of Tizen 4.0, when the .NET Core runtime will also ship to devices.
Microsoft continues to offer a great set of benefits and tools for any developer, any app, and any platform.
Since their inception, Microsoft has been using Connect() and Build events to announce many important development related releases. The last incarnation of both events was no exception. From Visual Studio 2017 and Visual Studio for Mac to new Xamarin tooling and new .NET Core versions, there was something of interest for any developer already working with Microsoft tools or technologies.
At the same time, as Microsoft expands its focus from Windows to other platforms, these announcements have become increasingly interesting to developers who are not in Microsoft’s ecosystem yet.
The new Microsoft is showing that it isn’t afraid of making big bets, and delivering on them. Wake up and Code!
This article was reviewed by Suprotim Agarwal
This article has been editorially reviewed by Suprotim Agarwal.
C# and .NET have been around for a very long time, but their constant growth means there’s always more to learn.
We at DotNetCurry are very excited to announce the The Absolutely Awesome Book on C# and .NET. This is a 500 pages concise technical eBook available in PDF, ePub (iPad), and Mobi (Kindle).
Organized around concepts, this eBook aims to provide a concise, yet solid foundation in C# and .NET, covering C# 6.0, C# 7.0 and .NET Core, with chapters on the latest .NET Core 3.0, .NET Standard and the C# 8.0 (final release) too. Use these concepts to deepen your existing knowledge of C# and .NET, to have a solid grasp of the latest in C# and .NET OR to crack your next .NET Interview.
Click here to Explore the Table of Contents or Download Sample Chapters!