Skip to content

Commit

Permalink
Merge branch 'release/Habu' into develop/github/consume-latest-nuget
Browse files Browse the repository at this point in the history
# Conflicts:
#	AltCover.Tests/Tests.fs
  • Loading branch information
SteveGilham committed Apr 15, 2024
2 parents 41e724a + 0deb424 commit 3314400
Show file tree
Hide file tree
Showing 63 changed files with 519 additions and 272 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"dotnet-reportgenerator-globaltool": {
"version": "5.2.2",
"version": "5.2.4",
"commands": [
"reportgenerator"
]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.202'
dotnet-version: '8.0.204'
- name: Tools
run: dotnet tool restore
- name: Setup
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.202'
dotnet-version: '8.0.204'
- name: Tools
run: dotnet tool restore
- name: Setup
Expand Down
2 changes: 1 addition & 1 deletion AltCover.Api.Tests/AltCover.Api.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="..\nupkg\build\AltCover.targets" Link="AltCover.targets" />
<EmbeddedResource Include="..\nupkg\build\AltCover.proj" Link="AltCover.proj" />
<EmbeddedResource Include="..\AltCover.Tests\CompressBoth.xml" Link="CompressBoth.xml" />
<EmbeddedResource Include="..\AltCover.Tests\Compressible.xml" Link="Compressible.xml" />
<EmbeddedResource Include="..\AltCover.Tests\CompressInterior.xml" Link="CompressInterior.xml" />
Expand Down
2 changes: 1 addition & 1 deletion AltCover.Api.Tests/FSApiTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ module FSApiTests =
Assembly
.GetExecutingAssembly()
.GetManifestResourceNames()
|> Seq.find _.EndsWith("AltCover.targets", StringComparison.Ordinal)
|> Seq.find _.EndsWith("AltCover.proj", StringComparison.Ordinal)

use stream =
Assembly
Expand Down
17 changes: 16 additions & 1 deletion AltCover.Engine/CecilEx.fs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ type internal AssemblyResolver() as self =
"dotnet|shared"
.Replace('|', Path.DirectorySeparatorChar)

let wingac =
"Microsoft.NET|assembly"
.Replace('|', Path.DirectorySeparatorChar)

let monogac =
"lib|mono|gac"
.Replace('|', Path.DirectorySeparatorChar)

let sources =
[ AssemblyConstants.packageEnv
[ Environment.GetEnvironmentVariable "ProgramFiles"
Expand All @@ -139,7 +147,14 @@ type internal AssemblyResolver() as self =
Some <| Path.Combine(shareLocal, dotnetShared)
AssemblyConstants.dotnetDir
|> Option.map (fun p -> Path.Combine(p, "shared"))
Some AssemblyConstants.nugetCache ]
Some AssemblyConstants.nugetCache
Some <| Path.Combine("usr", monogac)
Environment.GetEnvironmentVariable "WinDir"
|> Option.ofObj
|> Option.map (fun p -> Path.Combine(p, wingac))
Environment.GetEnvironmentVariable "MONO_GAC_PREFIX"
|> Option.ofObj
|> Option.map (fun p -> Path.Combine(p, monogac)) ]
|> List.choose id ]
|> List.concat
|> List.filter Directory.Exists
Expand Down
7 changes: 4 additions & 3 deletions AltCover.Engine/Json.fs
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,10 @@ module internal Json =
))

let tracked =
System.Collections.Generic.Dictionary<string, int *
NativeJson.Times *
NativeJson.Times>()
System.Collections.Generic.Dictionary<
string,
int * NativeJson.Times * NativeJson.Times
>()

x.Descendants(XName.Get "TrackedMethod")
|> Seq.iter (fun x ->
Expand Down
2 changes: 2 additions & 0 deletions AltCover.Engine/Runner.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,8 @@ module internal Runner =
|> J.getFirstOperandAsNumber
|> enum

use _ = fst pair

let hits =
Dictionary<string, Dictionary<int, PointVisit>>()

Expand Down
3 changes: 3 additions & 0 deletions AltCover.Engine/Strings.eo.resx
Original file line number Diff line number Diff line change
Expand Up @@ -471,4 +471,7 @@ Se la opcio ne ĉeestas, tiam la defaŭlta estas 'OC'.</value>
<data name="portable" xml:space="preserve">
<value>Laŭvola: porteblaj operacioj - priraporta raporto, kontroldosiero kaj registritaj datumoj samlokaj kun la registrilo.</value>
</data>
<data name="FailedToDelete" xml:space="preserve">
<value>Malsukcesis forigi dosieron {0}</value>
</data>
</root>
3 changes: 3 additions & 0 deletions AltCover.Engine/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -475,4 +475,7 @@ If the option is not present, then the default is 'OC'.</value>
<data name="portable" xml:space="preserve">
<value>Optional: portable operations - coverage report, control file and recorded data co-located with the recorder assembly</value>
</data>
<data name="FailedToDelete" xml:space="preserve">
<value>Failed to delete file {0}</value>
</data>
</root>
13 changes: 10 additions & 3 deletions AltCover.Engine/Tasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,20 @@ type RetryDelete() =
Justification = "MSBuild tasks use arrays")>]
member val Files: string array = [||] with get, set

