<p>The ReSharper reformat code feature is very handy and flexible, particularly with the new code layout templating flexibility JetBrains have added in version 3.0.</p>

<p>Is there a standard set of code style settings for ReSharper which match the rules enforced by <a href="http://code.msdn.microsoft.com/sourceanalysis" rel="noreferrer">Microsoft StyleCop</a>, so that StyleCop compliance can be as easy as running the ReSharper "reformat code" feature?</p>

[{'answer_id': 82540, 'author': 'David Laing', 'author_id': 13238, 'author_profile': 'https://Stackoverflow.com/users/13238', 'pm_score': 4, 'selected': True, 'text': '<p>Try the ReSharper StyleCop plugin at: <a href="http://www.codeplex.com/StyleCopForReSharper" rel="noreferrer">http://www.codeplex.com/StyleCopForReSharper</a></p>\n'}, {'answer_id': 271495, 'author': 'KeesDijk', 'author_id': 6434, 'author_profile': 'https://Stackoverflow.com/users/6434', 'pm_score': 2, 'selected': False, 'text': '<p>I am looking for the same things.</p>\n\n<p>Here is a Custom Type member layout:</p>\n\n<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;\n&lt;Patterns xmlns="urn:shemas-jetbrains-com:member-reordering-patterns"&gt;\n\n  &lt;!--Do not reorder COM interfaces and structs marked by \n      StructLayout attribute--&gt;\n  &lt;Pattern&gt;\n    &lt;Match&gt;\n      &lt;Or Weight="100"&gt;\n        &lt;And&gt;\n          &lt;Kind Is="interface"/&gt;\n          &lt;HasAttribute CLRName="System.Runtime.InteropServices.InterfaceTypeAttribute"/&gt;\n        &lt;/And&gt;\n        &lt;HasAttribute CLRName="System.Runtime.InteropServices.StructLayoutAttribute"/&gt;\n      &lt;/Or&gt;\n    &lt;/Match&gt;\n  &lt;/Pattern&gt;\n\n  &lt;!--Special formatting of NUnit test fixture--&gt;\n  &lt;Pattern RemoveAllRegions="true"&gt;\n    &lt;Match&gt;\n      &lt;And Weight="100"&gt;\n        &lt;Kind Is="class"/&gt;\n        &lt;HasAttribute CLRName="NUnit.Framework.TestFixtureAttribute" \n                      Inherit="true"/&gt;\n      &lt;/And&gt;\n    &lt;/Match&gt;\n\n    &lt;!--Setup/Teardow--&gt;\n    &lt;Entry&gt;\n      &lt;Match&gt;\n        &lt;And&gt;\n          &lt;Kind Is="method"/&gt;\n          &lt;Or&gt;\n            &lt;HasAttribute CLRName="NUnit.Framework.SetUpAttribute" \n                          Inherit="true"/&gt;\n            &lt;HasAttribute CLRName="NUnit.Framework.TearDownAttribute" \n                          Inherit="true"/&gt;\n            &lt;HasAttribute CLRName="NUnit.Framework.FixtureSetUpAttribute" \n                          Inherit="true"/&gt;\n            &lt;HasAttribute CLRName="NUnit.Framework.FixtureTearDownAttribute" \n                          Inherit="true"/&gt;\n          &lt;/Or&gt;\n        &lt;/And&gt;\n      &lt;/Match&gt;\n      &lt;Group Region="Setup/Teardown"/&gt;\n    &lt;/Entry&gt;\n\n    &lt;!--All other members--&gt;\n    &lt;Entry/&gt;\n\n    &lt;!--Test methods--&gt;\n    &lt;Entry&gt;\n      &lt;Match&gt;\n        &lt;And Weight="100"&gt;\n          &lt;Kind Is="method"/&gt;\n          &lt;HasAttribute CLRName="NUnit.Framework.TestAttribute" \n                        Inherit="false"/&gt;\n        &lt;/And&gt;\n      &lt;/Match&gt;\n      &lt;Sort&gt;\n        &lt;Name/&gt;\n      &lt;/Sort&gt;\n    &lt;/Entry&gt;\n  &lt;/Pattern&gt;\n\n  &lt;!--Default pattern--&gt;\n  &lt;Pattern&gt;\n    &lt;!--public delegate--&gt;\n    &lt;Entry&gt;\n      &lt;Match&gt;\n        &lt;And Weight="100"&gt;\n          &lt;Access Is="public"/&gt;\n          &lt;Kind Is="delegate"/&gt;\n        &lt;/And&gt;\n      &lt;/Match&gt;\n      &lt;Sort&gt;\n        &lt;Name/&gt;\n      &lt;/Sort&gt;\n      &lt;Group Region="Delegates"/&gt;\n    &lt;/Entry&gt;\n\n    &lt;!--public enum--&gt;\n    &lt;Entry&gt;\n      &lt;Match&gt;\n        &lt;And Weight="100"&gt;\n          &lt;Access Is="public"/&gt;\n          &lt;Kind Is="enum"/&gt;\n        &lt;/And&gt;\n      &lt;/Match&gt;\n      &lt;Sort&gt;\n        &lt;Name/&gt;\n      &lt;/Sort&gt;\n      &lt;Group&gt;\n        &lt;Name Region="${Name} enum"/&gt;\n      &lt;/Group&gt;\n    &lt;/Entry&gt;\n\n    &lt;!--fields and constants--&gt;\n    &lt;Entry&gt;\n      &lt;Match&gt;\n        &lt;Or&gt;\n          &lt;Kind Is="constant"/&gt;\n          &lt;Kind Is="field"/&gt;\n        &lt;/Or&gt;\n      &lt;/Match&gt;\n      &lt;Sort&gt;\n        &lt;Kind Order="constant field"/&gt;\n        &lt;Readonly/&gt;\n        &lt;Static/&gt;\n        &lt;Name/&gt;\n      &lt;/Sort&gt;\n      &lt;Group Region="Fields"/&gt;\n    &lt;/Entry&gt;\n\n    &lt;!-- Events--&gt;\n    &lt;Entry&gt;\n      &lt;Match&gt;\n        &lt;Kind Is="event"/&gt;\n      &lt;/Match&gt;\n      &lt;Sort&gt;\n        &lt;Name/&gt;\n      &lt;/Sort&gt;\n      &lt;Group Region="Events"/&gt;\n    &lt;/Entry&gt;\n\n    &lt;!--Constructors. Place static one first--&gt;\n    &lt;Entry&gt;\n      &lt;Match&gt;\n        &lt;Kind Is="constructor"/&gt;\n      &lt;/Match&gt;\n      &lt;Sort&gt;\n        &lt;Static/&gt;\n      &lt;/Sort&gt;\n      &lt;Group Region="Constructors"/&gt;\n    &lt;/Entry&gt;\n\n    &lt;!--properties, indexers--&gt;\n    &lt;Entry&gt;\n      &lt;Match&gt;\n        &lt;Or&gt;\n          &lt;Kind Is="property"/&gt;\n          &lt;Kind Is="indexer"/&gt;\n        &lt;/Or&gt;\n      &lt;/Match&gt;\n      &lt;Sort&gt;\n        &lt;Name/&gt;\n      &lt;/Sort&gt;\n      &lt;Group Region="Properties"/&gt;\n    &lt;/Entry&gt;\n\n    &lt;!--interface implementations--&gt;\n    &lt;Entry&gt;\n      &lt;Match&gt;\n        &lt;And Weight="100"&gt;\n          &lt;Kind Is="member"/&gt;\n          &lt;ImplementsInterface/&gt;\n        &lt;/And&gt;\n      &lt;/Match&gt;\n      &lt;Sort&gt;\n        &lt;ImplementsInterface Immediate="true"/&gt;\n        &lt;Kind Order="property"/&gt;\n        &lt;Name/&gt;\n      &lt;/Sort&gt;\n      &lt;Group&gt;\n        &lt;ImplementsInterface Immediate="true" \n                             Region="${ImplementsInterface} Members"/&gt;\n      &lt;/Group&gt;\n    &lt;/Entry&gt;\n\n    &lt;!-- public Methods --&gt;\n    &lt;Entry&gt;\n      &lt;Match&gt;\n        &lt;And&gt;\n          &lt;Kind Is="method"/&gt;\n          &lt;Access Is="public"/&gt;\n        &lt;/And&gt;\n      &lt;/Match&gt;\n      &lt;Sort&gt;\n        &lt;Static/&gt;\n        &lt;Name/&gt;\n      &lt;/Sort&gt;\n      &lt;Group&gt;\n      &lt;/Group&gt;\n    &lt;/Entry&gt;\n\n    &lt;!-- internal Methods --&gt;\n    &lt;Entry&gt;\n      &lt;Match&gt;\n        &lt;And&gt;\n          &lt;Kind Is="method"/&gt;\n          &lt;Access Is="internal"/&gt;\n        &lt;/And&gt;\n      &lt;/Match&gt;\n      &lt;Sort&gt;\n        &lt;Static/&gt;\n        &lt;Name/&gt;\n      &lt;/Sort&gt;\n      &lt;Group&gt;\n      &lt;/Group&gt;\n    &lt;/Entry&gt;\n\n    &lt;!--protected internal Methods --&gt;\n    &lt;Entry&gt;\n      &lt;Match&gt;\n        &lt;And&gt;\n          &lt;Kind Is="method"/&gt;\n          &lt;Access Is="protected-internal"/&gt;\n        &lt;/And&gt;\n      &lt;/Match&gt;\n      &lt;Sort&gt;\n        &lt;Static/&gt;\n        &lt;Name/&gt;\n      &lt;/Sort&gt;\n      &lt;Group&gt;\n      &lt;/Group&gt;\n    &lt;/Entry&gt;\n\n\n    &lt;!-- protected Methods --&gt;\n    &lt;Entry&gt;\n      &lt;Match&gt;\n        &lt;And&gt;\n          &lt;Kind Is="method"/&gt;\n          &lt;Access Is="protected"/&gt;\n        &lt;/And&gt;\n      &lt;/Match&gt;\n      &lt;Sort&gt;\n        &lt;Static/&gt;\n        &lt;Name/&gt;\n      &lt;/Sort&gt;\n      &lt;Group&gt;\n      &lt;/Group&gt;\n    &lt;/Entry&gt;\n\n    &lt;!-- private Methods --&gt;\n    &lt;Entry&gt;\n      &lt;Match&gt;\n        &lt;And&gt;\n          &lt;Kind Is="method"/&gt;\n          &lt;Access Is="private"/&gt;\n        &lt;/And&gt;\n      &lt;/Match&gt;\n      &lt;Sort&gt;\n        &lt;Static/&gt;\n        &lt;Name/&gt;\n      &lt;/Sort&gt;\n      &lt;Group&gt;\n      &lt;/Group&gt;\n    &lt;/Entry&gt;\n\n    &lt;!--all other members--&gt;\n    &lt;Entry/&gt;\n\n    &lt;!--nested types--&gt;\n    &lt;Entry&gt;\n      &lt;Match&gt;\n        &lt;Kind Is="type"/&gt;\n      &lt;/Match&gt;\n      &lt;Sort&gt;\n        &lt;Name/&gt;\n      &lt;/Sort&gt;\n      &lt;Group&gt;\n        &lt;Name Region="Nested type: ${Name}"/&gt;\n      &lt;/Group&gt;\n    &lt;/Entry&gt;\n  &lt;/Pattern&gt;\n&lt;/Patterns&gt;\n&lt;!--\nI. Overall\n\nI.1 Each pattern can have &lt;Match&gt;....&lt;/Match&gt; element. For the given type \n    declaration, the pattern with the match, evaluated to \'true\' with the \n    largest weight, will be used \nI.2 Each pattern consists of the sequence of &lt;Entry&gt;...&lt;/Entry&gt; elements. \n    Type member declarations are distributed between entries\nI.3 If pattern has RemoveAllRegions="true" attribute, then all regions \n    will be cleared prior to reordering. Otherwise, only auto-generated \n    regions will be cleared\nI.4 The contents of each entry is sorted by given keys (First key is \n    primary,  next key is secondary, etc). Then the declarations are \n    grouped and en-regioned by given property\n\nII. Available match operands\n\nEach operand may have Weight="..." attribute. This weight will be added \nto the match weight if the operand is evaluated to \'true\'.The default \nweight is 1\n\nII.1 Boolean functions:\nII.1.1 &lt;And&gt;....&lt;/And&gt;\nII.1.2 &lt;Or&gt;....&lt;/Or&gt;\nII.1.3 &lt;Not&gt;....&lt;/Not&gt;\n\nII.2 Operands\nII.2.1  &lt;Kind Is="..."/&gt;. Kinds are: class, struct, interface, enum, \n        delegate, type, constructor, destructor, property, indexer, method, \n        operator, field, constant, event, member\nII.2.2  &lt;Name Is="..." [IgnoreCase="true/false"] /&gt;. The \'Is\' attribute \n        contains regular expression\nII.2.3  &lt;HasAttribute CLRName="..." [Inherit="true/false"] /&gt;. The \'CLRName\'\n        attribute contains regular expression\nII.2.4  &lt;Access Is="..."/&gt;. The \'Is\' values are: public, protected, internal,\n        protected internal, private\nII.2.5  &lt;Static/&gt;\nII.2.6  &lt;Abstract/&gt;\nII.2.7  &lt;Virtual/&gt;\nII.2.8  &lt;Override/&gt;\nII.2.9  &lt;Sealed/&gt;\nII.2.10 &lt;Readonly/&gt;\nII.2.11 &lt;ImplementsInterface CLRName="..."/&gt;. The \'CLRName\' attribute \n        contains regular expression\nII.2.12 &lt;HandlesEvent /&gt;\n--&gt;\n</code></pre>\n\n<p>based on this one, that did not do the trick for me but who deserves the credit: <a href="http://www.clydesdalesoftware.net/blogs/jluif/CommentView,guid,1875594b-0d23-401f-8e22-f1cbf87beefe.aspx" rel="nofollow noreferrer">http://www.clydesdalesoftware.net/blogs/jluif/CommentView,guid,1875594b-0d23-401f-8e22-f1cbf87beefe.aspx</a></p>\n\n<p>This is a header snippet that complies to stylecop:</p>\n\n<pre><code>// &lt;copyright file="$FileName$" company="$Company$"&gt;\n// Copyright (c) 2008 All Right Reserved\n// &lt;/copyright&gt;\n// &lt;author&gt;$author$&lt;/author&gt;\n// &lt;email&gt;$email$&lt;/email&gt;\n// &lt;date&gt;$date$&lt;/date&gt;\n// &lt;summary&gt;$summary$&lt;/summary&gt;\n</code></pre>\n\n<p>Still not quite there but it is a start.</p>\n\n<p>Since this answer the Custom type member layout has been put in the StyleCop for resharper plugin. See <a href="http://1succeeded0failed0skipped.com/blogs/howardvanrooijen/archive/2008/12/07/stylecop-for-resharper-v0-0-14220-released.aspx" rel="nofollow noreferrer">here</a></p>\n'}]
['https://Stackoverflow.com/questions/57859', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5975/']