何となく Blog by Jitta
Microsoft .NET 考

目次

Blog 利用状況
  • 投稿数 - 761
  • 記事 - 18
  • コメント - 35928
  • トラックバック - 222
ニュース
  • IE7以前では、表示がおかしい。div の解釈に問題があるようだ。
    IE8の場合は、「互換」表示を OFF にしてください。
  • 検索エンジンで来られた方へ:
    お望みの情報は見つかりましたか? よろしければ、コメント欄にどのような情報を探していたのか、ご記入ください。
It's ME!
  • はなおか じった
  • 世界遺産の近くに住んでます。
  • Microsoft MVP for Visual Developer ASP/ASP.NET 10, 2004 - 9, 2011
広告

記事カテゴリ

書庫

日記カテゴリ

ギャラリ

その他

わんくま同盟

同郷

 

内容の非道い C# のコードを見ていて、何とかするために何ができるか考えた。結局、「これこれのコードで指摘が出るから直した方が良い」というのが、理由付けが簡単かな?と考え、FxCop を適用することにした。それを調べている途中で、StyleCop の事を知った。それらを使うための準備。

FxCop は、IL を解析して、様々なルールに沿っているかどうかをチェックするツール。IL を解析するので、VB だろうが C# だろうがドンとこい。しかし、IL を解析するので、指摘事項がコードのどこに該当するのか、分かり難い。しかし、ツール上に出てくる指摘に対する詳細が書かれたウェブ ページは日本語化されている。

StyleCop は、C# のコードを解析して、ルールに沿っているかどうかをチェックするツール。コードを解析するので、C# しか対応していない。また、指摘事項に対するコードを探すのが容易。しかし、今のところ英語しかない(有志による翻訳はある)。

まず、FxCop。Visual Studio の Premium エディション、Ultimate エディションの場合、VS のインストールで一緒にインストールされる(多分)。Professional 以下のエディションの場合、Windows SDK 7.1 をダウンロードしてくる。ウェブ インストーラのダウンロード ページからインストーラをダウンロードする。SDK インストール後、スタートメニューより「Microsoft Windows SDK v7.1→Tools→Install Microsoft FXCop」を選択して、FxCop のインストーラを実行する。

適用されるルールは以下の通り。一部注釈が付いているのは、手持ちのプロジェクトで指摘された項目。

