Skip to content

Commit dcfea04

Browse files
committed
Apply fixes from T-Gro to avoid NRE
1 parent e1be127 commit dcfea04

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/Compiler/Facilities/Activity.fs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace FSharp.Compiler.Diagnostics
44

55
open System
66
open System.Diagnostics
7+
open Internal.Utilities.Library
78

89
[<RequireQualifiedAccess>]
910
module Activity =
@@ -12,12 +13,14 @@ module Activity =
1213
let private activitySource = new ActivitySource(activitySourceName)
1314

1415
let start name (tags: (string * string) seq) : IDisposable =
15-
match activitySource.StartActivity(name) |> Option.ofObj with
16-
| Some activity ->
16+
let activity = activitySource.StartActivity(name)
17+
18+
match activity with
19+
| null -> ()
20+
| activity ->
1721
for key, value in tags do
1822
activity.AddTag(key, value) |> ignore
1923

20-
activity :> IDisposable
21-
| None -> null
24+
activity
2225

2326
let startNoTags name : IDisposable = activitySource.StartActivity(name)

src/Compiler/Utilities/illib.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ type CancellableBuilder() =
997997

998998
match compRes with
999999
| ValueOrCancelled.Value res ->
1000-
(resource :> IDisposable).Dispose()
1000+
Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicFunctions.Dispose resource
10011001

10021002
match res with
10031003
| Choice1Of2 r -> ValueOrCancelled.Value r

0 commit comments

Comments
 (0)