如何修改为新的C#类/接口Visual Studio的模板? [英] How do I edit the Visual Studio templates for new C# class/interface?

查看:188
本文介绍了如何修改为新的C#类/接口Visual Studio的模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现自己删除以下import语句在几乎所有的C#文件创建Visual Studio中:

 使用System.Collections.Generic;
使用System.Linq的;
使用System.Text;

当然它很容易与ReSharper的做到这一点,但我真的不应该。

必须有一些模板(类,接口)在VS目录的地方,从中我可以删除有问题的线路。我在哪里可以找到这些文件?有没有更好的办法来控制默认的导入列表?


解决方案

提取物,编辑和RECOM preSS。路径是类模板,但界面模板是在同一个文件夹中。

您可能需要编辑在每个VS模板文件删除的事实,他们不会自动添加引用到组件系统,System.Data这和/或的System.Xml。

2005


  

C:\\ Program Files文件(x86)的\\微软的Visual Studio 8 \\ Common7 \\ IDE \\的ItemTemplate \\ CSHARP \\ 1033 \\ Class.zip


2008


  

C:\\ Program Files文件(x86)的\\微软的Visual Studio 9.0 \\ Common7 \\ IDE \\的ItemTemplate \\ CSHARP \\ code \\ 1033 \\ Class.zip


2010


  

C:\\ Program Files文件(x86)的\\微软的Visual Studio 10.0 \\ Common7 \\ IDE \\的ItemTemplate \\ CSHARP \\ code \\ 1033 \\ Class.zip


与Visual Studio 2012开始,模板都没有压缩,因此您可以直接在每个适用的文件夹编辑每个的.cs 模板。

2012


  

C:\\ Program Files文件(x86)的\\微软的Visual Studio 11.0 \\ Common7 \\ IDE \\的ItemTemplate \\ CSHARP \\ code \\ 1033 \\类\\ Class.cs


2013


  

C:\\ Program Files文件(x86)的\\微软的Visual Studio 12.0 \\ Common7 \\ IDE \\的ItemTemplate \\ CSHARP \\ code \\ 1033 \\类\\ Class.cs


2015年:


  

C:\\ Program Files文件(x86)的\\微软的Visual Studio 14.0 \\ Common7 \\ IDE \\的ItemTemplate \\ CSHARP \\ code \\ 1033 \\类\\ Class.cs


注释

防爆preSS版本

在防爆preSS版,您将在子目录中搜索 WDEx preSS 中的 IDE 文件夹,所以如对VS 2015防爆preSS:


  

C:\\ Program Files文件(x86)的\\微软的Visual Studio 14.0 \\ Common7 \\ IDE \\ WDEx preSS \\的ItemTemplate \\ CSHARP \\ code \\ 1033 \\类\\ Class.cs


其他语言

如果你不使用Visual Studio的英语版本,文件夹 1033 可能不存在,但不同数量的重新presenting您的语言。例如,它是 1031 在德国安装。

I find myself removing the following import statements in nearly every C# file I create Visual Studio:

using System.Collections.Generic;
using System.Linq;
using System.Text;

Of course its really easy to do this with Resharper, but I really should not have to.

There must be a few template (class, interface) somewhere in the VS directory, from which I can remove the offending lines. Where do I find these files? Is there a better way to control the default import list?

解决方案

Extract, edit and recompress. Paths are for the class template, but the interface templates are in the same folder.

You may want to edit the VS template file in each to remove the fact that they don't automatically add references to the assemblies System, System.Data and/or System.Xml.

2005:

C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\ItemTemplates\CSharp\1033\Class.zip

2008:

C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip

2010:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip

Starting with Visual Studio 2012, the templates are not zipped, so you can edit each .cs template in each applicable folder directly.

2012:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class\Class.cs

2013:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class\Class.cs

2015:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class\Class.cs

Notes

Express Editions

In Express Editions you will have to search in the subdirectory WDExpress inside the IDE folder, so e.g. for VS 2015 Express:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\WDExpress\ItemTemplates\CSharp\Code\1033\Class\Class.cs

Other Languages

If you don't use the English version of Visual Studio, the folder 1033 may not exist, but a different number representing your language. For example it is 1031 in a German installation.

这篇关于如何修改为新的C#类/接口Visual Studio的模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