Generate code from usage
JetBrains Rider lets you use code symbols (classes, methods, variables, properties, fields, and so on) before you declare them. When JetBrains Rider 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 'Generate from usage' quick-fix](https://resources.jetbrains.com.cn/help/img/rider/2024.2/Code_Analysis__Examples_of_Quick-Fixes__undefined_method__quick-fixes.png)
For example, if you create a method from usage, JetBrains Rider will not only create a method, but also detect its return type and types of its parameters:
![JetBrains Rider: Generating code from usage JetBrains Rider: Generating code from usage](https://resources.jetbrains.com.cn/help/img/rider/2024.2/Code_Analysis__Examples_of_Quick-Fixes__undefined_method__return_type.png)
For additional examples of how JetBrains Rider creates code symbols from usages, see Undefined variable and Undefined method call samples in the Examples of quick-fixes.
Last modified: 11 February 2024