Design Rules
 CA1012: Abstract types should not have constructors
 CA2210: Assemblies should have valid strong names
   アセンブリは、正しい厳密名を持つべきです。
 CA1040: Avoid empty interfaces
 CA1005: Avoid excessive parameters on generic types
 CA1020: Avoid namespaces with few types
 CA1021: Avoid out parameters
   out パラメータを使わないようにします。
 CA1010: Collections should implement generic interface
 CA1011: Consider passing base types as parameters
 CA1009: Declare event handlers correctly
 CA1050: Declare types in namespaces
 CA1026: Default parameters should not be used
 CA1019: Define accessors for attribute arguments
 CA1031: Do not catch general exception types
   Exception あるいは SystemException をキャッチしてはいけません。
 CA1047: Do not declare protected members in sealed types
 CA1000: Do not declare static members on generic types
 CA1048: Do not declare virtual members in sealed types
 CA1051: Do not declare visible instance fields
   外部からアクセス可能なインスタンス フィールドを宣言しないようにします。
 CA1002: Do not expose generic lists
 CA1061: Do not hide base class methods
 CA1006: Do not nest generic types in member signatures
 CA1046: Do not overload operator equals on reference types
 CA1045: Do not pass types by reference
   ref パラメータを使うことは避けます。
 CA1065: Do not raise exceptions in ubexpected locations
 CA1028: Enum storage should be Int32
 CA1038: Enumerators should be strongly typed
 CA1008: Enums should have zero value
   列挙型は 0 の値を含むようにしましょう。
 CA1064: Exceptions should be public
 CA1004: Generic methods should provide type parameter
 CA1035: ICollection implementations have strongly typed members
 CA1063: Implement IDisposable collectly
 CA1032: Implement standard exception constructors
 CA1023: Indexers should not be multidimensional
 CA1033: Interface methods should be callable by child types
 CA1039: Lists are stongly typed
 CA1016: Mark assemblies with AssemblyVersionAttribute
 CA1014: Mark assenblies with CLSCompliantAttribute
   アセンブルを CLSCompliantAttribute でマークしましょう。
 CA1017: Mark assenblies with ComVisibleAttribute
 CA1018: Mark attributes with AttributeUsageAttribute
 CA1027: Mark enum with FlagAttribute
   列挙型を FlagsAttribute でマークしましょう。
 CA1059: Members should not expose certain concrete types
 CA1060: Move P/Invokes to NativeMethods class
   プラットフォーム呼び出しは、NativeMethods クラスに集約しましょう。
 CA1034: Nested types should not be visible
   型をグルーピングするためにネストした型を使わないようにしましょう。
 CA1013: Overload operator equals on overloading add and subtract
 CA1036: Override methods on comparable types
 CA1044: Properies should not be write only
 CA1041: Provide ObsoleteAttribute message
 CA1025: Replace repetitive arguments with params array
 CA1052: Static holder types should be sealed
 CA1053: Static holder types should not have constructors
 CA1057: String URI overloads call System.Uri overloads
 CA1058: Types should not extend certain base types
 CA1001: Types that own disposable fields should be disposable
 CA1049: Types that own native respources should be disposable
 CA1054: URI parameters should not be strings
 CA1056: URI properties should not bee strings
 CA1055: URI return values should not be strings
 CA1030: Use events where appropriate
 CA1003: Use generic event handler instances
 CA1007: Use generic where appropriate
 CA1043: Use integral or string argument for indexers
 CA1024: Use properties where appropriate

Globalization Rules
 CA1301: Avoid duplicate accelerators
 CA1302: Do not gardcode locale specific strings
 CA1308: Normalize strings to uppercase
 CA1306: Set locale for data types
 CA1304: Specify CultureInfo
 CA1305: Specify IFormatProvider
   IFormatProvider を受け入れるオーバーロードを利用するようにします。
 CA2101: Specify marshaling for P/Invoke string arguments
   文字列引数に対してマーシャリングを指定します。
 CA1300: Specify MessageBoxOptions
   MessageBox のオプションは明示するようにします。
 CA1307: Specify StringComparison
   StringComaprison パラメーターを指定するようにします。
 CA1309: Use ordinal StringComparison

Interoperability Rules
 CA1403: Auto layout types should not be COM visible
 CA1406: Avoid Int64 arguments for Visual Basic 6 client
 CA1413: Avoid non-public fields in COM visible value type
 CA1402: Avoid overloads in COM visible types
 CA1407: Avoid static members in COM visible types
 CA1404: Call GetLastError immediately after P/Invoke
 CA1410: COM registration methods should be matched
 CA1411: COM registration methods should not be visible
 CA1405: COM visible type base types should be COM visible
 CA1409: COM visible types should be creatable
 CA1415: Declare P/Invokes correctly
 CA1408: Do not use AutoDual ClassInterfaceType
 CA1414: Mark boolean P/Invoke arguments with MarshalAs
 CA1412: Mark ComSource interfaces as IDispatch
 CA1400: P/Invoke entry points should exist
 CA1401: P/Invokes should not be visible

Mobility Rules
 CA1600: Do not use idle process priority
 CA1601: Do not use timers that prevent power state changes
   省電力設定を妨げるようなタイマーを使用しません。
   1秒より短い時間を指定してください。

