Microsoft Source Analysis for C#

Posted on May 24, 2008
Yesterday Microsoft announced the release of a new developer tool - Source Analysis for C#. This tool has been used within Microsoft for years.
Opposite to FxCop, which operates on compiled binaries, the new tool analyzes the source code. The process can be triggered from within Visual Studio, or integrated into MSBuild
There are 7 groups of rules checked by Source Analysis for C#:
  • Documentation- rules which verify the content and formatting of code documentation.
  • SA1600Validates that an element contains a properly formatted documentation header.
    SA1601Validates that a partial class, struct, etc. contains a valid documentation header which contains either a summary tag or a content tag.
    SA1602Validates that an item within an enumeration contains a properly formatted documentation header.
    SA1603Indicates that a documentation header is composed of invalid Xml and cannot be parsed.
    SA1604Validates that a documentation header contains a properly formatted summary tag.
    SA1605Validates that a partial class, struct, etc. contains a documentation header with a properly formatted summary tag or content tag.
    SA1606Validates that an element's summary tag contains a filled-in description.
    SA1607Validates that a partial class, struct, etc. contains a documentation header with a filled-in summary description.
    SA1608Validates that the summary tag in an element's documentation header is not the default text generated by Visual Studio.
    SA1609Validates that a public or protected property contains a documentation header with a value tag.
    SA1610Validates that a property's value tag contains a filled-in description.
    SA1611Validates that an element's documentation header contains a param tag for each item in the element's parameter list.
    SA1612Validates that an element's documentation header does not contain param tags for parameters which do not exist in the element's parameter list.
    SA1613Validates that all param tags in an element's documentation header contain a filled-in name attribute.
    SA1614Validates that an element's documentation header contains filled-in descriptions for each parameter in the element's parameter list.
    SA1615Validates that an element's documentation header contains a returns tag if the element has a return value.
    SA1616Validates that an element's returns tag contains a filled-in description.
    SA1617Validates that an element's documentation header does not contain a returns tag if the element has no return value.
    SA1618Validates that an element's documentation header contains a typeparam tag for each of the element's generic types.
    SA1619Validates that a partial class, struct, etc. contains a documentation header with a typeparam tag for each of the element's generic types, unless these types are documented on another part of the element.
    SA1620Validates that an element's documentation header does not contain typeparam tags for types which are not part of the element's generic type list.
    SA1621Validates that all typeparam tags in an element's documentation header contain a filled-in name attribute.
    SA1622Validates that an element's documentation header contains filled-in descriptions for each item in the element's generic type list.
    SA1623Validates that a property's summary description text begins with the correct syntax, depending upon whether the property exposes get or set accessors.
    SA1624Validates that a property's summary description text does not include a description for a set accessor when the property exposes only a get accessor.
    SA1625Validates that an element's documentation header does not contain repeated documentation text.
    SA1626Validates that comments do not begin with three forward slashes in a row, making them difficult to distinguish from documentation headers.
    SA1627Validates that the description within a documentation tag is filled-in.
    SA1628Validates that the documentation text within a documentation section begins with a capital letter.
    SA1629Validates that the documentation text within a documentation section ends with a period.
    SA1630Verifies that the documentation text within a documentation section contains at least two words, separated by whitespace.
    SA1631Verifies that the documentation text within a documentation section does not contain an excessive amount of symbols, making it difficult to read.
    SA1632Verifies that the documentation text within a documentation section meets or exceeds a minimum length.
    SA1633Validates that a file contains a properly formatted file header.
    SA1634Validates that a file header contains a copyright tag.
    SA1635Validates that a file header contains a filled-in copyright tag.
    SA1636Validates that a file header contains a copyright matching specific copyright text.
    SA1637Validates that a file header contains a file attribute.
    SA1638Validates that a file header contains a file attribute which contains the name of the file.
    SA1639Validates that a file header contains a filled-in summary description.
    SA1640Validates that a file header contains a filled-in company attribute.
    SA1641Validates that a file header contains a company attribute which contains a specific company name.
  • Layout- rules which enforce code layout and line spacing.
  • SA1500Validates that the opening or closing curly bracket in a bracketed statement is placed on its own line if the statement spans multiple lines.
    SA1501Validates that a bracketed statement is not placed on a single line.
    SA1502Validates that a bracketed element is not placement on a single line.
    SA1503Validates that opening and closing curly brackets are always included, even if the statement type allows them to be omitted.
    SA1504Validates that an accessor in a property or indexer is only placed on a single line if all accessors in the property or indexer are placed on a single line.
    SA1505Validates that an opening curly bracket in a bracketed statement or element is not followed by a blank line.
    SA1506Validates that a documentation header is not followed by a blank line.
    SA1507Validates that the code does not contain multiple blank lines in a row.
    SA1508Validates that a closing curly bracket in a bracketed statement or element is not preceded by a blank line.
    SA1509Validates that an opening curly bracket in a bracketed statement or element is not preceded by a blank line.
    SA1510Validates than an else, catch, or finally statement is not preceded by a blank line.
    SA1511Validates that the while keyword in a do-while statement is not preceded by a blank line.
    SA1512Validates that a comment is not followed by a blank line. (This does not apply to C-style comments.)
    SA1513Validates that a bracketed statement or element is followed by a blank line.
    SA1514Validates that a documentation header is preceded by a blank line, or is the first item in its scope.
    SA1515Validates that a comment is preceded by a blank line, or is the first item in its scope.
  • Maintainability- rules which improve code maintainability.
  • SA1400Validates that an access modifier is declared for an element.
    SA1401Validates that a field is declared with private access.
    SA1402Validates that a C# document does not contain more than one class at the root level.
    SA1403Validates that a C# document does not contain more than one namespace directive.
    SA1404Validates that a Code Analysis suppression contains a justifiction describing the reason for the suppression.
    SA1405Validates that calls to Debug.Assert provide a message in the second parameter describing the reason for the assert.
    SA1406Validates that calls to Debug.Fail provide a message in the first parameter describing the reason for the failure.
  • Naming- rules which enforce naming requirements for members, types, and variables.
  • SA1300Validates that names of certain types of elements begin with an upper-case letter.
    SA1301Validates that names of certain types of elements begin with a lower-case letter.
    SA1302Validates that the name of an interface begins with the capital letter 'I'.
    SA1303Validates that the name of a constant begins with an upper-case letter.
    SA1304Validates that the name of a readonly field begins with an upper-case letter, unless the field is declared private.
    SA1305Validates that a variable name is not prepended with lower-case characters matching the signature of Hungarian notation.
    SA1306Validates that the name of a variable or field begins with a lower-case letter.
    SA1307Validates that the name of a public or internal field must begin with an upper-case letter.
    SA1308Validates that the name of a member variable does not begin with the 'm_' syntax.
    SA1309Validates that the name of a field does not begin with an underscore.
    SA1310Validates that the name of a field does not contain underscores.
  • Ordering- rules which enforce a standard ordering scheme for code contents.
  • SA1200Validates that all using directives are placed within a namespace, if a namespace exists in the file.
    SA1201Validates that elements are placed in the correct order.
    SA1202Validates that elements of the same type are placed in order by access.
    SA1203Validates that all constant and readonly elements are placed before non-constant, non readonly elements of the same type.
    SA1204Validates that all static elements are placed before non-static elements of the same type.
    SA1205Validates that a partial element has a declared access modifier, which is necessary for determining the order of partial elements.
    SA1206Verifies the ordering of keywords in an element declaration.
    SA1207Verifies the ordering of the internal and protected keywords in an element with protected internal access.
  • Readability- rules which ensure that the code is well-formatted and readable.
  • SA1100Verifies that the 'base.' prefix is not misused.
    SA1101Verifies that calls to local members are prefixed with the 'this.' notation.
    SA1102Validates that blank lines are not placed between clauses within a query expression.
    SA1103Verifies that each clause in a query expression must begin on a new line, unless the entire expression is on a single line.
    SA1104Verifies that a query clause begins on a new line if the previous clause spans multiple lines.
    SA1105Validates that a query clause spanning multiple lines begins on a new line.
    SA1106Detects the presense of extra, unnecessary semicolons in the code.
    SA1107Validates that multiple statements are not placed on a single line of code.
    SA1108Validates that there are no comments placed between the declaration and opening bracket in a bracketed statement.
    SA1109Validates that there are no regions placed between the declaration and opening bracket in a bracketed statement.
    SA1110Verifies that the opening bracket of a parameter list is placed just after the name of the method, on the same line.
    SA1111Verifies that the closing bracket of a parameter list is placed just after the last parameter, on the same line.
    SA1112Verifies that the closing bracket of a parameter list is placed just after the opening bracket when the method has no parameters.
    SA1113Verifies that a comma between two parameters is placed just after the previous parameter, on the same line.
    SA1114Verifies that the first parameter in a parameter list is placed on the same line as the opening bracket, or on the next line.
    SA1115Verifies that a parameter is placed on the line after the previous comma, in a multi-line parameter list.
    SA1116Verifies that the first parameter in a parameter list is placed on the line after the opening bracket, in a multi-line parameter list.
    SA1117Verifies that each parameter in a parameter list is placed on its own line, unless all parameters are on the same line.
    SA1118Validates that no parameter spans across multiple lines, other than the first parameter in a parameter list.
    SA1119Verifies that the code does not contain extra, unnecessary parenthesis.
    SA1120Validates that a comment contains description text.
    SA1121Enforces the use of the built-in types rather than the actual types that they represent.
  • Spacing- rules which verify the spacing placed between keywords and symbols in the code.
  • SA1000Validates the spacing before and after a reserved keyword.
    SA1001Validates the spacing before and a comma.
    SA1002Validates the spacing before and a semicolon.
    SA1003Validates the spacing before and after an operator symbol.
    SA1004Verifies that the forward slashes at the beginning of an documentation header line are followed by a single space.
    SA1005Verifies that the forward slashes at the beginning of a comment are followed by a single space.
    SA1006Verifies that there is no space between the opening hash mark and keyword within a preprocessor statement.
    SA1007Verifies that there is a single space between the 'operator' keyword and the operator symbol within an operator overload.
    SA1008Validates the spacing before and after an opening parenthesis.
    SA1009Validates the spacing before and after a closing parenthesis.
    SA1010Validates the spacing before and after an opening square bracket.
    SA1011Validates the spacing before and after a closing square bracket.
    SA1012Validates the spacing before and after an opening curly bracket.
    SA1013Validates the spacing before and after a closing curly bracket.
    SA1014Validates the spacing before and after an opening bracket in a generic type.
    SA1015Validates the spacing before and after a closing bracket in a generic type.
    SA1016Validates the spacing before and after an opening attribute bracket.
    SA1017Validates the spacing before and after a closing attribute bracket.
    SA1018Verifies that a nullable type symbol is not preceded by white space.
    SA1019Validates the spacing before and after a member access symbol.
    SA1020Validates the spacing before and after an increment or decrement symbol.
    SA1021Validates the spacing before and after a negative sign.
    SA1022Validates the spacing before and after a positive sign.
    SA1023Validates the spacing before and after a dereference or address-of symbol.
    SA1024Validates the spacing before and after a colon.
    SA1025Verifies that the code does not contain more than one spacing in a row.
    SA1026Verifies that there is no space between the new keyword and the opening square bracket in an implicitly typed array allocation.
    SA1027Verifies that the code does not contain tabs.
Comments
  1. yixyzlgqcApril 11, 2012 @ 03:25 AM
    small business is a must for any serious small business owner.Karen Millen started in 1981 with only £ karen millen dublin But, hey, nobody should set his foot under yours anyway.If you might be planning for a very hot romantic date or fun karen millen dresses year that they were expanding yet again to places these as Brighton, Guildford and eventually to the city of karen millen dress wardrobe. Speaking of summer season clothing, the swimsuit collection is just what you would expect from a top karen millen It is actually claimed that to the ideal on the main entrance is a side door built for Edward VII to make sure that he could http://www.karenmillenirelandsalestore.com the shows from this designer label have been packed to the gills with stars, celebrities, singers, fashion
Post a comment
Comment





Microsoft Certified Professional Developer Microsoft Certified Technology Specialist Microsoft Certified Application Developer