You can quickly generate different type members with ReSharper. To view the list of available code generation options for the current type, choose ReSharper | Edit | Generate Code on the main menu or press Alt+Insert.
Specifically, ReSharper helps you:
- Generate type constructors
- Generate properties
- Implement and override members
- Generate delegating members
- Generate partial members
- Generate equality members (Equals() and GetHashCode() methods)
- Generate equality comparer class for your type
- Generate formatting members (ToString() methods)
To bind any code generation command to its own shortcut, go to Tools | Options | Environment | Keyboard and look for commands starting with ReSharper_Generate.
However, ReSharper's code generation features are more than that - you can use undeclared code symbols, and ReSharper will help declare them with a quick-fix. See Generating Code from Usage for details.
You can control how new members are generated in two major ways:
- Configure a custom Naming Style for different members. When there's a naming style in place, ReSharper enforces its requirements when generating new members.
- Choose default body content for generated members. One of the three options - NotImplementedException(), returning default value, and non-compilable code - can be configured in the Members Generation Options.
Code generation features described in this section apply mostly to C# and VB.NET. However, ReSharper provides more code generation options for other languages, for example, Generate content for placeholders. To learn more, consult the corresponding subsections of the ReSharper by Language section.
- Creating Files from Templates
- Creating Source Code Using Live Templates
- Surrounding Code Fragments with Templates
- Examples of Quick-Fixes
- Surrounding with Region
- Importing Namespaces
- Usage Scenarios