Skip to content

Commit

Permalink
Merge branch 'master' into release/Ezoguma
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGilham committed Jul 31, 2019
2 parents bcb985c + d892b98 commit 31d25fe
Show file tree
Hide file tree
Showing 76 changed files with 1,535 additions and 736 deletions.
27 changes: 13 additions & 14 deletions AltCover.Avalonia/MainWindow.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ open Avalonia.Threading
module UICommon =
let GetResourceString(key : string) =
let executingAssembly = System.Reflection.Assembly.GetExecutingAssembly()
let resources = new ResourceManager("AltCover.Visualizer.Strings", executingAssembly)
let resources = ResourceManager("AltCover.Visualizer.Strings", executingAssembly)
resources.GetString(key)

module Persistence =
Expand Down Expand Up @@ -133,18 +133,18 @@ module Persistence =

let attribute (x : XElement) a =
x.Attribute(XName.Get a).Value
|> Double.TryParse
|> Int32.TryParse
|> snd
config.XPathSelectElements("//Geometry")
|> Seq.iter (fun e ->
let width = Math.Min(attribute e "width", 750.0)
let height = Math.Min(attribute e "height", 550.0)
let width = Math.Min(attribute e "width", 750)
let height = Math.Min(attribute e "height", 550)
let bounds = w.Screens.Primary.WorkingArea
let x = Math.Min(Math.Max(attribute e "x", 0.0), bounds.Width - width)
let y = Math.Min(Math.Max(attribute e "y", 0.0), bounds.Height - height)
w.Height <- height
w.Width <- width
w.Position <- Point(x, y))
let x = Math.Min(Math.Max(attribute e "x", 0), bounds.Width - width)
let y = Math.Min(Math.Max(attribute e "y", 0), bounds.Height - height)
w.Height <- float height
w.Width <- float width
w.Position <- PixelPoint(x, y))

let clearGeometry() =
let file, config = EnsureFile()
Expand Down Expand Up @@ -470,10 +470,9 @@ type MainWindow() as this =
if scroll >= textLines.Length then textLines.Length - 1
else scroll
// Scroll into mid-view -- not entirely reliable
text.CaretIndex <- textLines
|> Seq.take capped
|> Seq.map (fun l -> l.Length + 1) //System.Environment.NewLine.Length)
|> Seq.sum
text.CaretIndex <- Seq.sumBy (fun (l:String) -> l.Length + 1) (textLines //System.Environment.NewLine.Length
|> Seq.take capped)

// TODO -- colouring
let root = x.m.Clone()
root.MoveToRoot()
Expand Down Expand Up @@ -692,7 +691,7 @@ type MainWindow() as this =
+ UICommon.GetResourceString "WebsiteLabel" + "</a></center>"
link.PointerPressed |> Event.add (fun _ -> armed <- true)
link.PointerLeave |> Event.add (fun _ -> armed <- false)
link.PointerReleased |> Event.add (fun _ -> ())
link.PointerReleased |> Event.add ignore
// Windows -- Process Start (url)
// Mac -- ("open", url)
// *nix -- ("xdg-open", url)
Expand Down
16 changes: 8 additions & 8 deletions AltCover.Avalonia/altcover.avalonia.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<OutputPath>$(SolutionDir)_Binaries/$(AssemblyName)/$(Configuration)+$(Platform)/</OutputPath>
<IntermediateOutputPath>$(SolutionDir)_Intermediate/$(AssemblyName)/$(Configuration)+$(Platform)/</IntermediateOutputPath>
<OutputPath>$(SolutionDir)_Binaries/$(AssemblyName).Avalonia/$(Configuration)+$(Platform)/</OutputPath>
<IntermediateOutputPath>$(SolutionDir)_Intermediate/$(AssemblyName).Avalonia/$(Configuration)+$(Platform)/</IntermediateOutputPath>
<OtherFlags>--tailcalls+</OtherFlags>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<SolutionDir Condition="'$(SolutionDir)' == '$(ProjectDir)'">$(ProjectDir)../</SolutionDir>
<OutputPath>$(SolutionDir)_Binaries/$(AssemblyName)/$(Configuration)+$(Platform)/</OutputPath>
<IntermediateOutputPath>$(SolutionDir)_Intermediate/$(AssemblyName)/$(Configuration)+$(Platform)/</IntermediateOutputPath>
<OtherFlags>--keyfile:$(SolutionDir)Build\Infrastructure.snk</OtherFlags>
<OutputPath>$(SolutionDir)_Binaries/$(AssemblyName).Avalonia/$(Configuration)+$(Platform)/</OutputPath>
<IntermediateOutputPath>$(SolutionDir)_Intermediate/$(AssemblyName).Avalonia/$(Configuration)+$(Platform)/</IntermediateOutputPath>
<OtherFlags Condition="Exists('$(SolutionDir)Build\Infrastructure.snk')">--keyfile:$(SolutionDir)Build\Infrastructure.snk</OtherFlags>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<WarningLevel>4</WarningLevel>
Expand Down Expand Up @@ -86,8 +86,8 @@

