在作者的博客(Generate a C# delegate method stub)中引用了microsoft.com Generate method stub should support non-existent method names passed as delegates上的类似问题No "Add Method Stub" When Passing or Assigning Delegates和功能请求。他们在问题中表示该功能将在VS 2010中提供,并且功能请求被标记为已修复。但是,我没有得到任何关于在我的代码中创建委托处理程序的提示(使用VS 2010)。这是怎么回事?我做错了什么?这是一个示例代码:
class BaseEditor { }
delegate void ObjectEditorCreatedDelegate( BaseEditor editor );
class ArrayPropertyEditor
{
public ObjectEditorCreatedDelegate OnObjectEditorCreated;
}
class SomeUserCode
{
public void someMethod()
{
ArrayPropertyEditor ape = new ArrayPropertyEditor();
ape.OnObjectEditorCreated = new ObjectEditorCreatedDelegate( OnEditorCreated );
// -------------------------------------------------------------------------^
}
private void OnEditorCreated( BaseEditor editor ) { }
}
当光标位于指向的位置(使用OnEditorCreated
之后)并且尚未创建OnEditorCreated
时,VS 2010会建议“生成属性存根”和“生成字段存根”。如何生成方法?