Skip to content

Commit

Permalink
Merge branch 'develop/maintenance' into release/Habu
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGilham committed Apr 15, 2024
2 parents 9d0f1c4 + fc1d56b commit 0deb424
Show file tree
Hide file tree
Showing 66 changed files with 566 additions and 285 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
16 changes: 8 additions & 8 deletions 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 Expand Up @@ -73,20 +73,20 @@
</PackageReference>
<PackageReference Include="Mono.Cecil" Condition="'$(LocalCecil)' != 'true'" />
<Reference Include="Mono.Cecil" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Rocks" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.Rocks.dll</HintPath>
<HintPath>$(SolutionDir)\ThirdParty\cecil\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Mdb" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.Mdb.dll</HintPath>
<HintPath>$(SolutionDir)\ThirdParty\cecil\Mono.Cecil.Mdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Pdb" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.Pdb.dll</HintPath>
<HintPath>$(SolutionDir)\ThirdParty\cecil\Mono.Cecil.Pdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Rocks" Condition="'$(LocalCecil)' == 'true'">
<HintPath>$(SolutionDir)\ThirdParty\cecil\Mono.Cecil.Rocks.dll</HintPath>
</Reference>
<Reference Include="Unquote" Condition="'$(TargetFramework)' == 'net472'">
<HintPath>..\ThirdParty\Unquote.dll</HintPath>
</Reference>
</Reference>
</ItemGroup>

<ItemGroup>
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: 18 additions & 0 deletions AltCover.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,18 @@ module AltCoverTests =
let ShouldGetForeignPdbWithFallback () =
let path =
Path.Combine(SolutionDir(), "packages")

let exclude = Path.Combine(path, "altcover")

// Looking for the Mono.Options symbols
let files =
Directory.GetFiles(path, "*.pdb", SearchOption.AllDirectories)

files
|> 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 @@ -321,6 +328,8 @@ module AltCoverTests =

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

Expand All @@ -332,11 +341,18 @@ module AltCoverTests =

let path =
Path.Combine(SolutionDir(), "packages")

let exclude = Path.Combine(path, "altcover")

// Looking for the Mono.Options symbols
let files =
Directory.GetFiles(path, "*.pdb", SearchOption.AllDirectories)

files
|> 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 @@ -371,6 +387,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))
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
13 changes: 5 additions & 8 deletions AltCover.Toolkit/AltCover.Toolkit.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,16 @@
</PackageReference>
<PackageReference Include="Mono.Cecil" Condition="'$(LocalCecil)' != 'true'" />
<Reference Include="Mono.Cecil" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Rocks" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.Rocks.dll</HintPath>
<HintPath>$(MSBuildThisFileDirectory)\..\ThirdParty\cecil\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Mdb" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.Mdb.dll</HintPath>
<HintPath>$(MSBuildThisFileDirectory)\..\ThirdParty\cecil\Mono.Cecil.Mdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Pdb" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.Pdb.dll</HintPath>
<HintPath>$(MSBuildThisFileDirectory)\..\ThirdParty\cecil\Mono.Cecil.Pdb.dll</HintPath>
</Reference>
<Reference Include="Unquote" Condition="'$(TargetFramework)' == 'net472'">
<HintPath>..\ThirdParty\Unquote.dll</HintPath>
<Reference Include="Mono.Cecil.Rocks" Condition="'$(LocalCecil)' == 'true'">
<HintPath>$(MSBuildThisFileDirectory)\..\ThirdParty\cecil\Mono.Cecil.Rocks.dll</HintPath>
</Reference>
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
</Reference>
<PackageReference Include="Mono.Cecil" Condition="'$(LocalCecil)' != 'true'" />
<Reference Include="Mono.Cecil" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Rocks" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.Rocks.dll</HintPath>
<HintPath>$(SolutionDir)\ThirdParty\cecil\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Mdb" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.Mdb.dll</HintPath>
<HintPath>$(SolutionDir)\ThirdParty\cecil\Mono.Cecil.Mdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Pdb" Condition="'$(LocalCecil)' == 'true'">
<HintPath>..\ThirdParty\cecil\Mono.Cecil.Pdb.dll</HintPath>
<HintPath>$(SolutionDir)\ThirdParty\cecil\Mono.Cecil.Pdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Rocks" Condition="'$(LocalCecil)' == 'true'">
<HintPath>$(SolutionDir)\ThirdParty\cecil\Mono.Cecil.Rocks.dll</HintPath>
</Reference>
<Reference Include="Unquote" Condition="'$(TargetFramework)' == 'net472'">
<HintPath>..\ThirdParty\Unquote.dll</HintPath>
Expand Down
Loading

0 comments on commit 0deb424

Please sign in to comment.