Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Async methods not included in Code Coverage when using .runsettings file

Whenever I run the Visual Studio 2015 Code Coverage over my solution without specifying a Test Settings file, all of my Async methods that I have tested are included in the coverage results and colored appropriately:

enter image description here

However, when I include a .runsettings file, the async methods are no longer included in the Coverage result and remain uncolored:

enter image description here

As far as I can see there is nothing in the .runsettings file that would ignore async methods:

<RunSettings>
  <DataCollectionRunSettings>
    <DataCollectors>
      <DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
        <Configuration>
          <CodeCoverage>

            <!-- Match assembly file paths: -->
            <ModulePaths>
              <Exclude>
                <ModulePath>.*xunit.*</ModulePath>
              </Exclude>
            </ModulePaths>
            <!-- Match attributes on any code element: -->
            <Attributes>
              <Exclude>
                <!-- Don't forget "Attribute" at the end of the name -->

                <Attribute>^System\.Diagnostics\.DebuggerHiddenAttribute$</Attribute>
                <Attribute>^System\.Diagnostics\.DebuggerNonUserCodeAttribute$</Attribute>
                <Attribute>^System\.Runtime\.CompilerServices.CompilerGeneratedAttribute$</Attribute>
                <Attribute>^System\.CodeDom\.Compiler.GeneratedCodeAttribute$</Attribute>
                <Attribute>^System\.Diagnostics\.CodeAnalysis.ExcludeFromCodeCoverageAttribute$</Attribute>
              </Exclude>
            </Attributes>

            <!-- We recommend you do not change the following values: -->
            <UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
            <AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
            <CollectFromChildProcesses>True</CollectFromChildProcesses>
            <CollectAspDotNet>False</CollectAspDotNet>

          </CodeCoverage>
        </Configuration>
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
</RunSettings>

Am I missing something from my .runsettings file to make this work?

like image 930
Steve Avatar asked Dec 14 '22 10:12

Steve


1 Answers

Turns out the line

<Attribute>^System\.Runtime\.CompilerServices.CompilerGeneratedAttribute$</Attribute>

was causing async methods to not be included in the code coverage.

like image 150
Steve Avatar answered Dec 16 '22 22:12

Steve