Naming Rules
 CA1702: Compound words should be cased collectly
 CA1700: Do not name enum values 'Reserved'
 CA1712: Do not prefix enum values with type name
 CA1713: Events should not have before or after prefix
 CA1714: Flags enums should have plural names
 CA1709: Identifiers should be cased correctly
   識別子は、正しく大文字小文字を使用します。
   ※ 日本語識別子を使用する場合は OFF
 CA1704: Identifiers should be spelled correctly
   識別子は正しいスペルを使用します。
   ※ 日本語識別子を使用する場合は OFF
 CA1708: Identifiers should differ by more than case
 CA1715: Identifiers should have correct prefix
 CA1710: Identifiers should have correct suffix
 CA1720: Identifiers should not contain type names
 CA1707: Identifires should not contain underscores
   識別子にはアンダースコアを含まないようにします。
 CA1722: Identifiers should not have incorrect prefix
 CA1711: Identifiers should not have incorrect suffix
 CA1716: Identifiers should not match keywords
 CA1717: Only FlagsAttribute enum should have plural names
 CA1725: Parameter names should match base declaration
 CA1719: Parameter names should not match member names
 CA1721: Property names should not match get methods
 CA1701: Resource string compound words should be cased correctly
   ※ 日本語識別子を使用する場合は OFF
 CA1703: Resource strings should be spelled correctly
 CA1724: Type names should not match namespaces
 CA1726: Use preferred terms
   適切な用語を使用します。

Performance Rules
 CA1809: Avoid excessive locals
 CA1811: Avoid uncalled private code
   呼び出されていない private なメソッドを使用しません。
 CA1812: Avoid uninstantiated internal classes
 CA1813: Avoid unsealed attributes
 CA1823: Avoid unused private fields
   参照されていない private なフィールドを使用しません。
 CA1800: Do not cast unnecessarily
   不必要にキャストしません。
 CA1810: Initialize reference type static fields inline
 CA1824: Mark assemblies with NeutralResourcesLanguageAttribute
 CA1822: Mark members as static
   メンバーを static としてマークします。
 CA1815: Override equals and operator equals on value types
   構造体では euquals および operator equals をオーバーライドします。
 CA1814: Prefer jagged arrays over multidimensional
 CA1819: Properties should not returns arrays
   プロパティでは配列を返さないようにします。
 CA1821: Remove empty finalizers
 CA1804: Remove unused locals
   使用していないローカル変数を削除します。
 CA1820: Test for empty strings using string length
 CA1802: Use literals where appropriate

Portability Rules
 CA1901: P/Invoke declarations should be portable
   P/Invoke の宣言は、移植性を考慮しなければなりません。
 CA1903: Use only API from targeted framework
 CA1900: Value type fields should be portable

Security Rules
 CA2116: APTCA methods should only call APTCA methods
 CA2117: APTCA types should only extend APTCA base types
 CA2105: Array fields should not be read only
 CA2115: Call GC.KeepAlive when using native resources
 CA2102: Catch non-CLSCompliant exceptions in general handlers
 CA2104: Do not declare read only mutable reference types
 CA2122: Do not indirectly expose methods with link demands
   セキュリティ上の要求があるメンバーを呼び出すメソッドについて、セキュリティ要求が設定されていません。
 CA2114: Method security should be a superset of type
 CA2111: Pointers should not be visible
   パブリックな System.IntPtr 型のフィールドが読み取り専用ではありません。
 CA2108: Review declarative security on value types
 CA2107: Review deny and permit only usage
 CA2103: Review imperative security
 CA2118: Review SupressUnmanagedCodeSecurityAttribute usage
 CA2109: Review visible event handlers
 CA2119: Seal methods thar satisfy private interfaces
 CA2106: Secure asserts
 CA2120: Secure serialization constructors
 CA2112: Secured types should not expose fields
 CA2121: Static constructors should be private
 CA2126: Type link demands require inheritance demands
 CA2124: Wrap vulnerable finaly clauses in outer try

