Skip to content

Commit

Permalink
record access simplifications from net8rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGilham committed Sep 24, 2023
1 parent fccb948 commit 195248a
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 70 deletions.
7 changes: 4 additions & 3 deletions AltCover.Engine/AltCover.fs
Original file line number Diff line number Diff line change
Expand Up @@ -615,13 +615,14 @@ module AltCover =
Primitive.LoggingOptions.Create() |> Primitive

static member Translate(options: Abstract.ILoggingOptions) =
{ Primitive.LoggingOptions.Create() with
Failure = options.Failure |> LoggingOptions.ActionAdapter
let tmp: Primitive.LoggingOptions =
{ Failure = options.Failure |> LoggingOptions.ActionAdapter
Warn = options.Warn |> LoggingOptions.ActionAdapter
Echo = options.Echo |> LoggingOptions.ActionAdapter
Info = options.Info |> LoggingOptions.ActionAdapter
Verbose = options.Verbose |> LoggingOptions.ActionAdapter }
|> Primitive

tmp |> Primitive

static member ActionAdapter(action: Action<String>) =
match action with
Expand Down
4 changes: 2 additions & 2 deletions AltCover.Engine/NativeJson.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1405,8 +1405,8 @@ module
| MethodPoint m -> visitMethodPoint s m
| BranchPoint b -> visitBranchPoint s b
| AfterMethod m -> visitAfterMethod s m
| AfterType _ -> visitAfterType s
| AfterModule _ -> visitAfterModule s
| AfterType -> visitAfterType s
| AfterModule -> visitAfterModule s
| _ -> s

let result =
Expand Down
4 changes: 2 additions & 2 deletions AltCover.Engine/OpenCover.fs
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,8 @@ module internal OpenCover =
| MethodPoint m -> visitMethodPoint s m
| BranchPoint b -> visitBranchPoint s b
| AfterMethod m -> visitAfterMethod s m
| AfterType _ -> visitAfterType s
| AfterModule _ -> visitAfterModule s
| AfterType -> visitAfterType s
| AfterModule -> visitAfterModule s
| Finish -> afterAll s
| _ -> s

Expand Down
2 changes: 1 addition & 1 deletion AltCover.Engine/Report.fs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ module internal Report =
head.Remove()

tail
| AfterModule _ ->
| AfterModule ->
Visitor.moduleReport <- head.ToString()
tail
| Finish -> s
Expand Down
76 changes: 31 additions & 45 deletions AltCover.Tests/Tests2.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1491,10 +1491,9 @@ has been prefixed with Ldc_I4_1 (1 byte)
let state =
{ raw with
RecordingMethodRef =
{ raw.RecordingMethodRef with
Visit = null
Push = recorder.[1]
Pop = recorder.[2] } }
{ Visit = null
Push = recorder.[1]
Pop = recorder.[2] } }

let countBefore =
recorder.Head.Body.Instructions.Count
Expand Down Expand Up @@ -1572,10 +1571,9 @@ has been prefixed with Ldc_I4_1 (1 byte)
let state =
{ raw with
RecordingMethodRef =
{ raw.RecordingMethodRef with
Visit = null
Push = recorder.[1]
Pop = recorder.[2] } }
{ Visit = null
Push = recorder.[1]
Pop = recorder.[2] } }

let countBefore =
target.Body.Instructions.Count
Expand Down Expand Up @@ -1645,10 +1643,9 @@ has been prefixed with Ldc_I4_1 (1 byte)
let state =
{ raw with
RecordingMethodRef =
{ raw.RecordingMethodRef with
Visit = null
Push = recorder.[1]
Pop = recorder.[2] } }
{ Visit = null
Push = recorder.[1]
Pop = recorder.[2] } }

let countBefore =
target.Body.Instructions.Count
Expand Down Expand Up @@ -1723,10 +1720,9 @@ has been prefixed with Ldc_I4_1 (1 byte)
let state =
{ raw with
RecordingMethodRef =
{ raw.RecordingMethodRef with
Visit = null
Push = recorder.[1]
Pop = recorder.[2] } }
{ Visit = null
Push = recorder.[1]
Pop = recorder.[2] } }

let countBefore =
target.Body.Instructions.Count
Expand Down Expand Up @@ -1799,10 +1795,9 @@ has been prefixed with Ldc_I4_1 (1 byte)
let state =
{ raw with
RecordingMethodRef =
{ raw.RecordingMethodRef with
Visit = null
Push = recorder.[1]
Pop = recorder.[2] } }
{ Visit = null
Push = recorder.[1]
Pop = recorder.[2] } }