<ItemGroup>
<PackageReference Include="Avalonia.HtmlRenderer" Version="0.6.1" />
<PackageReference Include="Avalonia" Version="0.6.2-build6440-beta" />
<PackageReference Include="Avalonia.Desktop" Version="0.6.2-build6440-beta" />
<PackageReference Include="Avalonia" Version="0.8.0" />
<PackageReference Include="Avalonia.Desktop" Version="0.8.0" />
<PackageReference Condition="'$(OS)' == 'Windows_NT' AND '$(Configuration)'=='Release'" Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63127-02">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand All @@ -96,7 +96,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Update="FSharp.Core" Version="4.5.2" />
<PackageReference Update="FSharp.Core" Version="4.6.2" />
</ItemGroup>

</Project>
3 changes: 1 addition & 2 deletions AltCover.FSApi/OpenCover.fs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ module OpenCoverUtilities =
|> List.fold (fun (ki, ke) (_, bz) ->
let totalVisits =
bz
|> Seq.map (fun b ->
|> Seq.sumBy (fun b ->
b.GetAttribute("vc")
|> Int32.TryParse
|> snd)
|> Seq.sum

let h = bz |> Seq.head
h.SetAttribute
Expand Down
8 changes: 4 additions & 4 deletions AltCover.PowerShell/AltCover.PowerShell.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@
<HintPath>..\packages\FSharp.Core.4.5.2\lib\net45\FSharp.Core.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil">
<HintPath>..\packages\Mono.Cecil.0.10.3\lib\net40\Mono.Cecil.dll</HintPath>
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net40\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Mdb">
<HintPath>..\packages\Mono.Cecil.0.10.3\lib\net40\Mono.Cecil.Mdb.dll</HintPath>
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net40\Mono.Cecil.Mdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Pdb">
<HintPath>..\packages\Mono.Cecil.0.10.3\lib\net40\Mono.Cecil.Pdb.dll</HintPath>
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net40\Mono.Cecil.Pdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Rocks">
<HintPath>..\packages\Mono.Cecil.0.10.3\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
</Reference>
<Reference Include="Mono.Options">
<HintPath>..\packages\Mono.Options.Signed.0.2.3\lib\net45\Mono.Options.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion AltCover.PowerShell/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<packages>
<package id="BlackFox.CommandLine" version="1.0.0" targetFramework="net47" />
<package id="FSharp.Core" version="4.5.2" targetFramework="net47" />
<package id="Mono.Cecil" version="0.10.3" targetFramework="net47" />
<package id="Mono.Cecil" version="0.10.4" targetFramework="net47" />
<package id="Mono.Options.Signed" version="0.2.3" targetFramework="net47" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net47" />
<package id="PowerShellStandard.Library" version="5.1.0" targetFramework="net47" />
Expand Down
2 changes: 1 addition & 1 deletion AltCover.Visualizer/AltCover.Visualizer.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
<Private>False</Private>
</Reference>
<Reference Include="FSharp.Core">
<HintPath>..\packages\FSharp.Core.4.5.2\lib\net45\FSharp.Core.dll</HintPath>
<HintPath>..\packages\FSharp.Core.4.6.2\lib\net45\FSharp.Core.dll</HintPath>
</Reference>
<Reference Include="gdk-sharp">
<Private>False</Private>
Expand Down
6 changes: 3 additions & 3 deletions AltCover.Visualizer/Visualizer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ module Gui =

let private GetResourceString(key : string) =
let executingAssembly = System.Reflection.Assembly.GetExecutingAssembly()
let resources = new ResourceManager("AltCover.Visualizer.Resource", executingAssembly)
let resources = ResourceManager("AltCover.Visualizer.Resource", executingAssembly)
resources.GetString(key)

let private XmlIcon =
Expand Down Expand Up @@ -540,7 +540,7 @@ module Gui =

// -------------------------- UI set-up ---------------------------
let private InitializeHandler() =
let handler = new Handler()
let handler = Handler()
[ "mainWindow"; "fileOpenMenu"; "aboutVisualizer" ]
#if NETCOREAPP2_1
|> List.iter (fun name ->
Expand Down Expand Up @@ -1177,7 +1177,7 @@ module Gui =
|> Event.add (fun x ->
let executingAssembly = System.Reflection.Assembly.GetExecutingAssembly()
let resources =
new ResourceManager("AltCover.Visualizer.Resource", executingAssembly)
ResourceManager("AltCover.Visualizer.Resource", executingAssembly)
let format = resources.GetString("SelectFont")
#if NETCOREAPP2_1
let selector = new FontChooserDialog(format, handler.mainWindow)
Expand Down
6 changes: 3 additions & 3 deletions AltCover.Visualizer/altcover.visualizer.core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<SolutionDir Condition="'$(SolutionDir)' == '$(ProjectDir)'">$(ProjectDir)../</SolutionDir>
<OutputPath>$(SolutionDir)_Binaries/$(AssemblyName)/$(Configuration)+$(Platform)/</OutputPath>
<IntermediateOutputPath>$(SolutionDir)_Intermediate/$(AssemblyName)/$(Configuration)+$(Platform)/</IntermediateOutputPath>
<OtherFlags>--keyfile:$(SolutionDir)Build\Infrastructure.snk</OtherFlags>
<OtherFlags Condition="Exists('$(SolutionDir)Build\Infrastructure.snk')">--keyfile:$(SolutionDir)Build\Infrastructure.snk</OtherFlags>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<WarningLevel>4</WarningLevel>
Expand Down Expand Up @@ -81,11 +81,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Update="FSharp.Core" Version="4.5.2" />
<PackageReference Update="FSharp.Core" Version="4.6.2" />
</ItemGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="pwsh Prepare.ps1" />
<Exec Command="pwsh -NoProfile Prepare.ps1" />
</Target>

</Project>
2 changes: 1 addition & 1 deletion AltCover.Visualizer/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FSharp.Core" version="4.5.2" targetFramework="net47" />
<package id="FSharp.Core" version="4.6.2" targetFramework="net47" />
<package id="Mono.Options.Signed" version="0.2.3" targetFramework="net47" />
</packages>
8 changes: 4 additions & 4 deletions AltCover/AltCover.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@
<Reference Include="Microsoft.Build.Framework" />
<Reference Include="Microsoft.Build.Utilities.v4.0" />
<Reference Include="Mono.Cecil">
<HintPath>..\packages\Mono.Cecil.0.10.3\lib\net40\Mono.Cecil.dll</HintPath>
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net40\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Mdb">
<HintPath>..\packages\Mono.Cecil.0.10.3\lib\net40\Mono.Cecil.Mdb.dll</HintPath>
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net40\Mono.Cecil.Mdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Pdb">
<HintPath>..\packages\Mono.Cecil.0.10.3\lib\net40\Mono.Cecil.Pdb.dll</HintPath>
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net40\Mono.Cecil.Pdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Rocks">
<HintPath>..\packages\Mono.Cecil.0.10.3\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
</Reference>
<Reference Include="Mono.Options">
<HintPath>..\packages\Mono.Options.Signed.0.2.3\lib\net45\Mono.Options.dll</HintPath>
Expand Down
4 changes: 2 additions & 2 deletions AltCover/CommandLine.fs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ module internal CommandLine =
WriteColoured writer colour (fun w -> w.WriteLine(data))

let internal WriteErr line = Write Console.Error ConsoleColor.Yellow line
let internal WriteOut line = Write Console.Out ConsoleColor.White line
let internal WriteOut line = Write Console.Out Console.ForegroundColor line

let internal Filter line f =
if line
Expand Down Expand Up @@ -314,7 +314,7 @@ module internal CommandLine =
if ok then
stream.Position <- 0L
StrongNameKeyPair(stream)
else new NotSupportedException(x) |> raise
else NotSupportedException(x) |> raise

let internal ValidateStrongNameKey key x =
if ValidateFile key x then
Expand Down
11 changes: 5 additions & 6 deletions AltCover/Instrument.fs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ module internal Instrument =
| _ -> null
#endif

#if NETCOREAPP2_0
let private nugetCache =
Path.Combine
(Path.Combine
Expand All @@ -252,12 +251,15 @@ module internal Instrument =
let name = y.ToString()
if ResolutionTable.ContainsKey name then ResolutionTable.[name]
else
// Placate Gendarme here
let share = "|usr|share".Replace('|', Path.DirectorySeparatorChar)
let shared = "dotnet|shared".Replace('|', Path.DirectorySeparatorChar)
let candidate =
[ Environment.GetEnvironmentVariable "NUGET_PACKAGES"
Path.Combine(Environment.GetEnvironmentVariable "ProgramFiles"
|> Option.nullable
|> (Option.getOrElse "/usr/share"), "dotnet/shared")
"/usr/share/dotnet/shared"
|> (Option.getOrElse share), shared)
Path.Combine(share, shared)
nugetCache ]
|> List.filter (String.IsNullOrWhiteSpace >> not)
|> List.filter Directory.Exists
Expand Down Expand Up @@ -295,7 +297,6 @@ module internal Instrument =
hook.Invoke
(resolver, [| new AssemblyResolveEventHandler(ResolveFromNugetCache) :> obj |])
|> ignore
#endif

/// <summary>
/// Commit an instrumented assembly to disk
Expand Down Expand Up @@ -353,10 +354,8 @@ module internal Instrument =
let write (a : AssemblyDefinition) p pk =
use sink = File.Open(p, FileMode.Create, FileAccess.ReadWrite)
a.Write(sink, pk)
#if NETCOREAPP2_0
let resolver = assembly.MainModule.AssemblyResolver
HookResolver resolver
#endif
write assembly path pkey
finally
Directory.SetCurrentDirectory(here)
Expand Down
4 changes: 1 addition & 3 deletions AltCover/LCov.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ module internal LCov =
m.Attribute(X "excluded").Value <> "true"
&&
m.Descendants(X "seqpnt")
|> Seq.filter (fun s -> s.Attribute(X "excluded").Value <> "true")
|> Seq.isEmpty
|> not)
|> Seq.exists (fun s -> s.Attribute(X "excluded").Value <> "true"))
|> Seq.groupBy
(fun m ->
(m.Descendants(X "seqpnt") |> Seq.head).Attribute(X "document").Value)
Expand Down
23 changes: 10 additions & 13 deletions AltCover/Runner.fs
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,15 @@ module internal Runner =

covered

let InvariantParseDouble d = Double.TryParse(d, NumberStyles.Number, CultureInfo.InvariantCulture)

let StandardSummary (report : XDocument) (format : Base.ReportFormat) result =
let covered =
report
|> match format with
| Base.ReportFormat.NCover -> NCoverSummary
| _ -> OpenCoverSummary
|> Double.TryParse
|> InvariantParseDouble

let value =
match covered with
Expand Down Expand Up @@ -656,6 +658,10 @@ module internal Runner =
match format with
| Base.ReportFormat.OpenCoverWithTracking | Base.ReportFormat.OpenCover ->
let scoreToString raw = (sprintf "%.2f" raw).TrimEnd([| '0' |]).TrimEnd([| '.' |])
let stringToScore (node:XmlElement) name =
node.GetAttribute(name)
|> InvariantParseDouble
|> snd

let percentCover visits points =
if points = 0 then "0"
Expand Down Expand Up @@ -720,20 +726,11 @@ module internal Runner =

let crapScore (method : XmlElement) =
let coverage =
let cover =
method.GetAttribute("sequenceCoverage")
|> Double.TryParse
|> snd
let cover = stringToScore method "sequenceCoverage"
if cover > 0.0 then cover
else
method.GetAttribute("branchCoverage")
|> Double.TryParse
|> snd
else stringToScore method "branchCoverage"

let complexity =
method.GetAttribute("cyclomaticComplexity")
|> Double.TryParse
|> snd
let complexity = stringToScore method "cyclomaticComplexity"

let raw =
(Math.Pow(complexity, 2.0) * Math.Pow((1.0 - (coverage / 100.0)), 3.0)
Expand Down
3 changes: 2 additions & 1 deletion AltCover/Strings.eo.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
<value>Laŭvola: La dosierujo enhavanta asembleojn al instrumento (defaŭlta: aktuala dosierujo)</value>
</data>
<data name="o|outputDirectory=" xml:space="preserve">
<value>Laŭvola: La dosierujo ricevi la instrumentajn asembleojn kaj iliajn kunulojn (defaŭlte: sub-dosierujo '__Instrumented' de la aktuala dosierujo; aŭ '__Saved' se 'inplace' estas aro)</value>
<value>Laŭvola: La dosierujo ricevi la instrumentajn asembleojn kaj iliajn kunulojn (defaŭlte: sub-dosierujo '__Instrumented' de la aktuala dosierujo; aŭ '__Saved' se '--inplace' estas aro).
Vidu ankaŭ '--inplace'</value>
</data>
<data name="k|key=" xml:space="preserve">
<value>Laŭvola, multobla: iu ajn alia forta-nomo ŝlosilo por uzi</value>
Expand Down
3 changes: 2 additions & 1 deletion AltCover/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
<value>Optional: The folder containing assemblies to instrument (default: current directory)</value>
</data>
<data name="o|outputDirectory=" xml:space="preserve">
<value>Optional: The folder to receive the instrumented assemblies and their companions (default: sub-folder '__Instrumented' of the current directory; or '__Saved' if 'inplace' is set)</value>
<value>Optional: The folder to receive the instrumented assemblies and their companions (default: sub-folder '__Instrumented' of the current directory; or '__Saved' if '--inplace' is set).
See also '--inplace'</value>
</data>
<data name="k|key=" xml:space="preserve">
<value>Optional, multiple: any other strong-name key to use</value>
Expand Down
6 changes: 3 additions & 3 deletions AltCover/Tasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ type Prepare() =
member val OpenCover = true with get, set
member val InPlace = true with get, set
member val Save = true with get, set
member val Single = true |> not with get, set // work around Gendarme insistence on non-default values only
member val LineCover = true |> not with get, set
member val BranchCover = true |> not with get, set
member val Single = false with get, set // work around Gendarme insistence on non-default values only
member val LineCover = false with get, set
member val BranchCover = false with get, set
member val CommandLine : string array = [||] with get, set
member val SourceLink = false with get, set
member val Defer = false with get, set
Expand Down
Loading

0 comments on commit 31d25fe

Please sign in to comment.