Security Transparency Rules
 CA2132: Default constructors must be at least as critical as base type default constructors
 CA2133: Delegates must bind to methods with consistent transparancy
 CA2135: Level2 assemblies should not cintain LinkDemands
 CA2136: Members should not have conflicting transparency annotations
 CA2134: Methods must keep consistent transparency when overriding vase methods
 CA2123: Override link demands should be identical to base
 CA2130: Security critical constants should be transparent
 CA2131: Security critical types may not participate in type equivalance
 CA2147: Transparent code may not use security asserts
 CA2140: Transparent code must not reference security critical items
 CA2142: Transparent code should not be protected with LinkDemands
 CA2144: Transparent code should not load assemblies from byte arrays
 CA2139: Transparent methods may not use the HandleProcessCorruptingExceptions attribute
 CA2137: Transparent menthods must contain only verifiable IL
 CA2149: Transparent methods must not call into native code
 CA2138: Transparent methods must not call methods with the SuppressUnmanagedCodeSecurity attibute
 CA2141: Transparent methods must not satisfy LinkDemands
 CA2145: Transparent methods should not be decorated with the SuppressUnmanagedCodeSecurity attribute
 CA2143: Transparent methods should not use security demands
 CA2146: Types must be at least as critical as their base types and interfaces

Usage Rules
 CA2243: Attribute string literals should parase correctly
 CA2236: Call base class methods on ISerializable types
 CA1816: Call GC.SuppressFinalize correctly
   GC.SuppressFinalize メソッドの呼び出しが正しくありません。
   Dispose メソッドでは GC.SupressFilaze メソッドを呼び出します。
   IDispose インターフェイスを実装しないクラスでは GC.SupressFinalize メソッドを呼び出しません。
 CA2227: Collection properties should be read only
 CA2213: Disposable fields should be disposed
 CA2216: Disposable types should declare finalizer
 CA2214: Do not call overridable methods in constructors
 CA2222: Do not decrease inherited member visibility
 CA1806: Do not ignore method results
 CA2217: Do not mark enums with FlagsAttribute
 CA2212: Do not mark serviced components with WebMethod
 CA2219: Do not raise exceptions in exception clauses
 CA2201: Do not raise reserved exception types
 CA2228: Do not ship unreleased resource formats
 CA2221: Finalizers should be protected
 CA2220: Finalizers shoul call base class finalizer
 CA2240: Implement ISerializable correctly
 CA2229: Implement serialization constructors
 CA2238: Implement serialization methods correctly
 CA2207: Initialize value type static fields inline
 CA2208: Instantiate argument exceptions correctly
 CA2235: Mark all non-serializable fields
 CA2237: Mark ISerializable types with SerializableAttribute
 CA2232: Mark Windows Forms entry points with STAThread
 CA2223: Members should differ by more than return value
 CA2211: Non-constant fields should not be visible
 CA2233: Operations should not overflow
 CA2225: Operator overloads have named alternates
   演算子オーバーロードは、名前づけられた別名を使用するようにします。
 CA2226: Operator should have symmetrical overlods
 CA2231: Overloda operator equals on overriding ValueType.Equals
 CA2224: Override Equals on overloading operator equals
 CA2218: Override GetHashCode on overriding Equals
 CA2234: Pass System.Uri objects instead of string
 CA2239: Provide deserialization methods for optional fields
 CA2200: Rethrow to preserve stack details
 CA1801: Review unused parameters
 CA2242: Test for NaN correctly
 CA2205: Use managed equivalents of Win32 API
 CA2230: Use params for variable arguments