let countBefore =
target.Body.Instructions.Count
Expand Down Expand Up @@ -1875,10 +1870,9 @@ has been prefixed with Ldc_I4_1 (1 byte)
let state =
{ raw with
RecordingMethodRef =
{ raw.RecordingMethodRef with
Visit = null
Push = recorder.[1]
Pop = recorder.[2] } }
{ Visit = null
Push = recorder.[1]
Pop = recorder.[2] } }

let countBefore =
target.Body.Instructions.Count
Expand Down Expand Up @@ -1973,10 +1967,9 @@ has been prefixed with Ldc_I4_1 (1 byte)
let state =
{ raw with
RecordingMethodRef =
{ raw.RecordingMethodRef with
Visit = recorder.[1]
Push = recorder.[1]
Pop = recorder.[2] } }
{ Visit = recorder.[1]
Push = recorder.[1]
Pop = recorder.[2] } }

let switch =
target.Body.Instructions
Expand Down Expand Up @@ -2128,10 +2121,9 @@ has been prefixed with Ldc_I4_1 (1 byte)
let state =
{ raw with
RecordingMethodRef =
{ raw.RecordingMethodRef with
Visit = method
Push = null
Pop = null }
{ Visit = method
Push = null
Pop = null }
MethodWorker = method.Body.GetILProcessor() }

let next = branches.Head.Start.Next
Expand Down Expand Up @@ -2227,10 +2219,9 @@ has been prefixed with Ldc_I4_1 (1 byte)
let state =
{ raw with
RecordingMethodRef =
{ raw.RecordingMethodRef with
Visit = method
Push = null
Pop = null }
{ Visit = method
Push = null
Pop = null }
MethodWorker = method.Body.GetILProcessor() }

let next = branches.Head.Start.Next
Expand Down Expand Up @@ -2311,10 +2302,9 @@ has been prefixed with Ldc_I4_1 (1 byte)
let state =
{ raw with
RecordingMethodRef =
{ raw.RecordingMethodRef with
Visit = method
Push = null
Pop = null }
{ Visit = method
Push = null
Pop = null }
MethodWorker = method.Body.GetILProcessor() }

let next = branches.Head.Start.Next
Expand Down Expand Up @@ -3142,11 +3132,7 @@ has been prefixed with Ldc_I4_1 (1 byte)
let v =
def''.MainModule.ImportReference visit

let r =
{ RecorderRefs.Build() with
Visit = v
Push = v
Pop = v }
let r = { Visit = v; Push = v; Pop = v }

let state' =
{ state with
Expand Down
15 changes: 7 additions & 8 deletions AltCover.Toolkit/OpenCover.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1123,14 +1123,13 @@ coverlet on Tests.AltCoverRunnerTests/PostprocessShouldRestoreDegenerateOpenCove
records
|> Seq.fold
(fun state r ->
{ state with
Hash = accumulate r.Hash state.Hash
Token = accumulate r.Token state.Token
Name = accumulate r.Name state.Name
Strategy = r.Strategy @ state.Strategy
Entry = r.Entry @ state.Entry
Exit = r.Exit @ state.Exit
Uid = index + 1 })
{ Hash = accumulate r.Hash state.Hash
Token = accumulate r.Token state.Token
Name = accumulate r.Name state.Name
Strategy = r.Strategy @ state.Strategy
Entry = r.Entry @ state.Entry
Exit = r.Exit @ state.Exit
Uid = index + 1 })
{ Hash = String.Empty
Token = String.Empty
Name = String.Empty
Expand Down
16 changes: 7 additions & 9 deletions Build/targets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,9 @@ module Targets =
| Some path ->
try // detect if we have the SDK
DotNet.info (fun opt ->
{ opt with
Common =
{ dotnetOptions opt.Common with
DotNetCliPath = path } })
{ Common =
{ dotnetOptions opt.Common with
DotNetCliPath = path } })
|> ignore

perhaps
Expand Down Expand Up @@ -4986,11 +4985,10 @@ module Targets =
Environment.SetEnvironmentVariable("platform", "x86")

DotNet.info (fun o' ->
{ o' with
Common =
{ o'.Common with
WorkingDirectory = s
DotNetCliPath = dotnetPath86 |> Option.get } })
{ Common =
{ o'.Common with
WorkingDirectory = s
DotNetCliPath = dotnetPath86 |> Option.get } })
|> printfn "%A"

printfn "Build the sample2 code as x86"
Expand Down

0 comments on commit 195248a

Please sign in to comment.