仅通过转发参数生成调用 class 私有字段方法的方法?

Generate method that calls class private field method by just forwarding parameters?

是否可以在 Visual Studio 或 ReSharper 中生成仅将参数转发给私有字段方法的方法?

class Inner
{
 public void Test(String a, String b){}
}
class Outer
{
  private Inner _inner;
  public Outer(Inner inner)
  {_inner = inner;}
  /*
  //I want to generate this:
  public void Test(String a, String b)
  {
    _inner.Test(a, b);
  }
  */
}

您正在寻找的 Resharper 功能称为 "Generating delegating members" 并描述为 here:

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, the generated code will be added in the beginning of the type declaration.

  2. Press Alt+Insert or choose ReSharper | Edit | Generate Code… from the main menu. Alternatively, you can press Ctrl+Shift+A, start typing the command name in the pop-up, and then choose it there.

  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 ReSharper will generate wrappers in the current type that delegate execution to selected type members.
  5. Click Finish to complete the wizard. You can also click Options to review or modify common code generation preferences on the Code Editing | Members Generation page of ReSharper options.