JetBrains Rider 2017.2 Help

Generating Delegating Members

Code | Generate | Delegating Members
Alt+Insert | Delegating Members

With JetBrains Rider, you can quickly generate members that delegate execution to public members (methods and properties) available through private fields and properties - in other words, publish the desired part of the interface of any private field or property in the containing type.

In the example below, this command is used to generate delegating members for the _center field:

Before generationAfter generation
class Point { public Point(int x, int y) { X = x; Y = y; } public int X { get; } public int Y { get; } public void DoSomething() {} } class Circle { int _radius; Point _center; }
class Point { public Point(int x, int y) { X = x; Y = y; } public int X { get; } public int Y { get; } public void DoSomething() {} } class Circle { int _radius; Point _center; public int X { get { return _center.X; } } public int Y { get { return _center.Y; } } public void DoSomething() { _center.DoSomething(); } }

To generate delegating members

  1. In the editor, set the caret on the type name or within a type at the line where you want to insert delegating members. If the caret is on the type name, generated code will be added in the beginning of the type declaration.
  2. Press Alt+Insert or choose Code | Generate... in the main menu.
  3. In the Generate pop-up menu, select Delegating Members.
  4. In the Generate dialog that appears, you will see a list of private properties and fields in the current type. You can expand these items to see the members of their types. Select some or all of these type members, and JetBrains Rider will generate wrappers in the current type that delegate execution to selected type members.
    Generating delegating members with JetBrains Rider
  5. Click OK to complete the wizard.
Last modified: 21 November 2017

See Also