I like using the Microsoft StyleCop to make my code consistent and I ask the developers I work with to use it too. It helps ensure consistent formatted code regardless of the developer writing the code. I do however, disagree with a few of the default settings such as insisting that every code file have a file header. I also only think that public methods/properties should be required to have XML comments since those are the types that show up in intellisense. I also can't “control” auto-generated code so why should it be checked for style. Probably best to leave those files alone anyway.
Anyway, This is my main StyleCop Setting File:
<StyleCopSettings Version="105"> <GlobalSettings> <BooleanProperty Name="WriteCache">False</BooleanProperty> </GlobalSettings> <Parsers> <Parser ParserId="StyleCop.CSharp.CsParser"> <ParserSettings> <CollectionProperty Name="GeneratedFileFilters"> <Value>\.g\.cs$</Value> <Value>\.generated\.cs$</Value> <Value>\.g\.i\.cs$</Value> </CollectionProperty> </ParserSettings> </Parser> </Parsers> <Analyzers> <Analyzer AnalyzerId="StyleCop.CSharp.NamingRules"> <AnalyzerSettings> <CollectionProperty Name="Hungarian"> <Value>as</Value> <Value>do</Value> <Value>id</Value> <Value>if</Value> <Value>in</Value> <Value>is</Value> <Value>my</Value> <Value>no</Value> <Value>on</Value> <Value>to</Value> <Value>ui</Value> </CollectionProperty> </AnalyzerSettings> </Analyzer> <Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules"> <Rules> <Rule Name="FileMustHaveHeader"> <RuleSettings> <BooleanProperty Name="Enabled">False</BooleanProperty> </RuleSettings> </Rule> <Rule Name="FileHeaderMustShowCopyright"> <RuleSettings> <BooleanProperty Name="Enabled">False</BooleanProperty> </RuleSettings> </Rule> <Rule Name="FileHeaderMustHaveCopyrightText"> <RuleSettings> <BooleanProperty Name="Enabled">False</BooleanProperty> </RuleSettings> </Rule> <Rule Name="FileHeaderMustContainFileName"> <RuleSettings> <BooleanProperty Name="Enabled">False</BooleanProperty> </RuleSettings> </Rule> <Rule Name="FileHeaderFileNameDocumentationMustMatchFileName"> <RuleSettings> <BooleanProperty Name="Enabled">False</BooleanProperty> </RuleSettings> </Rule> <Rule Name="FileHeaderMustHaveValidCompanyText"> <RuleSettings> <BooleanProperty Name="Enabled">False</BooleanProperty> </RuleSettings> </Rule> <Rule Name="FileHeaderFileNameDocumentationMustMatchTypeName"> <RuleSettings> <BooleanProperty Name="Enabled">False</BooleanProperty> </RuleSettings> </Rule> </Rules> <AnalyzerSettings> <BooleanProperty Name="IncludeFields">False</BooleanProperty> <BooleanProperty Name="IgnorePrivates">True</BooleanProperty> <BooleanProperty Name="IgnoreInternals">True</BooleanProperty> </AnalyzerSettings> </Analyzer> <Analyzer AnalyzerId="StyleCop.CSharp.ReadabilityRules"> <Rules> <Rule Name="UseBuiltInTypeAlias"> <RuleSettings> <BooleanProperty Name="Enabled">False</BooleanProperty> </RuleSettings> </Rule> </Rules> <AnalyzerSettings /> </Analyzer> </Analyzers> </StyleCopSettings>