You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cannot exclude auto-generated code from code coverage with .runsettings file.
We are importing ElasticSearch which generates code under the path "/_/src/Elastic.Clients.Elasticsearch/_Generated" which is then deleted after the build is complete. (I cannot find this code when I search; we have no src and no _Generated directories.)
In our .runsettings file, I have tried multiple ways to exclude the ElasticSearch DLLs and the ElasticSearch generated code with negative results.
<ModulePaths>
<Include>
<!-- Include all loaded .dll assemblies (but not .exe assemblies): -->
<ModulePath>.*\.dll$</ModulePath>
</Include>
<Exclude>
<!-- But exclude some assemblies: -->
<ModulePath>.*\Elastic.Clients.Elasticsearch.dll$</ModulePath>
<ModulePath>.*\Elastic.Transport.dll$</ModulePath>
<!-- Exclude all file paths that contain "Temp": -->
<ModulePath>.*Temp.*</ModulePath>
<ModulePath>.*src.*</ModulePath>
<ModulePath>.*_Generated.*</ModulePath>
</Exclude>
</ModulePaths>
<Functions>
<Exclude>
<Function>^Elastic.Clients.Elasticsearch.*</Function>
</Exclude>
</Functions>
<Sources>
<Exclude>
<Source>.*src.*</Source>
<Source>.*_Generated.*</Source>
</Exclude>
</Sources>
Steps to reproduce
What steps can reproduce the defect?
Import ElasticSearch
Create a .runsettings file with the code snippit above.
Run the following command: dotnet-coverage collect -f cobertura,coverage "dotnet test --logger trx" -s .\.runsettings
Expected behavior
Auto-generated source code under the "src" and/or "_Generated" directories are excluded from code coverage.
Actual behavior
All auto-generated source code under the "src" and/or "_Generated" directories is included with code covaerage.
@cliffAtOsaic<Include>/<Exclude> are regex patterns. Can you please check if your source path/module path match patterns provided in runsettings?
If it still persists, then can you please provide a small repro solution?
@cliffAtOsaic<Include>/<Exclude> are regex patterns. Can you please check if your source path/module path match patterns provided in runsettings? If it still persists, then can you please provide a small repro solution?
Just seeing this; not sure why I didn't get an email. I'll take a look at this tomorrow and post what I learn. Thanks!
Description
Cannot exclude auto-generated code from code coverage with .runsettings file.
We are importing ElasticSearch which generates code under the path "/_/src/Elastic.Clients.Elasticsearch/_Generated" which is then deleted after the build is complete. (I cannot find this code when I search; we have no src and no _Generated directories.)
In our .runsettings file, I have tried multiple ways to exclude the ElasticSearch DLLs and the ElasticSearch generated code with negative results.
Steps to reproduce
What steps can reproduce the defect?
dotnet-coverage collect -f cobertura,coverage "dotnet test --logger trx" -s .\.runsettings
Expected behavior
Auto-generated source code under the "src" and/or "_Generated" directories are excluded from code coverage.
Actual behavior
All auto-generated source code under the "src" and/or "_Generated" directories is included with code covaerage.
Diagnostic logs
log.txt
Environment
Windows 11 Version 23H2 (OS Build 22631.3447)
dotnet --version = 8.0.204
The text was updated successfully, but these errors were encountered: