Change History

November 2012

  • Improved and shortened the introduction section and added a reference to the refactoring heustic on the rule of three
  • Introduced a less formal writing style, reduced the line spacing and changed the font for code blocks and elements into Consolas
  • Rephrased several guidelines to be more consise and clear about their purpose
  • Replaved the vague term 'identifier' with the more concrete names
  • Fixed the correct usage of arguments and parameters as explained in the C# language specification
  • Added hyperlinks to cross-reference guidelines and more links to related articles on the web, including some new async related articles.
  • AV1001; to warn for potential violations of AV1000 and AV1561.
  • AV1008; states to avoid static classes at all rather than just marking it as static.
  • AV1105; added a reference to the CQS principle
  • Removed AV1120 "Use a public static readonly field to define predefined value objects " since I think it is not important and not used that often
  • AV1130; Added a reference to the new .NET 4.5 read-only collection interfaces
  • AV1135; Renamed the guideline to include methods and parameters in addition to properties
  • AV1140; Rephrased to clarify that I was talking about domain-specific types
  • Remove AV1245 because I think it is pretty farfetched if you create a class in a .NET namespace
  • AV1515; Only kept the correct example
  • AV1521; Renamed the guideline to make it clear we want variables to be declared and initialized as a late as possible
  • Removed AV1526 since enumerations are so common these days, I hope nobody thinks of
  • AV1532: Removed the 'method' part so to say that nested loops should be avoid anywhere
  • AV1535: Renamed so that it includes concrete keywords rather than the vague 'flow control keywords'
  • AV1546: Merged into AV1545
  • Removed AV1580 because its purpose is already covered by other guidelines
  • AV1553: Added a reference to the Eric Lippert post on optional parameter corner cases
  • AV1720: Removed the example because it conflicted with someof the LINQ extension methods introduced in .NET 3.0.
  • AV1725: Rewrote and renamed to clearly explain the valid aspects of a namespace rather than emphasizing a particular pattern
  • AV1735: Used the generic event handler delegate
  • AV1800: Added a reference to the .NET 4.5 read-only collection classes
  • AV2207: Explain that deployment-specific settings should be in the application confiuration files rather than hard-coded or in a custom configuraiton file.
  • AV2211: Removed since most people don't even know how to supress compiler warnings
  • AV2315: Removed since we want to avoid inline comments anyway
  • AV2400: Added a remark not to interweave the from expressions with where
  • Added AV1137 "Define parameters as specific as possible"
  • Added AV1215 "Properly handle exceptions in asynchronous code"
  • Added AV1523 "Initialize each variable on a separate line"
  • Added AV1739 "Use an underscore for irrelevant lamba parameters"
  • Added AV1755 "Postfix asynchronous methods with Async of TaskAsync"
  • Added AV1820 "Only use async for low-impact long-running activities"
  • Added AV1825 "Prefer Task.Run for CPU intensive activities"
  • Added AV1830 "Beware of mixing up await/async with Task.Wait"
  • Added AV1835 "Beware of async/await deadlocks in single-threaded environments"

October 2012

  • Added a .dotSettings file for ReSharper 6 and 7

July 2011

  • Fixed the example for AV1010 after a report by Phil Winstanley.

January 2011

  • Added some info on the level indicators
  • Added some missing level 2 guidelines to the cheat sheat

December 2010

  • Use an interface to support multiple implementations, not a base class (AV1004)
  • Use an interface to decouple classes from each other (AV1005)
  • Avoid bidirectional dependencies (AV1020)
  • Classes should have state and behavior (AV1025)
  • Avoid mutual exclusive properties (AV1110)
  • Don’t expose stateful objects through static members (AV1125)
  • Use exceptions instead of return codes for reporting failures (AV1200)
  • Don’t use nested loops in a method (AV1532)
  • Consider abstracting an external dependency or 3rd party component (AV1580)

  • AV1044 Avoid side-effects when throwing recoverable exceptions
  • AV1050 Don’t make assumptions on the object’s state after raising an event
  • AV1075 Adhere to the LINQ Design Guidelines for custom IQueryable implementations
  • AV1551 Explicitly define the scope of a type or member, because it is a duplicate of AV1501

  • Rephrased AV1120 to make it clear it is talking about objects representing value objects
  • Split up the Design Guidelines section in smaller sections

