ReSharper 2023.3 Help

Generate code from usage

ReSharper lets you use code symbols (classes, methods, variables, properties, fields, and so on) before you declare them. When ReSharper detects an undeclared symbol, it suggests one or more quick-fixes Alt+Enter for generating a declaration based on the usage, and then smartly adjust the declaration according to the usage context:

'Generate from usage' quick-fix

For example, if you create a method from usage, ReSharper will not only create a method, but also detect its return type and types of its parameters:

ReSharper: Generating code from usage

For additional examples of how ReSharper creates code symbols from usages, see Undefined variable and Undefined method call samples in the Examples of quick-fixes.

This feature is supported in the following languages and technologies:

Language: C#

Language: VB.NET

Language: C++

Language: HTML

Language: ASP.NET

Language: Razor

Language: JavaScript

Language: TypeScript

Language: CSS

Language: XML

Language: XAML

Language: Resx

Language: Build Scripts

Language: Protobuf

Language: JSON

Feature is available in C#

Feature is available in Visual Basic

Feature is available in C++

Feature is available in HTML

Feature is available in ASP.NET

Feature is available in Razor

Feature is available in JavaScript

Feature is available in TypeScript

Feature is available in CSS

Feature is not available in XML

Feature is available in XAML

Feature is not available in Resource files

Feature is available in build script files

Feature is not available in Protobuf

Feature is not available in JSON

The instructions and examples given here address the use of the feature in C#. For more information about other languages, refer to corresponding topics in the ReSharper by language section.

Last modified: 21 March 2024