Liên quan đến số 1 của bạn, bạn có thể chỉnh sửa các mục mẫu dự án bằng cách sử dụng các hướng dẫn here hoặc here. Tôi đã làm điều này cho VS 2K8 để làm cho StyleCop và FxCop hạnh phúc theo mặc định, nhưng tôi đã không nhận được xung quanh để làm nó cho năm 2010 như tôi tìm thấy các thủ tục một chút tẻ nhạt và luôn luôn có khả năng một gói dịch vụ VS có thể ghi đè lên chúng .
Ví dụ, tôi chỉnh sửa program.cs trong mẫu ConsoleApplication trông như thế này:
// <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)
{
}
}
}
và AssemblyInfo.cs trông như thế này:
// <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")]
Tôi đã gửi an incident tại Microsoft Kết nối với hiệu ứng là mã được tạo tự động của công cụ của họ phải thỏa mãn StyleCop/FxCop và tài liệu hướng dẫn mã hóa của chúng.
Nguồn
2010-05-20 16:24:54
Hãy nhớ rằng ngay cả MS cũng lưu ý rằng bạn không phải tuân theo tất cả các quy tắc và bản thân họ cũng không phải (re: # 1). – user7116
Hm ... vậy họ không sử dụng quy tắc nào? Nó có được quyết định trên cơ sở dự án không? –