Skip to content

Commit

Permalink
Merge branch 'master' into release/Genbu
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGilham committed Dec 7, 2020
2 parents 770703d + 5d70f93 commit a7f6c7b
Show file tree
Hide file tree
Showing 40 changed files with 151 additions and 250 deletions.
4 changes: 2 additions & 2 deletions .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": "4.7.1",
"version": "4.8.1",
"commands": [
"reportgenerator"
]
Expand All @@ -15,7 +15,7 @@
]
},
"xmldocmd": {
"version": "2.3.0",
"version": "2.3.1",
"commands": [
"xmldocmd"
]
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.100'
Expand All @@ -22,6 +24,8 @@ jobs:
- name: Setup
run: dotnet fake run ./Build/setup.fsx
- name: Build
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: dotnet fake run ./Build/build.fsx
- uses: actions/upload-artifact@v2
with:
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 @@ -55,7 +55,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="YoloDev.Expecto.TestSdk" Version="0.9.2" Condition="'$(TargetFramework)' != 'net472'" />
<PackageReference Include="Mono.Cecil" Version="0.11.2" />
Expand Down
13 changes: 4 additions & 9 deletions AltCover.DataCollector/AltCover.DataCollector.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks Condition="'$(Configuration)'=='Debug'">netstandard2.0;net472</TargetFrameworks>
Expand All @@ -12,16 +12,11 @@
<SolutionDir Condition="'$(SolutionDir)' == '$(ProjectDir)'">$(ProjectDir)../</SolutionDir>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(SolutionDir)\Build\Infrastructure.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<OutputPath>$(SolutionDir)_Binaries/$(AssemblyName)/$(Configuration)+$(Platform)/</OutputPath>
<IntermediateOutputPath>$(SolutionDir)_Intermediate/$(AssemblyName)/$(Configuration)+$(Platform)/</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<NoWarn>1701;1702;NU1603</NoWarn>
<OutputPath>$(SolutionDir)_Binaries/$(AssemblyName)/$(Configuration)+$(Platform)/</OutputPath>
<IntermediateOutputPath>$(SolutionDir)_Intermediate/$(AssemblyName)/$(Configuration)+$(Platform)/</IntermediateOutputPath>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE;DEBUG;CODE_ANALYSIS</DefineConstants>
</PropertyGroup>
Expand All @@ -31,7 +26,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net472" Version="1.0.0" Condition="'$(TargetFramework)' == 'net472'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net472" Version="1.0.0" Condition="'$(TargetFramework)' == 'net472'">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion AltCover.Engine/AltCover.Engine.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<PackageReference Include="System.ValueTuple" />
<!-- Last static linkable version; the local version of [Nullable] kills later version linkage -->
<!-- PackageReference Include="Manatee.Json" Version="11.0.4" / -->
<PackageReference Include="Manatee.Json" Version="13.0.3" />
<PackageReference Include="Manatee.Json" Version="13.0.4" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net472" Version="1.0.0" Condition="'$(TargetFramework)' == 'net472'">
<PrivateAssets>all</PrivateAssets>
Expand Down
83 changes: 40 additions & 43 deletions AltCover.Engine/Instrument.fs
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,13 @@ type internal InstrumentContext =

// Module to handle instrumentation visitor
module internal Instrument =
let private resources =
ResourceManager("AltCover.JSONFragments", Assembly.GetExecutingAssembly())
let version = typeof<AltCover.Recorder.Tracer>.Assembly.GetName().Version.ToString()
let internal resolutionTable = Dictionary<string, AssemblyDefinition>()

[<SuppressMessage("Microsoft.Maintainability", "CA1506",
Justification = "partitioned into closures")>]
module internal I =

let dependencies =
(resources.GetString "frameworkDependencies").Replace("version", version)
let runtime =
(resources.GetString "frameworkRuntime")
.Replace("AltCover.Recorder.g/version", "AltCover.Recorder.g/" + version)
let newLibraries =
(resources.GetString "frameworkLibraries")
.Replace("AltCover.Recorder.g/version", "AltCover.Recorder.g/" + version)

// Locate the method that must be called to register a code point for coverage visit.
// param name="assembly">The assembly containing the recorder method</param>
// returns>A representation of the method to call to signal a coverage visit.</returns>
Expand Down Expand Up @@ -426,10 +415,6 @@ module internal Instrument =
|> Seq.map (fun p -> p.Key)
|> Set.ofSeq

let rawDependencies =
(JsonValue.Parse dependencies).Object
|> Seq.find (fun p -> p.Key = "dependencies")

let addFirst (properties : KeyValuePair<string, JsonValue> seq) (jsonObject:JsonObject) =
let existing = jsonObject |> Seq.toList
jsonObject.Clear()
Expand All @@ -441,37 +426,49 @@ module internal Instrument =
|> Seq.concat
|> Seq.iter (fun l -> jsonObject.Add(l.Key, l.Value))

match app |> Seq.tryFind (fun p -> p.Key = "dependencies") with
| None -> app
|> addFirst [rawDependencies]
| Some p ->
rawDependencies.Value.Object
|> Seq.filter (fun r ->
prior
|> Set.contains r.Key
|> not)
|> Seq.iter (fun r -> (p.Value.Object).Add(r.Key, r.Value))

(JsonValue.Parse runtime).Object
|> Seq.filter (fun r ->
prior
|> Set.contains (r.Key.Split('/') |> Seq.head)
|> not
&& targeted.ContainsKey(r.Key) |> not)
|> Seq.iter (fun r -> targeted.Add(r.Key, r.Value))
do

let dependencies = version |> sprintf """{"dependencies": {"AltCover.Recorder.g": "%s"}}"""
let updateDependencies () =
let rawDependencies =
(JsonValue.Parse dependencies).Object
|> Seq.find (fun p -> p.Key = "dependencies")

match app |> Seq.tryFind (fun p -> p.Key = "dependencies") with
| None -> app
|> addFirst [rawDependencies]
| Some p ->
let recorder = rawDependencies.Value.Object |> Seq.head
p.Value.Object.[recorder.Key] <- recorder.Value
updateDependencies()

let stripRecorderRefs (j:JsonObject) =
j.Keys
|> Seq.filter (fun k -> k.StartsWith("AltCover.Recorder.g/",
StringComparison.Ordinal))
|> Seq.toList
|> List.iter (j.Remove >> ignore)

do
let runtime = version |> sprintf """{"AltCover.Recorder.g/%s": {"runtime": { "AltCover.Recorder.g.dll": {}}}}"""
let updateRuntime() =
let runtimeObject = (JsonValue.Parse runtime).Object
stripRecorderRefs targeted
let recorder = runtimeObject |> Seq.head
targeted.[recorder.Key] <- recorder.Value
updateRuntime()

let libraries =
(oo |> Seq.find (fun p -> p.Key = "libraries")).Value.Object

let newlibs = (JsonValue.Parse newLibraries).Object
|> Seq.filter (fun r -> prior
|> Set.contains (r.Key.Split('/') |> Seq.head)
|> not
&& libraries.ContainsKey(r.Key) |> not)
|> Seq.rev

libraries
|> addFirst newlibs
do
let newLibraries = version |> sprintf """{"AltCover.Recorder.g/%s": {"type": "project", "serviceable": false, "sha512": "" }}"""
let updateLibraries () =
let newlibs = (JsonValue.Parse newLibraries).Object
stripRecorderRefs libraries
libraries
|> addFirst newlibs
updateLibraries()

o.GetIndentedString().Replace("\t\t", " ").Replace("\t", " ").Replace(" :", ":")

Expand Down Expand Up @@ -806,6 +803,6 @@ module internal Instrument =
Visitor.encloseState I.instrumentationVisitor (InstrumentContext.Build assemblies)

[<assembly: SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling",
Scope="member", Target="AltCover.Instrument+I+doTrack@620.#Invoke(AltCover.InstrumentContext,System.Tuple`2<System.Int32,System.String>)",
Scope="member", Target="AltCover.Instrument+I+doTrack@617.#Invoke(AltCover.InstrumentContext,System.Tuple`2<System.Int32,System.String>)",
Justification="Nice idea if you can manage it")>]
()
148 changes: 0 additions & 148 deletions AltCover.Engine/JSONFragments.resx

