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 Mar 21, 2023
2 parents 8061580 + ac05098 commit a51f588
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 15 deletions.
53 changes: 43 additions & 10 deletions AltCover.Engine/CecilEx.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ open System.Reflection

open Mono.Cecil
open Mono.Cecil.Cil
open Mono.Cecil.Metadata

module AssemblyConstants =
let internal nugetCache =
Expand All @@ -25,6 +24,31 @@ module AssemblyConstants =
"packages"
)

let internal dotnetDir =
let list =
Environment
.GetEnvironmentVariable("PATH")
.Split([| Path.PathSeparator |])
|> Seq.map (fun p -> p.Trim([| '"' |]))

let files = [ "dotnet"; "dotnet.exe" ]

list
|> Seq.tryFind (fun p ->
files
|> List.exists (fun f -> File.Exists(Path.Combine(p, f))))

let internal packageEnv =
let e =
Environment.GetEnvironmentVariable "NUGET_PACKAGES"
|> Option.ofObj
|> (Option.defaultValue String.Empty)

e.Split([| Path.PathSeparator |])
|> Seq.map (fun p -> p.Trim([| '"' |]))
|> Seq.filter (String.IsNullOrWhiteSpace >> not)
|> Seq.toList

let internal resolutionTable =
Dictionary<string, AssemblyDefinition>()

Expand Down Expand Up @@ -98,20 +122,29 @@ type internal AssemblyResolver() as self =
"|usr|share"
.Replace('|', Path.DirectorySeparatorChar)

let shared =
let shareLocal =
"|usr|local|share"
.Replace('|', Path.DirectorySeparatorChar)

let dotnetShared =
"dotnet|shared"
.Replace('|', Path.DirectorySeparatorChar)


let sources =
[ Environment.GetEnvironmentVariable "NUGET_PACKAGES"
Path.Combine(
Environment.GetEnvironmentVariable "ProgramFiles"
[ AssemblyConstants.packageEnv
[ Environment.GetEnvironmentVariable "ProgramFiles"
|> Option.ofObj
|> (Option.defaultValue share),
shared
)
Path.Combine(share, shared)
AssemblyConstants.nugetCache ]
|> Option.map (fun p -> Path.Combine(p, dotnetShared))
Some <| Path.Combine(share, dotnetShared)
Some <| Path.Combine(shareLocal, dotnetShared)
AssemblyConstants.dotnetDir
|> Option.map (fun p -> Path.Combine(p, "shared"))
Some AssemblyConstants.nugetCache ]
|> List.choose id ]
|> List.concat
|> List.filter Directory.Exists
|> List.distinct

let candidate source =
source
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ All `To do` and `On Hold` items are implicitly `up for grabs` and `Help Wanted`

tl;dr -- legacy framework/Mono support is not going away any time soon.

Despite earlier ruminations on the subject, as .net 4.7.2 can consume `netstandard2.0` libraries (everything but the recorder), and .net core 2+ can consume `net20` libraries (the recorder), legacy framework/Mono support continues after the release of .net 5 and until such a time as it is no longer possible to retain those API levels. Framework-targeted builds are kept to a minimum (executable entry-points and the recorder).
Despite earlier ruminations on the subject, as .net 4.7.2 can consume `netstandard2.0` libraries (everything but the recorder), and .net core 2+ can consume `net20` libraries (the recorder), legacy framework/Mono support continues until such a time as it is no longer possible to retain those API levels. Framework-targeted builds are kept to a minimum (executable entry-points and the recorder).

## Building

Expand All @@ -74,7 +74,7 @@ It is assumed that the following are available
.net SDK version as per global.json, or later minor version (`dotnet`) -- try https://www.microsoft.com/net/download
PowerShell Core 7.3.0 or later (`pwsh`) -- try https://github.com/powershell/powershell

The build may target `netstandard2.0` or `netcoreapp2.0/2.1` for deliverables, and `net6.0` for unit tests, but does not need any pre-6.0 runtimes to be installed (roll-forward policies are in place).
The build may target `netstandard2.0` or `netcoreapp2.0/2.1` for deliverables, and `net7.0` for unit tests, but does not need any pre-7.0 runtimes to be installed (roll-forward policies are in place).

**Note:** F# compiler code generation changes may cause incompatibilities due to some of the IL inspection performed by AltCover and its self-tests (e.g. by, at 5.0.201, generating non-closure function objects as static fields rather than locally instantiated objects)

Expand All @@ -101,13 +101,13 @@ Use `dotnet run --project .\Build\Build.fsproj --target <targetname>` to run to

#### If the build fails

If there's a passing build on the CI servers for this commit, then it's likely to be one of the [intermittent build failures](https://github.com/SteveGilham/altcover/wiki/Intermittent-build-issues) that can arise from the tooling used. The standard remedy is to try again.
If there's a passing build on the CI server for this commit, then it's likely to be one of the [intermittent build failures](https://github.com/SteveGilham/altcover/wiki/Intermittent-build-issues) that can arise from the tooling used. The standard remedy is to try again.

### Unit Tests

The tests in the `AltCover.Test` project are broadly ordered in the same dependency order as the code within the AltCover project (the later `Runner` tests aside). While working on any given layer, it would make sense to comment out all the tests for later files so as to show what is and isn't being covered by explicit testing, rather than merely being cascaded through.

Note that some of the unit tests expect that the separate build of test assemblies under Mono, full .net framework and .net core has taken place; these tests will be marked `ignore` when running the unit tests under `net472` and `pass` without doing anything under `net5.0` (as Expecto has no `ignore` option) if the build is not complete and thus those expected assemblies are not found e.g. in Visual Studio from clean, or after a build to targets like `Analysis` that only build code to be analysed.
Note that some of the unit tests expect that the separate build of test assemblies under Mono, full .net framework and .net core has taken place; these tests will be marked `ignore` when running the unit tests under `net472` and `pass` without doing anything under `net7.0` (as Expecto has no `ignore` option) if the build is not complete and thus those expected assemblies are not found e.g. in Visual Studio from clean, or after a build to targets like `Analysis` that only build code to be analysed.

## Thanks to

Expand Down
5 changes: 4 additions & 1 deletion ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
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 20)
# (Habu series release 21)
* [BUGFIX] Issue #179 - Improve and strengthen the heuristic for locating dependent assemblies, prossibly slightly speeding the look-up in the process by eliminating potentially duplicated effort.

# 8.6.40 (Habu series release 20)
* [BUGFIX] Issue #178 - possible NRE when instrumenting woven code e.g. using Fody
* [AvaloniaVisualizer] Now requires net5.0 or later
* Supports Fake 6.0.0. This is probably the last release that will support earlier versions, as 5.23.1 is almost 6 months old.
Expand Down

0 comments on commit a51f588

Please sign in to comment.