ちょっと参ったのは、IDisposable インターフェイスを実装して、Dispose メソッドの名称を変更しようとした場合。変更すると、CA1063, CA1816 あたりが指摘される。これを抑止する方法。アセンブリ単位で抑止したい場合、FxCop 上で「Exclude」を選ぶ。指摘ひとつひとつについて「理由」を入力する場合(こちらをお勧め)、次の方法。

  1. Visual Studio で、プロジェクトのプロパティを開く。
  2. [ビルド]ページを開く。
  3. 「条件付きコンパイル シンボル」に、「CODE_ANALYSIS」を追加する。(FxCop の検出を抑止するために必要)
  4. FxCop 上でエラーをポイントし、右クリックする。
  5. 「Copy As」→「SuppressMessage」を選択する。
  6. Visual Sttudio で、該当するコード(メソッド)の上に「貼り付け」する。
  7. 「SupprressMessage」に波線が引かれる場合、[Shilt]+[Alt]+[F10] で、名前空間を追加する。
  8. カッコ内に「, Justification = "抑止する理由"」を追加する。(追加しない場合、StyleCop で指摘される)

次、StyleCop。こちらは、ビルド後に StyleCop が自動実行されるようにする。

インストーラを、CodePlex のページからダウンロードする。こちらは、FxCop の様な二度実行はない。Visual Studio へは、プロジェクト単位に登録することになる。一部、バージョンに依存するところがあるが、ここでは v4.7 で説明する。

  1. ファイル ヘッダーを用意する。または、ファイル ヘッダーのチェックを適用しない(後述)。必要最小限のヘッダーは、次の通り。
    // <copyright file="ファイル名" company="会社名">
    //     ここに独自のコピーライト メッセージを書く
    // </copyright>
      
  2. プロジェクト ファイル(.csproj)をテキスト エディタで開く。
  3. <Project> 要素の中に、次の1行を追加する。(既にある Import の下が良い)
    <Import Project="$(ProgramFiles)\MSBuild\StyleCop\v4.7\StyleCop.targets" />
  4. ソリューション エクスプローラーでプロジェクトを右クリックして、StyleCop の設定を行う。
  5. [Company Information]タブを開き、「Comapny Name」と「Copyright」を入力する。これがファイル ヘッダーに指定されていないと指摘される。
  6. [Rules]タブを開き、設定を行う。
    ひとつのプロジェクトで設定をすると、「Settings.StyleCop」という名前のファイルが出来る。これを、全てのプロジェクトのひとつ上のディレクトリにコピーしておく。そうすると、各プロジェクトでは[Setting Files]タブを開き、「Mege with settings file found in parent folder」に設定するだけでよい。

適用されるルールは以下の通り。一部注釈が付いているのは、手持ちのプロジェクトで指摘された項目。★は、デフォルトでチェックされている項目。□は、デフォルトでチェックされていない項目。○は、チェックを外した項目。●は、チェックした項目。

C# [○Analyze designer files][○Analyze generated files]
  ※ デザイナーなど、自動生成ファイルは適用外とする。
