diff --git a/AltCover.Runner/Runner.fs b/AltCover.Runner/Runner.fs index 304112aa1..cb55dd06a 100644 --- a/AltCover.Runner/Runner.fs +++ b/AltCover.Runner/Runner.fs @@ -13,6 +13,11 @@ open Augment [] 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 = None @@ -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) diff --git a/Shadow.Tests/Tracer.fs b/Shadow.Tests/Tracer.fs index 55bfe7ddd..360845209 100644 --- a/Shadow.Tests/Tracer.fs +++ b/Shadow.Tests/Tracer.fs @@ -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 + [] type AltCoverCoreTests() = class @@ -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