diff --git a/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableObject.cs b/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableObject.cs index e1f2f36df6f..f1c9b8989b5 100644 --- a/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableObject.cs +++ b/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableObject.cs @@ -227,7 +227,7 @@ protected bool SetProperty(T oldValue, T newValue, IEqualityComparer compa /// The type of property (or field) to set. /// The current property value. /// The property's value after the change occurred. - /// The model + /// The model containing the property being updated. /// The callback to invoke to set the target property value, if a change has occurred. /// (optional) The name of the property that changed. /// if the property was changed, otherwise. @@ -236,6 +236,7 @@ protected bool SetProperty(T oldValue, T newValue, IEqualityComparer compa /// raised if the current and new value for the target property are the same. /// protected bool SetProperty(T oldValue, T newValue, TModel model, Action callback, [CallerMemberName] string? propertyName = null) + where TModel : class { if (EqualityComparer.Default.Equals(oldValue, newValue)) { @@ -263,11 +264,12 @@ protected bool SetProperty(T oldValue, T newValue, TModel model, Acti /// The current property value. /// The property's value after the change occurred. /// The instance to use to compare the input values. - /// The model + /// The model containing the property being updated. /// The callback to invoke to set the target property value, if a change has occurred. /// (optional) The name of the property that changed. /// if the property was changed, otherwise. protected bool SetProperty(T oldValue, T newValue, IEqualityComparer comparer, TModel model, Action callback, [CallerMemberName] string? propertyName = null) + where TModel : class { if (comparer.Equals(oldValue, newValue)) { diff --git a/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableRecipient.cs b/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableRecipient.cs index c4ec80709ce..5a43d09aea4 100644 --- a/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableRecipient.cs +++ b/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableRecipient.cs @@ -257,6 +257,7 @@ protected bool SetProperty(T oldValue, T newValue, IEqualityComparer compa /// (optional) The name of the property that changed. /// if the property was changed, otherwise. protected bool SetProperty(T oldValue, T newValue, TModel model, Action callback, bool broadcast, [CallerMemberName] string? propertyName = null) + where TModel : class { bool propertyChanged = SetProperty(oldValue, newValue, model, callback, propertyName); @@ -288,6 +289,7 @@ protected bool SetProperty(T oldValue, T newValue, TModel model, Acti /// (optional) The name of the property that changed. /// if the property was changed, otherwise. protected bool SetProperty(T oldValue, T newValue, IEqualityComparer comparer, TModel model, Action callback, bool broadcast, [CallerMemberName] string? propertyName = null) + where TModel : class { bool propertyChanged = SetProperty(oldValue, newValue, comparer, model, callback, propertyName); diff --git a/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableValidator.cs b/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableValidator.cs index a1c20d82817..2a96ab7b837 100644 --- a/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableValidator.cs +++ b/Microsoft.Toolkit.Mvvm/ComponentModel/ObservableValidator.cs @@ -170,6 +170,7 @@ protected bool SetProperty(T oldValue, T newValue, IEqualityComparer compa /// (optional) The name of the property that changed. /// if the property was changed, otherwise. protected bool SetProperty(T oldValue, T newValue, TModel model, Action callback, bool validate, [CallerMemberName] string? propertyName = null) + where TModel : class { if (validate) { @@ -199,6 +200,7 @@ protected bool SetProperty(T oldValue, T newValue, TModel model, Acti /// (optional) The name of the property that changed. /// if the property was changed, otherwise. protected bool SetProperty(T oldValue, T newValue, IEqualityComparer comparer, TModel model, Action callback, bool validate, [CallerMemberName] string? propertyName = null) + where TModel : class { if (validate) {