title: How do I exclude service references from code coverage using the runsettings file in Visual Studio 2012?
body: <p>I'm using a custom runsettings file to control what projects are inspected for code coverage. I used the default template provided by Microsoft and have so far been able to exclude the items I want with no issues. My next action is to exclude from code coverage the auto-generated web proxy classes that are created by Visual Studio when you add a service reference. </p>
  
  <p>This seemed something that should work with the default runsettings template since it has a section that looks like this: </p>
  
  <pre><code>&lt;Attributes&gt;
      &lt;Exclude&gt;
          &lt;!-- Don’t forget "Attribute" at the end of the name --&gt;
          &lt;Attribute&gt;^System.Diagnostics.DebuggerHiddenAttribute$&lt;/Attribute&gt;
          &lt;Attribute&gt;^System.Diagnostics.DebuggerNonUserCodeAttribute$&lt;/Attribute&gt;
          &lt;Attribute&gt;^System.Runtime.CompilerServices.CompilerGeneratedAttribute$&lt;/Attribute&gt;
          &lt;Attribute&gt;^System.CodeDom.Compiler.GeneratedCodeAttribute$&lt;/Attribute&gt;
          &lt;Attribute&gt;^System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute$&lt;/Attribute&gt;
      &lt;/Exclude&gt;
  &lt;/Attributes&gt;
  </code></pre>
  
  <p>All classes created when the service reference is added are decorated with the GeneratedCodeAttribute so they should all be excluded. However, when I run code coverage they are not ignored so code coverage reports a large block of un-covered code. I've experimented with the regular expression several times in an attempt to get it to select the attribute correctly to no avail.</p>
  
  <p>I'd appreciate suggestions on how to either:
  - get this attribute exclusion to work
  - an alternative that doesn't require me to exclude the entire project or that makes the runsettings file non-generic (we want to re-use this base file across all projects without specific edits)</p>
  
  <p>FYI - while I understand there are other code coverage tools, my goal here is to make the Visual Studio one work, so suggestions about switching to another tool are not helpful to me in this case.</p>