Skip to content

Commit 445f765

Browse files
authored
use latest System.CommandLine version (GA?) (#1660)
* Update System.CommandLine nuget package and improve documentation - Upgraded `System.CommandLine` package version. - Clarified documentation in `GlobalTool.md` regarding options and exit codes. - Modified Azure Pipelines YAML for package restoration and authentication. - Removed `PackageIconUrl` from `coverlet.collector.csproj`. - Updated `CommandExitCodes` enum in `ExitCodes.cs`. - Refactored `Program.cs` to utilize the new `System.CommandLine` API. - Changed command exit code handling to use a static variable. - Added new package references in `coverlet.console.csproj` and `coverlet.core.csproj`. - Revised integration tests for expected output and error handling. - Adjusted coverage output assertions in tests. - Improved directory handling and file deletion logic in `DeterministicBuild.cs`. - Added reference to `coverlet.console` in `coverlet.integration.tests.csproj`. * Refactor Main method to return exit code Changed Main method's return type to Task<int> to allow returning an exit code. Replaced Environment.Exit with a return statement for better control over the exit code and improved usability in asynchronous contexts. This avoids the termination of the process.
1 parent f547da7 commit 445f765

File tree

22 files changed

+168
-137
lines changed

22 files changed

+168
-137
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,4 @@ csharp_style_prefer_top_level_statements = true:silent
227227
csharp_style_prefer_primary_constructors = true:suggestion
228228
csharp_style_expression_bodied_lambdas = true:silent
229229
csharp_style_expression_bodied_local_functions = false:silent
230+
dotnet_diagnostic.IDE0007.severity = suggestion

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,3 +319,4 @@ FolderProfile.pubxml
319319
nuget.config
320320
*.dmp
321321
Playground*/
322+
coverlet.MTP/

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
1616
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
1717
<LangVersion>12.0</LangVersion>
18-
<NoWarn>$(NoWarn);NU1507;NU5105;CS1591</NoWarn>
18+
<NoWarn>$(NoWarn);NU1507;NU5105;CS1591;NU1608;NU1900</NoWarn>
1919
<GenerateDocumentationFile>true</GenerateDocumentationFile>
2020
<RestoreSources>
2121
https://api.nuget.org/v3/index.json;

Directory.Packages.props

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.7.115" />
99
</ItemGroup>
1010
<PropertyGroup>
11-
<MicrosoftBuildVersion>17.13.9</MicrosoftBuildVersion>
11+
<MicrosoftBuildVersion>17.11.31</MicrosoftBuildVersion> <!-- .NET 8.0 support -->
1212
<MicrosoftCodeAnalysisVersion>4.12.0</MicrosoftCodeAnalysisVersion>
1313
<!-- Test Platform, .NET Test SDK and Object Model -->
14-
<MicrosoftNETTestSdkVersion>17.13.0</MicrosoftNETTestSdkVersion>
15-
<NugetPackageVersion>6.13.2</NugetPackageVersion>
14+
<MicrosoftNETTestSdkVersion>17.14.1</MicrosoftNETTestSdkVersion>
15+
<NugetPackageVersion>6.14.0</NugetPackageVersion>
1616
<XunitV3Version>2.0.0</XunitV3Version>
1717
<XunitRunnerVisualstudioVersion>3.0.2</XunitRunnerVisualstudioVersion>
1818
</PropertyGroup>
@@ -21,7 +21,7 @@
2121
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
2222
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="$(MicrosoftBuildVersion)" />
2323
<PackageVersion Include="Microsoft.Build.Framework" Version="$(MicrosoftBuildVersion)" />
24-
<PackageVersion Include="Microsoft.Build.Locator" Version="1.7.8" />
24+
<PackageVersion Include="Microsoft.Build.Locator" Version="1.9.1" />
2525
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisVersion)" />
2626
<PackageVersion Include="Microsoft.Extensions.DependencyModel" Version="8.0.2" />
2727
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
@@ -48,7 +48,7 @@
4848
<PackageVersion Include="ReportGenerator.Core" Version="5.3.11" />
4949
<!--For test issue 809 https://github.com/coverlet-coverage/coverlet/issues/809-->
5050
<PackageVersion Include="LinqKit.Microsoft.EntityFrameworkCore" Version="8.1.8" />
51-
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
51+
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta6.25358.103" />
5252
<!--To test issue 1104 https://github.com/coverlet-coverage/coverlet/issues/1104-->
5353
<!-- latest Tmds.ExecFunction package uses EnvDTE V17.8.37221 -->
5454
<PackageVersion Include="Tmds.ExecFunction" Version="0.8.0" />

