Skip to content

Commit 5d352ca

Browse files
committed
use System.CommandLine V2.0.0-beta4 (latest)
1 parent e106d0d commit 5d352ca

20 files changed

+148
-114
lines changed

.editorconfig

+1
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

Directory.Build.props

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
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>
21+
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-libraries/nuget/v3/index.json
2122
https://api.nuget.org/v3/index.json;
2223
</RestoreSources>
2324
<!--<UsingMicrosoftArtifactsSdk>true</UsingMicrosoftArtifactsSdk>-->

Directory.Packages.props

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@
3939
<PackageVersion Include="ReportGenerator.Core" Version="5.3.11" />
4040
<!--For test issue 809 https://github.com/coverlet-coverage/coverlet/issues/809-->
4141
<PackageVersion Include="LinqKit.Microsoft.EntityFrameworkCore" Version="8.1.7" />
42-
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
42+
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.24528.1" />
4343
<!--To test issue 1104 https://github.com/coverlet-coverage/coverlet/issues/1104-->
4444
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" />
4545
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
46+
<PackageVersion Include="System.IO.Pipelines" Version="8.0.0" />
4647
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
4748
<PackageVersion Include="System.Reflection.Metadata" Version="8.0.1" />
4849
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.6.0" />

eng/azure-pipelines-nightly.yml

+3
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

src/coverlet.collector/coverlet.collector.csproj

-1
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/Program.cs

+74-64
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
// Copyright (c) Toni Solarin-Sodara
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4+
using System.Runtime.CompilerServices;
5+
46
[assembly: System.Reflection.AssemblyKeyFileAttribute("coverlet.console.snk")]
7+
[assembly: InternalsVisibleTo("coverlet.integration.tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010001d24efbe9cbc2dc49b7a3d2ae34ca37cfb69b4f450acd768a22ce5cd021c8a38ae7dc68b2809a1ac606ad531b578f192a5690b2986990cbda4dd84ec65a3a4c1c36f6d7bb18f08592b93091535eaee2f0c8e48763ed7f190db2008e1f9e0facd5c0df5aaab74febd3430e09a428a72e5e6b88357f92d78e47512d46ebdc3cbb")]

src/coverlet.console/coverlet.console.csproj

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
@@ -16,15 +16,21 @@
1616
<PackageTags>coverage;testing;unit-test;lcov;opencover;quality</PackageTags>
1717
<PackageReadmeFile>GlobalTool.md</PackageReadmeFile>
1818
<PackageReleaseNotes>https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/Changelog.md</PackageReleaseNotes>
19-
<PackageIconUrl>https://raw.githubusercontent.com/tonerdo/coverlet/master/_assets/coverlet-icon.svg?sanitize=true</PackageIconUrl>
2019
<PackageIcon>coverlet-icon.png</PackageIcon>
2120
<PackageProjectUrl>https://github.com/coverlet-coverage/coverlet</PackageProjectUrl>
2221
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2322
<RepositoryType>git</RepositoryType>
23+
<RestoreSources>
24+
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-libraries/nuget/v3/index.json
25+
https://api.nuget.org/v3/index.json;
26+
</RestoreSources>
2427
</PropertyGroup>
25-
28+
2629
<ItemGroup>
2730
<PackageReference Include="System.CommandLine" />
31+
<PackageReference Include="System.Security.Cryptography.Pkcs" />
32+
<PackageReference Include="System.Text.RegularExpressions" VersionOverride="4.3.1" />
33+
<PackageReference Include="System.Net.Http" VersionOverride="4.3.4" />
2834
</ItemGroup>
2935

3036
<ItemGroup>

src/coverlet.core/coverlet.core.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>Library</OutputType>
55
<TargetFrameworks>netstandard2.0</TargetFrameworks>
66
<IsPackable>false</IsPackable>
7+
<NoWarn>$(NoWarn);IDE0057</NoWarn>
78
</PropertyGroup>
89

910
<ItemGroup>

src/coverlet.msbuild.tasks/coverlet.msbuild.tasks.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
<Authors>tonerdo</Authors>
2929
<PackageLicenseExpression>MIT</PackageLicenseExpression>
3030
<PackageProjectUrl>https://github.com/coverlet-coverage/coverlet</PackageProjectUrl>
31-
<PackageIconUrl>https://raw.githubusercontent.com/tonerdo/coverlet/master/_assets/coverlet-icon.svg?sanitize=true</PackageIconUrl>
3231
<PackageIcon>coverlet-icon.png</PackageIcon>
3332
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
3433
<DevelopmentDependency>true</DevelopmentDependency>

