About teusje

https://teusje.wordpress.com

Visual Studio 2015 C#6 replace INotifyPropertyChanged with nameof()

In Visual Studio 2015 with C#6.0 you can write your OnPropertyChange using the new nameof().

NotifyOfPropertyChange(() => Prop);

with

NotifyOfPropertyChange(nameof(Prop));

Regex for Visual Studio 2015 to find and replace:

Text to search:

(?:\()[()][)][ ][=][>] (.*)(?:\);)

Replace with:

(nameof($1));

Make sure the option “Use Regular Expressions” is enabled in the find and replace window.

Quick and dirty, comment your regex below :-)