Skip to content

Commit

Permalink
Backport experiment
Browse files Browse the repository at this point in the history
  -- CLR2 tests run, but not when instrumented by AltCover
  -- System.IO.FileLoadException : Could not load file or assembly 'AltCover.Shadow, Version=5.3.0.0, Culture=neutral, PublicKeyToken=c02b1a9f5b7cade8' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
  • Loading branch information
SteveGilham committed Jun 19, 2019
1 parent 12d24e0 commit 3711c84
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 16 deletions.
3 changes: 3 additions & 0 deletions Shadow.Tests/Shadow.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@
<Reference Include="System.Numerics" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Unquote">
<HintPath>..\ThirdParty\Unquote.dll</HintPath>
</Reference>
<ProjectReference Include="..\AltCover.Recorder\AltCover.Shadow.fsproj">
<Name>AltCover.Shadow</Name>
<Project>{62480be3-4479-4a47-a23f-50858ecd74b3}</Project>
Expand Down
38 changes: 25 additions & 13 deletions Shadow.Tests/Tracer.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,22 @@ open System.Reflection
open AltCover.Recorder
open AltCover.Shadow
open NUnit.Framework
open Swensen.Unquote

[<TestFixture>]
type AltCoverCoreTests() =
class
let test' x message =
try
test x
with
| fail ->
let extended = message + Environment.NewLine + fail.Message
#if NET2
Assert.Fail(extended)
#else
AssertionFailedException(extended, fail)|> raise
#endif

[<Test>]
member self.WillNotConnectSpontaneously() =
Expand All @@ -37,7 +49,7 @@ type AltCoverCoreTests() =
let mutable client = Tracer.Create unique
try
client <- client.OnStart()
Assert.That(client.IsConnected(), Is.False)
test <@ client.IsConnected() |> not @>
with _ ->
client.Close()
reraise()
Expand All @@ -51,7 +63,7 @@ type AltCoverCoreTests() =
let mutable client = Tracer.Create unique
try
client <- client.OnStart()
Assert.That(client.IsConnected(), Is.True)
test <@ client.IsConnected() @>
finally
client.Close()

Expand All @@ -73,8 +85,8 @@ type AltCoverCoreTests() =
#else
| Tag.Both -> Both (formatter.ReadInt64(), formatter.ReadInt32())
#endif
| Tag.Table -> Assert.That (id, Is.Empty)
Assert.That (strike, Is.EqualTo 0)
| Tag.Table -> test <@ id = String.Empty @>
test <@ strike = 0 @>
let t = Dictionary<string, Dictionary<int, PointVisit>>()
let rec ``module`` () =
let m = formatter.ReadString()
Expand Down Expand Up @@ -102,7 +114,7 @@ type AltCoverCoreTests() =
| Tag.Both -> pv.Tracks.Add (Both (formatter.ReadInt64(), formatter.ReadInt32()))
#endif
tracking ()
| Tag.Table -> Assert.Fail ("No nested tables!!")
| Tag.Table -> test' <@ false @> "No nested tables!!"
| _ -> sequencePoint (pts - 1)
tracking()
else ``module``()
Expand Down Expand Up @@ -133,7 +145,7 @@ type AltCoverCoreTests() =
try
Adapter.VisitsClear()
Instance.trace <- client.OnStart()
Assert.That(Instance.trace.IsConnected(), "connection failed")
test' <@ Instance.trace.IsConnected() @> "connection failed"
Instance.IsRunner <- true
Adapter.VisitImplNone "name" 23
finally
Expand All @@ -143,9 +155,9 @@ type AltCoverCoreTests() =
Instance.trace <- save
use stream =
new DeflateStream(File.OpenRead(unique + ".0.acv"), CompressionMode.Decompress)
let results = self.ReadResults stream
Assert.That(Adapter.VisitsSeq() |> Seq.length, Is.EqualTo 0, "unexpected local write")
Assert.That(results, Is.EquivalentTo expected, "unexpected result")
let results = self.ReadResults stream |> Seq.toList
test' <@ Adapter.VisitsSeq() |> Seq.isEmpty @> "unexpected local write"
test' <@ results = expected @> "unexpected result"
finally
Adapter.Reset()

