VS自定义代码片段,快捷生成代码

1.XAML

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <Header>
    <SnippetTypes>
      <SnippetType>Expansion</SnippetType>
      <SnippetType>SurroundsWith</SnippetType>
    </SnippetTypes>
    <Title>流程Page界面</Title>
    <Author>zero</Author>
    <Description>流程Page界面</Description>
    <HelpUrl>
    </HelpUrl>
    <Shortcut>FPUI</Shortcut>
  </Header>
  <Snippet>
    <Declarations>
      <Literal Editable="true">
        <ID>TagName</ID>
        <ToolTip>新元素的名称</ToolTip>
        <Default></Default>
        <Function>
        </Function>
      </Literal>
    </Declarations>
    <Code Language="XAML">
        <![CDATA[
        --中间填写要生成的代码
          ]]>
    </Code>
  </Snippet>
</CodeSnippet>

 

2.C#

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>FlowViewNodel</Title>
			<Shortcut>FVM</Shortcut>
			<Description>流程ViewModel格式</Description>
			<Author>ZeroMa</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
				<SnippetType>SurroundsWith</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>expression</ID>
					<ToolTip>流程类型</ToolTip>
					<Function></Function>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[ 	
			--中间填写要生成的代码
			]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>

3.复制到相应位置,并改写文件后缀名为snippet

VS自定义代码片段,快捷生成代码

 

上一篇:nyoj222 整数中的1 数位DP


下一篇:使用文法的模糊测试