@@ -11,6 +11,7 @@ open FSharp.Compiler.BuildGraph
11
11
open FSharp.Compiler .DiagnosticsLogger
12
12
open Internal.Utilities .Library
13
13
open FSharp.Compiler .Diagnostics
14
+ open FSharp.Compiler .Tokenization .FSharpTokenTag
14
15
15
16
module BuildGraphTests =
16
17
@@ -338,6 +339,45 @@ module BuildGraphTests =
338
339
339
340
Tasks.Parallel.Invoke( task1, task2)
340
341
342
+
343
+ type internal DiagnosticsLoggerWithCallback ( callback ) =
344
+ inherit CapturingDiagnosticsLogger( " test" )
345
+ override _.DiagnosticSink ( e , s ) =
346
+ base .DiagnosticSink( e, s)
347
+ callback e.Exception.Message |> ignore
348
+
349
+ [<Fact>]
350
+ let ``MultipleDiagnosticsLoggers capture diagnostics in correct order`` () =
351
+
352
+ let mutable prevError = " 000."
353
+
354
+ let errorCommitted msg =
355
+ // errors come in correct order
356
+ Assert.shouldBeTrue ( msg > prevError)
357
+ prevError <- msg
358
+
359
+ let work i = async {
360
+ for c in 'A' .. 'F' do
361
+ do ! Async.SwitchToThreadPool()
362
+ errorR ( ExampleException $" %03d {i}{c}" )
363
+ }
364
+
365
+ let tasks = Seq.init 100 work
366
+
367
+ let logger = DiagnosticsLoggerWithCallback errorCommitted
368
+ use _ = UseDiagnosticsLogger logger
369
+ tasks |> Seq.take 50 |> MultipleDiagnosticsLoggers.Parallel |> Async.Ignore |> Async.RunImmediate
370
+
371
+ // all errors committed
372
+ errorCountShouldBe 300
373
+
374
+ tasks |> Seq.skip 50 |> MultipleDiagnosticsLoggers.Sequential |> Async.Ignore |> Async.RunImmediate
375
+
376
+ errorCountShouldBe 600
377
+
378
+
379
+
380
+
341
381
[<Fact>]
342
382
let ``AsyncLocal diagnostics context flows correctly`` () =
343
383
0 commit comments