Skip to content

Commit

Permalink
See about cross-version serialization issues from the CLR2 assembly t…
Browse files Browse the repository at this point in the history
…hat appeared on AppVeyor

  -- also learn that type Derived() = inherit Base() gets construction implemented as a suspicious recursive call
  • Loading branch information
SteveGilham committed Jan 30, 2018
1 parent 3aafbc7 commit 75af247
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions AltCover.Runner/Runner.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ open Augment
[<System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage>]
type Tracer = { Tracer : string }

type MonoTypeBinder (``type``:Type) =
inherit System.Runtime.Serialization.SerializationBinder()
override self.BindToType (_:string, _:string) =
``type``

module Runner =

let mutable internal recordingDirectory : Option<string> = None
Expand Down Expand Up @@ -109,6 +114,7 @@ module Runner =

use results = File.OpenRead(binpath)
let formatter = System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
formatter.Binder <- MonoTypeBinder(typeof<(string*int)>) // anything else is an error

let rec sink() = try
let hit = formatter.Deserialize(results) :?> (string*int)
Expand Down
6 changes: 6 additions & 0 deletions Shadow.Tests/Tracer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ open System.Reflection
open AltCover.Recorder
open NUnit.Framework

type UpdateBinder () =
inherit System.Runtime.Serialization.SerializationBinder()
override self.BindToType (_:string, _:string) =
typeof<(string*int)> // anything else is an error

[<TestFixture>]
type AltCoverCoreTests() = class

Expand Down Expand Up @@ -56,6 +61,7 @@ type AltCoverCoreTests() = class
member self.ReadResults (stream:Stream) =
let hits = List<(string*int)>()
let formatter = System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
formatter.Binder <- UpdateBinder()
let rec sink() = try
let hit = formatter.Deserialize(stream) :?> (string*int)
hit |> hits.Add
Expand Down

0 comments on commit 75af247

Please sign in to comment.