Documentation/GlobalTool.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Options:
3838
--merge-with <merge-with> Path to existing coverage result to merge.
3939
--use-source-link Specifies whether to use SourceLink URIs in place of file system paths.
4040
--does-not-return-attribute <does-not-return-attribute> Attributes that mark methods that do not return
41-
--exclude-assemblies-without-sources <exclude-assemblies-without-sources> Specifies behaviour of heuristic to ignore assemblies with missing source documents.
41+
--exclude-assemblies-without-sources <exclude-assemblies-without-sources> Specifies behavior of heuristic to ignore assemblies with missing source documents. [default: MissingAll]
4242
--source-mapping-file <source-mapping-file> Specifies the path to a SourceRootsMappings file.
4343
--version Show version information
4444
-?, -h, --help Show help and usage information
@@ -275,5 +275,4 @@ Coverlet outputs specific exit codes to better support build automation systems
275275
2 - Coverage percentage is below threshold.
276276
3 - Test fails and also coverage percentage is below threshold.
277277
101 - General exception occurred during coverlet process.
278-
102 - Missing options or invalid arguments for coverlet process.
279278
```

eng/azure-pipelines-nightly.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ steps:
1515
- task: NuGetAuthenticate@1
1616
displayName: Authenticate with NuGet feeds
1717

18+
- script: dotnet restore
19+
displayName: Restore packages
20+
1821
- script: dotnet pack -c Release /p:PublicRelease=false
1922
displayName: Create NuGet packages
2023

eng/build.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,23 @@ steps:
1515
New-Item -ItemType Directory -Path artifacts/package/release -Force
1616
displayName: create folder artifacts/package/$(BuildConfiguration)
1717

18-
- script: dotnet restore
18+
# Authenticate Azure DevOps NuGet feed
19+
- task: NuGetAuthenticate@1
20+
displayName: 'Authenticate Azure DevOps NuGet feed'
21+
inputs:
22+
forceReinstallCredentialProvider: true
23+
24+
- script: dotnet restore -v n -s "https://api.nuget.org/v3/index.json"
1925
displayName: Restore packages
2026

27+
# - task: DotNetCoreCLI@2
28+
# displayName: Restore packages
29+
# inputs:
30+
# command: restore
31+
# projects: 'coverlet.sln'
32+
# feedsToUse: 'config'
33+
# nugetConfigPath: 'nuget.config'
34+
2135
- script: dotnet build -c $(BuildConfiguration) --no-restore -bl:build.msbuild.binlog
2236
displayName: Build
2337

src/coverlet.collector/coverlet.collector.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
<Authors>tonerdo</Authors>
2828
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2929
<PackageProjectUrl>https://github.com/coverlet-coverage/coverlet</PackageProjectUrl>
30-
<PackageIconUrl>https://raw.githubusercontent.com/tonerdo/coverlet/master/_assets/coverlet-icon.svg?sanitize=true</PackageIconUrl>
3130
<PackageIcon>coverlet-icon.png</PackageIcon>
3231
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
3332
<Description>Coverlet is a cross platform code coverage library for .NET, with support for line, branch and method coverage.</Description>

src/coverlet.console/ExitCodes.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,5 @@ internal enum CommandExitCodes
2929
/// </summary>
3030
Exception = 101,
3131

32-
/// <summary>
33-
/// Indicates missing options or empty arguments for Coverlet process.
34-
/// </summary>
35-
CommandParsingException = 102
3632
}
3733

0 commit comments

Comments
 (0)