diff --git a/AltCover.CSApi/Definitions.cs b/AltCover.CSApi/Definitions.cs
index 26cd48662..f10983208 100644
--- a/AltCover.CSApi/Definitions.cs
+++ b/AltCover.CSApi/Definitions.cs
@@ -60,6 +60,11 @@ public interface ILogArgs
Logging ToParameters();
}
+
+ public interface ICLIArg
+ {
+ bool Force { get; }
+ }
}
namespace AltCover.Parameters.Primitive
@@ -240,6 +245,11 @@ public static LogArgs Default
}
}
}
+
+ public class CLIArgs : ICLIArg
+ {
+ public bool Force { get; set; }
+ }
}
namespace AltCover
@@ -270,17 +280,21 @@ public static string Version()
public static string ToTestArguments(IPrepareArgs p,
ICollectArgs c,
- bool force)
+ ICLIArg force)
{
- return DotNet.ToTestArguments(p.ToParameters(), c.ToParameters(), force);
+ return DotNet.ToTestArguments(p.ToParameters(),
+ c.ToParameters(),
+ DotNetTest.CLIArgs.NewForce(force.Force));
}
public static string[] ToTestArgumentList(IPrepareArgs p,
ICollectArgs c,
- bool force)
+ ICLIArg force)
{
- return DotNet.ToTestArgumentList(p.ToParameters(), c.ToParameters(), force).
- ToArray();
+ return DotNet.ToTestArgumentList(p.ToParameters(),
+ c.ToParameters(),
+ DotNetTest.CLIArgs.NewForce(force.Force)).
+ ToArray();
}
}
}
\ No newline at end of file
diff --git a/AltCover.Cake/DotNet.cs b/AltCover.Cake/DotNet.cs
index 84d83dc75..b3fae6b0a 100644
--- a/AltCover.Cake/DotNet.cs
+++ b/AltCover.Cake/DotNet.cs
@@ -13,7 +13,7 @@ public class AltCoverSettings
{
public IPrepareArgs PreparationPhase { get; set; }
public ICollectArgs CollectionPhase { get; set; }
- public bool Force { get; set; }
+ public ICLIArg Force { get; set; }
}
[CakeAliasCategory("DotNetCore")]
diff --git a/AltCover.FSApi/AltCover.FSApi.fsproj b/AltCover.FSApi/AltCover.FSApi.fsproj
index 03948cd57..b1553ddb2 100644
--- a/AltCover.FSApi/AltCover.FSApi.fsproj
+++ b/AltCover.FSApi/AltCover.FSApi.fsproj
@@ -69,6 +69,7 @@
AssemblyVersion.fs
+
diff --git a/AltCover.FSApi/CLIArgs.fs b/AltCover.FSApi/CLIArgs.fs
new file mode 100644
index 000000000..375bc4940
--- /dev/null
+++ b/AltCover.FSApi/CLIArgs.fs
@@ -0,0 +1,18 @@
+#if RUNNER
+namespace AltCover
+
+[] // work around coverlet attribute bug
+module DotNetTest =
+#else
+[] // work around coverlet attribute bug
+module AltCover_Fake.DotNet.Testing.DotNetTest
+#endif
+ []
+
+ type CLIArgs =
+ | Force of bool
+ with member self.ForceDelete =
+ match self with
+ | Force b -> b
\ No newline at end of file
diff --git a/AltCover.FSApi/Definitions.fs b/AltCover.FSApi/Definitions.fs
index dbb348c61..443036b01 100644
--- a/AltCover.FSApi/Definitions.fs
+++ b/AltCover.FSApi/Definitions.fs
@@ -2,11 +2,15 @@
namespace AltCover
#else
module internal AltCover.Internals
-
#endif
open System
open System.Linq
+#if RUNNER
+open AltCover.DotNetTest
+#else
+open AltCover_Fake.DotNet.Testing
+#endif
[]
[]
@@ -30,12 +34,12 @@ module DotNet =
let ToTestArgumentList
(prepare : AltCover.FSApi.PrepareParams)
(collect : AltCover.FSApi.CollectParams)
- (force : bool) =
+ (force : DotNetTest.CLIArgs) =
#else
let ToTestArgumentList
(prepare : AltCover_Fake.DotNet.Testing.AltCover.PrepareParams)
(collect : AltCover_Fake.DotNet.Testing.AltCover.CollectParams)
- (force : bool) =
+ (force : DotNetTest.CLIArgs) =
#endif
[ FromArg String.Empty "true"
@@ -55,7 +59,7 @@ module DotNet =
FromArg "Threshold" collect.Threshold
(Arg "LineCover" "true", prepare.LineCover)
(Arg "BranchCover" "true", prepare.BranchCover)
- (Arg "Force" "true", force)]
+ (Arg "Force" "true", force.ForceDelete)]
|> List.filter snd
|> List.map fst
@@ -63,11 +67,11 @@ module DotNet =
let ToTestArguments
(prepare : AltCover.FSApi.PrepareParams)
(collect : AltCover.FSApi.CollectParams)
- (force : bool) =
+ (force : DotNetTest.CLIArgs) =
#else
let ToTestArguments
(prepare : AltCover_Fake.DotNet.Testing.AltCover.PrepareParams)
(collect : AltCover_Fake.DotNet.Testing.AltCover.CollectParams)
- (force : bool) =
+ (force : DotNetTest.CLIArgs) =
#endif
ToTestArgumentList prepare collect force |> Join
\ No newline at end of file
diff --git a/AltCover.FSApi/altcover.fsapi.core.fsproj b/AltCover.FSApi/altcover.fsapi.core.fsproj
index 5baf8bd49..bf44281d7 100644
--- a/AltCover.FSApi/altcover.fsapi.core.fsproj
+++ b/AltCover.FSApi/altcover.fsapi.core.fsproj
@@ -31,6 +31,7 @@
+
diff --git a/AltCover.Fake.DotNet.Testing.AltCover/AltCover.Fake.DotNet.Testing.AltCover.fsproj b/AltCover.Fake.DotNet.Testing.AltCover/AltCover.Fake.DotNet.Testing.AltCover.fsproj
index d280711b1..464c3c0b5 100644
--- a/AltCover.Fake.DotNet.Testing.AltCover/AltCover.Fake.DotNet.Testing.AltCover.fsproj
+++ b/AltCover.Fake.DotNet.Testing.AltCover/AltCover.Fake.DotNet.Testing.AltCover.fsproj
@@ -69,6 +69,9 @@
Api.fs
+
+ CLIArgs.fs
+
Definitions.fs
diff --git a/AltCover.Fake.DotNet.Testing.AltCover/altcover.fake.dotnet.testing.altcover.core.fsproj b/AltCover.Fake.DotNet.Testing.AltCover/altcover.fake.dotnet.testing.altcover.core.fsproj
index 45f838871..905060e39 100644
--- a/AltCover.Fake.DotNet.Testing.AltCover/altcover.fake.dotnet.testing.altcover.core.fsproj
+++ b/AltCover.Fake.DotNet.Testing.AltCover/altcover.fake.dotnet.testing.altcover.core.fsproj
@@ -34,6 +34,7 @@
+
diff --git a/AltCover.Fake/Fake.fs b/AltCover.Fake/Fake.fs
index cc2384789..1744730d9 100644
--- a/AltCover.Fake/Fake.fs
+++ b/AltCover.Fake/Fake.fs
@@ -59,6 +59,7 @@ namespace AltCover_Fake.DotNet
open System
open System.Reflection
open AltCover.Internals
+open AltCover_Fake.DotNet.Testing
#endif
module DotNet =
@@ -110,11 +111,11 @@ module DotNet =
#if RUNNER
member self.WithParameters (prepare : PrepareParams)
(collect : CollectParams)
- (force : bool) =
+ (force : DotNetTest.CLIArgs) =
#else
member self.WithParameters (prepare : AltCover_Fake.DotNet.Testing.AltCover.PrepareParams)
(collect : AltCover_Fake.DotNet.Testing.AltCover.CollectParams)
- (force : bool) =
+ (force : DotNetTest.CLIArgs) =
#endif
DotNet.ToTestArguments prepare collect force |> self.ExtendCustomParams
diff --git a/Build/rules-posh.xml b/Build/rules-posh.xml
index 0ca2460f4..80bde2de1 100644
--- a/Build/rules-posh.xml
+++ b/Build/rules-posh.xml
@@ -1,46 +1,46 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Build/setup.fsx b/Build/setup.fsx
index b09d05d75..1d6995a36 100644
--- a/Build/setup.fsx
+++ b/Build/setup.fsx
@@ -58,6 +58,7 @@ nuget YamlDotNet >= 5.2.1 //"
#load "../AltCover/Primitive.fs"
#load "../AltCover/TypeSafe.fs"
#load "../AltCover/Api.fs"
+#load "../AltCover.FSApi/CLIArgs.fs"
#load "../AltCover.FSApi/Definitions.fs"
#load "../AltCover.Fake/Fake.fs"
#load "actions.fsx"
diff --git a/Build/targets.fsx b/Build/targets.fsx
index ad276efe2..a305fafdd 100644
--- a/Build/targets.fsx
+++ b/Build/targets.fsx
@@ -127,6 +127,9 @@ let NuGetAltCover =
|> Seq.filter File.Exists
|> Seq.tryHead
+
+let ForceTrue = DotNetTest.CLIArgs.Force true
+
let _Target s f =
Target.description s
Target.create s f
@@ -2755,9 +2758,10 @@ _Target "DoIt"
let collect = FSApi.CollectParams.Primitive { AltCover.Primitive.CollectParams.Create() with LcovReport = "x" }
let prepare = FSApi.PrepareParams.Primitive { AltCover.Primitive.PrepareParams.Create() with TypeFilter = [| "a"; "b" |] }
- printfn "%s" (DotNet.ToTestArguments prepare collect true)
+ let ForceTrue = DotNetTest.CLIArgs.Force true
+ printfn "%s" (DotNet.ToTestArguments prepare collect ForceTrue)
- let t = DotNet.TestOptions.Create().WithParameters prepare collect true
+ let t = DotNet.TestOptions.Create().WithParameters prepare collect ForceTrue
printfn "returned '%A'" t.Common.CustomParams
let p2 = { Primitive.PrepareParams.Create() with CallContext = [| "[Fact]"; "0" |]
@@ -2777,8 +2781,8 @@ _Target "DoIt"
DotNet.test
(fun to' ->
- { to'.WithCommon(setBaseOptions).WithParameters pp2 cc2 true with MSBuildParams =
- cliArguments })
+ { to'.WithCommon(setBaseOptions).WithParameters pp2 cc2 ForceTrue with MSBuildParams =
+ cliArguments })
"dotnettest.fsproj"
let ipmo = AltCover.Api.Ipmo().Trim().Split().[1].Trim([| '\"' |])
let command = "$ipmo = '" + ipmo + "'; Import-Module $ipmo; ConvertTo-BarChart -?"
@@ -2873,7 +2877,7 @@ _Target "DotnetTestIntegration" (fun _ ->
DotNet.test
(fun to' ->
(to'.WithCommon(withWorkingDirectoryVM "_DotnetTest")
- .WithGetVersion().WithImportModule()).WithParameters pp1 cc0 true |> withCLIArgs)
+ .WithGetVersion().WithImportModule()).WithParameters pp1 cc0 ForceTrue |> withCLIArgs)
"dotnettest.fsproj"
let x = Path.getFullName "./_DotnetTest/coverage.xml"
@@ -2903,7 +2907,7 @@ _Target "DotnetTestIntegration" (fun _ ->
DotNet.test
(fun to' ->
to'.WithCommon(withWorkingDirectoryVM "_DotnetTestLineCover").WithParameters
- pp2 cc0 true |> withCLIArgs) ""
+ pp2 cc0 ForceTrue |> withCLIArgs) ""
let x = Path.getFullName "./_DotnetTestLineCover/coverage.xml"
@@ -2943,7 +2947,7 @@ _Target "DotnetTestIntegration" (fun _ ->
DotNet.test
(fun to' ->
(to'.WithCommon(withWorkingDirectoryVM "_DotnetTestBranchCover").WithParameters
- pp3 cc0 true) |> withCLIArgs) ""
+ pp3 cc0 ForceTrue) |> withCLIArgs) ""
let x = Path.getFullName "./_DotnetTestBranchCover/coverage.xml"
@@ -2972,7 +2976,7 @@ _Target "DotnetTestIntegration" (fun _ ->
DotNet.test
(fun to' ->
(to'.WithCommon(withWorkingDirectoryVM "RegressionTesting/issue29").WithParameters
- pp0 cc0 true) |> withCLIArgs) ""
+ pp0 cc0 ForceTrue) |> withCLIArgs) ""
let proj = XDocument.Load "./RegressionTesting/issue37/issue37.xml"
let pack = proj.Descendants(XName.Get("PackageReference")) |> Seq.head
@@ -2989,7 +2993,7 @@ _Target "DotnetTestIntegration" (fun _ ->
(fun to' ->
{ ((to'.WithCommon
(withWorkingDirectoryVM "RegressionTesting/issue37")).WithParameters
- pp4 cc0 true) with Configuration = DotNet.BuildConfiguration.Release } |> withCLIArgs)
+ pp4 cc0 ForceTrue) with Configuration = DotNet.BuildConfiguration.Release } |> withCLIArgs)
""
let cover37 = XDocument.Load "./RegressionTesting/issue37/coverage.xml"
@@ -3030,7 +3034,7 @@ _Target "Issue20" (fun _ ->
DotNet.BuildConfiguration.Debug
NoBuild =
false }).WithParameters
- pp0 cc0 true
+ pp0 cc0 ForceTrue
|> withCLIArgs) ""
//let shared =
@@ -3046,12 +3050,12 @@ _Target "Issue20" (fun _ ->
// { to'.WithCommon(fun c ->
// { c with WorkingDirectory =
// Path.getFullName"./RegressionTesting/issue20/xunit-tests"
- // Verbosity = SomeDotNet.Verbosity.Minimal }).WithParameters p1 c0 with Configuration =
- // DotNet.BuildConfiguration.Debug
- // NoBuild =
- // false
- // MSBuildParams =
- // cliArguments })
+ // Verbosity = SomeDotNet.Verbosity.Minimal }).WithParameters p1 c0 ForceTrue with Configuration =
+ // DotNet.BuildConfiguration.Debug
+ // NoBuild =
+ // false
+ // MSBuildParams =
+ // cliArguments })
// ""
finally
let folder = (nugetCache @@ "altcover") @@ !Version
@@ -3084,7 +3088,7 @@ _Target "Issue23" (fun _ ->
let cc0 = AltCover.CollectParams.Primitive c0
DotNet.test (fun p ->
(({ p.WithCommon(withWorkingDirectoryVM "_Issue23") with Configuration = DotNet.BuildConfiguration.Debug
- NoBuild = false }).WithParameters pp0 cc0 true)
+ NoBuild = false }).WithParameters pp0 cc0 ForceTrue)
.WithImportModule().WithGetVersion()
|> withCLIArgs) ""
finally
@@ -3183,10 +3187,10 @@ _Target "DotnetCLIIntegration" (fun _ ->
let c0 = Primitive.CollectParams.Create()
let cc0 = AltCover.CollectParams.Primitive c0
DotNet.test (fun to' ->
- { to'.WithCommon(withWorkingDirectoryVM "_DotnetCLITest").WithParameters pp0 cc0 true with Configuration =
- DotNet.BuildConfiguration.Debug
- NoBuild =
- false }
+ { to'.WithCommon(withWorkingDirectoryVM "_DotnetCLITest").WithParameters pp0 cc0 ForceTrue with Configuration =
+ DotNet.BuildConfiguration.Debug
+ NoBuild =
+ false }
|> withCLIArgs) ""
"./_DotnetCLITest/coverage.xml"