Ham*_*jan 13 c# intellisense stylecop visual-studio-2010
相关的默认StyleCop规则是:
using陈述放在里面namespace.using字母顺序排序语句.System using先来(仍然试图弄清楚这是否意味着using System;或者using System[.*];).所以,我的用例:
Debug.Assert(,intellisense用红色标记它.我将鼠标悬停在Debug其间using System.Diagnostics;并System.Diagnostics.Debug选择前者.这将using System.Diagnostics; 在所有其他using语句之后插入.如果VS2010没有帮助我编写由于警告错误而无法构建的代码,那将是很好的.如何让VS2010更智能?是否有某种设置,或者这需要某种完整的加载项?
关于您的#1,您可以使用此处或此处的说明编辑项目模板项目.我已经为VS 2K8做了这个,默认情况下使StyleCop和FxCop很开心,但我还没有完成2010年的操作,因为我觉得这个程序有点乏味,并且VS服务包总是有可能覆盖它们.
例如,我在ConsoleApplication模板中编辑了program.cs,如下所示:
// <copyright file="Program.cs" company="$registeredorganization$">
// Copyright (c) $year$ All Rights Reserved
// </copyright>
// <author></author>
// <email></email>
// <date>$time$</date>
// <summary></summary>
namespace $safeprojectname$
{
using System;
using System.Collections.Generic;
$if$ ($targetframeworkversion$ == 3.5)using System.Linq;
$endif$using System.Text;
/// <summary>
/// Contains the program's entry point.
/// </summary>
internal static class Program
{
/// <summary>
/// The program's entry point.
/// </summary>
/// <param name="args">The command-line arguments.</param>
private static void Main(string[] args)
{
}
}
}
Run Code Online (Sandbox Code Playgroud)
和assemblyinfo.cs看起来像这样:
// <copyright file="AssemblyInfo.cs" company="$registeredorganization$">
// Copyright (c) $year$ All Rights Reserved
// </copyright>
// <author></author>
// <email></email>
// <date>$time$</date>
// <summary></summary>
using System;
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("$projectname$")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("$registeredorganization$")]
[assembly: AssemblyProduct("$projectname$")]
[assembly: AssemblyCopyright("Copyright © $registeredorganization$ $year$")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
[assembly: CLSCompliant(true)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("$guid1$")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Run Code Online (Sandbox Code Playgroud)
我在Microsoft Connect上提交了一个事件,即他们的工具的自动生成代码应该满足StyleCop/FxCop及其编码指南文档.
对于 2008 年,我使用Power Commands加载项。它包括一个用于排序和删除未使用的 using 语句的命令。我将其映射到 Ctrl-O、Ctrl-R。它不是自动的,但速度非常快。
2010 也有一个 Power Commands,但我认为使用语句的排序和顺序现在已经内置了。您只需要为其设置一个快捷方式。
附言。由于资源开销,我不使用 Resharper。每次我告诉人们它会破坏我的硬盘驱动器并导致内存使用量激增时,他们都会告诉我“尝试最新版本 - 现在好多了”。可以说,从来没有……不过我确实使用 CodeRush Xpress。
| 归档时间: |
|
| 查看次数: |
1377 次 |
| 最近记录: |