A state of .NET in late 2020

by on under programming
17 minute read

A state of .NET in late 2020

A hub of links and comments which cover most of the realization of .NET Core. Acting as a snapshot in time of the current stack.

Hopefully also highlights some issues which can aid in predicting potential future concerns going forwards with various new technologies.

Otherwise useful as a historic reference for frameworks built on these stacks.

Razor pages

ASP.NET Razor Pages vs MVC: How Do Razor Pages Fit in Your Toolbox?

Blazor

Razor/Blazor class libs

WinForms

  • Windows Forms
  • Still relevant for Windows native .NET Framework programs and Microsoft recently added support for .NET Core WinForms.
  • Drag and drop UI visual designer.

WebForms

  • A bit like WinForms but for the web.
  • Deprecated for a while now in favour of MVC.
  • Wont be in .NET 5 as replaced by Blazor.

WPF

UWP

MVC

Areas

Namespaces

MyOrg.SpecialApp.Models.System1.CustomerModel.cs

MyOrg.SpecialApp.Controllers.System1.CustomerController.cs

Reference example: using Models.System1.CustomerModel.cs

vs

MyOrg.SpecialApp.Areas.System1.Models.CustomerModel.cs

MyOrg.SpecialApp.Areas.System1.Controllers.CustomerController.cs

Reference example: using Models.CustomerModel.cs

.NET Core with Angular/React

  • Allows you to create a solution which comes with a .NET Core as the backend API and Angular or React as the SPA.
  • Not useful if you already have an established API or you don’t want the confusion of building/running Angular/React inside a VS project/solution.
  • TypeScript is great and required imo for such complex JS.

Cross platform UI

Some consolidation works already and abstractions

  • wikipedia.org/wiki/ASP.NET_Core
    • > The framework is a complete rewrite that unites the previously separate ASP.NET MVC and ASP.NET Web API into a single programming model.
  • The controllers are the same for both Web API and MVC projects.
  • ASP.NET Core IActionResult instead of HttpActionResult ASP.NET Framework MVC or IHttpActionResult ASP.NET Framework Web API
  • Tool for migrating from .NET Framework to .NET Core: try-convert
  • Consolidating .NET GitHub repos

Overview of framework topology

ASP.NET Framework Web Forms
ASP.NET Framework MVC
ASP.NET Framework Web API
ASP.NET Core Blazor
ASP.NET Core Pages 
ASP.NET Core MVC
ASP.NET Core Web API

ASP.NET Framework
ASP.NET Core

.NET Framework
.NET Core

.NET Standard

Language e.g. C#

MSIL

CLR

Overview of build system topology

.NET Framework

MSBuild -> Roslyn -> csc.exe

.NET Core

.NET Core CLI -> MSBuild -> Roslyn -> csc.dll

Linux

strace

strace -o strace.txt -f -t -e trace=file dotnet build

/usr/share/dotnet/sdk/2.2.402/MSBuild.dll

/usr/share/dotnet/sdk/2.2.402/Roslyn/bincore/csc.dll

Verbose build

dotnet build --verbosity normal

CoreCompile:
	/usr/share/dotnet/dotnet exec "/usr/share/dotnet/sdk/2.2.402/Roslyn/bincore/csc.dll"

and the newest 2.2.2 SDK ships with csc.dll and vbc.dll instead of csc.exe and vbc.exe

Ref: https://stackoverflow.com/a/47697996

Project/package management

Project structure

I personally stick with the way .NET Framework projects where historically laid out. Fredrik’s below blog post shows how Dapper is similar to that. There does however seem to be a movement towards src/test/docs convention for some Open Source .NET projects.

Configuration management

Unit testing

DI (Dependency Injection)

Service reference/Web service/WCF

IDEs

  • VS Code, Visual Studio and SMMS.
  • I am mostly using a Visual Studio 2017, SMSS 2017 and VS Code workflow at the moment. This matches with my C# version and framework version choices.
  • I noticed many are shifting to light weight IDEs. See my blog post: A state of text editors in late 2019
  • Many extensions have been created for VS Code which allow interaction with databases etc. Will these replace tools like SMSS eventually?
  • TODO: My blog post on: TBA - virtualised programming specifically around live share?
  • Visual Studio version table

VS Code and .NET Framework

Windows

  • Seems to work reasonable on Windows for viewing, occasionally struggles to find or peek references.
  • TODO: dotnet run on a .NET Framework console app?
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
	Located 2 MSBuild instance(s)
		1: Visual Studio Professional 2017 15.x.xxxxx.xxx s- "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin"
		2: StandAlone 16.4 - "C:\Users\peter\.vscode\extensions\ms-dotnettools.csharp-1.21.18\.omnisharp\1.35.1\.msbuild\Current\Bin"

Linux

  • Doesn’t work well if using Linux, probably because it’s missing the tooling/SDK for intellisense to work.
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 16.4 - "/home/peter/.vscode/extensions/ms-dotnettools.csharp-1.21.18/.omnisharp/1.35.1/omnisharp/.msbuild/Current/Bin"
...
[fail]: OmniSharp.MSBuild.ProjectLoader
        The reference assemblies for .NETFramework,Version=v4.6.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

VS Code and .NET Core

  • Works fantastic on Windows and Linux now however when it first came out with support for .NET Core it had barely any intellisense and was unusable imo.

VS Code and .NET Standard

  • Works fantastic on Windows and Linux.

Visual Studio 2017

Visual Studio 2019

  • Current latest.

Language versioning

C# language versioning