Expand Down Expand Up @@ -182,7 +194,7 @@ type AltCoverCoreTests() =
let mutable client = Tracer.Create tag
try
Instance.trace <- client.OnStart()
Assert.That(Instance.trace.IsConnected(), "connection failed")
test' <@ Instance.trace.IsConnected() @> "connection failed"
Instance.IsRunner <- true

Adapter.VisitsClear()
Expand All @@ -195,9 +207,9 @@ type AltCoverCoreTests() =
use stream =
new DeflateStream(File.OpenRead(unique + ".0.acv"), CompressionMode.Decompress)
let results = self.ReadResults stream
Assert.That(Adapter.VisitsSeq() |> Seq.length, Is.EqualTo 0, "unexpected local write")
Assert.That (results.Count, Is.EqualTo 2)
Assert.That(results |> Seq.skip 1, Is.EquivalentTo (expected |> Seq.skip 1), "unexpected result")
test' <@ Adapter.VisitsSeq() |> Seq.isEmpty @> "unexpected local write"
test <@ results.Count = 2 @>
test' <@ (results |> Seq.skip 1 |> Seq.head) = (expected |> Seq.skip 1 |> Seq.head) @> "unexpected result"
match results |> Seq.head with
| (n, p, Table d) ->
Assert.That (n, Is.Empty)
Expand Down
1 change: 1 addition & 0 deletions Shadow.Tests/altcover.recorder.tests.core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Unquote" Version="4.0.0" />
<PackageReference Include="coverlet.msbuild" Version="2.6.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
11 changes: 11 additions & 0 deletions Shadow.Tests2/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="2.3.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
19 changes: 16 additions & 3 deletions Shadow.Tests2/Shadow.Tests2.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<Error Condition="!Exists('..\packages\NUnit.3.12.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.12.0\build\NUnit.props'))" />
</Target>
<ItemGroup>
<Content Include="App.config" Condition="'$(OS)' == 'Windows_NT'" />
<Compile Include="..\Shadow.Tests\AssemblyInfo.fs">
<Link>AssemblyInfo.fs</Link>
</Compile>
Expand Down Expand Up @@ -98,13 +99,25 @@
<Reference Condition="'$(OS)' != 'Windows_NT'" Include="FSharp.Core">
<HintPath>..\packages\FSharp.Core.4.5.2\lib\net45\FSharp.Core.dll</HintPath>
</Reference>
<Reference Include="FSharp.PowerPack" Condition="'$(OS)' == 'Windows_NT'">
<HintPath>..\packages\FSPowerPack.Community.2.0.0.0\lib\Net20\FSharp.PowerPack.dll</HintPath>
</Reference>
<Reference Include="FSharp.PowerPack.Linq" Condition="'$(OS)' == 'Windows_NT'">
<HintPath>..\packages\FSPowerPack.Community.2.0.0.0\lib\Net20\FSharp.PowerPack.Linq.dll</HintPath>
</Reference>
<Reference Include="FSharp.PowerPack.Metadata" Condition="'$(OS)' == 'Windows_NT'">
<HintPath>..\packages\FSPowerPack.Community.2.0.0.0\lib\Net20\FSharp.PowerPack.Metadata.dll</HintPath>
</Reference>
<Reference Include="Unquote2" Condition="'$(OS)' == 'Windows_NT'">
<HintPath>..\ThirdParty\Unquote2.dll</HintPath>
</Reference>
<Reference Include="Unquote" Condition="'$(OS)' != 'Windows_NT'">
<HintPath>..\ThirdParty\Unquote.dll</HintPath>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.3.12.0\lib\net35\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="NUnit.System.Linq">
<HintPath>..\packages\NUnit.3.12.0\lib\net35\NUnit.System.Linq.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
<ProjectReference Include="..\AltCover.Recorder\AltCover.Shadow.fsproj">
Expand Down
2 changes: 2 additions & 0 deletions Shadow.Tests2/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Unquote" version="1.3.0" targetFramework="net40" />
<package id="FSPowerPack.Community" version="2.0.0.0" targetFramework="net35" />
<package id="NUnit" version="3.12.0" targetFramework="net20" />
</packages>
Binary file added ThirdParty/Unquote2.dll
Binary file not shown.
156 changes: 156 additions & 0 deletions ThirdParty/Unquote2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
Comparing files .\Unquote.il and .\UNQUOTE2.IL
***** .\Unquote.il
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
***** .\UNQUOTE2.IL
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 2:0:0:0
}
*****

