Code Generation


Create from Usage

With ReSharper, you can use a method/function, property, local or field variable or even a class before it's been declared. ReSharper will suggest a quick-fix (for C#) or several context actions (for VB.NET) for generating the corresponding symbol based on the usage, and then smartly adjust the declaration according to the usage context. For example, if you create a method from usage, ReSharper will not only create a method, but also detect its return type as well as the types of its parameters.

to the top

Generate Type Members

You can quickly generate different type members with ReSharper, by simply pressing Alt+Ins.

to the top

Generate Type Constructor

Select Constructor in the Generate pop-up menu, and then select the fields, auto-properties and base constructors that you wish to initialize in the constructor. Creating constructors in this way takes just a few keystrokes.

to the top

Generate Properties

First, select Read-only properties or Properties in the Generate menu. Second, select one or more fields when prompted in the dialog box. Voila. Optionally, you can make the new property virtual, or copy XML documentation from field declarations.

to the top

Implement/Override Methods

Create stubs for implementing interface/overriding inherited member functions. When a list of available methods to implement/override is provided; appropriate stubs are generated. You can generate several stubs at once by selecting several methods when prompted. Overriden properties can be made automatic.

to the top

Generate Delegating Members

Delegating members provides a means to encapsulate some behavior or publish methods of a class's field through the class's own interface. Specify fields and their methods, and ReSharper will generate wrapping methods in the current class.

to the top

Generate Formatting Members

In any class, you can quickly generate a ToString() override which returns a format string with any number of type fields or auto-properties.

to the top

Generate Equality Members

Quickly generate Equals() and GetHashCode() method for the current type. ReSharper not only creates the methods, but also generates the necessary code for an equality check and/or for calculating hash code. In addition, ReSharper can generate equality and inequality operators, or strongly typed IEquatable<T> interface.

to the top