|.NET Community Toolkit Updated|
|Written by Kay Ewbank|
|Monday, 23 January 2023|
Microsoft has announced an updated version of the .NET Community Toolkit, a collection of helpers and APIs that work for all .NET developers. The updated version adds some features requested by users, and has much faster versions of the MVVM Toolkit source generators.
The Community Toolkit is described by Microsoft as agnostic of any specific UI platform. It is maintained and published by Microsoft, and is part of the .NET Foundation.
The toolkit is made up of libraries that were originally part of the Windows Community Toolkit that Microsoft released to simplify building UWP and .NET apps for Windows 10 and Windows 11. The collection of helpers, extensions, and custom controls evolved over time to be applicable to .NET in general rather than having Windows-specific dependencies.
The first improvement to the new release is support for using custom attributes for the ObservableProperty. The toolkit team says this is one of the most frequently requested improvements, and has been implemented using the existing property: syntax in C# to let developers mark attributes to propagate to generated properties.
The second improvement is the addition of dedicated analyzers to help developers find the best way to use the MVVM Toolkit. The MVVM Toolkit now goes further than emitting diagnostics for features used incorrectly, and now shows recommendations to improve the code and avoid common errors.
The other headline improvement is major performance optimizations to the MVVM Toolkit, especially when used for very large solutions. There are a number of strands to this, starting with the addition of multi-targeting for Roslyn 4.3. Roslyn is the .NET compiler platform that provides open-source C# and Visual Basic compilers with rich code analysis APIs. If supported, the MVVM Toolkit source generators will now use the Roslyn 4.3 target meaning they can opt-in into some more optimized APIs if the host supports it. Other performance improvements also make use of higher performance Roslyn APIs, including ObservableProperty.
The diagnostics have been moved to diagnostics analyzers that are run out of process and independently from source generators. This significantly reduces overhead when typing. The incremental models and incremental pipelines have all also been overhauled to significantly improve performance and reduce memory allocations.
.NET Community Toolkit is available now on GitHub.
or email your comment to: firstname.lastname@example.org