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

Subscribe on YouTube