ReSharper Help  

Delegating Members

With ReSharper's help you are able to quickly generate delegating members for a class.

To generate delegating members:

  1. Position the caret inside the class for which you want to generate delegating members.
  2. Press Alt + Ins or select ReSharper | Code | Generate in the main menu. The Generate popup menu is displayed:

     

     

  3. Select Delegating members from the popup menu. The Delegating Members dialog appears:

  4. In the list, select the field of property for which you want to generate delegating members. Click Continue. The following dialog appears:

  5. In the list, select the methods, properties and indexers for which you want to generate delegating members. Selecting the checkbox for a class selects all its members. Use the icons  (Tree View) and  (List View) to switch between the two available views (the Tree View shows the hierarchy of applicable types and methods).
  6. Select the Copy documentation comments checkbox if you want to include the documentation comments from the source implementation.
  7. Click Finish.

Example

We would like the FooBar class to be able to implement MethodFoo() in the same way as it is implemented in FooClass. However, FooBar already inherits from BarClass. One possible solution is to create an instance of FooClass (fooObject) and generate a delegating member for MethodFoo.

After we go through the steps described above and click Finish, FooBar class looks like the following:

See Also

Advanced Editing Features | Automatic Code Generation