★Documentation Rules
 ★Element Documentation [●Ignore privates][□ignore internals][★include fields]
   ※ private メンバーについてはドキュメント化の対象外とする。
  ★SA1600: Elements must be documented
    エレメントはドキュメントを持たなければなりません。
  ★SA1601: Partial elements must be documented
  ★SA1602: Enumeration item must be documented
  ★SA1603: Documentation must contain valid XML
    ドキュメントは正当な XML を含んでいなければなりません。
  ★SA1604: Element documentation must have summary
  ★SA1605: Partial element documentation must have summary text
  ★SA1606: Element documentation must have summary text
  ★SA1607: Partial element documentation must have summary text
  ★SA1608: Element documentation must not have default summary
  □SA1609: Property documentation must have value
  □SA1610: Property documentation must have value text
  ★SA1611: Element parameters must be documented
    エレメントのパラメータはドキュメント化されていなければなりません。
  ★SA1612: Element parameter documentation must match element parameters
    エレメントのパラメータのドキュメントは、エレメントのパラメータと一致していなければなりません。
  ★SA1613: Element parameter documentation must declare parameter name
  ★SA1614: Element parameter documentation must have text
    エレメントのパラメータのドキュメントは、テキストを含んでいなければなりません。
  ★SA1615: Element return value must be documented
    エレメントの戻り値はドキュメント化されていなければなりません。
  ★SA1616: Element return value documentation must have text
    エレメントの戻り値のドキュメントは、テキストを含んでいなければなりません。
  ★SA1617: Void return value must not be documented
    戻り値がない場合はドキュメント化されていてはなりません。
  ★SA1618: Generic type parameters must be documented
  ★SA1619: Generic type parameters must be documented partial class
  ★SA1620: Generic type parameter documentation must match type parameters
  ★SA1621: Generic type parameter documentation must declare parameter name
  ★SA1622: Generic type parameter documentation must have text
  ○SA1623: Property summary documentation must match accessors
    プロパティの要約ドキュメントは、アクセッサーと一致していなければなりません。
    ※ 日本語とは一致しないため、外す。
  ★SA1624: Property summary documentation must omit set accessor with restricted access
  ★SA1625: Element documentation must not be copied and pasted
  ★SA1626: Single-line comments must not use documentation style slashes
    一行コメントは、XML ドキュメント形式のスラッシュを使用してはいけません。
  ★SA1627: Documentation text must not be empty
  □SA1628: Documentation text must begin with a capital letter
  □SA1629: Documentation text must end with a period
  ○SA1630: Documentation text must contain whitespace
    ドキュメントの中にホワイトスペースが含まれていません。
    ※ 日本語とは一致しないため、外す。
  ★SA1631: Documentation must meet character percentage
  □SA1632: Documentation text must meer minimum character length
  ○SA1642: Constructor summary documentation must begin with standard text
    コンストラクタの要約ドキュメントは、標準テキストで始めなければなりません。
    ※ 日本語とは一致しないため、外す。
  ○SA1643: Destructor summary documentation must begin with standard text
    デストラクタの要約ドキュメントは、標準テキストで始めなければなりません。
    ※ 日本語とは一致しないため、外す。
  ★SA1644: Documentation headers must not contain blank-lines
  ★SA1646: Included documentation XPath does not extist
  ★SA1647: Included node does not contain valid file and path
  ★SA1648: Inherit doc must be used with inheriting class
 ★File Headers
  ★SA1633: File must have header
    ファイル ヘッダーを含まなければなりません。
  ★SA1634: File header must show copyright
  ★SA1635: File header must have Copyright text
  ★SA1637: File header must contain file name
  ★SA1638: File header file name documentation must match file name
  □SA1639: File header must have summary
  ★SA1640: File header must have valid company text
  ★SA1649: File header file name documentation must match type name

★Layout Rules
 ★Curly Blakets
  ★SA1500: Curly brackets for multi-line statements must not share line
    複文のための中括弧は違う行に配置します。
  ★SA1501: Statement must not be on single-line
  ★SA1502: Element must not be on single-line
  ★SA1503: Curly brackets must not be omitted
    中括弧を忘れてはいけません。
  ★SA1504: All accessors must be multi-line or single-line
 ★Line Spacing
  ★SA1505: Opening curly brackets must not be followed by blank line
    開き中括弧に空行を続けてはいけません。
  ★SA1506: Element documentation headers must not be followed by blank line
  ★SA1507: Code must not contain multiple blank lines in a row
    複数行からなる空行を含んではいけません。
  ★SA1508: Closing curly blackets must not be preceded by blank line
    閉じ中括弧の前が空行であってはいけません。
  ★SA1509: Opening curly brackets must not be preceded by blank line
  ★SA1510: Chained statement blocks must not be preceded by blank line
  ★SA1511: While do footer must not be preceded by blank line
  ★SA1512: Single-line comment must not be followed by blank line
  ★SA1513: Closing curly bracket must be followed by blank line
    閉じ中括弧の後は空行でなければなりません。(括弧や catch などのキーワードは除く)
  ★SA1514: Element documentation header must be preceded by blank line
    エレメントのドキュメントは空行に続かなければなりません。
  ★SA1515: Single line comment must be preceded by blank line
    一行コメントは空行に続かなければなりません。(一時的にコメントアウトしたい場合は '////' を使用します。)
  ★SA1516: Elements must be separated by blank line
    エレメント間は空行で分けます。
  ★SA1517: Code must not contain blank lines at start of file
  ★SA1518: Code must not contain blank lines at end of file

