News

.NET Community Toolkit 8.0 Goes GA

After multiple previews, Microsoft shipped .NET Community Toolkit 8.0 almost exactly one year after it released v7.1 of its precursor, Windows Community Toolkit.

This .NET Foundation project that's maintained by Microsoft is a collection of UI-agnostic helpers and APIs that work for all .NET developers, as all the APIs have no runtime or framework dependencies and its libraries can target everything from .NET Standard 2.0 to .NET 6. It's one of a number of similar toolkits, which typically are collections of helper functions, custom controls and app services designed to simplify and demonstrate common developer tasks for projects of varying types.

The relatively young toolkit comprises several .NET-specific libraries that were split from the Windows Community Toolkit into a separate dedicated GitHub repository (hence the 8.0 designation, picking up from where the Windows kit versioning was at time of the split). Those libraries are Common helpers, High Performance and Diagnostics, and MVVM.

MVVM Toolkit
In one highlight of the release, that latter main component concerning the Model-ViewModel-View software design pattern (separating UI code from core business or back-end logic) sports new MVVM source generators, which were revamped in Preview 1 of the main toolkit. Those source generators, which reduce the amount of boilerplate code needed to set up an application using MVVM, now run faster, feature simplified commands, add new observable properties attributes and include a Viewmodel composition tweak to get around C#'s lack of multiple inheritance support.

Other highlights for source generators and other MVVM aspects concern commands, observable properties, cancellation support for commands, broadcast change support for generated properties, ViewModel composition, improved messenger APIs and revamped collection APIs.

MVVM Toolkit Sample App in Animated Action
[Click on image for larger view.] MVVM Toolkit Sample App in Animated Action (source: Microsoft).

MVVM Toolkit Sample App
With v8.0 going GA the dev team announced a new MVVM Toolkit Sample App, available in the Microsoft store.

"This is a sample app which demonstrates a wide variety of features available to developers. It contains examples and documentation for various components," the store item's description reads.

The announcement post provides more details: "It includes all the documentation also available on MS Docs, along with interactive samples for many of the available APIs. It's meant to be a companion for the MVVM Toolkit, and we hope it will help people getting started with this library to become more familiar with it!"

Improved Diagnostics APIs
The diagnostics libraries, meanwhile, also received some new improvements, leveraging the new C# 10 interpolated string handler and caller argument expression features.

"Several Guard APIs previously taking a string now also accept a custom handler, allowing callsites to completely skip the interpolation step if no exception is thrown, and it is also no longer need to indicate the argument name manually," Microsoft said in an Aug. 4 announcement post.

.NET 6 support
The new release of the .NET Community Toolkit provides .NET 6 as a new target across all available libraries.

Microsoft said associated benefits include:

  • Trimming support is now enabled for all libraries. To support this, all packages also have full trimming annotations for all APIs, to ensure that everything is either linker-friendly, or explicitly showing the correct warnings at compile-time (eg. this is the case for some validation APIs in the MVVM Toolkit, which use some APIs from the BCL that inherently need some reflection to work).
  • The Count<T>() extension in the HighPerformance package now also supports nint and nuint.
  • Several other optimizations across all packages have been introduced when on .NET 6.

"Of course, all libraries will keep supporting down to .NET Standard 2.0, so you can keep referencing them from projects with different target frameworks as well," Microsoft said. "And due to how NuGet package resolution works, if you author a library using any of these packages and a lower target framework (eg. .NET Standard 2.0) and a consumer references it from a project targeting a new .NET version (eg. .NET 6), they'll still automatically get the most optimized version of the .NET Community Toolkit assemblies that is available for them!"

.NET Community Toolkit documentation can be found here.

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube