A state of .NET in late 2020
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 Core 3.1
- Razor pages ASP.NET Core 2.2
@Html.helpers. See: What is the advantage of using Tag Helpers in ASP.NET Core MVC
- Keeps the code closer to the view for better organisation.
- Blazor Build client web apps with C#
- WebAssembly and server side rendering mode although the WebAssembly stuff doesn’t seem to be pushed as much yet.
- Baked in SignalR which is useful for that alone.
- dotNET South West - What is Blazor? And why’s it so exciting? with Chris Sainty, April 2020
Razor/Blazor class libs
- Useful for sharing partial views across services. E.g. Login form controls.
- Common error page and privacy page razor views.
- Create reusable UI using the Razor class library project in ASP.NET Core 3.1
- Razor class library and reusable blazor components
.NET Standard 2.0so can work across .NET Framework and .NET Core.
- 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.
- 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.
- Platform comparison: UWP, WPF, and Windows Forms
- More powerful and advance UI over WinForms if you need flashy design.
- Native .NET Framework calls like WinForms.
- Works on .NET Core.
- XAML based.
- Microsoft Confirms UWP is Not the Future of Windows Apps
- Going to be replaced by .NET MAUI? See: Cross Platform UI
- Going to be transitioned into WinUI 3.0? Windows only.
- Building Modern & Performant Desktop Apps—Is WinUI 3.0 the Way to Go?
- Doesn’t support Win32 calls due to abstracted set of APIs. See: Project Reunion
- Specifically designed to only run on Windows 10, Windows RT (tablets), Xbox and Windows Phone (now defunct).
- Sandboxed access to IO. Permissions model.
- XAML based.
- Overview of ASP.NET Core MVC
- Getting started with ASP.NET MVC 5 .NET Framework 4.6.1
- I’m lost. What happened to ASP.NET MVC 5?
- Do not confuse ASP.NET Framework 4.x.x MVC or ASP.NET 5 MVC with MVC 5 or ASP.NET MVC 5.
- See the following table which shows MVC version supported by .NET Framework version: ASP.NET MVC Version History
- > The ASP.NET MVC is a not actively developed web application framework developed by Microsoft
- > ASP.NET Core has since been released, which unified ASP.NET, ASP.NET MVC, ASP.NET Web API, and ASP.NET Web Pages (a platform using only Razor pages). MVC 6 was abandoned due to Core and is not expected to be released. Core is currently planned to merge into “.NET 5”.
- See the release history section for versions.
- > The ASP.NET releases history tightly correlates with the .NET Framework releases
- See the versions section.
- Session, TempData, ViewBag and ViewData
- TODO: One day explain some MVC recommendations and why to avoid evil ViewBags or hidden fields for certain things.
- ViewBag isn’t available in Razor Pages.
- ASP.NET Core prefers ViewData over ViewBag in it’s MVC project scaffolding, this is probably because it’s strongly typed.
- You have to manually serialise TempData due to different in memory backing options in ASP.NET Core , I personally use Newtonsoft.Json.
- >The ViewData attribute was introduced in ASP.NET Core 2.1
- Session in ASP.NET Core is a bit different to .NET Framework.
- Session and state management in ASP.NET Core
- An introduction to Session storage in ASP.NET Core
- Areas in ASP.NET Core
- Useful for organising MVC projects where you want to keep Models, Views and Controllers isolated.
- See real example: 2E0PGS - Core/Areas
- My blog post on: Portable data layer library - Namespaces
- Better namespaces for easier and shorter references as the Controllers can reference Models within same namespace.
.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
- Introducing .NET Multi-platform App UI
- > .NET MAUI is an evolution of the increasingly popular Xamarin.Forms toolkit
- Xamarin.Forms single shared UI layer instead of one for each platform like Xamarin traditional. However you can still implement native APIs if required.
- Uno Platform
Some consolidation works already and abstractions
- > 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
HttpActionResultASP.NET Framework MVC or
IHttpActionResultASP.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
MSBuild -> Roslyn -> csc.exe
.NET Core CLI -> MSBuild -> Roslyn -> csc.dll
strace -o strace.txt -f -t -e trace=file dotnet 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
- Various project management methods:
- PR I opened: Replace typo package.config with packages.config
- My blog post on: Submodules in .NET specifically around some of the quirks and teething problems with NuGet and framework interoperability.
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.
- My blog post on: .NET Core 2.2 configs
- Settings.settings: Using Application Settings and User Settings
- Settings.Default: How To: Read Settings at Run Time With C#
- My blog post on: MSTest for exception thrown in .NET Core and .NET Framework.
DI (Dependency Injection)
- DI is built into ASP.NET Core which is nice, this should help consolidate and eliminate the need to know the intricacies of various DI frameworks across multiple projects in an organisation.
- Dependency injection in ASP.NET Core
- My blog post on: Portable data layer library - DI example
Service reference/Web service/WCF
- “Web Reference” - .NET Framework
- “Service Reference” - .NET Framework
- “WCF Web Service Reference Provider” - .NET Core and .NET Standard
- 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
- I prefer using Visual Studio running in Windows still.
- omnisharp-vscode - Desktop .NET Framework
- Visual Studio Code for .Net Framework
- Using Visual Studio Code for .NET Framework Projects in C#
- Seems to work reasonable on Windows for viewing, occasionally struggles to find or peek references.
dotnet runon 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"
- 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
- Works great for C# 7, .NET Framework 4.6.1, .NET Core 2.1, .NET Core 2.2 and .NET Standard 2.0
- Announcing F# support for .NET Core and .NET Standard projects in Visual Studio
Visual Studio 2019
- Current latest.
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:
Otherwise using the compiler option:
- What’s new in C# 9.0
- Microsoft Developer YouTube Channel - Future of C#
- I believe it requires VS 2019.
- The language is becoming less “belts and braces”, looking like you can use C# in more of a scripting way with less overhead of entry method declarations. Reminds me of Python.
withexpressions to mutate objects safely. A bit like shallow copying.
- Method params creating members automatically.
- New C#9 keywords ‘and’ ‘or’ ‘not’ could be confused with T-SQL, I have seen other developers put T-SQL syntax/logical operators into C# by mistake.
- Similar things mentioned in: .NET Conf 2020
- Try .NET
- .NET In-Browser
- My blog post: REPL maths and notation
- Immediate Window are they going to replace this entirely with Interactive Window I wonder.
- Rather hard to find this package. Seems to be Microsoft’s version of Jupyter notebooks. It’s aka “.NET notebooks” or “native notebook” .NET Interactive Notebooks also see: GitHub Issue Notebook
- One of the only videos I have seen on “.NET Interactive Notebooks”: F# as a Better Python - Phillip Carter - NDC Oslo 2020 besides a mention By Phillip in .NET Conf 2020
- There is also regular Jupyter file support using a “kernel” in other words a Jupyter server: Working with Jupyter Notebooks in Visual Studio Code
- .csx files - Essential .NET C# Scripting
.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.
- This mostly covers new features in .NET 5 however some features already released or not directly related maybe mentioned under other headings.
- And now .NET 5 is unifying everything, I guess MS realised things could be getting a bit “bitty”. However let’s hope the package management, project/solution management, build tools and such can be unified.
- IAmTimCorey - What is the Future of .NET? Is .NET Framework Dead? Is .NET Core Dead?
- Introducing .NET 5 | .NET Blog
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.exeIf 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 dumpfor 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
- 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
- A issue I opened: OS compatibility/portability information
- Second issue I opened: NuGet Gallery platform specific API information
- Useful NuGet package for analysis: Platform Compatibility Analyzer
- The .NET Portability Analyzer
- 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 newwill list available templates for .NET Core.
$ 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
- AWS, see my blog post: ASP.NET Core Web API AWS Lambda
- TODO: Azure
- See my blog post: ASP.NET WebHooks
- Pascalcase vs Camelcase in ASP.net Core this is more specifically about JSON and API properties/model serialisation. I also briefly mention PascalCase vs CamelCase under my blog post: .NET Core 2.2 configs
Some useful topology diagrams of the current stack.
Let me know what you think of this article on twitter @M3PGS or leave a comment below!