***** .\Unquote.il
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....:
.ver 4:0:0:0
}
***** .\UNQUOTE2.IL
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....:
.ver 2:3:0:0
}
*****

***** .\Unquote.il
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
***** .\UNQUOTE2.IL
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 2:0:0:0
}
*****

***** .\Unquote.il
}
.assembly /*20000001*/ Unquote
{
***** .\UNQUOTE2.IL
}
.assembly /*20000001*/ Unquote2
{
*****

***** .\Unquote.il
int32) /* 0A000001 */ = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 )
.custom /*0C000004:0A000002*/ instance void [mscorlib/*23000001*/]System.Runtime.Versioning.TargetFrameworkAttribute/*0100001
E*/::.ctor(string) /* 0A000002 */ = ( 01 00 1A 2E 4E 45 54 46 72 61 6D 65 77 6F 72 6B // ....NETFramework

2C 56 65 72 73 69 6F 6E 3D 76 34 2E 30 01 00 54 // ,Version=v4.0..T

0E 14 46 72 61 6D 65 77 6F 72 6B 44 69 73 70 6C // ..FrameworkDispl

61 79 4E 61 6D 65 10 2E 4E 45 54 20 46 72 61 6D // ayName..NET Fram

65 77 6F 72 6B 20 34 ) // ework 4
.hash algorithm 0x00008004
.ver 0:0:0:0
}
***** .\UNQUOTE2.IL
int32) /* 0A000001 */ = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 )
.hash algorithm 0x00008004
.ver 1:3:0:0
}
*****

***** .\Unquote.il
}
.module Unquote.dll
// MVID: {4D977DC0-FCD7-ECF4-A745-0383C07D974D}
***** .\UNQUOTE2.IL
}
.module Unquote2.dll
// MVID: {4D977DC0-FCD7-ECF4-A745-0383C07D974D}
*****

***** .\Unquote.il

.class /*020000D2*/ private abstract auto ansi sealed '<StartupCode$Unquote>.$.NETFramework,Version=v4.0'.AssemblyAttributes
extends [mscorlib/*23000001*/]System.Object/*01000001*/
***** .\UNQUOTE2.IL

.class /*020000D3*/ private abstract auto ansi sealed beforefieldinit '<PrivateImplementationDetails$Unquote>'
extends [mscorlib/*23000001*/]System.Object/*01000001*/
*****

***** .\Unquote.il
{
} // end of class '<StartupCode$Unquote>.$.NETFramework,Version=v4.0'.AssemblyAttributes