June 2010

  • AV1000 A class or interface should have a single purpose
  • AV1003 An interface should be small and focused
  • AV1013 Base Classes Depending on Their Derivatives
  • AV1014 Avoid exposing the objects an object depends on
  • AV1018 A method or property should do only one thing
  • AV1501 Make all members private and types internal by default
  • AV1502 Avoid conditions with double negatives
  • AV1550 Encapsulate Conditional Statement With More Than One AV1553 Only use optional parameters for replacing overloads
  • AV1555 Avoid using named parameters
  • AV1564 Avoid methods that take a boolean flag
  • AV1575 Don’t Comment Out Code
  • AV1668 Don’t use parameters as temporary variables
  • AV1704 Don’t include numbers in identifiers
  • AV1800 Use the Any method when checking if an IEnumerable<T> is empty
  • AV2230 Only use the dynamic keyword when talking to a dynamic object
  • AV2310 Avoid inline comments
  • AV2318 Don’t use comments for tracking work to be done later

The following rules have been removed, either because they are supported by FxCop, are already covered by other rules, are still valid but hardly ever occur, or are intended for very specific and rare circumstances.
  • AV1003 Do seal a class unless it has been designed for inheritance)
  • AV1026 Don’t use readonly fields of arrays
  • AV1030 Avoid using friend assemblies
  • AV1043 Prefer throwing existing exceptions
  • AV1060 Do only implement casts that operate on the complete object
  • AV1061 Don’t generate a semantically different value with a cast
  • AV1522 Do use constant fields for variables that will never change
  • AV1531 Do update loop variables close to where the loop condition is checked
  • AV1560 Do be consistent in the ordering of parameters in overloaded members
  • AV1730 Do add the suffix Callback to delegates related to callback methods
  • AV1736 Don’t add an Event suffix to the name of an event
  • AV1800 Clearly document if calling a member has a performance impact
  • AV2206 Don’t hardcode strings that are presented to end-users
  • AV2216 Do always sign assemblies with a private key
  • AV2308 Do document preconditions
  • AV2309 Do document post conditions
  • AV2310 Do document the exceptions that a member can throw
  • AV2402 Do order and group namespaces according the company
  • AV2403 Don’t define multiple namespaces in one file
  • AV2405 Do place modifiers in a well-defined order

  • Added a priority to each rule: 1 (required), 2 (strongly recommended), 3 (recommendation)
  • Renumbered AV1001 (Use a public static readonly field to define predefined object instances) and AV1002 (Mark classes that only contain static members as static) to AV1005 and AV1008
  • Rewrote the introduction including some background, basic design principles and how to get your team started with this document.
  • Rewrote the titles in a less formal style
  • Changed AV1025 (Don’t return an array) to suggest returning IEnumerable<T>
  • Changed AV1062 (Avoid casting to and from System.Object in code that uses generics ) to promote generic constraints
  • Strictened AV1561 (Avoid methods with more than 5 arguments) to at most three parameters.
  • Changed AV2316 (Only write comments to explain complex algorithms or decisions) to restrict comments to algorithms and decisions
  • Replaced the individual layout rules AV2410-AV2415 with AV2400 (Use a common layout)
  • Refined AV1708 (Name types using nouns, noun phrases or adjective phrases)
  • Changed the title of AV1706 (Don’t use abbreviations) to match the strictness of its description
  • Renamed AV1501 to AV1712 (Avoid short names or names that can be mistaken with other names)
  • Relaxed AV1540 (Be reluctant with multiple return statements)
  • Changed AV2315 to forbid block comments
  • Reintroduced AV1702 (Use proper casing for members)
  • Clarified AV2201 (Use C# type aliases instead of types from the System namespace) and added an exception for static members
  • Removed the lists of FxCop rules and replaced them with downloadable Rule Sets

March 2009

  • Major overhaul.
  • Introduced recommended use of Code Analysis / FxCop and removed overlapping guidelines.
  • Added C# 3.0 / LINQ coding guidelines.

January 2006

  • Initial version based on the Philips C# 1.0 Standard

Last edited Nov 25, 2012 at 7:55 PM by dennisdoomen, version 14