The Convert Property to Method(s) refactoring converts type properties to getter and/or setter methods. A read property is converted to a getter method, a write property is converted to a setter method, and a read-write property is converted to two separate methods: a getter and a setter.
- Place the caret at the name of a property in the editor, in the File Structure window, in Class View or Object Browser.
Do one of the following:
- On the main menu, choose ReSharper| Refactor | Convert | Property to Method(s).
- Choose Refactor | Convert | Property to Method(s) on the context menu.
- Press Ctrl+Shift+RCtrl+Shift+R, then click Convert Property to Method(s).
The Convert Property to Method(s) dialog box opens.
Type method names in the appropriate text boxes or leave the default ones:
NoteFor a read-write property you may generate a pair of methods, or a single method for either getter or setter, by leaving the appropriate check box selected.
- Click Next. If no conflicts are found, ReSharper performs the refactoring immediately and the property is converted into appropriate method(s). At the same time, all usages of the property (both read and write) will be substituted with the corresponding method calls. Otherwise, resolve conflicts.
Consider the example below:
After converting the BackgroundColor property into a pair of methods, the code looks as follows: