INotifyPropertyChanged is widely used in .NET applications to send notifications when a property of a class has changed its value. ReSharper provides the set of features that help you implement this interface.
ReSharper helps implement property change notification for the following frameworks:
- MVVM Light (WPF 3 and 4; Silverlight 3, 4 and 5; Windows Phone 7 and 7.1)
- Caliburn.Micro (WPF 3 and 4; Silverlight 4 and 5; Windows Phone 7.1)
- Prism (WPF 4; Silverlight 4)
- Catel (WPF 3 and 4)
- MVVMHelpers (WPF 3 and 4, only lambda expressions supported)
First of all, ReSharper detects that the INotifyPropertyChanged
is being used and provides a special quick-fix to put the required implementation in place.
After applying the quick-fix, ReSharper generates a method for property change notification and prompts you to provide a name for this method.
If there are some properties in your class that do not notify about changes, you can easily transform them into properties with change notification using the corresponding context action.
When you generate properties for existing fields, select the Notify on property changes check box in the Generate dialog box to get properties with change notification.
Also, ReSharper provides code analysis and code completion for the arguments passed to the OnPropertyChanged method.
ReSharper 7.1 takes advantage of Caller Info attributes when it implements INotifyPropertyChanged in
.NET Framework 4.5 projects.
It also helps migrate to CallerMemberName-based implementations by highlighting redundant arguments
and suggesting the appropriate quick-fix.