StyleCop安装及配置
How to modify the default new class template for C# in Visual Studio 2008 or 2010?
可参考博客:
http://www.rhyous.com/2010/02/17/how-to-modify-the-default-new-class-template-in-visual-studio-2008/
http://www.thecodinghumanist.com/Content/HowToEditVSTemplates.aspx
1.StyleCop安装网址:http://stylecop.codeplex.com/可下载最新版本
实现前系统默认方式:
|
1 2 3 4 5 6 7 8 9 10 11 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MyNameSpace { class MyClass { } } |
需要实现后的方式:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MyNameSpace { public class MyClass { #region Member Variables #endregion #region Constructors /// <summary> /// The default Constructor. /// </summary> public MyClass() { } #endregion #region Properties #endregion #region Functions #endregion #region Enums #endregion } } |
操作步骤:
1、找到Class.zip文件包。具体目录因操作系统不同而不同,如下:
Visual Studio 2008
· For 64 bit: C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip
· For 32 bit: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip
Visual Studio 2010
· For 64 bit: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip
· For 32 bit: C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip
2、解压Calss.zip文件包找到并打开 Class.cs 文件.
文件内容如下::
|
1 2 3 4 5 6 7 8 9 10 11 |
using System; using System.Collections.Generic; $if$ ($targetframeworkversion$ >= 3.5)using System.Linq; $endif$using System.Text; namespace $rootnamespace$ { class $safeitemrootname$ { } } |
3、将文件格式写成如下方式:
//-----------------------------------------------------------------------
// <copyright file="$safeitemrootname$.cs" company="Company">
// Copyright (C) Company. All Rights Reserved.
// </copyright>
// <author></author>
// <summary></summary>
//-----------------------------------------------------------------------
namespace $rootnamespace$
{
using System;
using System.Collections.Generic;
$if$ ($targetframeworkversion$ >= 3.5)using System.Linq;
$endif$using System.Text;
/// <summary>
///
/// </summary>
public class $safeitemrootname$
{
#region Fields
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the $safeitemrootname$ class.
/// </summary>
public $safeitemrootname$()
{
}
#endregion
#region Finalizers (Destructors)
#endregion
#region Delegates
#endregion
#region Events
#endregion
#region Enums
#endregion
#region Interfaces
#endregion
#region Properties
#endregion
#region Indexers
#endregion
#region Methods
#endregion
#region Structs
#endregion
#region Classes
#endregion
}
}
保存该文件并重新打包成Class.zip。(该文件已经默认写好全部集成在了Vss中的Class.zip内只需要覆盖)
Rebuild the zip file with the new Class.cs. Be careful to build the zip file correctly.
4、找到如下目录进行覆盖:
Visual Studio 2008
· For 64 bit: C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip
· For 32 bit: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip
Visual Studio 2010
· For 64 bit:
· C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip
· C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\5052\Class.zip
·
· For 32 bit:
· C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip
· C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\5052\Class.zip
·
5、以管理员身份打开“命令提示符”,执行如下命令
1. Visual Studio 2008
64-bit
cd C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\
32-bit
cd C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\
Visual Studio 2010
64-bit
cd C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\
32-bit
cd C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\
2. Run this command:
devenv.exe /installvstemplates
6、集成到VS2010
a.关闭工程,打开工程的.csproj文件准备编辑;
b.找到 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 这一行;
c.在该行下面加上 <Import Project="$(ProgramFiles)\MSBuild\StyleCop\v4.7\StyleCop.targets" />
d.保存文件。
7、出现CA0503,CA0505警告提示如何解决
集成到vs2010后会经常出现,CA0503,CA0505警告提示,该提示可以通过如下方式进行禁用。
A、通过注册表,运行regedit打开注册表找到下面节点:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\Setup\EDev\CodeAnalysisErrorListViolationLimit
系统默认是最多200代码分析警告显示错误列表。查看更多警告,你必须修改或增加这些警告以提高性能。你通过改变注册表键中的这个值从而超过这个限度,,如把200改成1000,注意不能无限放大。
B、如果上述方法还是没能够解决请打开项目中的.csproj文件,查找下是否在删除<PropertyGroup>节点中含有CodeAnalysisRules/CodeAnalysisRuleSet 重新的生成下项目即可
StyleCop安装及配置的更多相关文章
- JDK安装与配置
JDK安装与配置 一.下载 JDK是ORACLE提供免费下载使用的,官网地址:https://www.oracle.com/index.html 一般选择Java SE版本即可,企业版的选择Java ...
- Node.js 教程 01 - 简介、安装及配置
系列目录: Node.js 教程 01 - 简介.安装及配置 Node.js 教程 02 - 经典的Hello World Node.js 教程 03 - 创建HTTP服务器 Node.js 教程 0 ...
- 烂泥:redis3.2.3安装与配置
本文由ilanniweb提供友情赞助,首发于烂泥行天下 想要获得更多的文章,可以关注我的微信ilanniweb 前一段时间写过一篇codis集群的文章,写那篇文章主要是因为当时的项目不支持redis自 ...
- mysql源码包手动安装、配置以及测试(亲测可行)
笔记编者:小波/qq463431476博客首页:http://www.cnblogs.com/xiaobo-Linux/ 记下这篇mysql笔记,望日后有用! redhat6采用centos yum源 ...
- 环境搭建系列-系统安装之centos 6.5安装与配置
按照国际惯例,系列目录先奉上: 系列一:系统安装之centos 6.5安装与配置 系列二:准备工作之Java环境安装 系列三:数据为先之MySQL读写集群搭建 系列四:谈分布式之RabbitMQ集群搭 ...
- ZooKeeper安装与配置
一. 单机安装.配置: 1. 下载zookeeper二进制安装包下载地址:http://apache.dataguru.cn/zookeeper/zookeeper-3.4.3/zookeeper-3 ...
- mac 下JDK 与 tomcat 的安装与配置
一.Mac下JDK的安装 1.先检测Mac是否已经安装过JDK,在终端中输入java 或者 javac 显示说明,表明已经安装过JDK,JDK版本查询终端键入java -version,终端会返回JD ...
- 烂泥:zabbix3.0安装与配置
本文由ilanniweb提供友情赞助,首发于烂泥行天下 想要获得更多的文章,可以关注我的微信ilanniweb 这个月又快过完了,最近也比较忙,没时间写文章,今天挤点时间把zabbix3.0安装与配置 ...
- Jenkins入门系列之——02第二章 Jenkins安装与配置
2014-12-08:已不再担任SCM和CI的职位,Jenkins的文章如无必要不会再维护. 写的我想吐血,累死了. 网页看着不爽的,自己去下载PDF.有问题请留言! Jenkins入门系列之——03 ...
随机推荐
- hadoop2.2编程:MRUnit
examples: Overview This document explains how to write unit tests for your map reduce code, and test ...
- [转] HDU 题目分类
转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...
- GitHub常用 库
来自: http://www.jianshu.com/p/6475c90e8b4d 网络请求库 https://github.com/AFNetworking/AFNetworking https:/ ...
- ora-01589
今天遇到了ORA-01589这个错误,下面把解决方案记录如下: SQL*Plus: Release 9.2.0.1.0 - Production on 星期四 4月 17 15:01:26 2008C ...
- 步步为营 SharePoint 开发学习笔记系列总结
转:http://www.cnblogs.com/springyangwc/archive/2011/08/03/2126763.html 概要 为时20多天的sharepoint开发学习笔记系列终于 ...
- lightoj 1008
水题,开根号判断大致范围,再找即可. #include<cstdio> #include<cmath> #include<cstdlib> using namesp ...
- POJ 2570
思路:floyd + 位运算.map[i][j]的二进制位前26位表示i到j路径里面字母a-z的存在情况,为1说明该字母存在,为0不存在. #include<iostream> #incl ...
- Bootstrap之表格checkbox复选框全选 [转]
转自: http://blog.csdn.net/shangmingchao/article/details/49761315 效果图: HTML中无需添加额外的一列来表示复选框,而是由JS完成,所以 ...
- [POJ3684]Physics Experiment
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1363 Accepted: 476 Special Judge ...
- [洛谷2397]yyy loves Maths VI
题目背景 自动上次redbag用加法好好的刁难过了yyy同学以后,yyy十分愤怒.他还击给了redbag一题,但是这题他惊讶的发现自己居然也不会,所以只好找你 题目描述 他让redbag找众数他还特意 ...