diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
index 1903d864e..4c03ce6b6 100644
--- a/.config/dotnet-tools.json
+++ b/.config/dotnet-tools.json
@@ -3,11 +3,11 @@
"isRoot": true,
"tools": {
"dotnet-reportgenerator-globaltool": {
- "version": "5.4.3",
+ "version": "5.4.7",
"commands": [
"reportgenerator"
],
"rollForward": false
}
}
-}
\ No newline at end of file
+}
diff --git a/.gitignore b/.gitignore
index 514880624..2179436d8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -318,3 +318,4 @@ FolderProfile.pubxml
/NuGet.config
nuget.config
*.dmp
+Playground*/
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index ffe337455..f0616b11f 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -4,9 +4,9 @@ Contributions are highly welcome, however, except for very small changes, kindly
## Requirements
-[.NET SDK 6.0](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
-[.NET SDK 7.0](https://dotnet.microsoft.com/en-us/download/dotnet/7.0)
-[.NET SDK 8.0](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)
+STS version [.NET SDK 9.0](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) for development environment
+
+LTS version [.NET SDK 8.0](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) for runtime environment
## Building the Project
diff --git a/Directory.Build.props b/Directory.Build.props
index 0b0e187d0..8b247342e 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -48,35 +48,4 @@
@(VSTestLogger)
-
-
-
-
- 15.9.20
- 1.6.0
- 1.5.0
-
-
-
-
diff --git a/Directory.Packages.props b/Directory.Packages.props
index eba94e254..40dfdfeae 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -8,20 +8,20 @@
- 17.13.9
- 4.12.0
+ 17.13.26
+ 4.13.0
+ 6.14.0
17.13.0
- 6.13.2
2.0.0
- 3.0.2
+ 3.1.0
-
+
@@ -39,7 +39,6 @@
vstest 17.8 version
NuGetFrameworksVersion is defined here https://github.com/microsoft/vstest/blob/9a0c41811637edf4afe0e265e08fdd1cb18109ed/eng/Versions.props#L94C1-L94C1
-->
-
@@ -54,18 +53,20 @@
-
+
+
-
+
-
-
+
+
+
-
+
diff --git a/Documentation/Changelog.md b/Documentation/Changelog.md
index b78c5a295..cb6dd70d0 100644
--- a/Documentation/Changelog.md
+++ b/Documentation/Changelog.md
@@ -1,4 +1,5 @@
# Changelog
+
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
@@ -7,12 +8,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
### Fixed
+
- Fix branchpoint exclusion for sdk 8.0.407 [#1741](https://github.com/coverlet-coverage/coverlet/issues/1741)
- Use `netstandard2.0` for _coverlet.collector_ and _coverlet.msbuild.tasks_ Packages´
### Improvements
-- Use [xunit.v3](https://xunit.net/docs/getting-started/v3/whats-new) for tests and example code
+- Upgraded minimum required .NET SDK and runtime to .NET 8.0 LTS (Long Term Support) (**Breaking Change**)
+- Use [xunit.v3](https://xunit.net/docs/getting-started/v3/whats-new) for tests and example code
## Release date 2024-01-20
### Packages
diff --git a/Documentation/Examples/MSBuild/DeterministicBuild/HowTo.md b/Documentation/Examples/MSBuild/DeterministicBuild/HowTo.md
index ffe46ca71..b11712440 100644
--- a/Documentation/Examples/MSBuild/DeterministicBuild/HowTo.md
+++ b/Documentation/Examples/MSBuild/DeterministicBuild/HowTo.md
@@ -1,57 +1,34 @@
-To run test we need to generates packages to reference in on test project.
-Run from repo root
+# Using Deterministic Builds with Coverlet MSBuild Integration
+
+## Prerequisites
+
+Before running tests with deterministic builds, you need to generate the local NuGet packages:
```shell
-C:\git\coverlet
-λ dotnet pack
-Microsoft (R) Build Engine version 17.7.4+3ebbd7c49 for .NET Core
-Copyright (C) Microsoft Corporation. All rights reserved.
-
- Restore completed in 73,36 ms for C:\git\coverlet\src\coverlet.core\coverlet.core.csproj.
- Restore completed in 73,41 ms for C:\git\coverlet\test\coverlet.testsubject\coverlet.testsubject.csproj.
- Restore completed in 73,33 ms for C:\git\coverlet\test\coverlet.tests.projectsample.excludedbyattribute\coverlet.tests.projectsample.excludedbyattribute.csproj.
- Restore completed in 73,34 ms for C:\git\coverlet\src\coverlet.collector\coverlet.collector.csproj.
- Restore completed in 73,35 ms for C:\git\coverlet\test\coverlet.tests.xunit.extensions\coverlet.tests.xunit.extensions.csproj.
- Restore completed in 75,92 ms for C:\git\coverlet\test\coverlet.integration.tests\coverlet.integration.tests.csproj.
- Restore completed in 73,41 ms for C:\git\coverlet\src\coverlet.console\coverlet.console.csproj.
- Restore completed in 73,36 ms for C:\git\coverlet\test\coverlet.tests.projectsample.empty\coverlet.tests.projectsample.empty.csproj.
- Restore completed in 73,47 ms for C:\git\coverlet\src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj.
- Restore completed in 73,37 ms for C:\git\coverlet\test\coverlet.core.tests.samples.netstandard\coverlet.core.tests.samples.netstandard.csproj.
- Restore completed in 76,37 ms for C:\git\coverlet\test\coverlet.collector.tests\coverlet.collector.tests.csproj.
- Restore completed in 77,05 ms for C:\git\coverlet\test\coverlet.integration.template\coverlet.integration.template.csproj.
- Restore completed in 77,2 ms for C:\git\coverlet\test\coverlet.core.performancetest\coverlet.core.performancetest.csproj.
- Restore completed in 87,7 ms for C:\git\coverlet\test\coverlet.core.tests\coverlet.core.tests.csproj.
- coverlet.core -> C:\git\coverlet\src\coverlet.core\bin\Debug\netstandard2.0\coverlet.core.dll
- coverlet.collector -> C:\git\coverlet\src\coverlet.collector\bin\Debug\netcoreapp2.0\coverlet.collector.dll
- coverlet.msbuild.tasks -> C:\git\coverlet\src\coverlet.msbuild.tasks\bin\Debug\netstandard2.0\coverlet.msbuild.tasks.dll
- coverlet.console -> C:\git\coverlet\src\coverlet.console\bin\Debug\net6.0\coverlet.console.dll
- Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.collector.6.0.1-preview.6.g918cd179e0.nupkg'.
- Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.collector.6.0.1-preview.6.g918cd179e0.snupkg'.
- Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.msbuild.6.0.1-preview.6.g918cd179e0.nupkg'.
- Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.msbuild.6.0.1-preview.6.g918cd179e0.snupkg'.
- Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.console.6.0.1-preview.6.g918cd179e0.nupkg'.
- Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.console.6.0.1-preview.6.g918cd179e0.snupkg'.
+# Run from repository root
+dotnet pack
```
-Add msbuild package version generated to `"..\Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\XUnitTestProject1.csproj"`
+## Project Setup
+
+Update your test project file `XUnitTestProject1.csproj`:
```xml
-
- net6.0
+ net8.0
false
-
-
+
+
all
runtime; build; native; contentfiles; analyzers
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
@@ -60,50 +37,25 @@ Add msbuild package version generated to `"..\Documentation\Examples\MSBuild\Det
-
```
-Go to test project folder and run
+## Running Tests
+
+Navigate to your test project directory and run:
```shell
-C:\git\coverlet\Documentation\Examples\MSBuild\DeterministicBuild (detbuilddocs -> origin)
-λ dotnet test /p:CollectCoverage=true /p:DeterministicSourcePaths=true
-Test run for C:\git\coverlet\Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\bin\Debug\net6.0\XUnitTestProject1.dll(.NETCoreApp,Version=v6.0)
-Microsoft (R) Test Execution Command Line Tool Version 17.5.0
-Copyright (c) Microsoft Corporation. All rights reserved.
-
-Starting test execution, please wait...
-
-A total of 1 test files matched the specified pattern.
-
-Test Run Successful.
-Total tests: 1
- Passed: 1
- Total time: 1,1471 Seconds
-
-Calculating coverage result...
- Generating report 'C:\git\coverlet\Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\coverage.json'
-
-+---------------+------+--------+--------+
-| Module | Line | Branch | Method |
-+---------------+------+--------+--------+
-| ClassLibrary1 | 100% | 100% | 100% |
-+---------------+------+--------+--------+
-
-+---------+------+--------+--------+
-| | Line | Branch | Method |
-+---------+------+--------+--------+
-| Total | 100% | 100% | 100% |
-+---------+------+--------+--------+
-| Average | 100% | 100% | 100% |
-+---------+------+--------+--------+
+dotnet test /p:CollectCoverage=true /p:DeterministicSourcePaths=true
```
-You should see on output folder the coverlet source root mapping file generated. The filename starts with 'CoverletSourceRootsMapping_'. Do not use `--no-build` option
-This is the confirmation that you're running coverage on deterministic build e.g. `Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\bin\Debug\net6.0\CoverletSourceRootsMapping_XUnitTestProject1`
+> **Important**: Do not use the `--no-build` option as it will prevent the generation of deterministic build artifacts.
+## Verification
+
+After running the tests, verify the deterministic build by checking for the source root mapping file:
```text
-Documentation\Examples\MSBuild\DeterministicBuild\XUnitTestProject1\bin\Debug\net6.0\CoverletSourceRootsMapping_XUnitTestProject1
+bin\Debug\net8.0\CoverletSourceRootsMapping_XUnitTestProject1
```
+
+The presence of this file confirms that your coverage report was generated with deterministic build settings.
\ No newline at end of file
diff --git a/Documentation/Examples/MSBuild/DeterministicBuild/XUnitTestProject1/XUnitTestProject1.csproj b/Documentation/Examples/MSBuild/DeterministicBuild/XUnitTestProject1/XUnitTestProject1.csproj
index 96969ce77..2a6bca4c1 100644
--- a/Documentation/Examples/MSBuild/DeterministicBuild/XUnitTestProject1/XUnitTestProject1.csproj
+++ b/Documentation/Examples/MSBuild/DeterministicBuild/XUnitTestProject1/XUnitTestProject1.csproj
@@ -1,15 +1,15 @@
- net6.0
+ net8.0
false
false
-
-
+
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/Documentation/Examples/MSBuild/MergeWith/HowTo.md b/Documentation/Examples/MSBuild/MergeWith/HowTo.md
index 4135a1379..c57b5b83e 100644
--- a/Documentation/Examples/MSBuild/MergeWith/HowTo.md
+++ b/Documentation/Examples/MSBuild/MergeWith/HowTo.md
@@ -1,24 +1,57 @@
-**Run from solution root sln**
+# Merging Coverage Reports
-To merge report together you need to run separate test and merge in one `json` format file.
-Last command will join and create final needed format file.
+## Running Tests Separately
-```shell
-dotnet test XUnitTestProject1\XUnitTestProject1.csproj /p:CollectCoverage=true /p:CoverletOutput=../CoverageResults/
-dotnet test XUnitTestProject2\XUnitTestProject2.csproj /p:CollectCoverage=true /p:CoverletOutput=../CoverageResults/ /p:MergeWith="../CoverageResults/coverage.json"
-dotnet test XUnitTestProject3\XUnitTestProject3.csproj /p:CollectCoverage=true /p:CoverletOutput=../CoverageResults/ /p:MergeWith="../CoverageResults/coverage.json" /p:CoverletOutputFormat="opencover"
+To merge coverage reports, run tests for each project and combine them into a single file:
+
+```bash
+# Generate coverage for first project
+dotnet test XUnitTestProject1/XUnitTestProject1.csproj \
+ /p:CollectCoverage=true \
+ /p:CoverletOutput=../CoverageResults/
+
+# Merge coverage from second project
+dotnet test XUnitTestProject2/XUnitTestProject2.csproj \
+ /p:CollectCoverage=true \
+ /p:CoverletOutput=../CoverageResults/ \
+ /p:MergeWith="../CoverageResults/coverage.json"
+
+# Merge coverage from third project and generate final OpenCover report
+dotnet test XUnitTestProject3/XUnitTestProject3.csproj \
+ /p:CollectCoverage=true \
+ /p:CoverletOutput=../CoverageResults/ \
+ /p:MergeWith="../CoverageResults/coverage.json" \
+ /p:CoverletOutputFormat="opencover"
```
-You can merge also running `dotnet test` and merge with single command from a solution file, but you need to ensure that tests will run sequentially(`-m:1`). This slow down testing but avoid invalid coverage result.
+## Running Tests from Solution
-```shell
-dotnet test /p:CollectCoverage=true /p:CoverletOutput=../CoverageResults/ /p:MergeWith="../CoverageResults/coverage.json" /p:CoverletOutputFormat=\"opencover,json\" -m:1
+To merge coverage using a single command (requires sequential execution):
+
+```bash
+dotnet test \
+ /p:CollectCoverage=true \
+ /p:CoverletOutput=../CoverageResults/ \
+ /p:MergeWith="../CoverageResults/coverage.json" \
+ /p:CoverletOutputFormat="opencover,json" \
+ -m:1
```
-N.B. You need to specify `json` format plus another format(the final one), because Coverlet can only merge proprietary format. At the end you can delete temporary `coverage.json` file.
+> **Note**: Sequential execution (`-m:1`) ensures accurate coverage but increases test duration.
+
+## Important Considerations
+
+- Include `json` format alongside your desired output format
+- Coverlet only merges its proprietary JSON format
+- The temporary `coverage.json` file can be deleted after merging
-You can also merge the coverage result and generate another valid format to export the content than opencover, like cobertura.
+## Example with Cobertura Output
-```shell
-dotnet test /p:CollectCoverage=true /p:CoverletOutput=../CoverageResults/ /p:MergeWith="../CoverageResults/coverage.json" /p:CoverletOutputFormat=\"cobertura,json\" -m:1
+```bash
+dotnet test \
+ /p:CollectCoverage=true \
+ /p:CoverletOutput=../CoverageResults/ \
+ /p:MergeWith="../CoverageResults/coverage.json" \
+ /p:CoverletOutputFormat="cobertura,json" \
+ -m:1
```
diff --git a/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject1/XUnitTestProject1.csproj b/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject1/XUnitTestProject1.csproj
index f88747048..43fbc590c 100644
--- a/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject1/XUnitTestProject1.csproj
+++ b/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject1/XUnitTestProject1.csproj
@@ -1,13 +1,13 @@
- net6.0
+ net8.0
false
false
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject2/XUnitTestProject2.csproj b/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject2/XUnitTestProject2.csproj
index 348f9a927..8332dfefa 100644
--- a/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject2/XUnitTestProject2.csproj
+++ b/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject2/XUnitTestProject2.csproj
@@ -1,19 +1,19 @@
- net6.0
+ net8.0
false
false
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject3/XUnitTestProject3.csproj b/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject3/XUnitTestProject3.csproj
index b06c78138..20c0af736 100644
--- a/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject3/XUnitTestProject3.csproj
+++ b/Documentation/Examples/MSBuild/MergeWith/XUnitTestProject3/XUnitTestProject3.csproj
@@ -1,19 +1,19 @@
- net6.0
+ net8.0
false
false
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/Documentation/Examples/VSTest/DeterministicBuild/HowTo.md b/Documentation/Examples/VSTest/DeterministicBuild/HowTo.md
index f14a48124..f7b53bb1f 100644
--- a/Documentation/Examples/VSTest/DeterministicBuild/HowTo.md
+++ b/Documentation/Examples/VSTest/DeterministicBuild/HowTo.md
@@ -1,91 +1,55 @@
-To run test we need to generates packages to reference in on test project.
-Run from repo root
+# Using Deterministic Builds with Coverlet and VSTest
-```shell
-C:\git\coverlet
-λ dotnet pack
-Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core
-Copyright (C) Microsoft Corporation. All rights reserved.
+## Prerequisites
- Restore completed in 73,36 ms for C:\git\coverlet\src\coverlet.core\coverlet.core.csproj.
- Restore completed in 73,41 ms for C:\git\coverlet\test\coverlet.testsubject\coverlet.testsubject.csproj.
- Restore completed in 73,33 ms for C:\git\coverlet\test\coverlet.tests.projectsample.excludedbyattribute\coverlet.tests.projectsample.excludedbyattribute.csproj.
- Restore completed in 73,34 ms for C:\git\coverlet\src\coverlet.collector\coverlet.collector.csproj.
- Restore completed in 73,35 ms for C:\git\coverlet\test\coverlet.tests.xunit.extensions\coverlet.tests.xunit.extensions.csproj.
- Restore completed in 75,92 ms for C:\git\coverlet\test\coverlet.integration.tests\coverlet.integration.tests.csproj.
- Restore completed in 73,41 ms for C:\git\coverlet\src\coverlet.console\coverlet.console.csproj.
- Restore completed in 73,36 ms for C:\git\coverlet\test\coverlet.tests.projectsample.empty\coverlet.tests.projectsample.empty.csproj.
- Restore completed in 73,47 ms for C:\git\coverlet\src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj.
- Restore completed in 73,37 ms for C:\git\coverlet\test\coverlet.core.tests.samples.netstandard\coverlet.core.tests.samples.netstandard.csproj.
- Restore completed in 76,37 ms for C:\git\coverlet\test\coverlet.collector.tests\coverlet.collector.tests.csproj.
- Restore completed in 77,05 ms for C:\git\coverlet\test\coverlet.integration.template\coverlet.integration.template.csproj.
- Restore completed in 77,2 ms for C:\git\coverlet\test\coverlet.core.performancetest\coverlet.core.performancetest.csproj.
- Restore completed in 87,7 ms for C:\git\coverlet\test\coverlet.core.tests\coverlet.core.tests.csproj.
- coverlet.core -> C:\git\coverlet\src\coverlet.core\bin\Debug\netstandard2.0\coverlet.core.dll
- coverlet.collector -> C:\git\coverlet\src\coverlet.collector\bin\Debug\netcoreapp2.0\coverlet.collector.dll
- coverlet.msbuild.tasks -> C:\git\coverlet\src\coverlet.msbuild.tasks\bin\Debug\netstandard2.0\coverlet.msbuild.tasks.dll
- coverlet.console -> C:\git\coverlet\src\coverlet.console\bin\Debug\net6.0\coverlet.console.dll
- Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.collector.6.0.1-preview.6.g918cd179e0.nupkg'.
- Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.collector.6.0.1-preview.6.g918cd179e0.snupkg'.
- Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.msbuild.6.0.1-preview.6.g918cd179e0.nupkg'.
- Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.msbuild.6.0.1-preview.6.g918cd179e0.snupkg'.
- Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.console.6.0.1-preview.6.g918cd179e0.nupkg'.
- Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.console.6.0.1-preview.6.g918cd179e0.snupkg'.
+Before running tests with deterministic builds, you need to generate the required NuGet packages. Run the following command from the repository root:
+
+```powershell
+dotnet pack
```
-Add collectors package version generated to `"..\Documentation\Examples\VSTest\DeterministicBuild\XUnitTestProject1\XUnitTestProject1.csproj"`
+## Project Setup
+
+Update your test project file `XUnitTestProject1.csproj` with the following configuration:
```xml
-
- net6.0
+ net8.0
false
-
-
+
+
all
runtime; build; native; contentfiles; analyzers
-
-
+
+
-
-
```
-Go to test project folder and run
+## Running Tests
-```shell
-C:\git\coverlet\Documentation\Examples\VSTest\DeterministicBuild (detbuilddocs -> origin)
-λ dotnet test --collect:"XPlat Code Coverage" /p:DeterministicSourcePaths=true -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.DeterministicReport=true
-Test run for C:\git\coverlet\Documentation\Examples\VSTest\DeterministicBuild\XUnitTestProject1\bin\Debug\netcoreapp3.1\XUnitTestProject1.dll(.NETCoreApp,Version=v6.0)
-Microsoft (R) Test Execution Command Line Tool Version 17.5.0
-Copyright (c) Microsoft Corporation. All rights reserved.
+Navigate to your test project directory and execute:
-Starting test execution, please wait...
-
-A total of 1 test files matched the specified pattern.
-
-Attachments:
- C:\git\coverlet\Documentation\Examples\VSTest\DeterministicBuild\XUnitTestProject1\TestResults\7305d38e-0134-4fda-a99c-3672b410f472\coverage.cobertura.xml
-Test Run Successful.
-Total tests: 1
- Passed: 1
- Total time: 1,3472 Seconds
+```powershell
+dotnet test --collect:"XPlat Code Coverage" /p:DeterministicSourcePaths=true -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.DeterministicReport=true
```
-You should see on output folder the coverlet source root mapping file generated.
-This is the confirmation that you're running coverage on deterministic build.
+## Verification
+
+After running the tests, verify that the deterministic build is working by checking for the source root mapping file:
```text
-Documentation\Examples\VSTest\DeterministicBuild\XUnitTestProject1\bin\Debug\net6.0\CoverletSourceRootsMapping_XUnitTestProject1
+\bin\Debug\net8.0\CoverletSourceRootsMapping_XUnitTestProject1
```
+
+The presence of this file confirms that your coverage report was generated with deterministic build settings.
\ No newline at end of file
diff --git a/Documentation/Examples/VSTest/DeterministicBuild/XUnitTestProject1/XUnitTestProject1.csproj b/Documentation/Examples/VSTest/DeterministicBuild/XUnitTestProject1/XUnitTestProject1.csproj
index 556574ff0..ae20b19ef 100644
--- a/Documentation/Examples/VSTest/DeterministicBuild/XUnitTestProject1/XUnitTestProject1.csproj
+++ b/Documentation/Examples/VSTest/DeterministicBuild/XUnitTestProject1/XUnitTestProject1.csproj
@@ -1,15 +1,15 @@
- net6.0
+ net8.0
false
false
-
-
+
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/Documentation/Examples/VSTest/HelloWorld/XUnitTestProject1/XUnitTestProject1.csproj b/Documentation/Examples/VSTest/HelloWorld/XUnitTestProject1/XUnitTestProject1.csproj
index 8c1660832..9c3c04433 100644
--- a/Documentation/Examples/VSTest/HelloWorld/XUnitTestProject1/XUnitTestProject1.csproj
+++ b/Documentation/Examples/VSTest/HelloWorld/XUnitTestProject1/XUnitTestProject1.csproj
@@ -1,7 +1,7 @@
- net6.0
+ net8.0
false
false
$(MSBuildThisFileDirectory).runsettings
@@ -9,8 +9,8 @@
-
-
+
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/Documentation/KnownIssues.md b/Documentation/KnownIssues.md
index c181e7ea3..6a6686384 100644
--- a/Documentation/KnownIssues.md
+++ b/Documentation/KnownIssues.md
@@ -131,7 +131,7 @@ dotnet test test-assembly.dll /collect:"XPlat Code Coverage" -- DataCollectionRu
*Symptoms:* during build/instrumentation you may get an exception like:
```text
-[coverlet] Unable to instrument module: ..\UnitTests\bin\Debug\net6.0\Core.Messaging.dll because : Failed to resolve assembly: 'Microsoft.Azure.ServiceBus, Version=7.16.1.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c' [..\UnitTests.csproj]
+[coverlet] Unable to instrument module: ..\UnitTests\bin\Debug\net8.0\Core.Messaging.dll because : Failed to resolve assembly: 'Microsoft.Azure.ServiceBus, Version=7.16.1.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c' [..\UnitTests.csproj]
```
In the instrumentation phase, Coverlet needs to load all references used by your instrumented module. Sometimes the build phase (out of Coverlet's control) does not copy those dlls to the output folder because they are not resolved till runtime or at publish phase from the NuGet packages folders.
@@ -155,13 +155,13 @@ or by adding the property `` to the project file
NB. This **DOESN'T ALWAYS WORK**, for example in case of the shared framework
-We can do nothing at the moment as this is a build behaviour out of our control.
+We can do nothing at the moment as this is a build behavior out of our control.
For .NET runtime version >= 3.0 the new default behavior is to copy all assets to the build output (CopyLocalLockFileAssemblies=true) , unfortunately the issue could still arise.
In this case the only workaround at the moment is to *manually copy* missing dlls to the output folder:
-> The only reliable way to work around this problem is to drop the DLL in the unit tests project's bin\Release\netcoreapp2.2 directory.
+> The only reliable way to work around this problem is to drop the DLL in the unit tests project's bin\Release directory.
## Tests fail if assembly is strong named
diff --git a/Documentation/ReleasePlan.md b/Documentation/ReleasePlan.md
index 42a87f13a..467ae24ad 100644
--- a/Documentation/ReleasePlan.md
+++ b/Documentation/ReleasePlan.md
@@ -61,20 +61,20 @@ This is the steps to release new packages to nuget.org
dotnet pack -c release /p:TF_BUILD=true /p:PublicRelease=true
...
coverlet.core -> C:\GitHub\coverlet\artifacts\bin\coverlet.core\release_netstandard2.0\coverlet.core.dll
- coverlet.core -> C:\GitHub\coverlet\artifacts\bin\coverlet.core\release_net6.0\coverlet.core.dll
+ coverlet.core -> C:\GitHub\coverlet\artifacts\bin\coverlet.core\release_net8.0\coverlet.core.dll
coverlet.collector -> C:\GitHub\coverlet\artifacts\bin\coverlet.collector\release_netstandard2.0\coverlet.collector.dll
- coverlet.collector -> C:\GitHub\coverlet\artifacts\bin\coverlet.collector\release_net6.0\coverlet.collector.dll
+ coverlet.collector -> C:\GitHub\coverlet\artifacts\bin\coverlet.collector\release_net8.0\coverlet.collector.dll
coverlet.msbuild.tasks -> C:\GitHub\coverlet\artifacts\bin\coverlet.msbuild.tasks\release_netstandard2.0\coverlet.msbuild.tasks.dll
- coverlet.msbuild.tasks -> C:\GitHub\coverlet\artifacts\bin\coverlet.msbuild.tasks\release_net6.0\coverlet.msbuild.tasks.dll
+ coverlet.msbuild.tasks -> C:\GitHub\coverlet\artifacts\bin\coverlet.msbuild.tasks\release_net8.0\coverlet.msbuild.tasks.dll
coverlet.console -> C:\GitHub\coverlet\artifacts\bin\coverlet.console\release\coverlet.console.dll
coverlet.console -> C:\GitHub\coverlet\artifacts\bin\coverlet.console\release\coverlet.console.exe
...
- Successfully created package 'C:\GitHub\coverlet\artifacts\package\release\coverlet.msbuild.6.0.1.nupkg'.
- Successfully created package 'C:\GitHub\coverlet\artifacts\package\release\coverlet.msbuild.6.0.1.snupkg'.
- Successfully created package 'C:\GitHub\coverlet\artifacts\package\release\coverlet.collector.6.0.1.nupkg'.
- Successfully created package 'C:\GitHub\coverlet\artifacts\package\release\coverlet.collector.6.0.1.snupkg'.
- Successfully created package 'C:\GitHub\coverlet\artifacts\package\release\coverlet.console.6.0.1.nupkg'.
- Successfully created package 'C:\GitHub\coverlet\artifacts\package\release\coverlet.console.6.0.1.snupkg'.
+ Successfully created package 'C:\GitHub\coverlet\artifacts\package\release\coverlet.msbuild.8.0.1.nupkg'.
+ Successfully created package 'C:\GitHub\coverlet\artifacts\package\release\coverlet.msbuild.8.0.1.snupkg'.
+ Successfully created package 'C:\GitHub\coverlet\artifacts\package\release\coverlet.collector.8.0.1.nupkg'.
+ Successfully created package 'C:\GitHub\coverlet\artifacts\package\release\coverlet.collector.8.0.1.snupkg'.
+ Successfully created package 'C:\GitHub\coverlet\artifacts\package\release\coverlet.console.8.0.1.nupkg'.
+ Successfully created package 'C:\GitHub\coverlet\artifacts\package\release\coverlet.console.8.0.1.snupkg'.
...
```
diff --git a/Documentation/Troubleshooting.md b/Documentation/Troubleshooting.md
index df0fe5246..87fb28a55 100644
--- a/Documentation/Troubleshooting.md
+++ b/Documentation/Troubleshooting.md
@@ -32,18 +32,18 @@ Search inside with filter '[coverlet]'
## Coverlet Global Tool
```shell
-coverlet "C:\git\coverlet\test\coverlet.core.tests\bin\Debug\net6.0\coverlet.core.tests.dll" --target "dotnet" --targetargs "test C:\git\coverlet\test\coverlet.core.tests --no-build" --verbosity detailed
+coverlet "C:\git\coverlet\test\coverlet.core.tests\bin\Debug\net8.0\coverlet.core.tests.dll" --target "dotnet" --targetargs "test C:\git\coverlet\test\coverlet.core.tests --no-build" --verbosity detailed
```
Sample output
```text
...
-Instrumented module: 'C:\git\coverlet\test\coverlet.core.tests\bin\Debug\net6.0\coverlet.core.dll'
-Instrumented module: 'C:\git\coverlet\test\coverlet.core.tests\bin\Debug\net6.0\xunit.runner.reporters.netcoreapp10.dll'
-Instrumented module: 'C:\git\coverlet\test\coverlet.core.tests\bin\Debug\net6.0\xunit.runner.utility.netcoreapp10.dll'
-Instrumented module: 'C:\git\coverlet\test\coverlet.core.tests\bin\Debug\net6.0\xunit.runner.visualstudio.dotnetcore.testadapter.dll'
-Test run for C:\git\coverlet\test\coverlet.core.tests\bin\Debug\net6.0\coverlet.core.tests.dll(.NETCoreApp,Version=v2.0)
+Instrumented module: 'C:\git\coverlet\test\coverlet.core.tests\bin\Debug\net8.0\coverlet.core.dll'
+Instrumented module: 'C:\git\coverlet\test\coverlet.core.tests\bin\Debug\net8.0\xunit.runner.reporters.netcoreapp10.dll'
+Instrumented module: 'C:\git\coverlet\test\coverlet.core.tests\bin\Debug\net8.0\xunit.runner.utility.netcoreapp10.dll'
+Instrumented module: 'C:\git\coverlet\test\coverlet.core.tests\bin\Debug\net8.0\xunit.runner.visualstudio.dotnetcore.testadapter.dll'
+Test run for C:\git\coverlet\test\coverlet.core.tests\bin\Debug\net8.0\coverlet.core.tests.dll(.NETCoreApp,Version=v2.0)
Microsoft (R) Test Execution Command Line Tool Version 16.0.1
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
@@ -57,7 +57,7 @@ Test execution time: 4,6411 Seconds
Calculating coverage result...
Hits file:'C:\Users\Marco\AppData\Local\Temp\coverlet.core_703263e9-21f0-4d1c-9ce3-98ddeacecc01' not found for module: 'coverlet.core'
- Generating report 'C:\git\coverlet\src\coverlet.console\bin\Debug\net6.0\coverage.json'
+ Generating report 'C:\git\coverlet\src\coverlet.console\bin\Debug\net8.0\coverage.json'
+--------------------------------------------------+--------+--------+--------+
| Module | Line | Branch | Method |
+--------------------------------------------------+--------+--------+--------+
@@ -101,14 +101,14 @@ You can "load" your local build using simple switch:
Restore completed in 60.42 ms for D:\git\coverlet\test\coverlet.core.performancetest\coverlet.core.performancetest.csproj.
Restore completed in 60.47 ms for D:\git\coverlet\test\coverlet.core.tests\coverlet.core.tests.csproj.
Restore completed in 22.85 ms for D:\git\coverlet\test\coverlet.core.tests\coverlet.core.tests.csproj.
- coverlet.testsubject -> D:\git\coverlet\test\coverlet.testsubject\bin\Debug\net6.0\coverlet.testsubject.dll
+ coverlet.testsubject -> D:\git\coverlet\test\coverlet.testsubject\bin\Debug\net8.0\coverlet.testsubject.dll
coverlet.core -> D:\git\coverlet\src\coverlet.core\bin\Debug\netstandard2.0\coverlet.core.dll
coverlet.msbuild.tasks -> D:\git\coverlet\src\coverlet.msbuild.tasks\bin\Debug\netstandard2.0\coverlet.msbuild.tasks.dll
coverlet.collector -> D:\git\coverlet\src\coverlet.collector\bin\Debug\netstandard2.0\coverlet.collector.dll
- coverlet.console -> D:\git\coverlet\src\coverlet.console\bin\Debug\net6.0\coverlet.console.dll
- coverlet.core.performancetest -> D:\git\coverlet\test\coverlet.core.performancetest\bin\Debug\net6.0\coverlet.core.performancetest.dll
- coverlet.core.tests -> D:\git\coverlet\test\coverlet.core.tests\bin\Debug\net6.0\coverlet.core.tests.dll
- coverlet.collector.tests -> D:\git\coverlet\test\coverlet.collector.tests\bin\Debug\net6.0\coverlet.collector.tests.dll
+ coverlet.console -> D:\git\coverlet\src\coverlet.console\bin\Debug\net8.0\coverlet.console.dll
+ coverlet.core.performancetest -> D:\git\coverlet\test\coverlet.core.performancetest\bin\Debug\net8.0\coverlet.core.performancetest.dll
+ coverlet.core.tests -> D:\git\coverlet\test\coverlet.core.tests\bin\Debug\net8.0\coverlet.core.tests.dll
+ coverlet.collector.tests -> D:\git\coverlet\test\coverlet.collector.tests\bin\Debug\net8.0\coverlet.collector.tests.dll
Build succeeded.
0 Warning(s)
@@ -146,8 +146,8 @@ To use/debug local collectors build we need to tell to our project to restore an
Restore completed in 50,28 ms for C:\git\coverlet\src\coverlet.core\coverlet.core.csproj.
coverlet.core -> C:\git\coverlet\src\coverlet.core\bin\Debug\netstandard2.0\coverlet.core.dll
coverlet.collector -> C:\git\coverlet\src\coverlet.collector\bin\Debug\netstandard2.0\coverlet.collector.dll
- Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.collector.6.0.4.nupkg'.
- Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.collector.6.0.4.snupkg'.
+ Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.collector.8.0.1.nupkg'.
+ Successfully created package 'C:\git\coverlet\bin\Debug\Packages\coverlet.collector.8.0.1.snupkg'.
```
2) Add new `NuGet.Config` file on your test project/solution
@@ -172,18 +172,18 @@ To use/debug local collectors build we need to tell to our project to restore an
- net6.0
+ net8.0
false
-
-
+
+
all
runtime; build; native; contentfiles; analyzers
- <-- My local package version -->
+ <-- My local package version -->
diff --git a/Documentation/VSTestIntegration.md b/Documentation/VSTestIntegration.md
index a2c4140e1..9285d0f27 100644
--- a/Documentation/VSTestIntegration.md
+++ b/Documentation/VSTestIntegration.md
@@ -2,12 +2,12 @@
**Supported runtime versions**:
-Since version `6.0.0`
+Since version `8.0.0`
-* .NET Core >= 6.0
+* .NET Core >= 8.0
* .NET Framework >= 4.7.2
-As explained in quick start section, to use collectors you need to run *SDK v6.0.100* (LTS) or newer and your project file must reference `coverlet.collector` and a minimum version of `Microsoft.NET.Test.Sdk`.
+As explained in quick start section, to use collectors you need to run *SDK v8.0.411* (LTS) or newer and your project file must reference `coverlet.collector` and a minimum version of `Microsoft.NET.Test.Sdk`.
A sample project file looks like:
@@ -20,7 +20,7 @@ A sample project file looks like:
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
@@ -43,10 +43,10 @@ or
```text
dotnet publish
...
- ... -> C:\project\bin\Debug\net6.0\testdll.dll
- ... -> C:\project\bin\Debug\net6.0\publish\
+ ... -> C:\project\bin\Debug\net8.0\testdll.dll
+ ... -> C:\project\bin\Debug\net8.0\publish\
...
-dotnet vstest C:\project\bin\Debug\net6.0\publish\testdll.dll --collect:"XPlat Code Coverage"
+dotnet vstest C:\project\bin\Debug\net8.0\publish\testdll.dll --collect:"XPlat Code Coverage"
```
As you can see in case of `vstest` verb you **must** publish project before.
@@ -75,11 +75,11 @@ We're working to fill the gaps.
> [!TIP]
> *Some alternative solutions to merge coverage files*
>
-> * use _dotnet-coverage_ tool and merge multiple coverage files
+> * use *dotnet-coverage* tool and merge multiple coverage files
>
> `dotnet-coverage merge artifacts/coverage/**/coverage.cobertura.xml -f cobertura -o artifacts/coverage/coverage.xml`*
>
-> * use _dotnet-reportgenerator-globaltool_ to create a HTML report and a merged coverage file
+> * use *dotnet-reportgenerator-globaltool* to create a HTML report and a merged coverage file
>
> `reportgenerator -reports:"**/*.cobertura.xml" -targetdir:"artifacts\reports.cobertura" -reporttypes:"HtmlInline_AzurePipelines_Dark;Cobertura"`
@@ -110,8 +110,8 @@ These are a list of options that are supported by coverlet. These can be specifi
| Option | Summary |
|:-------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Format | Coverage output format. These are either cobertura, json, lcov, opencover or teamcity as well as combinations of these formats. |
-| Exclude | Exclude from code coverage analysing using filter expressions. |
-| ExcludeByAttribute | Exclude a method, an entire class or assembly from code coverage decorated by an attribute. |
+| Exclude | Exclude from code coverage analyzing using filter expressions. |
+| ExcludeByAttribute | Exclude a method, an entire class or assembly from code coverage decorated by an attribute. |
| ExcludeByFile | Ignore specific source files from code coverage. |
| Include | Explicitly set what to include in code coverage analysis using filter expressions. |
| IncludeDirectory | Explicitly set which directories to include in code coverage analysis. |
@@ -120,8 +120,8 @@ These are a list of options that are supported by coverlet. These can be specifi
| IncludeTestAssembly | Include coverage of the test assembly. |
| SkipAutoProps | Neither track nor record auto-implemented properties. |
| DoesNotReturnAttribute | Methods marked with these attributes are known not to return, statements following them will be excluded from coverage |
-| DeterministicReport | Generates deterministic report in context of deterministic build. Take a look at [documentation](DeterministicBuild.md) for further informations.
-| ExcludeAssembliesWithoutSources | Specifies whether to exclude assemblies without source. Options are either MissingAll, MissingAny or None. Default is MissingAll.|
+| DeterministicReport | Generates deterministic report in context of deterministic build. Take a look at [documentation](DeterministicBuild.md) for further information. |
+| ExcludeAssembliesWithoutSources | Specifies whether to exclude assemblies without source. Options are either MissingAll, MissingAny or None. Default is MissingAll. |
How to specify these options via runsettings?
diff --git a/README.md b/README.md
index cea37fcfc..39aa23b69 100644
--- a/README.md
+++ b/README.md
@@ -44,8 +44,8 @@ Coverlet supports only SDK-style projects https://docs.microsoft.com/en-us/visua
```bash
dotnet add package coverlet.collector
```
-
-N.B. You **MUST** add package only to test projects and if you create xunit test projects (`dotnet new xunit`) you'll find the reference already present in `csproj` file because Coverlet is the default coverage tool for every .NET Core and >= .NET 6 applications, you've only to update to last version if needed. Do not add `coverlet.collector` and `coverlet.msbuild` package in a test project.
+> [!NOTE]
+> You **MUST** add package only to test projects and if you create xunit test projects (`dotnet new xunit`) you will find the reference already present in `csproj` file because Coverlet is the default coverage tool for every .NET Core and >= *.NET 8* applications, you've only to update to last version if needed. Add `coverlet.collector` *OR* `coverlet.msbuild` package in a test project.
### Usage (coverlet.collector)
@@ -61,11 +61,11 @@ See [documentation](Documentation/VSTestIntegration.md) for advanced usage.
#### Requirements (coverlet.collector)
-* _You need to be running .NET 6.0 SDK v6.0.316 or newer_
-* _You need to reference version 17.5.0 and above of Microsoft.NET.Test.Sdk_
+* _You need to be running .NET 8.0 SDK v8.0.112 or newer_
+* _You need to reference version 17.12.0 and above of Microsoft.NET.Test.Sdk_
```xml
-
+
```
### MSBuild Integration (suffers of possible [known issue](https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/KnownIssues.md#1-vstest-stops-process-execution-earlydotnet-test))
@@ -120,7 +120,7 @@ See [documentation](Documentation/GlobalTool.md) for advanced usage.
.NET global tools rely on a .NET Core runtime installed on your machine https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools#what-could-go-wrong
-.NET Coverlet global tool requires _.NET Core 2.2 and above_
+.NET Coverlet global tool requires _.NET 8.0 or above_
## How It Works
diff --git a/coverlet.sln b/coverlet.sln
index a449bd072..228793780 100644
--- a/coverlet.sln
+++ b/coverlet.sln
@@ -90,6 +90,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "coverlet.tests.projectsampl
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "coverlet.core.coverage.tests", "test\coverlet.core.coverage.tests\coverlet.core.coverage.tests.csproj", "{F74AD549-EFE0-4CD9-AD10-B2189E3FD5BB}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "coverlet.integration.determisticbuild", "test\coverlet.integration.determisticbuild\coverlet.integration.determisticbuild.csproj", "{C80BF6A9-63EE-6D36-8913-627A7E2EA459}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -196,6 +198,10 @@ Global
{F74AD549-EFE0-4CD9-AD10-B2189E3FD5BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F74AD549-EFE0-4CD9-AD10-B2189E3FD5BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F74AD549-EFE0-4CD9-AD10-B2189E3FD5BB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C80BF6A9-63EE-6D36-8913-627A7E2EA459}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C80BF6A9-63EE-6D36-8913-627A7E2EA459}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C80BF6A9-63EE-6D36-8913-627A7E2EA459}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C80BF6A9-63EE-6D36-8913-627A7E2EA459}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -227,6 +233,7 @@ Global
{0B109210-03CB-413F-888C-3023994AA384} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
{71004336-9896-4AE5-8367-B29BB1680542} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
{F74AD549-EFE0-4CD9-AD10-B2189E3FD5BB} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
+ {C80BF6A9-63EE-6D36-8913-627A7E2EA459} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9CA57C02-97B0-4C38-A027-EA61E8741F10}
diff --git a/eng/azure-pipelines-nightly.yml b/eng/azure-pipelines-nightly.yml
index ab78bae71..556fc4cb0 100644
--- a/eng/azure-pipelines-nightly.yml
+++ b/eng/azure-pipelines-nightly.yml
@@ -2,15 +2,10 @@ pool:
vmImage: 'windows-latest'
steps:
-- task: UseDotNet@2
- inputs:
- version: 6.0.428
- displayName: Install .NET Core SDK 6.0.428
-
- task: UseDotNet@2
inputs:
useGlobalJson: true
- displayName: Install .NET Core SDK 8.0.113
+ displayName: Install .NET Core SDK 8.0.411
- task: NuGetAuthenticate@1
displayName: Authenticate with NuGet feeds
diff --git a/eng/build.yml b/eng/build.yml
index 570bd0f2c..e9dba3973 100644
--- a/eng/build.yml
+++ b/eng/build.yml
@@ -1,13 +1,8 @@
steps:
-- task: UseDotNet@2
- inputs:
- version: 6.0.428
- displayName: Install .NET Core SDK 6.0.428
-
- task: UseDotNet@2
inputs:
useGlobalJson: true
- displayName: Install .NET Core SDK 8.0.113
+ displayName: Install .NET Core SDK 8.0.411
# create artifact/package folder
- pwsh: |
diff --git a/global.json b/global.json
index 6dfc6666e..fb6d6a3df 100644
--- a/global.json
+++ b/global.json
@@ -1,5 +1,5 @@
{
"sdk": {
- "version": "8.0.407"
+ "version": "8.0.411"
}
}
diff --git a/src/coverlet.collector/build/coverlet.collector.targets b/src/coverlet.collector/build/coverlet.collector.targets
index 12cf946c8..095bf034e 100644
--- a/src/coverlet.collector/build/coverlet.collector.targets
+++ b/src/coverlet.collector/build/coverlet.collector.targets
@@ -17,7 +17,7 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
-
+
$(VSTestTestAdapterPath);$(MSBuildThisFileDirectory)
@@ -27,7 +27,7 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
<_CoverletSdkNETCoreSdkVersion>$(NETCoreSdkVersion)
<_CoverletSdkNETCoreSdkVersion Condition="$(_CoverletSdkNETCoreSdkVersion.Contains('-'))">$(_CoverletSdkNETCoreSdkVersion.Split('-')[0])
- <_CoverletSdkMinVersionWithDependencyTarget>6.0.100
+ <_CoverletSdkMinVersionWithDependencyTarget>8.0.100
<_CoverletSourceRootTargetName>CoverletGetPathMap
<_CoverletSourceRootTargetName Condition="'$([System.Version]::Parse($(_CoverletSdkNETCoreSdkVersion)).CompareTo($([System.Version]::Parse($(_CoverletSdkMinVersionWithDependencyTarget)))))' >= '0' ">InitializeSourceRootMappedPaths
diff --git a/src/coverlet.core/Coverage.cs b/src/coverlet.core/Coverage.cs
index 3cc80c4c8..918d8aedf 100644
--- a/src/coverlet.core/Coverage.cs
+++ b/src/coverlet.core/Coverage.cs
@@ -6,11 +6,11 @@
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
+using System.Text.Json;
+using System.Text.Json.Nodes;
using Coverlet.Core.Abstractions;
using Coverlet.Core.Helpers;
using Coverlet.Core.Instrumentation;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
namespace Coverlet.Core
{
@@ -60,6 +60,14 @@ internal class Coverage
public string Identifier { get; }
+ readonly JsonSerializerOptions _options = new()
+ {
+ PropertyNameCaseInsensitive = true,
+ DictionaryKeyPolicy = JsonNamingPolicy.CamelCase,
+ IncludeFields = true,
+ WriteIndented = true
+ };
+
public Coverage(string moduleOrDirectory,
CoverageParameters parameters,
ILogger logger,
@@ -313,7 +321,7 @@ public CoverageResult GetCoverageResult()
{
_logger.LogInformation($"MergeWith: '{_parameters.MergeWith}'.");
string json = _fileSystem.ReadAllText(_parameters.MergeWith);
- coverageResult.Merge(JsonConvert.DeserializeObject(json));
+ coverageResult.Merge(JsonSerializer.Deserialize(json, _options));
}
else
{
@@ -366,8 +374,8 @@ private void CalculateCoverage()
var documents = result.Documents.Values.ToList();
if (_parameters.UseSourceLink && result.SourceLink != null)
{
- JToken jObject = JObject.Parse(result.SourceLink)["documents"];
- Dictionary sourceLinkDocuments = JsonConvert.DeserializeObject>(jObject.ToString());
+ JsonNode jObject = JsonNode.Parse(result.SourceLink)["documents"];
+ Dictionary sourceLinkDocuments = JsonSerializer.Deserialize>(jObject.ToString());
foreach (Document document in documents)
{
document.Path = GetSourceLinkUrl(sourceLinkDocuments, document.Path);
@@ -480,9 +488,9 @@ internal string GetSourceLinkUrl(Dictionary sourceLinkDocuments,
{
string key = sourceLinkDocument.Key;
if (Path.GetFileName(key) != "*") continue;
-
+#pragma warning disable IDE0057
IReadOnlyList rootMapping = _sourceRootTranslator.ResolvePathRoot(key.Substring(0, key.Length - 1));
-
+#pragma warning restore IDE0057
foreach (string keyMapping in rootMapping is null ? [key] : new List(rootMapping.Select(m => m.OriginalPath)))
{
string directoryDocument = Path.GetDirectoryName(document);
@@ -494,8 +502,9 @@ internal string GetSourceLinkUrl(Dictionary sourceLinkDocuments,
{
if (!directoryDocument.StartsWith(sourceLinkRoot + Path.DirectorySeparatorChar))
continue;
-
+#pragma warning disable IDE0057
relativePath = directoryDocument.Substring(sourceLinkRoot.Length + 1);
+#pragma warning restore IDE0057
}
if (relativePathOfBestMatch.Length == 0)
diff --git a/src/coverlet.core/CoverageResult.cs b/src/coverlet.core/CoverageResult.cs
index 7b002053c..c3a92ee29 100644
--- a/src/coverlet.core/CoverageResult.cs
+++ b/src/coverlet.core/CoverageResult.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Linq;
+using System.Text.Json.Serialization;
using Coverlet.Core.Enums;
using Coverlet.Core.Instrumentation;
@@ -22,6 +23,7 @@ internal class Branches : List { }
internal class Method
{
+ [JsonConstructor]
internal Method()
{
Lines = [];
diff --git a/src/coverlet.core/Exceptions.cs b/src/coverlet.core/Exceptions.cs
index d65b22096..365df85f3 100644
--- a/src/coverlet.core/Exceptions.cs
+++ b/src/coverlet.core/Exceptions.cs
@@ -5,25 +5,17 @@
namespace Coverlet.Core.Exceptions
{
- [Serializable]
public class CoverletException : Exception
{
public CoverletException() { }
public CoverletException(string message) : base(message) { }
public CoverletException(string message, System.Exception inner) : base(message, inner) { }
- protected CoverletException(
- System.Runtime.Serialization.SerializationInfo info,
- System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
}
- [Serializable]
internal class CecilAssemblyResolutionException : CoverletException
{
public CecilAssemblyResolutionException() { }
public CecilAssemblyResolutionException(string message) : base(message) { }
public CecilAssemblyResolutionException(string message, System.Exception inner) : base(message, inner) { }
- protected CecilAssemblyResolutionException(
- System.Runtime.Serialization.SerializationInfo info,
- System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
}
}
diff --git a/src/coverlet.core/Helpers/InstrumentationHelper.cs b/src/coverlet.core/Helpers/InstrumentationHelper.cs
index 0b1b3439c..e6e3f0702 100644
--- a/src/coverlet.core/Helpers/InstrumentationHelper.cs
+++ b/src/coverlet.core/Helpers/InstrumentationHelper.cs
@@ -415,8 +415,10 @@ private static string GetIncludeModuleKeysForValidFilters(char escapeSymbol, str
}
private static string CreateRegexExcludePattern(IEnumerable filters, char escapeSymbol)
- //only look for module filters here, types will be filtered out when instrumenting
+ //only look for module filters here, types will be filtered out when instrumenting
+#pragma warning disable IDE0057 // Use range operator
=> CreateRegexPattern(filters, escapeSymbol, filter => filter.Substring(filter.IndexOf(']') + 1) == "*");
+#pragma warning restore IDE0057 // Use range operator
private static string CreateRegexIncludePattern(IEnumerable filters, char escapeSymbol) =>
CreateRegexPattern(filters, escapeSymbol);
@@ -424,8 +426,10 @@ private static string CreateRegexIncludePattern(IEnumerable filters, cha
private static string CreateRegexPattern(IEnumerable filters, char escapeSymbol, Func filterPredicate = null)
{
IEnumerable filteredFilters = filterPredicate != null ? filters.Where(filterPredicate) : filters;
+#pragma warning disable IDE0057 // Use range operator
IEnumerable regexPatterns = filteredFilters.Select(x =>
$"{escapeSymbol}{WildcardToRegex(x.Substring(1, x.IndexOf(']') - 1)).Trim('^', '$')}{escapeSymbol}");
+#pragma warning restore IDE0057 // Use range operator
return string.Join("|", regexPatterns);
}
diff --git a/src/coverlet.core/Instrumentation/CecilAssemblyResolver.cs b/src/coverlet.core/Instrumentation/CecilAssemblyResolver.cs
index 649b6c369..e4f0e19bd 100644
--- a/src/coverlet.core/Instrumentation/CecilAssemblyResolver.cs
+++ b/src/coverlet.core/Instrumentation/CecilAssemblyResolver.cs
@@ -5,12 +5,12 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Text.Json;
using Coverlet.Core.Abstractions;
using Coverlet.Core.Exceptions;
using Microsoft.Extensions.DependencyModel;
using Microsoft.Extensions.DependencyModel.Resolution;
using Mono.Cecil;
-using Newtonsoft.Json.Linq;
using NuGet.Versioning;
namespace Coverlet.Core.Instrumentation
@@ -296,29 +296,35 @@ public RuntimeConfigurationReader(string runtimeConfigFile)
{
string jsonString = File.ReadAllText(_runtimeConfigFile);
- var jsonLoadSettings = new JsonLoadSettings()
+ var documentOptions = new JsonDocumentOptions
{
- CommentHandling = CommentHandling.Ignore
+ CommentHandling = JsonCommentHandling.Skip
};
- var configuration = JObject.Parse(jsonString, jsonLoadSettings);
+ using var configuration = JsonDocument.Parse(jsonString, documentOptions);
- JToken rootElement = configuration.Root;
- JToken runtimeOptionsElement = rootElement["runtimeOptions"];
+ JsonElement rootElement = configuration.RootElement;
+ if (!rootElement.TryGetProperty("runtimeOptions", out JsonElement runtimeOptionsElement))
+ {
+ throw new InvalidOperationException($"The 'runtimeOptions' property is missing in the runtime configuration file {_runtimeConfigFile}.");
+ }
- if (runtimeOptionsElement?["framework"] != null)
+ if (runtimeOptionsElement.TryGetProperty("framework", out JsonElement frameworkElement))
{
- return [(runtimeOptionsElement["framework"]["name"]?.Value(), runtimeOptionsElement["framework"]["version"]?.Value())];
+ return new List<(string, string)>
+ {
+ (runtimeOptionsElement.GetProperty("framework").GetProperty("name").GetString(), runtimeOptionsElement.GetProperty("framework").GetProperty("version").GetString())
+ };
}
- if (runtimeOptionsElement?["frameworks"] != null)
+ if (runtimeOptionsElement.TryGetProperty("frameworks", out JsonElement frameworksElement))
{
- return runtimeOptionsElement["frameworks"].Select(x => (x["name"]?.Value(), x["version"]?.Value())).ToList();
+ return frameworksElement.EnumerateArray().Select(x => (x.GetProperty("name").GetString(), x.GetProperty("version").GetString())).ToList();
}
- if (runtimeOptionsElement?["includedFrameworks"] != null)
+ if (runtimeOptionsElement.TryGetProperty("includedFrameworks", out JsonElement runtimeoptionselement))
{
- return runtimeOptionsElement["includedFrameworks"].Select(x => (x["name"]?.Value(), x["version"]?.Value())).ToList();
+ return runtimeoptionselement.EnumerateArray().Select(x => (x.GetProperty("name").GetString(), x.GetProperty("version").GetString())).ToList();
}
throw new InvalidOperationException($"Unable to read runtime configuration from {_runtimeConfigFile}.");
diff --git a/src/coverlet.core/Reporters/JsonReporter.cs b/src/coverlet.core/Reporters/JsonReporter.cs
index e684e8c8a..62be3373a 100644
--- a/src/coverlet.core/Reporters/JsonReporter.cs
+++ b/src/coverlet.core/Reporters/JsonReporter.cs
@@ -1,8 +1,9 @@
// Copyright (c) Toni Solarin-Sodara
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using System.Text.Encodings.Web;
+using System.Text.Json;
using Coverlet.Core.Abstractions;
-using Newtonsoft.Json;
namespace Coverlet.Core.Reporters
{
@@ -16,7 +17,13 @@ internal class JsonReporter : IReporter
public string Report(CoverageResult result, ISourceRootTranslator _)
{
- return JsonConvert.SerializeObject(result.Modules, Formatting.Indented);
+ var options = new JsonSerializerOptions
+ {
+ Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
+ IncludeFields = true,
+ WriteIndented = true,
+ };
+ return JsonSerializer.Serialize(result.Modules, options);
}
}
}
diff --git a/src/coverlet.core/coverlet.core.csproj b/src/coverlet.core/coverlet.core.csproj
index f3e16e3f1..4ed1994d6 100644
--- a/src/coverlet.core/coverlet.core.csproj
+++ b/src/coverlet.core/coverlet.core.csproj
@@ -1,24 +1,26 @@
-
+
Library
- netstandard2.0
+ netstandard2.0;net8.0
false
+ $(NoWarn);IDE0057
-
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/src/coverlet.msbuild.tasks/coverlet.msbuild.targets b/src/coverlet.msbuild.tasks/coverlet.msbuild.targets
index e8bbfac20..0defe0138 100644
--- a/src/coverlet.msbuild.tasks/coverlet.msbuild.targets
+++ b/src/coverlet.msbuild.tasks/coverlet.msbuild.targets
@@ -6,7 +6,7 @@
<_CoverletSdkNETCoreSdkVersion>$(NETCoreSdkVersion)
<_CoverletSdkNETCoreSdkVersion Condition="$(_CoverletSdkNETCoreSdkVersion.Contains('-'))">$(_CoverletSdkNETCoreSdkVersion.Split('-')[0])
- <_CoverletSdkMinVersionWithDependencyTarget>6.0.100
+ <_CoverletSdkMinVersionWithDependencyTarget>8.0.100
<_CoverletSourceRootTargetName>CoverletGetPathMap
<_CoverletSourceRootTargetName Condition="'$([System.Version]::Parse($(_CoverletSdkNETCoreSdkVersion)).CompareTo($([System.Version]::Parse($(_CoverletSdkMinVersionWithDependencyTarget)))))' >= '0' ">InitializeSourceRootMappedPaths
diff --git a/src/coverlet.msbuild.tasks/coverlet.msbuild.tasks.csproj b/src/coverlet.msbuild.tasks/coverlet.msbuild.tasks.csproj
index c04e823b0..225c6211f 100644
--- a/src/coverlet.msbuild.tasks/coverlet.msbuild.tasks.csproj
+++ b/src/coverlet.msbuild.tasks/coverlet.msbuild.tasks.csproj
@@ -40,7 +40,8 @@
-
+
+
diff --git a/test/coverlet.core.tests.samples.netstandard/coverlet.core.tests.samples.netstandard.csproj b/test/coverlet.core.tests.samples.netstandard/coverlet.core.tests.samples.netstandard.csproj
index 36bc43a36..a7ce141f5 100644
--- a/test/coverlet.core.tests.samples.netstandard/coverlet.core.tests.samples.netstandard.csproj
+++ b/test/coverlet.core.tests.samples.netstandard/coverlet.core.tests.samples.netstandard.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/test/coverlet.core.tests/Coverage/CoverageTests.cs b/test/coverlet.core.tests/Coverage/CoverageTests.cs
index 86a306269..f99dbb4e6 100644
--- a/test/coverlet.core.tests/Coverage/CoverageTests.cs
+++ b/test/coverlet.core.tests/Coverage/CoverageTests.cs
@@ -1,16 +1,17 @@
-// Copyright (c) Toni Solarin-Sodara
+// Copyright (c) Toni Solarin-Sodara
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
-using System.Collections;
using System.Collections.Generic;
using System.IO;
+using System.Text.Encodings.Web;
+using System.Text.Json;
+using System.Text.Json.Serialization;
using Coverlet.Core.Abstractions;
using Coverlet.Core.Helpers;
using Coverlet.Core.Instrumentation;
using Coverlet.Core.Symbols;
using Moq;
-using Newtonsoft.Json;
using Xunit;
namespace Coverlet.Core.Tests
@@ -18,6 +19,16 @@ namespace Coverlet.Core.Tests
public partial class CoverageTests
{
private readonly Mock _mockLogger = new();
+ readonly JsonSerializerOptions _options = new()
+ {
+ Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
+ IncludeFields = true,
+ WriteIndented = true,
+ Converters =
+ {
+ new BranchDictionaryConverterFactory()
+ }
+ };
[Fact]
public void TestCoverage()
@@ -90,7 +101,7 @@ public void TestCoverageWithTestAssembly()
new SourceRootTranslator(module, _mockLogger.Object, new FileSystem(), new AssemblyAdapter()), new CecilSymbolHelper());
coverage.PrepareModules();
- string result = JsonConvert.SerializeObject(coverage.GetCoverageResult(), Formatting.Indented, new BranchDictionaryConverter());
+ string result = JsonSerializer.Serialize(coverage.GetCoverageResult(), _options);
Assert.Contains("coverlet.core.tests.dll", result);
@@ -129,7 +140,7 @@ public void TestCoverageMergeWithParameter()
var coverage = new Coverage(Path.Combine(directory.FullName, Path.GetFileName(module)), parameters, _mockLogger.Object, instrumentationHelper, new FileSystem(), new SourceRootTranslator(_mockLogger.Object, new FileSystem()), new CecilSymbolHelper());
coverage.PrepareModules();
- string result = JsonConvert.SerializeObject(coverage.GetCoverageResult(), Formatting.Indented, new BranchDictionaryConverter());
+ string result = JsonSerializer.Serialize(coverage.GetCoverageResult(), _options);
Assert.Contains("DeepThought.cs", result);
@@ -170,7 +181,7 @@ public void TestCoverageMergeWithWrongParameter()
var coverage = new Coverage(Path.Combine(directory.FullName, Path.GetFileName(module)), parameters, _mockLogger.Object, instrumentationHelper, new FileSystem(), new SourceRootTranslator(_mockLogger.Object, new FileSystem()), new CecilSymbolHelper());
coverage.PrepareModules();
- JsonConvert.SerializeObject(coverage.GetCoverageResult());
+ string result = JsonSerializer.Serialize(coverage.GetCoverageResult(), _options);
_mockLogger.Verify(l => l.LogInformation(It.Is(v => v.Equals("MergeWith: file 'FileDoesNotExist.json' does not exist.")), It.IsAny()), Times.Once);
@@ -220,36 +231,43 @@ public void GetSourceLinkUrl_ReturnsOriginalDocument_WhenNoMatch()
}
}
- public class BranchDictionaryConverter : JsonConverter
+ public class BranchDictionaryConverterFactory : JsonConverterFactory
{
- public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ public override bool CanConvert(Type typeToConvert)
{
- Type type = value.GetType();
- var keys = (IEnumerable)type.GetProperty("Keys")?.GetValue(value, null);
- var values = (IEnumerable)type.GetProperty("Values")?.GetValue(value, null);
- IEnumerator valueEnumerator = values.GetEnumerator();
-
- writer.WriteStartArray();
- foreach (object key in keys)
- {
- valueEnumerator.MoveNext();
-
- writer.WriteStartArray();
- serializer.Serialize(writer, key);
- serializer.Serialize(writer, valueEnumerator.Current);
- writer.WriteEndArray();
- }
- writer.WriteEndArray();
+ return typeof(Dictionary).IsAssignableFrom(typeToConvert);
}
-
- public override object ReadJson(JsonReader reader, Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer)
+ public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
{
- throw new NotImplementedException();
+ Type[] genericArgs = typeToConvert.GetGenericArguments();
+ Type keyType = genericArgs[0];
+ Type valueType = genericArgs[1];
+
+ JsonConverter converter = (JsonConverter)Activator.CreateInstance(
+ typeof(BranchDictionaryConverter<,>).MakeGenericType(new Type[] { keyType, valueType }));
+
+ return converter;
}
+ }
+}
- public override bool CanConvert(Type objectType)
+public class BranchDictionaryConverter : JsonConverter>
+{
+ public override Dictionary Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void Write(Utf8JsonWriter writer, Dictionary value, JsonSerializerOptions options)
+ {
+ writer.WriteStartObject();
+
+ foreach (KeyValuePair pair in value)
{
- return typeof(Dictionary).IsAssignableFrom(objectType);
+ writer.WritePropertyName(pair.Key.ToString());
+ JsonSerializer.Serialize(writer, pair.Value, options);
}
+
+ writer.WriteEndObject();
}
}
diff --git a/test/coverlet.core.tests/coverlet.core.tests.csproj b/test/coverlet.core.tests/coverlet.core.tests.csproj
index ff6c28869..96a1fd922 100644
--- a/test/coverlet.core.tests/coverlet.core.tests.csproj
+++ b/test/coverlet.core.tests/coverlet.core.tests.csproj
@@ -1,4 +1,4 @@
-
+
diff --git a/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj b/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj
index 38d1c8820..558c97dfb 100644
--- a/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj
+++ b/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj
@@ -1,12 +1,12 @@
-
-
+
+
- net6.0
+ net8.0
false
coverletsample.integration.determisticbuild
- NU1604;NU1701
+ NU1604
false
https://api.nuget.org/v3/index.json;
@@ -14,6 +14,12 @@
+
+
+ 6.0.4
+ 6.0.4
+
+
@@ -29,6 +35,5 @@
all
runtime; build; native; contentfiles; analyzers
-
diff --git a/test/coverlet.integration.template/nuget.config b/test/coverlet.integration.template/nuget.config
index fbcef1011..765346e53 100644
--- a/test/coverlet.integration.template/nuget.config
+++ b/test/coverlet.integration.template/nuget.config
@@ -2,6 +2,6 @@
-
+
diff --git a/test/coverlet.integration.tests/Collectors.cs b/test/coverlet.integration.tests/Collectors.cs
index a19e814e1..fb5a935cc 100644
--- a/test/coverlet.integration.tests/Collectors.cs
+++ b/test/coverlet.integration.tests/Collectors.cs
@@ -9,11 +9,11 @@
namespace Coverlet.Integration.Tests
{
- public class TestSDK_17_8_0 : Collectors
+ public class TestSDK_17_13_0 : Collectors
{
- public TestSDK_17_8_0()
+ public TestSDK_17_13_0()
{
- TestSDKVersion = "17.8.0";
+ TestSDKVersion = "17.13.0";
}
private protected override void AssertCollectorsInjection(ClonedTemplateProject clonedTemplateProject)
@@ -27,11 +27,11 @@ private protected override void AssertCollectorsInjection(ClonedTemplateProject
}
}
- public class TestSDK_17_6_0 : Collectors
+ public class TestSDK_17_12_0 : Collectors
{
- public TestSDK_17_6_0()
+ public TestSDK_17_12_0()
{
- TestSDKVersion = "17.6.0";
+ TestSDKVersion = "17.12.0";
}
}
@@ -39,7 +39,7 @@ public class TestSDK_Preview : Collectors
{
public TestSDK_Preview()
{
- TestSDKVersion = "17.9.0-preview-23531-01";
+ TestSDKVersion = "17.14.0-preview-25107-01";
}
}
diff --git a/test/coverlet.integration.tests/DeterministicBuild.cs b/test/coverlet.integration.tests/DeterministicBuild.cs
index 9c8a181db..742aac85e 100644
--- a/test/coverlet.integration.tests/DeterministicBuild.cs
+++ b/test/coverlet.integration.tests/DeterministicBuild.cs
@@ -13,6 +13,7 @@
namespace Coverlet.Integration.Tests
{
+ [Collection("DeterministicBuild Collection")]
public class DeterministicBuild : BaseTest, IDisposable
{
private static readonly string s_projectName = "coverlet.integration.determisticbuild";
@@ -30,7 +31,6 @@ public class DeterministicBuild : BaseTest, IDisposable
public DeterministicBuild(ITestOutputHelper output)
{
_buildConfiguration = TestUtils.GetAssemblyBuildConfiguration().ToString();
- //_buildTargetFramework = TestUtils.GetAssemblyTargetFramework();
_output = output;
_type = output.GetType();
_testMember = _type.GetField("test", BindingFlags.Instance | BindingFlags.NonPublic);
@@ -38,16 +38,19 @@ public DeterministicBuild(ITestOutputHelper output)
private void CreateDeterministicTestPropsFile()
{
- var deterministicTestProps = new XDocument();
+ string propsFile = Path.Combine(_testProjectPath, PropsFileName);
+ File.Delete(propsFile);
+
+ XDocument deterministicTestProps = new();
deterministicTestProps.Add(
new XElement("Project",
new XElement("PropertyGroup",
new XElement("coverletMsbuildVersion", GetPackageVersion("*msbuild*.nupkg")),
new XElement("coverletCollectorsVersion", GetPackageVersion("*collector*.nupkg")))));
_testProjectTfm = XElement.Load(Path.Combine(_testProjectPath, "coverlet.integration.determisticbuild.csproj"))!.
- Descendants("PropertyGroup")!.Single().Element("TargetFramework")!.Value;
+ Descendants("PropertyGroup")!.First().Element("TargetFramework")!.Value;
- deterministicTestProps.Save(Path.Combine(_testProjectPath, PropsFileName));
+ deterministicTestProps.Save(propsFile);
}
private protected void AssertCoverage(string standardOutput = "", bool checkDeterministicReport = true)
@@ -381,4 +384,11 @@ public void Dispose()
File.Delete(Path.Combine(_testProjectPath, PropsFileName));
}
}
+ [CollectionDefinition("DeterministicBuild Collection", DisableParallelization = true)]
+ public class DeterministicBuildCollection
+ {
+ // This class has no code, and is never created.
+ // Its purpose is to be the place to apply [CollectionDefinition] and all the
+ // ICollectionFixture<> interfaces.
+ }
}
diff --git a/test/coverlet.integration.tests/DotnetTool.cs b/test/coverlet.integration.tests/DotnetTool.cs
index 91e989f02..c37e1156d 100644
--- a/test/coverlet.integration.tests/DotnetTool.cs
+++ b/test/coverlet.integration.tests/DotnetTool.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Toni Solarin-Sodara
+// Copyright (c) Toni Solarin-Sodara
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.IO;
diff --git a/test/coverlet.integration.tests/Msbuild.cs b/test/coverlet.integration.tests/Msbuild.cs
index abb784d10..3687ac95b 100644
--- a/test/coverlet.integration.tests/Msbuild.cs
+++ b/test/coverlet.integration.tests/Msbuild.cs
@@ -4,6 +4,7 @@
using System;
using System.IO;
using System.Linq;
+using System.Runtime.InteropServices;
using Coverlet.Tests.Utils;
using Xunit;
@@ -109,7 +110,7 @@ public void TestMsbuild_CoverletOutput_Folder_FileNameExtension()
public void TestMsbuild_CoverletOutput_Folder_FileNameExtension_SpecifyFramework()
{
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject();
- string[] targetFrameworks = new string[] { "net6.0" };
+ string[] targetFrameworks = new string[] { "net8.0" };
UpdateProjectTargetFramework(clonedTemplateProject, targetFrameworks);
Assert.False(clonedTemplateProject.IsMultipleTargetFramework());
string framework = clonedTemplateProject.GetTargetFrameworks().Single();
@@ -152,7 +153,8 @@ public void TestMsbuild_CoverletOutput_Folder_FileNameWithDoubleExtension()
public void Test_MultipleTargetFrameworkReport_NoCoverletOutput()
{
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject();
- string[] targetFrameworks = new string[] { "net6.0", "net8.0" };
+ string[] targetFrameworks = new string[] { "net8.0" };
+ string fileToCheck = "";
UpdateProjectTargetFramework(clonedTemplateProject, targetFrameworks);
DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!);
if (!string.IsNullOrEmpty(standardError))
@@ -168,17 +170,24 @@ public void Test_MultipleTargetFrameworkReport_NoCoverletOutput()
foreach (string targetFramework in targetFrameworks)
{
- Assert.True(File.Exists(Path.Combine(clonedTemplateProject.ProjectRootPath, $"coverage.{targetFramework}.json")));
+ //if targetFrameworks has more than one framework
+ fileToCheck = Path.Combine(clonedTemplateProject.ProjectRootPath, $"coverage.{targetFramework}.json");
+ if (targetFrameworks.Length == 1)
+ {
+ fileToCheck = Path.Combine(clonedTemplateProject.ProjectRootPath, $"coverage.json");
+ }
+ Assert.True(File.Exists(fileToCheck), $"Expected file '{fileToCheck}'\nOutput:\n{standardOutput}");
}
- AssertCoverage(clonedTemplateProject, "coverage.*.json");
+ AssertCoverage(clonedTemplateProject, Path.GetFileName(fileToCheck));
}
[Fact]
public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder()
{
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject();
- string[] targetFrameworks = new string[] { "net6.0", "net8.0" };
+ string[] targetFrameworks = new string[] { "net8.0" };
+ string fileToCheck = "";
UpdateProjectTargetFramework(clonedTemplateProject, targetFrameworks);
int result = DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!);
if (!string.IsNullOrEmpty(standardError))
@@ -195,18 +204,24 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder()
foreach (string targetFramework in targetFrameworks)
{
- string fileToCheck = Path.Combine(clonedTemplateProject.ProjectRootPath, $"coverage.{targetFramework}.json");
+ //if targetFrameworks has more than one framework
+ fileToCheck = Path.Combine(clonedTemplateProject.ProjectRootPath, $"coverage.{targetFramework}.json");
+ if (targetFrameworks.Length == 1)
+ {
+ fileToCheck = Path.Combine(clonedTemplateProject.ProjectRootPath, $"coverage.json");
+ }
Assert.True(File.Exists(fileToCheck), $"Expected file '{fileToCheck}'\nOutput:\n{standardOutput}");
}
- AssertCoverage(clonedTemplateProject, "coverage.*.json");
+ AssertCoverage(clonedTemplateProject, Path.GetFileName(fileToCheck));
}
[Fact]
public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWithoutExtension()
{
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject();
- string[] targetFrameworks = new string[] { "net6.0", "net8.0" };
+ string[] targetFrameworks = new string[] { "net8.0" };
+ string fileToCheck = "";
UpdateProjectTargetFramework(clonedTemplateProject, targetFrameworks);
DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!);
if (!string.IsNullOrEmpty(standardError))
@@ -222,17 +237,24 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit
foreach (string targetFramework in targetFrameworks)
{
- Assert.True(File.Exists(Path.Combine(clonedTemplateProject.ProjectRootPath, $"file.{targetFramework}.json")));
+ //if targetFrameworks has more than one framework
+ fileToCheck = Path.Combine(clonedTemplateProject.ProjectRootPath, $"file.{targetFramework}.json");
+ if (targetFrameworks.Length == 1)
+ {
+ fileToCheck = Path.Combine(clonedTemplateProject.ProjectRootPath, $"file.json");
+ }
+ Assert.True(File.Exists(fileToCheck), $"Expected file '{fileToCheck}'\nOutput:\n{standardOutput}");
}
- AssertCoverage(clonedTemplateProject, "file.*.json");
+ AssertCoverage(clonedTemplateProject, Path.GetFileName(fileToCheck));
}
[Fact]
public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWithExtension_SpecifyFramework()
{
+ Assert.SkipUnless(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Test requires Windows [net48]");
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject();
- string[] targetFrameworks = new string[] { "net6.0", "net8.0" };
+ string[] targetFrameworks = new string[] { "net8.0", "net48" };
UpdateProjectTargetFramework(clonedTemplateProject, targetFrameworks);
Assert.True(clonedTemplateProject.IsMultipleTargetFramework());
string[] frameworks = clonedTemplateProject.GetTargetFrameworks();
@@ -261,7 +283,6 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit
Assert.False(File.Exists(Path.Combine(clonedTemplateProject.ProjectRootPath, $"file.{targetFramework}.ext")));
}
}
-
AssertCoverage(clonedTemplateProject, "file.*.ext");
}
@@ -269,7 +290,8 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit
public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWithExtension()
{
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject();
- string[] targetFrameworks = new string[] { "net6.0", "net8.0" };
+ string[] targetFrameworks = new string[] { "net8.0" };
+ string fileToCheck = "";
UpdateProjectTargetFramework(clonedTemplateProject, targetFrameworks);
DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file.ext", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!);
if (!string.IsNullOrEmpty(standardError))
@@ -285,17 +307,24 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit
foreach (string targetFramework in targetFrameworks)
{
- Assert.True(File.Exists(Path.Combine(clonedTemplateProject.ProjectRootPath, $"file.{targetFramework}.ext")));
+ //if targetFrameworks has more than one framework
+ fileToCheck = Path.Combine(clonedTemplateProject.ProjectRootPath, $"file.{targetFramework}.ext");
+ if (targetFrameworks.Length == 1)
+ {
+ fileToCheck = Path.Combine(clonedTemplateProject.ProjectRootPath, $"file.ext");
+ }
+ Assert.True(File.Exists(fileToCheck), $"Expected file '{fileToCheck}'\nOutput:\n{standardOutput}");
}
- AssertCoverage(clonedTemplateProject, "file.*.ext");
+ AssertCoverage(clonedTemplateProject, Path.GetFileName(fileToCheck));
}
[Fact]
public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWithDoubleExtension()
{
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject();
- string[] targetFrameworks = new string[] { "net6.0", "net8.0" };
+ string[] targetFrameworks = new string[] { "net8.0" };
+ string fileToCheck = "";
UpdateProjectTargetFramework(clonedTemplateProject, targetFrameworks);
DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file.ext1.ext2", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!);
if (!string.IsNullOrEmpty(standardError))
@@ -311,10 +340,16 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit
foreach (string targetFramework in targetFrameworks)
{
- Assert.True(File.Exists(Path.Combine(clonedTemplateProject.ProjectRootPath, $"file.ext1.{targetFramework}.ext2")));
+ //if targetFrameworks has more than one framework
+ fileToCheck = Path.Combine(clonedTemplateProject.ProjectRootPath, $"file.ext1.{targetFramework}.ext2");
+ if (targetFrameworks.Length == 1)
+ {
+ fileToCheck = Path.Combine(clonedTemplateProject.ProjectRootPath, "file.ext1.ext2");
+ }
+ Assert.True(File.Exists(fileToCheck), $"Expected file '{fileToCheck}'\nOutput:\n{standardOutput}");
}
- AssertCoverage(clonedTemplateProject, "file.ext1.*.ext2");
+ AssertCoverage(clonedTemplateProject, Path.GetFileName(fileToCheck));
}
}
}
diff --git a/test/coverlet.integration.tests/coverlet.integration.tests.csproj b/test/coverlet.integration.tests/coverlet.integration.tests.csproj
index 4c8cc9c50..e08143035 100644
--- a/test/coverlet.integration.tests/coverlet.integration.tests.csproj
+++ b/test/coverlet.integration.tests/coverlet.integration.tests.csproj
@@ -17,13 +17,12 @@
+
all
runtime; build; native; contentfiles; analyzers
-
-
diff --git a/test/coverlet.msbuild.tasks.tests/coverlet.msbuild.tasks.tests.csproj b/test/coverlet.msbuild.tasks.tests/coverlet.msbuild.tasks.tests.csproj
index f363d52ac..8cb949dee 100644
--- a/test/coverlet.msbuild.tasks.tests/coverlet.msbuild.tasks.tests.csproj
+++ b/test/coverlet.msbuild.tasks.tests/coverlet.msbuild.tasks.tests.csproj
@@ -20,7 +20,7 @@
-
+
diff --git a/test/coverlet.tests.projectsample.aspmvcrazor/coverlet.tests.projectsample.aspmvcrazor.csproj b/test/coverlet.tests.projectsample.aspmvcrazor/coverlet.tests.projectsample.aspmvcrazor.csproj
index 6e46d7306..cf1079a1b 100644
--- a/test/coverlet.tests.projectsample.aspmvcrazor/coverlet.tests.projectsample.aspmvcrazor.csproj
+++ b/test/coverlet.tests.projectsample.aspmvcrazor/coverlet.tests.projectsample.aspmvcrazor.csproj
@@ -1,7 +1,7 @@
- net6.0
+ net8.0
enable
false
false
diff --git a/test/coverlet.tests.utils/TestUtils.cs b/test/coverlet.tests.utils/TestUtils.cs
index f24f13399..4940f0f36 100644
--- a/test/coverlet.tests.utils/TestUtils.cs
+++ b/test/coverlet.tests.utils/TestUtils.cs
@@ -38,6 +38,12 @@ public static string GetAssemblyTargetFramework()
#endif
#if NET8_0
return "net8.0";
+#endif
+#if NET9_0
+ return "net9.0";
+#endif
+#if NET10_0
+ return "net10.0";
#endif
throw new NotSupportedException($"Build configuration not supported");
}