.class /*020000D3*/ private abstract auto ansi sealed beforefieldinit '<PrivateImplementationDetails$Unquote>'
extends [mscorlib/*23000001*/]System.Object/*01000001*/
{
.class /*020000D4*/ explicit ansi sealed nested assembly beforefieldinit T7551_482Bytes@
***** .\UNQUOTE2.IL
{
.class /*020000D4*/ explicit ansi sealed nested assembly beforefieldinit T7551_482Bytes@
*****

***** .\Unquote.il
73 01 4E 46 53 68 61 72 70 2E 43 6F 72 65 2C 20 // s.NFSharp.Core,
56 65 72 73 69 6F 6E 3D 34 2E 30 2E 30 2E 30 2C // Version=4.0.0.0,
20 43 75 6C 74 75 72 65 3D 6E 65 75 74 72 61 6C // Culture=neutral
***** .\UNQUOTE2.IL
73 01 4E 46 53 68 61 72 70 2E 43 6F 72 65 2C 20 // s.NFSharp.Core,
56 65 72 73 69 6F 6E 3D 32 2E 33 2E 30 2E 30 2C // Version=2.3.0.0,
20 43 75 6C 74 75 72 65 3D 6E 65 75 74 72 61 6C // Culture=neutral
*****

***** .\Unquote.il
73 01 4E 46 53 68 61 72 70 2E 43 6F 72 65 2C 20 // s.NFSharp.Core,
56 65 72 73 69 6F 6E 3D 34 2E 30 2E 30 2E 30 2C // Version=4.0.0.0,
20 43 75 6C 74 75 72 65 3D 6E 65 75 74 72 61 6C // Culture=neutral
***** .\UNQUOTE2.IL
73 01 4E 46 53 68 61 72 70 2E 43 6F 72 65 2C 20 // s.NFSharp.Core,
56 65 72 73 69 6F 6E 3D 32 2E 33 2E 30 2E 30 2C // Version=2.3.0.0,
20 43 75 6C 74 75 72 65 3D 6E 65 75 74 72 61 6C // Culture=neutral
*****

***** .\Unquote.il
73 01 4E 46 53 68 61 72 70 2E 43 6F 72 65 2C 20 // s.NFSharp.Core,
56 65 72 73 69 6F 6E 3D 34 2E 30 2E 30 2E 30 2C // Version=4.0.0.0,
20 43 75 6C 74 75 72 65 3D 6E 65 75 74 72 61 6C // Culture=neutral
***** .\UNQUOTE2.IL
73 01 4E 46 53 68 61 72 70 2E 43 6F 72 65 2C 20 // s.NFSharp.Core,
56 65 72 73 69 6F 6E 3D 32 2E 33 2E 30 2E 30 2C // Version=2.3.0.0,
20 43 75 6C 74 75 72 65 3D 6E 65 75 74 72 61 6C // Culture=neutral
*****

***** .\Unquote.il
73 01 4E 46 53 68 61 72 70 2E 43 6F 72 65 2C 20 // s.NFSharp.Core,
56 65 72 73 69 6F 6E 3D 34 2E 30 2E 30 2E 30 2C // Version=4.0.0.0,
20 43 75 6C 74 75 72 65 3D 6E 65 75 74 72 61 6C // Culture=neutral
***** .\UNQUOTE2.IL
73 01 4E 46 53 68 61 72 70 2E 43 6F 72 65 2C 20 // s.NFSharp.Core,
56 65 72 73 69 6F 6E 3D 32 2E 33 2E 30 2E 30 2C // Version=2.3.0.0,
20 43 75 6C 74 75 72 65 3D 6E 65 75 74 72 61 6C // Culture=neutral
*****

***** .\Unquote.il
73 01 4E 46 53 68 61 72 70 2E 43 6F 72 65 2C 20 // s.NFSharp.Core,
56 65 72 73 69 6F 6E 3D 34 2E 30 2E 30 2E 30 2C // Version=4.0.0.0,
20 43 75 6C 74 75 72 65 3D 6E 65 75 74 72 61 6C // Culture=neutral
***** .\UNQUOTE2.IL
73 01 4E 46 53 68 61 72 70 2E 43 6F 72 65 2C 20 // s.NFSharp.Core,
56 65 72 73 69 6F 6E 3D 32 2E 33 2E 30 2E 30 2C // Version=2.3.0.0,
20 43 75 6C 74 75 72 65 3D 6E 65 75 74 72 61 6C // Culture=neutral
*****

***** .\Unquote.il
73 01 4E 46 53 68 61 72 70 2E 43 6F 72 65 2C 20 // s.NFSharp.Core,
56 65 72 73 69 6F 6E 3D 34 2E 30 2E 30 2E 30 2C // Version=4.0.0.0,
20 43 75 6C 74 75 72 65 3D 6E 65 75 74 72 61 6C // Culture=neutral
***** .\UNQUOTE2.IL
73 01 4E 46 53 68 61 72 70 2E 43 6F 72 65 2C 20 // s.NFSharp.Core,
56 65 72 73 69 6F 6E 3D 32 2E 33 2E 30 2E 30 2C // Version=2.3.0.0,
20 43 75 6C 74 75 72 65 3D 6E 65 75 74 72 61 6C // Culture=neutral
*****

4 changes: 4 additions & 0 deletions ThirdParty/Unquote2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- nuget Unquote 1.3.0
ildasm /all /out=Unquote.il Unquote.dll
-- patch per Unquote2.patch
C:\Windows\Microsoft.NET\Framework\v2.0.50727\ilasm.exe /dll /output=C:\Users\steve\Documents\GitHub\altcover\ThirdParty\Unquote2.dll /key=C:\Users\steve\Documents\GitHub\altcover\ThirdParty\ThirdParty.snk /resource=Unquote.res Unquote2.il

0 comments on commit 3711c84

Please sign in to comment.