.NET Community Toolkit 8.0 Moves to General Availability — Visual Studio Magazine
.NET Community Toolkit 8.0 goes into general availability
After several previews, Microsoft shipped .NET Community Toolkit 8.0 almost exactly one year after the release of version 7.1 of its precursor, Windows Community Toolkit.
This Microsoft-maintained .NET Foundation project is a collection of UI-independent APIs and wizards that work for all .NET developers because not all APIs have runtime or framework dependencies and its libraries can target everything from .NET Standard 2.0 to . NET 6. This is one of many similar toolkits, which are typically collections of helper functions, custom controls, and application services designed to simplify and demonstrate common developer tasks for projects of different types.
The relatively young toolkit includes several .NET-specific libraries that have been separated from the Windows Community Toolkit in a separate dedicated GitHub repository (hence the 8.0 designation, picking up where the Windows Kit version was at the time of the split). These libraries are Common helpers, High Performance and Diagnostics and MVVM.
In one of the highlights of the release, this last major component regarding the Model-ViewModel-View software design pattern (separating UI code from core business or back-end logic) sports new MVVM source generators, which have been revamped in preview 1 of the main toolkit. These source generators, which reduce the amount of boilerplate code required to set up an application using MVVM, now run faster, offer simplified commands, add new observable property attributes, and include an adjustment to Viewmodel composition to work around C#’s lack of multiple inheritance support.
Other highlights for source generators and other MVVM aspects are in commands, observable properties, command undo support, broadcast change support for generated properties, composition from ViewModel, improved messaging APIs, and revamped collection APIs.
Sample Application of MVVM Toolkit
With version 8.0 in general availability, the development team announced a new MVVM Toolkit sample application, available on the Microsoft store.
“This is a sample app that showcases a wide variety of features available to developers. It contains samples and documentation for various components,” the store item’s description reads.
The announcement post provides more details: “It includes all documentation also available on MS Docs, as well as interactive examples for many APIs available. It is meant to be a companion for the MVVM Toolkit, and we hope it will help people get started with this library to get familiar with it!”
Improved diagnostic APIs
The diagnostics libraries, meanwhile, have also received new enhancements, taking advantage of the new C# 10 interpolated string handler and caller argument expression features.
“Several API Guards that previously took a string now also accept a custom handler, allowing call sites to completely skip the interpolation step if no exception is thrown, and also no longer need to manually specify the name of the argument,” Microsoft said in an Aug. 28 statement. 4 announcement post.
.NET 6 support
The new version of .NET Community Toolkit provides .NET 6 as a new target in all available libraries.
Microsoft said associated benefits include:
- Slicing support is now enabled for all libraries. To support this, all packages also have full slicing annotations for all APIs, to ensure that everything is compatible with the linker or explicitly shows the correct compile-time warnings (e.g. c is the case for some validation APIs in the MVVM Toolkit, which use some BCL APIs that inherently require some thought to work).
- The Count extension
() of the HighPerformance package now also supports nint and nuint.
- Several other optimizations across all packages were introduced on .NET 6.
“Of course, all libraries will continue to support up to .NET Standard 2.0, so you can continue to reference them from projects with different target frameworks,” Microsoft said. “And because of how NuGet package resolution works, if you build a library using one of these packages and an inferior target framework (e.g. .NET Standard 2.0) and a consumer benchmark from a project targeting a newer .NET version (e.g. .NET 6), they will always automatically get the most optimized version of .NET Community Toolkit assemblies available to them!”
.NET Community Toolkit documentation is available here.
David Ramel is an editor and writer for Converge360.