★Maintainability Rules
 ★Access Modifiers
  ★SA1400: Access modifier must be declared
  ★SA1401: Fields must be private
    フィールドは private であるべきです。
 ★Debug Text
  ★SA1404: Code analysis suppression must have justification
  ★SA1405: Debug assert must provide message text
  ★SA1406: Debug fail must provide message text
 ★File Contents
  ★SA1402: File may only contain a single class
  ★SA1403: File may only contain a single namespace
 ★Parenthesis
  ★SA1119: Statement must not use unnecessary parenthesisparenthesis
    不必要な括弧を含んではいけません。
  ★SA1407: Arithmetic expressions must declare precedence
  ★SA1408: Conditional expressions must declare precedence
  ★SA1410: Remoce delegate parenthesis when possible
  ★SA1411: Attribute constructor must not use unnecessary parenthesis
 ★Removable Code
  ★SA1409: Remove unnecessary code

★Naming Rules
  ★SA1300: Element must begin with upper case letter
    エレメントは大文字から始めなければなりません。
    ※日本語エレメント名を使用するときは無視します。
  ★SA1301: Element must begin with lower case letter
  ★SA1302: Interface names must begin with 'I'
  ★SA1303: Const field names must begin with upper case letter
  ★SA1304: Non private readonly fields must begin with upper case letter
  ★SA1305: Field names must not use hangarian notation
    フィールド名にはハンガリアン記法を使用しません。
  ★SA1306: Field names must begin with lower case letter
    フィールド名は小文字から始めなければなりません。
    ※日本語フィールド名を使用するときは無視します。
  ★SA1307: Accessible fields must begin with upper case letter
    アクセス制限によって、フィールド名は大文字から始めます。
  ★SA1308: Variable names must not be prefixed
  ★SA1309: Field names must not begin with underscore
    フィールド名をアンダースコアから始めてはいけません。
  ★SA1310: Field names must not contain underscode
    フィールド名にアンダースコアを含めてはいけません。

★Ordering Rules [○Include generated code]
 ★Element Order
  ○SA1200: Using directives must be placed within namespace
    using ディレクティブは namespace の中に書かなければなりません。
    ※ 初期設定と異なるため、適用除外とする。
  ★SA1201: Elements must appear in the correct order
    エレメントは一定の順序で書かれていなければなりません。
     フィールド
     コンストラクター
     ファイナライザー
     デリゲート
     イベント
     列挙体
     インターフェイス
     プロパティ
     インデクサー
     メソッド
     構造体
     内部クラス
  ★SA1202: Element must be orderd by access
    エレメントは、アクセス可能性の順に書かれていなければなりません。
     public
     internal
     protected internal
     protected
     private
  ★SA1203: Constants must appear before fields
  ★SA1204: Static elements must appear vefore instace elements
  ★SA1206: Declaration keywords must follow order
    宣言文のキーワードは、一定の順序で書かれていなければなりません。
     アクセス修飾子
     static
     その他のキーワード
  ★SA1207: Protected must come before internal
  ★SA1212: Property accessors must follow order
    プロパティのアクセッサーは、get, set の順に書かれていなければなりません。
  ★SA1213: Event accessors must follow order
    イベントのアクセッサーは、add, remove の順に書かれていなければなりません。
 ★Using Directives
  ★SA1208: System using directices must be placed before other using directives
    System の using ディレクティブは、他の要素よりも先に書かれていなければなりません。
    ※ コンテキスト メニューから起動するコマンド「using の整理」→「using の並べ替え」を使用します。
  ★SA1209: Using alias directives must be placed after other using directives
  ★SA1210: Using directives mmust be orderd alphabetically by namespace
    ※ コンテキスト メニューから起動するコマンド「using の整理」→「using の並べ替え」を使用します。
  ★SA1211: Using alias directives must be ordered alphabetically by alias name

