默认情况下,Visual Studio的“Extract method ...”命令会生成具有最低访问级别的方法存根,通常为private
。它的相关代码段仅引用“签名”,但如何编辑此签名?
供参考,C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC#\Snippets\1033\Refactoring\MethodStub.snippet
的内容:
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Method Stub - Body</Title>
<Description>Snippet for generating method stub with a body</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Refactoring</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal Editable="true">
<ID>signature</ID>
<Default>signature</Default>
</Literal>
<Literal>
<ID>Exception</ID>
<Function>SimpleTypeName(global::System.NotImplementedException)</Function>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[$signature$
{
$end$throw new $Exception$();
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>