test/coverlet.core.tests/coverlet.core.tests.csproj

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3131
</PackageReference>
3232
<PackageReference Include="System.Collections.Immutable" />
33-
<PackageReference Include="System.Buffers" />
34-
<PackageReference Include="System.Memory" />
3533
<PackageReference Include="System.Text.Encoding.CodePages" />
3634
</ItemGroup>
3735

test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<!-- Import coverlet version-->
33
<Import Project="$(MSBuildThisFileDirectory)\DeterministicTest.props" />
44

test/coverlet.integration.template/coverlet.integration.template.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFrameworks>net8.0</TargetFrameworks>

test/coverlet.integration.tests/BaseTest.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private protected ClonedTemplateProject CloneTemplateProject(bool cleanupOnDispo
7979
return new ClonedTemplateProject(finalRoot.FullName, cleanupOnDispose);
8080
}
8181

82-
private protected bool RunCommand(string command, string arguments, out string standardOutput, out string standardError, string workingDirectory = "")
82+
private protected int RunCommand(string command, string arguments, out string standardOutput, out string standardError, string workingDirectory = "")
8383
{
8484
Debug.WriteLine($"BaseTest.RunCommand: {command} {arguments}\nWorkingDirectory: {workingDirectory}");
8585
// https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.standardoutput?view=net-7.0&redirectedfrom=MSDN#System_Diagnostics_Process_StandardOutput
@@ -101,10 +101,10 @@ private protected bool RunCommand(string command, string arguments, out string s
101101
throw new XunitException($"Command 'dotnet {arguments}' didn't end after 5 minute");
102102
}
103103
standardError = eOut;
104-
return commandProcess.ExitCode == 0;
104+
return commandProcess.ExitCode;
105105
}
106106

107-
private protected bool DotnetCli(string arguments, out string standardOutput, out string standardError, string workingDirectory = "")
107+
private protected int DotnetCli(string arguments, out string standardOutput, out string standardError, string workingDirectory = "")
108108
{
109109
return RunCommand("dotnet", arguments, out standardOutput, out standardError, workingDirectory);
110110
}

