生成方法存根片段:更改签名以使访问级别公开

时间:2013-03-22 12:03:08

标签: c# visual-studio-2012 refactoring code-snippets

默认情况下,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>

0 个答案:

没有答案