★Readability Rules
 ★Comments
  ★SA1120: Commrnts must contain text
 ★Member Access
  ★SA1100: Do not prefix calls with base unless local implementation exists
  ★SA1101: Prefix local calls with this
 ★Method Parameter Placement
  ★SA1110: Opening parenthesis must be on declaration line
  ★SA1111: Closing parenthesis must be on line of last parameter
  ★SA1112: Closing parenthesis must ve on line of opening parenthesis
  ★SA1113: Comma must be on same line as previous parameter
  ★SA1114: Parameter list must follow declaraion
  ★SA1115: Parameter must follow comma
  ★SA1116: Split parameters must start on line after separate lines
  ★SA1117: Parameters must be on same line or separate lines
  ★SA1118: Parameter must not span multiple lines
 ★Query Expressions
  ★SA1102: Query clause must follow previous clause
  ★SA1103: Query clauses must be on separate lines or all on one line
  ★SA1104: Query clause must begin on new line when previous clause spans multiple line
  ★SA1105: Query clauses spanning multiple line must begin on own line
 ★Regions
  ★SA1123: Do not place regions within elements
  □SA1124: Do not use regions
 ★Statements
  ★SA1106: Code must not contain empty statements
  ★SA1107: Code must not contain multiple statements on one line
  ★SA1108: Block staements must not contain embedded comments
  ★SA1109: Block statements must not contain embedded regions
 ★Strings
  ★SA1122: Use string empty for empty string
 ★Types
  ○SA1121: Use builtin type alias
    型の完全な名称よりも、ビルトインで用意されている別名を使いましょう。
    ※ Int16 など、完全な名称を使う方が幅が明記できるため、見やすい場合もあるため、無効とする。
  ★SA1125: Use shorthand for nullable types

★Spacing Rules
  ★SA1000: Keywords must be spaced correctly
  ★SA1001: Commas must be spaced correctly
  ★SA1002: Semicolons must be spaced correctly
  ★SA1003: Symbols must be spaced correctly
  ★SA1004: Documentation lines must begin with single space
  ★SA1005: Single line comments must begin with single space
  ★SA1006: Preprocessor keywords must not be preceded by space
  ★SA1007: Operator keyword must be followed by space
  ★SA1008: Opening parenthesis must be spaced correctly
  ★SA1009: Closing parenthesis must be spaced correctly
  ★SA1010: Opening square brackets must be spaced correctly
  ★SA1011: Closing square brackets must be spaced correctly
  ★SA1012: Opening curly brackets must be spaced correctly
  ★SA1013: Closing culy brackets must be spaced correctly
  ★SA1014: Opening generic brackets must be spaced correctly
  ★SA1015: Closing generic brackets must be spaced correctly
  ★SA1016: Opening attribute brackets must be spaced correctly
  ★SA1017: Closing attribute brackets must be spaced correctly
  ★SA1018: Nullable type symbols must not be preceded by space
  ★SA1019: MemberAccess symbols must be spaced correctly
  ★SA1020: Increment decrement symbols must be spaced correctly
  ★SA1021: Negative signs must be spaced correctly
  ★SA1022: Positive sign must be spaced correctly
  ★SA1023: Dereference and access of symbols must be spaced correctly
  ★SA1024: Colons must bespaced correctly
  ★SA1025: Code must not cintain multiple wtitespace in a row
  ★SA1026: Code must not contain space after new keyword in implicitly typed array allocation
  ○SA1027: Tabs must not be used
    TAB 文字を使用してはいけません。
    ※ TAB と SPACE については意見が二分するので適用外とする。
投稿日時 : 2012年3月18日 19:47
コメント
タイトル  
名前  
Url
コメント