test/coverlet.integration.tests/Collectors.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private protected virtual void AssertCollectorsInjection(ClonedTemplateProject c
8181
public void TestVsTest_Test()
8282
{
8383
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject();
84-
Assert.True(DotnetCli($"test -c {_buildConfiguration} -f {_buildTargetFramework} \"{clonedTemplateProject.ProjectRootPath}\" --collect:\"XPlat Code Coverage\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!), standardOutput);
84+
Assert.Equal(0, DotnetCli($"test -c {_buildConfiguration} -f {_buildTargetFramework} \"{clonedTemplateProject.ProjectRootPath}\" --collect:\"XPlat Code Coverage\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!));
8585
// We don't have any result to check because tests and code to instrument are in same assembly so we need to pass
8686
// IncludeTestAssembly=true we do it in other test
8787
Assert.Contains("Passed!", standardOutput);
@@ -93,7 +93,7 @@ public void TestVsTest_Test_Settings()
9393
{
9494
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject();
9595
string runSettingsPath = AddCollectorRunsettingsFile(clonedTemplateProject.ProjectRootPath!);
96-
Assert.True(DotnetCli($"test -c {_buildConfiguration} -f {_buildTargetFramework} \"{clonedTemplateProject.ProjectRootPath}\" --collect:\"XPlat Code Coverage\" --settings \"{runSettingsPath}\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out string standardOutput, out string standardError), standardOutput);
96+
Assert.Equal(0, DotnetCli($"test -c {_buildConfiguration} -f {_buildTargetFramework} \"{clonedTemplateProject.ProjectRootPath}\" --collect:\"XPlat Code Coverage\" --settings \"{runSettingsPath}\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out string standardOutput, out string standardError));
9797
Assert.Contains("Passed!", standardOutput);
9898
AssertCoverage(clonedTemplateProject);
9999
AssertCollectorsInjection(clonedTemplateProject);
@@ -104,10 +104,10 @@ public void TestVsTest_VsTest()
104104
{
105105
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject();
106106
string runSettingsPath = AddCollectorRunsettingsFile(clonedTemplateProject.ProjectRootPath!);
107-
Assert.True(DotnetCli($"publish -c {_buildConfiguration} -f {_buildTargetFramework} {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError), standardOutput);
107+
Assert.Equal(0, DotnetCli($"publish -c {_buildConfiguration} -f {_buildTargetFramework} {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError));
108108
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => f.Contains("publish"));
109109
Assert.NotNull(publishedTestFile);
110-
Assert.True(DotnetCli($"vstest \"{publishedTestFile}\" --collect:\"XPlat Code Coverage\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out standardOutput, out standardError), standardOutput);
110+
Assert.Equal(0, DotnetCli($"vstest \"{publishedTestFile}\" --collect:\"XPlat Code Coverage\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out standardOutput, out standardError));
111111
// We don't have any result to check because tests and code to instrument are in same assembly so we need to pass
112112
// IncludeTestAssembly=true we do it in other test
113113
Assert.Contains("Passed!", standardOutput);
@@ -119,10 +119,10 @@ public void TestVsTest_VsTest_Settings()
119119
{
120120
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject();
121121
string runSettingsPath = AddCollectorRunsettingsFile(clonedTemplateProject.ProjectRootPath!);
122-
Assert.True(DotnetCli($"publish -c {_buildConfiguration} -f {_buildTargetFramework} \"{clonedTemplateProject.ProjectRootPath}\"", out string standardOutput, out string standardError), standardOutput);
122+
Assert.Equal(0, DotnetCli($"publish -c {_buildConfiguration} -f {_buildTargetFramework} \"{clonedTemplateProject.ProjectRootPath}\"", out string standardOutput, out string standardError));
123123
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => f.Contains("publish"));
124124
Assert.NotNull(publishedTestFile);
125-
Assert.True(DotnetCli($"vstest \"{publishedTestFile}\" --collect:\"XPlat Code Coverage\" --ResultsDirectory:\"{clonedTemplateProject.ProjectRootPath}\" /settings:\"{runSettingsPath}\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out standardOutput, out standardError), standardOutput);
125+
Assert.Equal(0, DotnetCli($"vstest \"{publishedTestFile}\" --collect:\"XPlat Code Coverage\" --ResultsDirectory:\"{clonedTemplateProject.ProjectRootPath}\" /settings:\"{runSettingsPath}\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out standardOutput, out standardError));
126126
Assert.Contains("Passed!", standardOutput);
127127
AssertCoverage(clonedTemplateProject);
128128
AssertCollectorsInjection(clonedTemplateProject);

test/coverlet.integration.tests/DeterministicBuild.cs

+11-11
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public void Msbuild()
110110
string testResultFile = Path.Join(testResultPath, "coverage.json");
111111
string cmdArgument = $"test -c {_buildConfiguration} --no-build /p:CollectCoverage=true /p:CoverletOutput=\"{testResultFile}\" /p:DeterministicReport=true /p:CoverletOutputFormat=\"cobertura%2cjson\" /p:Include=\"[coverletsample.integration.determisticbuild]*DeepThought\" /p:IncludeTestAssembly=true";
112112
_output.WriteLine($"Command: dotnet {cmdArgument}");
113-
bool result = DotnetCli(cmdArgument, out standardOutput, out standardError, _testProjectPath);
113+
int result = DotnetCli(cmdArgument, out standardOutput, out standardError, _testProjectPath);
114114
if (!string.IsNullOrEmpty(standardError))
115115
{
116116
_output.WriteLine(standardError);
@@ -119,7 +119,7 @@ public void Msbuild()
119119
{
120120
_output.WriteLine(standardOutput);
121121
}
122-
Assert.True(result);
122+
Assert.Equal(0, result);
123123
Assert.Contains("Passed!", standardOutput);
124124
Assert.Contains("| coverletsample.integration.determisticbuild | 100% | 100% | 100% |", standardOutput);
125125
Assert.True(File.Exists(testResultFile));
@@ -154,7 +154,7 @@ public void Msbuild_SourceLink()
154154
string testResultFile = Path.Join(testResultPath, "coverage.json");
155155
string cmdArgument = $"test -c {_buildConfiguration} --no-build /p:CollectCoverage=true /p:CoverletOutput=\"{testResultFile}\" /p:CoverletOutputFormat=\"cobertura%2cjson\" /p:UseSourceLink=true /p:Include=\"[coverletsample.integration.determisticbuild]*DeepThought\" /p:IncludeTestAssembly=true";
156156
_output.WriteLine($"Command: dotnet {cmdArgument}");
157-
bool result = DotnetCli(cmdArgument, out standardOutput, out standardError, _testProjectPath);
157+
int result = DotnetCli(cmdArgument, out standardOutput, out standardError, _testProjectPath);
158158
if (!string.IsNullOrEmpty(standardError))
159159
{
160160
_output.WriteLine(standardError);
@@ -163,7 +163,7 @@ public void Msbuild_SourceLink()
163163
{
164164
_output.WriteLine(standardOutput);
165165
}
166-
Assert.True(result);
166+
Assert.Equal(0, result);
167167
Assert.Contains("Passed!", standardOutput);
168168
Assert.Contains("| coverletsample.integration.determisticbuild | 100% | 100% | 100% |", standardOutput);
169169
Assert.True(File.Exists(testResultFile));
@@ -203,7 +203,7 @@ public void Collectors()
203203
string runSettingsPath = AddCollectorRunsettingsFile(_testProjectPath, "[coverletsample.integration.determisticbuild]*DeepThought", deterministicReport: true);
204204
string cmdArgument = $"test -c {_buildConfiguration} --no-build --collect:\"XPlat Code Coverage\" --results-directory:\"{testResultPath}\" --settings \"{runSettingsPath}\" --diag:{Path.Combine(testLogFilesPath, "log.txt")}";
205205
_output.WriteLine($"Command: dotnet {cmdArgument}");
206-
bool result = DotnetCli(cmdArgument, out standardOutput, out standardError, _testProjectPath);
206+
int result = DotnetCli(cmdArgument, out standardOutput, out standardError, _testProjectPath);
207207
if (!string.IsNullOrEmpty(standardError))
208208
{
209209
_output.WriteLine(standardError);
@@ -212,7 +212,7 @@ public void Collectors()
212212
{
213213
_output.WriteLine(standardOutput);
214214
}
215-
Assert.True(result);
215+
Assert.Equal(0, result);
216216
Assert.Contains("Passed!", standardOutput);
217217
AssertCoverage(standardOutput);
218218

@@ -258,7 +258,7 @@ public void Collectors_SourceLink()
258258
string runSettingsPath = AddCollectorRunsettingsFile(_testProjectPath, "[coverletsample.integration.determisticbuild]*DeepThought", sourceLink: true);
259259
string cmdArgument = $"test -c {_buildConfiguration} --no-build --collect:\"XPlat Code Coverage\" --results-directory:\"{testResultPath}\" --settings \"{runSettingsPath}\" --diag:{Path.Combine(testLogFilesPath, "log.txt")}";
260260
_output.WriteLine($"Command: dotnet {cmdArgument}");
261-
bool result = DotnetCli(cmdArgument, out standardOutput, out standardError, _testProjectPath);
261+
int result = DotnetCli(cmdArgument, out standardOutput, out standardError, _testProjectPath);
262262
if (!string.IsNullOrEmpty(standardError))
263263
{
264264
_output.WriteLine(standardError);
@@ -267,7 +267,7 @@ public void Collectors_SourceLink()
267267
{
268268
_output.WriteLine(standardOutput);
269269
}
270-
Assert.True(result);
270+
Assert.Equal(0, result);
271271
Assert.Contains("Passed!", standardOutput);
272272
AssertCoverage(standardOutput, checkDeterministicReport: false);
273273

@@ -300,7 +300,7 @@ private static void DeleteTestIntermediateFiles(string testResultsPath)
300300
{
301301
if (Directory.Exists(testResultsPath))
302302
{
303-
DirectoryInfo hdDirectory = new DirectoryInfo(testResultsPath);
303+
DirectoryInfo hdDirectory = new (testResultsPath);
304304

305305
// search for directory "In" which has second copy e.g. '_fv-az365-374_2023-10-10_14_26_42\In\fv-az365-374\coverage.json'
306306
DirectoryInfo[] intermediateFolder = hdDirectory.GetDirectories("In", SearchOption.AllDirectories);
@@ -316,7 +316,7 @@ private static void DeleteLogFiles(string directory)
316316
{
317317
if (Directory.Exists(directory))
318318
{
319-
DirectoryInfo hdDirectory = new DirectoryInfo(directory);
319+
DirectoryInfo hdDirectory = new (directory);
320320
FileInfo[] filesInDir = hdDirectory.GetFiles("log.*.txt");
321321

322322
foreach (FileInfo foundFile in filesInDir)
@@ -344,7 +344,7 @@ private static void DeleteCoverageFiles(string directory)
344344
{
345345
if (Directory.Exists(directory))
346346
{
347-
DirectoryInfo hdDirectory = new DirectoryInfo(directory);
347+
DirectoryInfo hdDirectory = new (directory);
348348
FileInfo[] filesInDir = hdDirectory.GetFiles("coverage.cobertura.xml");
349349

350350
foreach (FileInfo foundFile in filesInDir)

0 commit comments

Comments
 (0)