The rules in this article apply to the compiler delivered with Visual Studio 2019 or the .NET SDK. The C# compilers that are part of the Visual Studio 2017 installation or earlier .NET Core SDK versions target C# 7.0 by default.

You can override target language version in the Project.csproj:

<LangVersion>7.1</LangVersion>

Otherwise using the compiler option: -langversion:7.1

C# 7

C# 8

C# 9

Interactive

Frameworks

.NET Core and .NET Framework

Because most of this document covers these two frameworks, this heading will only cover bits that don’t fit elsewhere.

  • .NET Core is the Future of .NET
    • > New applications should be built on .NET Core. .NET Core is where future investments in .NET will happen. Existing applications are safe to remain on .NET Framework which will be supported.
  • dotnet --list-sdks
  • dotnet --list-runtimes

.NET 5

Some interesting points from the .NET blog post include:

  • The ability to swap CoreCLR and Mono runtimes interchangeably via build flags.
  • The names “.NET Core 5” and “.NET 5” can be used interchangeably however they dropped the “Core” to show it’s a unifying framework.
  • .NET 5 is the future for the .NET platform.
  • “Ahead Of Time” native compilation added for certain workloads. Previously only “Just In Time” compilation.
  • Also see the below diagram which shows the stack along with tooling. Notice CLI is on there and a big part of .NET now.

.NET Conf 2020

Some interesting points from .NET Conf 2020 include:

  • OpenAPI/Swagger support in .NET 5 Web API projects on-by-default.
  • More use of REPL e.g. httprepl.exe If you don’t know what a REPL is see heading: Interactive
  • Platform Compatibility Analyzer included/on-by-default in new projects.
  • Plans for Blazor on the desktop.
  • New .NET releases every year.
  • Protected browser storage. Is that new?
  • Xamarin not merged till .NET 6?
  • Linux debugging with VS on Windows and WSL 2 or remote Linux debugging over SSH.
  • dotnet dump for memory dumps on .NET Core, dumps can be analysed on other platforms.
  • EF Core with tooling. Lots of providers: Entity Framework Core - Database Providers
  • The new YARP reverse proxy middleware/toolkit written in C# with good extensibility. Relates to IIS ARR (see my blog post: IIS reverse proxy server) and Kestrel. Will this replace NGINX reverse proxy for many use cases?
  • Bringing .NET Interactive to Azure Data Studio Notebooks

.NET Standard

  • The future of .NET Standard | .NET Blog
  • Continue using .NET Standard 2.0+ for portable libraries across .NET Framework and .NET Core.
  • Going forwards when projects are migrated to .NET 5 there will be no need for .NET Standard.

Platform specific APIs

Blueprints/templates/scaffolding

  • Shame all 3 words get thrown around a bit. Could be a more consolidated term.
  • Anyway I noticed these have changed a fair bit for .NET Core projects. Specifically for MVC projects.
  • You can get extra ones online for example: AWS blueprints
  • You can use this command to list installed templates and their versions: dotnet new -u
  • dotnet new will list available templates for .NET Core.

Example

$ dotnet --version
2.2.402

$ dotnet new
...
Templates                                         Short Name         Language          Tags                                 
----------------------------------------------------------------------------------------------------------------------------
Console Application                               console            [C#], F#, VB      Common/Console                       
Class library                                     classlib           [C#], F#, VB      Common/Library                       
Unit Test Project                                 mstest             [C#], F#, VB      Test/MSTest                          
NUnit 3 Test Project                              nunit              [C#], F#, VB      Test/NUnit                           
NUnit 3 Test Item                                 nunit-test         [C#], F#, VB      Test/NUnit                           
xUnit Test Project                                xunit              [C#], F#, VB      Test/xUnit                           
Razor Page                                        page               [C#]              Web/ASP.NET                          
MVC ViewImports                                   viewimports        [C#]              Web/ASP.NET                          
MVC ViewStart                                     viewstart          [C#]              Web/ASP.NET                          
ASP.NET Core Empty                                web                [C#], F#          Web/Empty                            
ASP.NET Core Web App (Model-View-Controller)      mvc                [C#], F#          Web/MVC                              
ASP.NET Core Web App                              webapp             [C#]              Web/MVC/Razor Pages                  
ASP.NET Core with Angular                         angular            [C#]              Web/MVC/SPA                          
ASP.NET Core with React.js                        react              [C#]              Web/MVC/SPA                          
ASP.NET Core with React.js and Redux              reactredux         [C#]              Web/MVC/SPA                          
Razor Class Library                               razorclasslib      [C#]              Web/Razor/Library/Razor Class Library
ASP.NET Core Web API                              webapi             [C#], F#          Web/WebAPI                           
global.json file                                  globaljson                           Config                               
NuGet Config                                      nugetconfig                          Config                               
Web Config                                        webconfig                            Config                               
Solution File                                     sln                                  Solution

Cloud

WebHooks/API

Diagrams

Some useful topology diagrams of the current stack.

.NET Core, .NET Framework, Xamarin – The “WHAT and WHEN to use it”

Cross-platform targeting

ASP.NET Core 1.0. Part 1: Introduction, general description and the future of .NET Framework

ASP.NET vNext - DevExpress Plans for ASP.NET 5

.NET Core CLI msbuild architecture

Uncovering the cross-platform capabilities of .NET

C# 7.1 and .NET Core 2.0 - Modern Cross-Platform Development - Third Edition

execution process of .NET Core and compare it with the .NET Framework.

comments powered by Disqus