Skip to content

Note

不挑戰記憶力的技術筆記

Menu
Menu

[C#] 利用Stylecop控制Code Style on Visual Studio

Posted on 2014 年 4 月 23 日 by febr

Stylecop 主要是針對 C# 語言特性所定義,

用來檢測 C# 是否符合Code Style,讓coding人員統一照這些rule。

從官網下載安裝後記得要做設定,官方文件有說明:Setting Up StyleCop MSBuild Integration

安裝完成後,於Visaul Stuidio專案按右鍵會看到多了兩個選項:

StyleCop

  • 首先是在*.csproj import StyleCop.targets檔案:
  <Import Project="$(MSBuildBinPath)Microsoft.CSharp.targets" />
  <Import Project="$(ProgramFiles)MSBuildStyleCopv4.7StyleCop.targets" />

記得version更改成自己安裝的版號

  • 將StyleCop檢查視為error:

若要讓沒通過rule的warning變成error,可於專案檔(*.csproj)中的<PropertyGroup>加上MSBuild屬性設定:<StyleCopTreatErrorsAsWarniings>

false

接著就可以開始定義Team的Code Style囉

近期文章

  • [AWS] S3 Object Initiate restore (復原回 Standard)
  • [Windows] 使用者快速登出的方法 Logout/ Logoff/Sign Out from Windows User Account
  • [Windows] Windows 11 安裝Server管理工具Install RSAT(Remote Server Administrator Tools)
  • Chrome出現:你的連線不是私人連線 Your connection is not private
  • [C#] 取得 Request URL 的方法

近期留言

    彙整

    分類

    • Ajax
    • Android
    • ASP
    • ASP.NET MVC
    • Azure
    • C#
    • Cisco
    • CSS
    • Delphi
    • Developer Tools
    • Framework
    • FreeBSD
    • Git
    • HTML5
    • javascript
    • jQuery
    • Juniper
    • Linux
    • Mac
    • PHP
    • Python
    • Server&OS
    • Software
    • SQL server
    • Sublime Text
    • Ubuntu
    • Visual Studio
    • Vmware
    • Web Design
    • Web Development
    • Windows
    • WordPress
    • 未分類
    • 未分類

    彙整

    分類

    • Ajax
    • Android
    • ASP
    • ASP.NET MVC
    • Azure
    • C#
    • Cisco
    • CSS
    • Delphi
    • Developer Tools
    • Framework
    • FreeBSD
    • Git
    • HTML5
    • javascript
    • jQuery
    • Juniper
    • Linux
    • Mac
    • PHP
    • Python
    • Server&OS
    • Software
    • SQL server
    • Sublime Text
    • Ubuntu
    • Visual Studio
    • Vmware
    • Web Design
    • Web Development
    • Windows
    • WordPress
    • 未分類
    • 未分類

    其他操作

    • 登入
    • 訂閱網站內容的資訊提供
    • 訂閱留言的資訊提供
    • WordPress.org 台灣繁體中文
    © 2025 Note | Powered by Superbs Personal Blog theme