Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News .NET Community Toolkit 8.2.1: New Code Fixers, Diagnostics and QoL Improvements

.NET Community Toolkit 8.2.1: New Code Fixers, Diagnostics and QoL Improvements

Microsoft has published the latest version of its .NET Community Toolkit, version 8.2.1, with several new enhancements and features. According to the release, this new version brings quality-of-life improvements across all libraries, performance optimizations to the MVVM Toolkit source generators, new code fixers and improved diagnostics.

In a comprehensive blog post penned by Sergio Pedri on the official website, the following key information has been shared.

This release is mostly focused on incremental improvements: there’s no new features, but lots of tweaks and fixes!

The first and most notable improvement of the 8.2.1 version is the new analyzer and code fixer for RelayCommand. From this version, developers will be presented diagnostic for the usage of async void and the code fixer suggesting the change related to the usage of Tasks. This example can is available as a code sample provided by the original blog post.

(source: Improved Source Generators and Code Fixers Arrive in .NET Community Toolkit 8.2.1! article on Microsoft .NET Blog)

Another significant fix in this release is the resolution of an access violation error that could occur when indexing elements in a sliced Memory2D<T> instance. Previously, users experienced crashes when attempting to access elements after slicing this instance; this issue has now been successfully rectified.

Another bug fix involves forwarding attributes with negative enum values. Prior to this update, using enum members with negative values caused problems with the MVVM Toolkit generators for generated observable properties. This issue has been addressed, ensuring the smooth functioning of the generators.

The release also includes a fix for a generator crash when forwarding invalid attributes. Previously, attempting to forward attributes that were not correctly referenced resulted in errors. However, with the latest update, the generator now gracefully handles such cases and provides clear and easily understandable error messages, aiding developers in identifying and resolving the issue. Regarding the generator's functionality, version 8.2.1 also addresses a bug where the ObservableValidator generator failed to detect inherited properties. From this version the generator has been enhanced to include properties from base types for the target view model, eliminating any unintentional omission.

Additionally, the MVVM Toolkit now warns users when utilizing packages.config. Previously, the toolkit's generators only worked when using <PackageReference>, but users using packages.config encountered difficulties without any clear indication of the problem. The MVVM Toolkit now includes improved diagnostics that display a helpful warning message in such scenarios, aiding users in understanding and resolving the issue.

Also, to enhance IDE responsiveness when utilizing the MVVM Toolkit, version 8.2.1 introduces more frequent generator cancellation checks, and this release includes a memory optimization by removing unnecessary temporary array allocations. As reported in the official announcement blog post, these updates are expected to yield slight improvements in IDE responsiveness while utilizing the MVVM Toolkit, along with additional memory optimizations in the source generators.

Lastly, the generator now handles ObservableProperty fields with keyword identifiers more effectively. Previously, if fields annotated with ObservableProperty utilized keyword identifiers that had been escaped in the source code (e.g., @event), the generator would produce an invalid code. This issue has been resolved, ensuring valid and error-free code generation.

Alongside the original blog post, the community within a few comments expressed their desire for the inclusion of an MVU (Model-View-Update) C# framework. The complete list of changes made in this release can be viewed on the GitHub release page.

About the Author

Rate this Article