Back to Devexpress

Code Providers

coderushforroslyn-115829-coding-assistance-code-providers.md

latest4.5 KB
Original Source

Code Providers

  • Jul 19, 2021
  • 3 minutes to read

CodeRush ships with over 40 Code Providers that can generate a lot of code for you: declare class, declare property, declare method; add a getter/setter accessor to a property, add missing constructors; add the implementation of IDisposable, ISerializable, IComparable or IEquatable interfaces, and more. This simplifies and speeds up the code creation process.

The topics in the Code Providers section describe each code provider in detail. The description includes the purpose of the code provider, its availability and the “how to use” example.

How to Use

  1. Invoke the Code Actions menu. Place the caret in the part of the code you want to change, and press Ctrl + . or Ctrl + ~.

  2. Choose the action from the invoked menu. For example, Declare Field with Initializer.

  3. Press Enter to perform the action.

  4. Use the Up Arrow and Down Arrow keys to move the target picker.

  5. Press Enter to generate code in the selected position. For example, the Declare Field with Initializer code provider adds the initialized field declaration to the current class and assigns the parameter value to it.

csharp
int iD;
bool DeleteRecord(int ID) {
    iD = ID;
    // ...
    return true;
}
vb
Private _ID As Integer
Function DeleteRecord(ID As Integer) As Boolean
    _ID = ID
    ' ...
    Return True
End Function

You can run most code providers in C# and Visual Basic. CodeRush also includes code providers that you can run in Blazor, TypeScript, JavaScript, and XAML.

Blazor Support

The following code providers are available in .razor files:

You can run Declare providers from the following places in .razor files:

  • From @code sections.

  • From Razor markup.

Note

Code providers for Blazor cannot update references in closed .razor files. Ensure all files that may be impacted by a particular code provider are open in Visual Studio before you apply the code provider.