From 8ce053831728267da00cebf859c1b2d56023c2f7 Mon Sep 17 00:00:00 2001 From: Bert Date: Sat, 29 Mar 2025 12:37:09 +0100 Subject: [PATCH 01/17] use .NET 8.0 assembies for coverlet.core and remove Newtonsoft.Json --- Directory.Packages.props | 1 - README.md | 12 +-- src/coverlet.core/Coverage.cs | 25 ++++-- src/coverlet.core/CoverageResult.cs | 2 + src/coverlet.core/Exceptions.cs | 8 -- .../Helpers/InstrumentationHelper.cs | 6 +- .../Instrumentation/CecilAssemblyResolver.cs | 27 ++++--- src/coverlet.core/Reporters/JsonReporter.cs | 11 ++- src/coverlet.core/coverlet.core.csproj | 27 ++++--- .../coverlet.msbuild.targets | 2 +- .../Coverage/CoverageTests.cs | 76 ++++++++++++------- .../coverlet.core.tests.csproj | 2 +- ...verlet.integration.determisticbuild.csproj | 2 +- .../nuget.config | 2 +- .../DeterministicBuild.cs | 8 +- test/coverlet.integration.tests/DotnetTool.cs | 2 +- .../coverlet.integration.tests.csproj | 3 +- .../coverlet.msbuild.tasks.tests.csproj | 2 +- 18 files changed, 129 insertions(+), 89 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index eba94e254..14ef5c80e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -39,7 +39,6 @@ vstest 17.8 version NuGetFrameworksVersion is defined here https://github.com/microsoft/vstest/blob/9a0c41811637edf4afe0e265e08fdd1cb18109ed/eng/Versions.props#L94C1-L94C1 --> - 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/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..ecef745e2 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,32 @@ 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; + JsonElement runtimeOptionsElement = rootElement.GetProperty("runtimeOptions"); - 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..bce9fe7c9 100644 --- a/src/coverlet.core/coverlet.core.csproj +++ b/src/coverlet.core/coverlet.core.csproj @@ -1,25 +1,30 @@ - + 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/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..2fbb5f2b1 100644 --- a/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj +++ b/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj @@ -3,7 +3,7 @@ - net6.0 + net8.0 false coverletsample.integration.determisticbuild NU1604;NU1701 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/DeterministicBuild.cs b/test/coverlet.integration.tests/DeterministicBuild.cs index 9c8a181db..e04d40428 100644 --- a/test/coverlet.integration.tests/DeterministicBuild.cs +++ b/test/coverlet.integration.tests/DeterministicBuild.cs @@ -30,7 +30,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,7 +37,10 @@ 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", @@ -47,7 +49,7 @@ private void CreateDeterministicTestPropsFile() _testProjectTfm = XElement.Load(Path.Combine(_testProjectPath, "coverlet.integration.determisticbuild.csproj"))!. Descendants("PropertyGroup")!.Single().Element("TargetFramework")!.Value; - deterministicTestProps.Save(Path.Combine(_testProjectPath, PropsFileName)); + deterministicTestProps.Save(Path.Combine(propsFile)); } private protected void AssertCoverage(string standardOutput = "", bool checkDeterministicReport = true) 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/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 @@ - + From cef7021a80e940a43489b66f84cb63a661825974 Mon Sep 17 00:00:00 2001 From: Bert Date: Thu, 10 Apr 2025 09:06:42 +0200 Subject: [PATCH 02/17] update .NET SDK 8.0.408 --- Directory.Packages.props | 4 ++-- global.json | 2 +- src/coverlet.core/coverlet.core.csproj | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 14ef5c80e..9cb9de104 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -60,11 +60,11 @@ - + - + diff --git a/global.json b/global.json index 6dfc6666e..0417b6523 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "8.0.407" + "version": "8.0.408" } } diff --git a/src/coverlet.core/coverlet.core.csproj b/src/coverlet.core/coverlet.core.csproj index bce9fe7c9..5295a382d 100644 --- a/src/coverlet.core/coverlet.core.csproj +++ b/src/coverlet.core/coverlet.core.csproj @@ -25,6 +25,7 @@ + From b67be9c6885c04b34ad5e06b46a4c5a020f9593d Mon Sep 17 00:00:00 2001 From: Bert Date: Sat, 10 May 2025 11:44:04 +0200 Subject: [PATCH 03/17] update package and framework versions --- .gitignore | 1 + CONTRIBUTING.md | 6 +- Directory.Packages.props | 8 +-- Documentation/VSTestIntegration.md | 6 +- src/coverlet.core/coverlet.core.csproj | 2 +- ...rlet.core.tests.samples.netstandard.csproj | 2 +- test/coverlet.integration.tests/Msbuild.cs | 71 ++++++++++++++----- ...let.tests.projectsample.aspmvcrazor.csproj | 2 +- 8 files changed, 67 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index 514880624..4fb82efe2 100644 --- a/.gitignore +++ b/.gitignore @@ -318,3 +318,4 @@ FolderProfile.pubxml /NuGet.config nuget.config *.dmp +/test/coverlet.core.coverage.tests/System.Private.CoreLib-version.png diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ffe337455..594165a27 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/9.0) for runtime environment ## Building the Project diff --git a/Directory.Packages.props b/Directory.Packages.props index 9cb9de104..1aa667567 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -9,19 +9,19 @@ 17.13.9 - 4.12.0 + 4.13.0 17.13.0 6.13.2 - 2.0.0 - 3.0.2 + 2.0.2 + 3.1.0 - + diff --git a/Documentation/VSTestIntegration.md b/Documentation/VSTestIntegration.md index a2c4140e1..834ab498c 100644 --- a/Documentation/VSTestIntegration.md +++ b/Documentation/VSTestIntegration.md @@ -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. diff --git a/src/coverlet.core/coverlet.core.csproj b/src/coverlet.core/coverlet.core.csproj index 5295a382d..96aea4a49 100644 --- a/src/coverlet.core/coverlet.core.csproj +++ b/src/coverlet.core/coverlet.core.csproj @@ -15,6 +15,7 @@ + @@ -25,7 +26,6 @@ - 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.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.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 From ed1a24c7955d98c99013cb1b574f1b1ee8f8e456 Mon Sep 17 00:00:00 2001 From: Bert Date: Sat, 10 May 2025 14:47:10 +0200 Subject: [PATCH 04/17] Update Directory.Packages.props --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 1aa667567..0f1b47649 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -13,7 +13,7 @@ 17.13.0 6.13.2 - 2.0.2 + 2.0.0 3.1.0 From 8632f773c3252f268fbdba4a4bd0e9b8ee7428ae Mon Sep 17 00:00:00 2001 From: Bert Date: Sun, 11 May 2025 11:08:14 +0200 Subject: [PATCH 05/17] incorporate review comments --- .gitignore | 1 - CONTRIBUTING.md | 2 +- Directory.Packages.props | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 4fb82efe2..514880624 100644 --- a/.gitignore +++ b/.gitignore @@ -318,4 +318,3 @@ FolderProfile.pubxml /NuGet.config nuget.config *.dmp -/test/coverlet.core.coverage.tests/System.Private.CoreLib-version.png diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 594165a27..f0616b11f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,7 +6,7 @@ Contributions are highly welcome, however, except for very small changes, kindly 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/9.0) for runtime 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.Packages.props b/Directory.Packages.props index 0f1b47649..440b75449 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -61,7 +61,7 @@ - + From 26cdf12f2a6fc0f4349b357026c89dcfbcc79928 Mon Sep 17 00:00:00 2001 From: Bert Date: Tue, 27 May 2025 14:21:17 +0200 Subject: [PATCH 06/17] Update global.json --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 0417b6523..8b2877a60 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "8.0.408" + "version": "8.0.409" } } From 9934cff183033cd7ad920e313e7ef9017d79591e Mon Sep 17 00:00:00 2001 From: Bert Date: Fri, 6 Jun 2025 09:34:55 +0200 Subject: [PATCH 07/17] apply copilot comments --- src/coverlet.core/Instrumentation/CecilAssemblyResolver.cs | 5 ++++- test/coverlet.integration.tests/DeterministicBuild.cs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/coverlet.core/Instrumentation/CecilAssemblyResolver.cs b/src/coverlet.core/Instrumentation/CecilAssemblyResolver.cs index ecef745e2..e4f0e19bd 100644 --- a/src/coverlet.core/Instrumentation/CecilAssemblyResolver.cs +++ b/src/coverlet.core/Instrumentation/CecilAssemblyResolver.cs @@ -304,7 +304,10 @@ public RuntimeConfigurationReader(string runtimeConfigFile) using var configuration = JsonDocument.Parse(jsonString, documentOptions); JsonElement rootElement = configuration.RootElement; - JsonElement runtimeOptionsElement = rootElement.GetProperty("runtimeOptions"); + if (!rootElement.TryGetProperty("runtimeOptions", out JsonElement runtimeOptionsElement)) + { + throw new InvalidOperationException($"The 'runtimeOptions' property is missing in the runtime configuration file {_runtimeConfigFile}."); + } if (runtimeOptionsElement.TryGetProperty("framework", out JsonElement frameworkElement)) { diff --git a/test/coverlet.integration.tests/DeterministicBuild.cs b/test/coverlet.integration.tests/DeterministicBuild.cs index e04d40428..78f8b1717 100644 --- a/test/coverlet.integration.tests/DeterministicBuild.cs +++ b/test/coverlet.integration.tests/DeterministicBuild.cs @@ -49,7 +49,7 @@ private void CreateDeterministicTestPropsFile() _testProjectTfm = XElement.Load(Path.Combine(_testProjectPath, "coverlet.integration.determisticbuild.csproj"))!. Descendants("PropertyGroup")!.Single().Element("TargetFramework")!.Value; - deterministicTestProps.Save(Path.Combine(propsFile)); + deterministicTestProps.Save(propsFile); } private protected void AssertCoverage(string standardOutput = "", bool checkDeterministicReport = true) From 68bd6e83c8f10d25729bb8eab4e5861b963100b2 Mon Sep 17 00:00:00 2001 From: Bert Date: Tue, 10 Jun 2025 17:12:09 +0200 Subject: [PATCH 08/17] Update dotnet-tools.json --- .config/dotnet-tools.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 +} From 1cc039f6750e36ecc5bdd6cc82a849716265a278 Mon Sep 17 00:00:00 2001 From: Bert Date: Wed, 11 Jun 2025 10:41:29 +0200 Subject: [PATCH 09/17] Update project for .NET 8.0 and improve documentation - Add notable changes section in `Changelog.md` for .NET 8.0 LTS upgrade and xUnit updates. - Revise `HowTo.md` for prerequisites on deterministic builds and local NuGet package generation. - Modify `KnownIssues.md` for assembly resolution behavior and `CopyLocalLockFileAssemblies`. - Update `ReleasePlan.md` with new package versions for `coverlet.msbuild` and `coverlet.collector`. - Revise `Troubleshooting.md` for output directory changes and local build instructions. - Update `VSTestIntegration.md` for new minimum version requirements for .NET SDK and `coverlet.collector`. - Update CI configuration files to install .NET SDK version 8.0.411. - Update `global.json` to specify .NET SDK version 8.0.411. --- .gitignore | 1 + Documentation/Changelog.md | 5 +- .../MSBuild/DeterministicBuild/HowTo.md | 100 +++++------------- .../XUnitTestProject1.csproj | 6 +- .../Examples/MSBuild/MergeWith/HowTo.md | 61 ++++++++--- .../XUnitTestProject1.csproj | 4 +- .../XUnitTestProject2.csproj | 8 +- .../XUnitTestProject3.csproj | 8 +- .../VSTest/DeterministicBuild/HowTo.md | 84 +++++---------- .../XUnitTestProject1.csproj | 6 +- .../XUnitTestProject1.csproj | 6 +- Documentation/KnownIssues.md | 6 +- Documentation/ReleasePlan.md | 18 ++-- Documentation/Troubleshooting.md | 36 +++---- Documentation/VSTestIntegration.md | 20 ++-- eng/azure-pipelines-nightly.yml | 7 +- eng/build.yml | 7 +- global.json | 2 +- ...verlet.integration.determisticbuild.csproj | 2 +- test/coverlet.tests.utils/TestUtils.cs | 6 ++ 20 files changed, 171 insertions(+), 222 deletions(-) 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/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 834ab498c..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 @@ -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/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 8b2877a60..fb6d6a3df 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "8.0.409" + "version": "8.0.411" } } diff --git a/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj b/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj index 2fbb5f2b1..6e42c864a 100644 --- a/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj +++ b/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj @@ -29,6 +29,6 @@ all runtime; build; native; contentfiles; analyzers - + 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"); } From 9dc24086f9a2b07020a6ba3a582a6f891174486d Mon Sep 17 00:00:00 2001 From: Bert Date: Wed, 11 Jun 2025 16:33:36 +0200 Subject: [PATCH 10/17] define nuget package versions only in Directory.Packages.props --- Directory.Build.props | 31 -------------------------- Directory.Packages.props | 10 +++++---- src/coverlet.core/coverlet.core.csproj | 16 +++++-------- 3 files changed, 12 insertions(+), 45 deletions(-) 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 440b75449..de6870903 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -8,11 +8,12 @@ - 17.13.9 + 17.11.31 + 17.13.26 4.13.0 17.13.0 - 6.13.2 + 6.14.0 2.0.0 3.1.0 @@ -53,11 +54,12 @@ - + + - + diff --git a/src/coverlet.core/coverlet.core.csproj b/src/coverlet.core/coverlet.core.csproj index 96aea4a49..4ed1994d6 100644 --- a/src/coverlet.core/coverlet.core.csproj +++ b/src/coverlet.core/coverlet.core.csproj @@ -8,24 +8,20 @@ - - + - - - + + - - - - - + + + From 72f4a71e474b9cb2c8d0712d0eaf8a396445e772 Mon Sep 17 00:00:00 2001 From: Bert Date: Thu, 12 Jun 2025 09:46:08 +0200 Subject: [PATCH 11/17] update version of System.Security.AccessControl --- Directory.Packages.props | 4 ++-- src/coverlet.msbuild.tasks/coverlet.msbuild.tasks.csproj | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index de6870903..40dfdfeae 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -8,12 +8,11 @@ - 17.11.31 17.13.26 4.13.0 + 6.14.0 17.13.0 - 6.14.0 2.0.0 3.1.0 @@ -63,6 +62,7 @@ + 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 @@ - + + From 9a478f57ffda058aab63684cc5cf76a62e40d9cd Mon Sep 17 00:00:00 2001 From: Bert Date: Thu, 12 Jun 2025 11:01:24 +0200 Subject: [PATCH 12/17] Disable Parallelization for Deterministic Build --- .../coverlet.integration.determisticbuild.csproj | 3 ++- test/coverlet.integration.tests/Collectors.cs | 14 +++++++------- .../DeterministicBuild.cs | 8 ++++++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj b/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj index 6e42c864a..2b8eb6482 100644 --- a/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj +++ b/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj @@ -6,7 +6,7 @@ net8.0 false coverletsample.integration.determisticbuild - NU1604;NU1701 + NU1604 false https://api.nuget.org/v3/index.json; @@ -16,6 +16,7 @@ + all runtime; build; native; contentfiles; analyzers; buildtransitive 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 78f8b1717..0c52f54ac 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"; @@ -383,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. + } } From 6ef611104860485898cce809e0961d9d8e185e80 Mon Sep 17 00:00:00 2001 From: Bert Date: Fri, 13 Jun 2025 10:10:37 +0200 Subject: [PATCH 13/17] update _CoverletSdkMinVersionWithDependencyTarget and fix coverlet.integration.determisticbuild.csproj --- coverlet.sln | 7 +++++++ src/coverlet.collector/build/coverlet.collector.targets | 4 ++-- .../coverlet.integration.determisticbuild.csproj | 9 ++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) 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/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/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj b/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj index 2b8eb6482..a9325b620 100644 --- a/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj +++ b/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj @@ -1,6 +1,11 @@ - + + + + 6.0.4 + 6.0.4 + net8.0 @@ -16,7 +21,6 @@ - all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -30,6 +34,5 @@ all runtime; build; native; contentfiles; analyzers - From 8a5689e5c827c29142576425dd1ee28671f6f6f5 Mon Sep 17 00:00:00 2001 From: Bert Date: Fri, 13 Jun 2025 10:36:56 +0200 Subject: [PATCH 14/17] fix CreateDeterministicTestPropsFile and use first PropertyGroup --- .../coverlet.integration.determisticbuild.csproj | 13 +++++++------ .../DeterministicBuild.cs | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj b/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj index a9325b620..558c97dfb 100644 --- a/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj +++ b/test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj @@ -1,12 +1,7 @@ - - - 6.0.4 - 6.0.4 - - + net8.0 false @@ -19,6 +14,12 @@ + + + 6.0.4 + 6.0.4 + + diff --git a/test/coverlet.integration.tests/DeterministicBuild.cs b/test/coverlet.integration.tests/DeterministicBuild.cs index 0c52f54ac..742aac85e 100644 --- a/test/coverlet.integration.tests/DeterministicBuild.cs +++ b/test/coverlet.integration.tests/DeterministicBuild.cs @@ -48,7 +48,7 @@ private void CreateDeterministicTestPropsFile() 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(propsFile); } From 361823cdb089ec5f5afb2ffe2001070707407bd9 Mon Sep 17 00:00:00 2001 From: Bert Date: Thu, 17 Jul 2025 10:20:49 +0200 Subject: [PATCH 15/17] update .NET SDK version --- Directory.Packages.props | 13 +++++++------ global.json | 2 +- .../coverlet.integration.tests.csproj | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 40dfdfeae..f14e23316 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -8,13 +8,13 @@ - 17.13.26 - 4.13.0 + 17.11.31 + 4.12.0 6.14.0 - 17.13.0 + 17.14.1 2.0.0 - 3.1.0 + 3.0.2 @@ -56,8 +56,9 @@ + - + @@ -65,7 +66,7 @@ - + diff --git a/global.json b/global.json index fb6d6a3df..d0137450f 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "8.0.411" + "version": "8.0.412" } } diff --git a/test/coverlet.integration.tests/coverlet.integration.tests.csproj b/test/coverlet.integration.tests/coverlet.integration.tests.csproj index e08143035..6543c2241 100644 --- a/test/coverlet.integration.tests/coverlet.integration.tests.csproj +++ b/test/coverlet.integration.tests/coverlet.integration.tests.csproj @@ -23,7 +23,7 @@ all runtime; build; native; contentfiles; analyzers - + From 018d7b110148d48e186a36e2bf2b316d0c857db2 Mon Sep 17 00:00:00 2001 From: Bert Date: Thu, 17 Jul 2025 14:44:01 +0200 Subject: [PATCH 16/17] remove version string from displayName --- eng/azure-pipelines-nightly.yml | 2 +- eng/build.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/azure-pipelines-nightly.yml b/eng/azure-pipelines-nightly.yml index 556fc4cb0..bc9a89ba1 100644 --- a/eng/azure-pipelines-nightly.yml +++ b/eng/azure-pipelines-nightly.yml @@ -5,7 +5,7 @@ steps: - task: UseDotNet@2 inputs: useGlobalJson: true - displayName: Install .NET Core SDK 8.0.411 + displayName: Install .NET Core SDK (global.json) - task: NuGetAuthenticate@1 displayName: Authenticate with NuGet feeds diff --git a/eng/build.yml b/eng/build.yml index e9dba3973..e563becca 100644 --- a/eng/build.yml +++ b/eng/build.yml @@ -2,7 +2,7 @@ steps: - task: UseDotNet@2 inputs: useGlobalJson: true - displayName: Install .NET Core SDK 8.0.411 + displayName: Install .NET Core SDK (global.json) # create artifact/package folder - pwsh: | From 0696828b189819bc0c3fc685547c7e0bb52c1b4f Mon Sep 17 00:00:00 2001 From: Bert Date: Wed, 23 Jul 2025 09:01:02 +0200 Subject: [PATCH 17/17] update xunit package version --- .gitignore | 2 ++ Directory.Packages.props | 7 ++++--- .../coverlet.core.coverage.tests.csproj | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 2179436d8..5b2486c50 100644 --- a/.gitignore +++ b/.gitignore @@ -319,3 +319,5 @@ FolderProfile.pubxml nuget.config *.dmp Playground*/ +# extended playground +coverlet.MTP/ diff --git a/Directory.Packages.props b/Directory.Packages.props index f14e23316..da7049a4b 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -13,8 +13,8 @@ 6.14.0 17.14.1 - 2.0.0 - 3.0.2 + 3.0.0 + 3.1.3 @@ -56,8 +56,9 @@ - + + diff --git a/test/coverlet.core.coverage.tests/coverlet.core.coverage.tests.csproj b/test/coverlet.core.coverage.tests/coverlet.core.coverage.tests.csproj index 43b19b7ad..094601175 100644 --- a/test/coverlet.core.coverage.tests/coverlet.core.coverage.tests.csproj +++ b/test/coverlet.core.coverage.tests/coverlet.core.coverage.tests.csproj @@ -1,4 +1,4 @@ - + @@ -22,7 +22,7 @@ - + all runtime; build; native; contentfiles; analyzers