member internal self.Write message =
``base``.Log.LogMessage(MessageImportance.High, message)
[<SuppressMessage("Gendarme.Rules.Performance",
"AvoidUnusedParametersRule",
Justification = "Replace the raw exception dump")>]
member internal self.Write0 (o: string -> unit) (f: string) (_: string) : unit =
CommandLine.Format.Local("FailedToDelete", f) |> o

member internal self.Write (f: string) (dummy: string) : unit =
self.Write0 (``base``.Log.LogWarning) f dummy

override self.Execute() =
if self.Files.IsNotNull then
self.Files
|> Seq.filter File.Exists
|> Seq.iter (CommandLine.I.doRetry File.Delete self.Write 10 1000 0)
|> Seq.iter (fun f ->
(CommandLine.I.doRetry File.Delete (self.Write f) 100 100 0 f))

true
4 changes: 2 additions & 2 deletions AltCover.PowerShell/Command.fs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ type InvokeAltCoverCommand() =
member val Single: SwitchParameter = SwitchParameter(false) with get, set

/// <summary>
/// <para type="description">Do not record branch coverage. Is not compatible with, the -ReportFormat "ncover" option. Incompatible with `-BranchCover`.</para>
/// <para type="description">Do not record branch coverage. Is not compatible with the -ReportFormat "ncover" option. Incompatible with `-BranchCover`.</para>
/// </summary>
[<Parameter(ParameterSetName = "Instrument",
Mandatory = false,
Expand All @@ -517,7 +517,7 @@ type InvokeAltCoverCommand() =
member val LineCover: SwitchParameter = SwitchParameter(false) with get, set

/// <summary>
/// <para type="description">Do not record line coverage. Is not compatible with, the -ReportFormat "ncover" option. Incompatible with `-LineCover`.</para>
/// <para type="description">Do not record line coverage. Is not compatible with the -ReportFormat "ncover" option. Incompatible with `-LineCover`.</para>
/// </summary>
[<Parameter(ParameterSetName = "Instrument",
Mandatory = false,
Expand Down
6 changes: 2 additions & 4 deletions AltCover.Recorder.Tests/Adapter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,8 @@ module Adapter =
Definitive = false }

let internal invokeIssue71Wrapper<'T when 'T :> System.Exception>
(
(unique: string),
(called: bool array)
) =
((unique: string), (called: bool array))
=
let constructor =
typeof<'T>
.GetConstructor([| typeof<System.String> |])
Expand Down
2 changes: 1 addition & 1 deletion AltCover.Tests/AltCover.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<EmbeddedResource Include="AltCover.Usage.txt" />
<EmbeddedResource Include="AltCover.Runner.Usage.txt" />
<EmbeddedResource Include="coverage-04.xsd" />
<EmbeddedResource Include="..\nupkg\build\AltCover.targets" Link="AltCover.targets" />
<EmbeddedResource Include="..\nupkg\build\AltCover.proj" Link="AltCover.proj" />
<EmbeddedResource Include="HandRolledMonoCoverage.xml" />
<EmbeddedResource Include="Sample1WithOpenCover.xml" />
<EmbeddedResource Include="Sample1ClassExclusion.xml" />
Expand Down
2 changes: 1 addition & 1 deletion AltCover.Tests/Runner.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ module AltCoverRunnerTests =
Assembly
.GetExecutingAssembly()
.GetManifestResourceNames()
|> Seq.find _.EndsWith("AltCover.targets", StringComparison.Ordinal)
|> Seq.find _.EndsWith("AltCover.proj", StringComparison.Ordinal)

use stream =
Assembly
Expand Down
18 changes: 12 additions & 6 deletions AltCover.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,10 @@ module AltCoverTests =
Directory.GetFiles(path, "*.pdb", SearchOption.AllDirectories)

files
|> Seq.filter (_.StartsWith(exclude, StringComparison.OrdinalIgnoreCase) >> not)
|> Seq.filter (
_.StartsWith(exclude, StringComparison.OrdinalIgnoreCase)
>> not
)
|> Seq.filter (fun p -> Path.ChangeExtension(p, ".dll") |> File.Exists)
|> Seq.iter (fun p ->
let dll = Path.ChangeExtension(p, ".dll")
Expand All @@ -326,8 +329,8 @@ module AltCoverTests =

match pdb with
| Some name -> Assert.That(name, Is.EqualTo normalized)
//| _ ->
// raise <| InvalidOperationException((sprintf "%A for %A" dll normalized))
//| _ ->
// raise <| InvalidOperationException((sprintf "%A for %A" dll normalized))
with :? BadImageFormatException ->
())

Expand All @@ -348,7 +351,10 @@ module AltCoverTests =
Directory.GetFiles(path, "*.pdb", SearchOption.AllDirectories)

files
|> Seq.filter (_.StartsWith(exclude, StringComparison.OrdinalIgnoreCase) >> not)
|> Seq.filter (
_.StartsWith(exclude, StringComparison.OrdinalIgnoreCase)
>> not
)
|> Seq.filter (fun p -> Path.ChangeExtension(p, ".dll") |> File.Exists)
|> Seq.iter (fun p ->
let dll0 = Path.ChangeExtension(p, ".dll")
Expand Down Expand Up @@ -383,8 +389,8 @@ module AltCoverTests =
Assert.That(name, Is.EqualTo normalized)
AltCover.ProgramDatabase.readSymbols def
Assert.That(def.MainModule.HasSymbols, def.MainModule.FileName)
//| _ ->
// raise <| InvalidOperationException((sprintf "%A for %A" dll normalized))
//| _ ->
// raise <| InvalidOperationException((sprintf "%A for %A" dll normalized))
with :? BadImageFormatException ->
())
finally
Expand Down
21 changes: 19 additions & 2 deletions AltCover.Tests/Tests3.fs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ module AltCoverTests3 =
Assembly
.GetExecutingAssembly()
.GetManifestResourceNames()
|> Seq.find _.EndsWith("AltCover.targets", StringComparison.Ordinal)
|> Seq.find _.EndsWith("AltCover.proj", StringComparison.Ordinal)

use stream =
Assembly
Expand Down Expand Up @@ -4899,14 +4899,31 @@ module AltCoverTests3 =
monitor ("Hello")
test <@ builder.ToString() = "Hello" @>

let write0 =
subject
.GetType()
.GetMethod("Write0", BindingFlags.NonPublic ||| BindingFlags.Instance)

let mutable written = "written"

write0.Invoke(
subject,
[| (fun x -> written <- x)
"xx"
"yy" |]
)
|> ignore

test <@ written = "Failed to delete file xx" @>

let write =
subject
.GetType()
.GetMethod("Write", BindingFlags.NonPublic ||| BindingFlags.Instance)

let ex =
Assert.Throws<TargetInvocationException>(fun () ->
write.Invoke(subject, [| "xx" |]) |> ignore)
write.Invoke(subject, [| "xx"; "yy" |]) |> ignore)

test <@ ex.InnerException.GetType().FullName = "System.InvalidOperationException" @>
// Recorder.fs => Recorder.Tests
1 change: 1 addition & 0 deletions AltCover.sln
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ 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\AltCover.proj = nupkg\build\AltCover.proj
nupkg\build\AltCover.props = nupkg\build\AltCover.props
nupkg\build\AltCover.targets = nupkg\build\AltCover.targets
Build\Apply-Xslt.ps1 = Build\Apply-Xslt.ps1
Expand Down
8 changes: 4 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<PackageVersion Include="AltCode.Fake.DotNet.Gendarme" Version="5.23.0.42" />
<PackageVersion Include="AltCode.Dixon" Version="2022.12.6.11014" />
<PackageVersion Include="altcode.gendarme" Version="2023.12.27.19054" />
<PackageVersion Include="altcover" Version="8.8.10" />
<PackageVersion Include="AltCover.Api" Version="8.8.10" />
<PackageVersion Include="AltCover.Fake" Version="8.8.10" />
<PackageVersion Include="altcover" Version="8.8.21" />
<PackageVersion Include="AltCover.Api" Version="8.8.21" />
<PackageVersion Include="AltCover.Fake" Version="8.8.21" />
<PackageVersion Include="Avalonia" Version="11.0.10" />
<PackageVersion Include="Avalonia.Desktop" Version="11.0.10" />
<PackageVersion Include="Avalonia.Themes.Fluent" Version="11.0.10" />
Expand All @@ -21,7 +21,7 @@
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="CsvTextFieldParser" Version="1.2.2" />
<PackageVersion Include="DotNet.ReproducibleBuilds" Version="1.1.1" />
<PackageVersion Include="Expecto" Version="10.1.0" />
<PackageVersion Include="Expecto" Version="10.2.1" />
<PackageVersion Include="Expecto.TestResults" Version="8.13.2" />
<PackageVersion Include="FAKE.Core.Environment" Version="6.0.0" />
<PackageVersion Include="FAKE.Core.Process" Version="6.0.0" />
Expand Down
1 change: 1 addition & 0 deletions RegressionTesting/issue156/Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
</PackageReference>
<PackageReference Include="MSTest.TestFramework" />
<PackageReference Include="MSTest.TestAdapter" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ClassLibrary1\ClassLibrary1.csproj" />
Expand Down
10 changes: 8 additions & 2 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
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 27)
# (Habu series release 28)
* [BREAKING; BUGFIX] Issue #206 : Update to net6+ for `dotnet test` integration and respect the `$(IsTestProject)` setting from the `Microsoft.NET.Test.Sdk` package.
* Simplify the use of the AltCover MSBuild tasks via the associated package-level `.targets` file by not even including the `VSTest` integration unless both `'$(AltCover)' == 'true' AND '$(IsTestProject)' == 'true'`.
* Mitigate instances of `System.IO.IOException: The process cannot access the file '[coverage report]' because it is being used by another process.`
* Explicitly add GAC locations to the paths inspected for dependency resolution

# 8.8.10 (Habu series release 27)
* [BUGFIX] Add `Json` member to the report format enumerations for the typesafe API and for the `InvokeAltCover` cmdlet.
* [BUGFIX] Issue #214 - patch Mono.Cecil to use FIPS compliant algorithm
* [BUGFIX] Issue #214 : patch Mono.Cecil to use FIPS compliant algorithm
* [Enhancement] Discussion #206, maybe also Issue #203 : Option `--portable` and equivalent APIs to place the coverage report file and related coverage data in the same folder as the recorder assembly, wherever that might be, allowing the whole instrumented folder structure to be moved into another file structure (e.g. different machine, different OS).

# 8.7.3 (Habu series release 26)
Expand Down
8 changes: 4 additions & 4 deletions Samples/Sample7/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ module Problematic =

for row = 0 to g.Height do
for col = 0 to g.Width do
Assert.AreEqual(
Assert.That(
System.Drawing.Rectangle(col, row, col, row),
g.Rectangle(col, row)
Is.EqualTo(g.Rectangle(col, row))
)

[<Test>]
Expand All @@ -64,9 +64,9 @@ module Problematic =

for row = 0 to g.Height do
for col = 0 to g.Width do
Assert.AreEqual(
Assert.That(
System.Drawing.Rectangle(col, row, col, row),
g.Rectangle(col, row)
Is.EqualTo(g.Rectangle(col, row))
)
finally
System.Console.WriteLine("Finally")
Expand Down
4 changes: 2 additions & 2 deletions Samples/Sample7/Sample7.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FsUnit" VersionOverride="5.6.0" />
<PackageReference Include="NUnit" VersionOverride="3.14.0" />
<PackageReference Include="FsUnit" />
<PackageReference Include="NUnit" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NUnit3TestAdapter">
<PrivateAssets>all</PrivateAssets>
Expand Down
Binary file removed ThirdParty/cecil/Mono.Cecil.pdb
Binary file not shown.
1 change: 1 addition & 0 deletions docs/AltCover.Cake/AltCover.Cake/PrepareOptions-apidoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class PrepareOptions
| [OutputDirectories](PrepareOptions/OutputDirectories-apidoc) { get; } | Gets the output directories (overridden by the MSBuild integration) |
| virtual [OutputRoot](PrepareOptions/OutputRoot-apidoc) { get; } | Corresponds to dotnet test option `/p:AltCoverOutputRoot` |
| virtual [PathFilter](PrepareOptions/PathFilter-apidoc) { get; } | Corresponds to command line option `-p, --pathFilter=VALUE` |
| virtual [Portable](PrepareOptions/Portable-apidoc) { get; } | Corresponds to command line option `--portable` |
| virtual [Report](PrepareOptions/Report-apidoc) { get; } | Gets or sets the value that corresponds to command line option `-r, --report=VALUE` |
| virtual [ReportFormat](PrepareOptions/ReportFormat-apidoc) { get; } | Corresponds to command line option `--reportFormat=VALUE` |
| virtual [Save](PrepareOptions/Save-apidoc) { get; } | Corresponds to command line option `--save` |
Expand Down
14 changes: 14 additions & 0 deletions docs/AltCover.Cake/AltCover.Cake/PrepareOptions/Portable-apidoc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# PrepareOptions.Portable property

Corresponds to command line option `--portable`

```csharp
public virtual bool Portable { get; }
```

## See Also

* class [PrepareOptions](../PrepareOptions-apidoc)
* namespace [AltCover.Cake](../../AltCover.Cake-apidoc)

<!-- DO NOT EDIT: generated by xmldocmd for AltCover.Cake.dll -->

0 comments on commit 3314400

Please sign in to comment.