This file was deleted.

9 changes: 6 additions & 3 deletions AltCover.Engine/ProgramDatabase.fs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ module internal ProgramDatabase =
|> I.getEmbeddedPortablePdbEntry).IsNotNull))

let internal getPdbWithFallback(assembly : AssemblyDefinition) =
let path = assembly.MainModule.FileName
match getPdbFromImage assembly with
| None ->
let foldername = Path.GetDirectoryName assembly.MainModule.FileName
let filename = Path.GetFileName assembly.MainModule.FileName
| None when path
|> String.IsNullOrWhiteSpace
|> not -> // i.e. assemblies read from disk only
let foldername = Path.GetDirectoryName path
let filename = Path.GetFileName path
foldername :: (Seq.toList symbolFolders)
|> Seq.map (I.getSymbolsByFolder filename)
|> Seq.choose id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<IntermediateOutputPath>$(SolutionDir)_Intermediate/$(AssemblyName)/$(Configuration)+$(Platform)/</IntermediateOutputPath>
<DocumentationFile>$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<OtherFlags>--keyfile:$(SolutionDir)Build\Infrastructure.snk</OtherFlags>
<MSBuildWarningsAsMessages>MSB3277</MSBuildWarningsAsMessages>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Debug'">
Expand Down
Loading

0 comments on commit a7f6c7b

Please sign in to comment.