`

vs.net 2010中使用code snippets

    博客分类:
  • .NET
阅读更多
其实在vs.net 2010中,使用code snippets跟以前差别不是很大,笔记之:



1 在工程中,建立一个xxx.snippetXML文件



2 然后切换到XML代码视图,然后右键,选择插入“代码片段”

3 之后就可以修改代码片段中的比如名称,作者,说明等,比如现在是做一个简单的单元测试的snippets,可以这样:

  

<?xml version="1.0" encoding="utf-8" ?>

<CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <Header>
    <Title>Test Fixture</Title>
    <Author>lyr</Author>
    <Shortcut>fixture</Shortcut>
    <Description>create a basic nuint</Description>
    <SnippetTypes>
      <SnippetType>Expansion</SnippetType>
    </SnippetTypes>
  </Header>
  <Snippet>
    <Declarations>
      <Literal>
        <ID>namespaceName</ID>
        <Default>theNamespceForTheFixture</Default>
      </Literal>
      <Literal>
        <ID>testFixtureName</ID>
        <Default>yourTestFixtureName</Default>
      </Literal>
    </Declarations>
    <Code Language="CSharp">
      <![CDATA[using System;
       using NUnitt.Framework;
       namespace $namespaceName$
       {
       [TestFixture]
       public class $testFixtureName$
       {
       }
      
       }
     
     
      ]]>
    </Code>
  </Snippet>
</CodeSnippet>





4 然后在工具--代码片段管理器中,选择导入或保存

5 在使用时,输入比如fixture,注意这里是 <Shortcut>fixture</Shortcut>,连续按TAB两次即可

2
1
分享到:
评论

相关推荐

    asp.net知识库

    在ASP.NET中使用WINDOWS验证方式连接SQL SERVER数据库 改进ADO.Net数据库访问方式 ASP.NET 2.0 绑定高级技巧 简单实用的DataSet更新数据库的类+总结 [ADO.NET]由数据库触发器引发的问题 为ASP.NET封装的SQL数据库...

    AutoCADSnippet vb.net 开发用代码片段

    C:\Users\【你的用户名字】\Documents\Visual Studio 2015\Code Snippets\Visual Basic\My Code Snippets 里面 或者 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VB\Snippets\2052 (Program Files (x86)\...

    .net PDFSharp 开源码

    the Wiki introduces many of the PDFsharp and MigraDoc samples with screen shots, code snippets, generated PDF files, etc.

    vonage-dotnet-code-snippets:使用Nexmo的.NET代码示例

    使用CSharp的.NET的Vonage API代码段 代码段项目的目的是提供针对一个目标的简单示例。 例如,发送SMS,处理传入的SMS Webhook或进行“文字转语音”通话。 使用您的Vonage凭证进行配置 要使用此样本,您首先需要一...

    ASP.NET jQuery Cookbook

    -Tips and tricks for interfacing the jQuery library with ASP.NET controls ...-Step-by-step guide with plenty of code snippets and screen images -Simple, effective, and easy-to-follow recipes

    ASP.NET 3.5 CMS Development

    A step-by-step guide with plenty of code snippets and screen images ASP.NET 3.5 is equipped with a built-in security system, standard design templates, and easy configurations for database ...

    微软开源的跨平台编辑器 Visual Studio Code.zip

    Visual Studio Code 为开发者们提供了对多种编程语言的内置支持,并且正如 Microsoft 在今天 Build 大会的 keynote 中所指出的,这款编辑器也会为这些语言都提供了丰富的代码补全和导航功能。JavaScript,TypeScript...

    Fesslersoft-Extensions:Codesnippets.Fesslersoft.de扩展

    该库将与.NET Framework 3.5及更高版本一起使用。 ##关于Fesslersoft 我们提供多种语言的源代码片段,例如Java,Python,C ++,C#,VB.NET,XML,HTML,PHP,Javascript,jQuery,AngularJs,Batch等。 ## NuGet ...

    bootstrap5-snippets:适用于Visual Studio代码的Bootstrap 5代码段

    适用于Visual Studio Code的Bootstrap 5片段该扩展提供了Bootstrap 5片段版本文献资料要求Bootstrap Version : 5.0安装启动代码的命令面板ext install adereksisusanto.bootstrap5-snippets片段入门模板命令 : b5-...

    Fesslersoft-WindowsAPI:Windows API包装器Codesnippets.Fesslersoft.de

    该库将与.NET Framework 2.0及更高版本一起使用。 ##关于Fesslersoft 我们提供多种语言的源代码片段,例如C#,VB.NET,XML,Java,Python,C ++,HTML,PHP,Javascript,jQuery,AngularJs,Batch等。 ## ...

    hough变换提取直线(Matlab实现)

    hough变换提取直线(Matlab实现)

    Script Inspector 3 v3.0.30

    – Customizable code snippets – Code generators for Unity magic methods – Code generators for override methods – Auto-closing braces – Auto-indent – Automated saving and reloading – Quick ...

    Python库 | generate_vscode_snippets-0.0.1-py3-none-any.whl

    资源分类:Python库 所属语言:Python 使用前提:需要解压 资源全名:generate_vscode_snippets-0.0.1-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    NET.4.for.Enterprise.Architects.and.Developers

    It illustrates key scenarios and specific features with code snippets to help you understand the technical aspects of implementation. Praise for the book: ... presents broad and deep coverage of ...

    Mastering Linux Shell Scripting(PACKT,2015)

    Learn about various conditional statements’ code snippets, and realize the power of repetition and loops in your shell script. Implement functions and edit files using the Stream Editor, script in ...

    JGsoft.RegexBuddy.v3.4.2

    根据你使用的特定的编程语言自动在你的源代码中使用正则表达式代码片断。收集归档正则表达式例库以便将来重用。可以把RegexBuddy整合到你喜好的搜索和编辑工具里,以便快速使用。 RegexBuddy 使用 RegexBuddy 可以...

    Visual Studio 2015 Cookbook(PACKT,2ed,2016)

    From customization and the interface to code snippets and debugging, the Visual Studio upgrade expands your options ― and this book is your fast-track guide to getting on board quickly. Visual ...

Global site tag (gtag.js) - Google Analytics