Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Classes with no base types should prefer inheriting from ObservableObject instead of using attributes to generate INotifyPropertyChanged code, as that will reduce the binary size of the application (the attributes are only meant to support cases where the annotated types are already inheriting from a different type). This diagnostic applies to cases where [INotifyPropertyChanged] is used in particular.
The following sample generates MVVMTK0032:
using CommunityToolkit.Mvvm.ComponentModel;
namespace MyApp;
[INotifyPropertyChanged]
public partial class SampleViewModel
{
}
And you can fix it by updating the code as follows:
using CommunityToolkit.Mvvm.ComponentModel;
namespace MyApp;
public partial class SampleViewModel : ObservableObject
{
}
Additional resources
- You can find more examples in the unit tests.
MVVM Toolkit