[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
  System Requirements
  Improve Performance
 [Expand]Features by Language
 [Expand]Getting Started
 [Expand]How To
 [Collapse]Coding Assistance
  [Expand]Code Templates
  [Expand]Auto Completion
  [Expand]Clipboard Tools
  [Expand]Selection Tools
  [Collapse]Code Providers
   [Expand]Contract Providers
   [Collapse]Declaration Providers
     Declare Class
     Declare Constant
     Declare Field
     Declare Field with Initializer
     Declare Interface
     Declare Local
     Declare Method
     Declare Parameter
     Declare Property
     Declare Property with Initializer
   [Expand]Implementation Providers
    Add Copyright Header
    Add Else Statement
    Add Getter/Setter
    Add Missing Constructors
    Add Parameter
    Add to Interface
    Add XML Comments
    Convert to Function
    Convert to Procedure
    Convert to Property With Change Notification/Introduce Change Notification
    Create Event Trigger
    Encapsulate Property
    Import Type/All Types (XAML)
    Introduce Format Item
    Introduce Setter Guard Clause
    Invert Selection
    Promote to Parameter
    XPO Fields
  [Expand]Declare Menu
  [Expand]Typing Helpers
 [Expand]Navigation and Search Tools
 [Expand]Static Code Analysis
 [Expand]Visualization Tools
 [Expand]Code Style Assistance
  Building Assistance
  Debugging Assistance
 [Expand]Refactoring Assistance
 [Expand]Unit Testing Assistance
 [Expand]Decompiling Tools
 [Expand]Configuration Options
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Declare Method

Expanded Purpose

Generates a method with appropriate parameters for the selected method call. This Code Provider is useful for Test-Driven Development. It allows you to easily create declarations for methods referenced in a code fragment.


A method declared in the interface is automatically added to all its implementers.

Expanded Availability

Available when the caret is on the line with an undeclared method.

Expanded Usage

  1. Place the caret on an undeclared method's name.

  2. Hit Ctrl + . or Ctrl + ~ to invoke the Code Actions Menu.

  3. Use the mouse to select Declare Method from the menu and press Enter. The red target picker marker appears. It allows you to choose the place where the generated code can be inserted.

You can configure the Target Picker on the Editor | All Languages | Code Actions | Target Picker options page.

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

  2. Press Enter to generate a code in the selected place.

After execution, the Code Provider adds the method declaration to the class.

You can configure the default body of newly-generated methods on the Editor | <Language>| Code Actions | Code Actions Settings options page. The default value is "Throw NotImplementedException instance".

The following screencast shows the described steps in action:


The default visibility modifier of the generated member is configured on the Editor | <Language> | Scope Options options page. Refer to the Scope topic for details.

Is this topic helpful?​​​​​​​