To generate properties
- Position the caret within a class where you'd like to generate properties.
- On the main menu, choose ReSharper | Edit | Generate Code, or press Alt+Insert.
- From the Generate pop-up menu, select Properties or Read-only properties.
- On the Generate properties or Generate read-only properties
page of the Generate wizard, select fields to generate properties
- Optionally, use the following controls that are applied to all properties at this point (see
next step for guidelines on
customizing individual properties):
- Access Rights defines common access rights for generated properties.
- Read-only defines whether to generate properties as read-only or not. If you choose Automatic, ReSharper will generate only getters for read-only fields, and both getters and setters for any other fields.
- Virtual (if applicable) adds the
virtualmodifier to generated properties.
- Debugger steps through adds the
DebuggerStepThroughattribute to getters and setters of generated properties.
- Copy XML documentation copies XML documentation from fields to properties.
- Do one of the following:
- To configure generation options (listed in the previous step) individually for specific
fields, click Advanced. You can then select individual
fields, or Ctrl-click two or more fields to configure
their respective settings in a uniform fashion.
After finishing this step, click Next, and as soon as the following screen appears, click Finish.
- Click Finish to complete the wizard.
For example, if two fields are configured to be accessed with public read-only properties with duplicated XML documentation, and the other two are configured to be accessed with protected virtual read-write properties that debugger should step through, the following code is generated:
- To configure generation options (listed in the previous step) individually for specific fields, click Advanced. You can then select individual fields, or Ctrl-click two or more fields to configure their respective settings in a uniform fashion.