@@ -1735,7 +1735,7 @@ and [<Sealed>] TcImports
17351735 m
17361736 ) =
17371737
1738- let startingErrorCount = DiagnosticsThreadStatics .DiagnosticsLogger.ErrorCount
1738+ let startingErrorCount = DiagnosticsAsyncState .DiagnosticsLogger.ErrorCount
17391739
17401740 // Find assembly level TypeProviderAssemblyAttributes. These will point to the assemblies that
17411741 // have class which implement ITypeProvider and which have TypeProviderAttribute on them.
@@ -1936,7 +1936,7 @@ and [<Sealed>] TcImports
19361936 with RecoverableException e ->
19371937 errorRecovery e m
19381938
1939- if startingErrorCount < DiagnosticsThreadStatics .DiagnosticsLogger.ErrorCount then
1939+ if startingErrorCount < DiagnosticsAsyncState .DiagnosticsLogger.ErrorCount then
19401940 error ( Error( FSComp.SR.etOneOrMoreErrorsSeenDuringExtensionTypeSetting (), m))
19411941
19421942 providers
@@ -2158,14 +2158,14 @@ and [<Sealed>] TcImports
21582158 (
21592159 ctok ,
21602160 r : AssemblyResolution
2161- ) : NodeCode <( _ * ( unit -> AvailableImportedAssembly list )) option > =
2162- node {
2161+ ) : Async <( _ * ( unit -> AvailableImportedAssembly list )) option > =
2162+ async {
21632163 CheckDisposed()
21642164 let m = r.originalReference.Range
21652165 let fileName = r.resolvedPath
21662166
21672167 let! contentsOpt =
2168- node {
2168+ async {
21692169 match r.ProjectReference with
21702170 | Some ilb -> return ! ilb.EvaluateRawContents()
21712171 | None -> return ProjectAssemblyDataResult.Unavailable true
@@ -2228,27 +2228,29 @@ and [<Sealed>] TcImports
22282228
22292229 // NOTE: When used in the Language Service this can cause the transitive checking of projects. Hence it must be cancellable.
22302230 member tcImports.RegisterAndImportReferencedAssemblies ( ctok , nms : AssemblyResolution list ) =
2231- node {
2231+ async {
22322232 CheckDisposed()
22332233
22342234 let tcConfig = tcConfigP.Get ctok
22352235
22362236 let runMethod =
22372237 match tcConfig.parallelReferenceResolution with
2238- | ParallelReferenceResolution.On -> NodeCode.Parallel
2239- | ParallelReferenceResolution.Off -> NodeCode.Sequential
2240-
2241- let! results =
2242- nms
2243- |> List.map ( fun nm ->
2244- node {
2245- try
2246- return ! tcImports.TryRegisterAndPrepareToImportReferencedDll( ctok, nm)
2247- with e ->
2248- errorR ( Error( FSComp.SR.buildProblemReadingAssembly ( nm.resolvedPath, e.Message), nm.originalReference.Range))
2249- return None
2250- })
2251- |> runMethod
2238+ | ParallelReferenceResolution.On -> Async.Parallel
2239+ | ParallelReferenceResolution.Off -> Async.SequentialImmediate
2240+
2241+ let! results = async {
2242+ use captureTasks = new CaptureDiagnosticsConcurrently( DiagnosticsAsyncState.DiagnosticsLogger)
2243+ return ! nms |> List.map ( fun nm ->
2244+ async {
2245+ use _ = UseDiagnosticsLogger captureTasks.LoggerForTask
2246+ try
2247+ return ! tcImports.TryRegisterAndPrepareToImportReferencedDll( ctok, nm)
2248+ with e ->
2249+ errorR ( Error( FSComp.SR.buildProblemReadingAssembly ( nm.resolvedPath, e.Message), nm.originalReference.Range))
2250+ return None
2251+ })
2252+ |> runMethod
2253+ }
22522254
22532255 let _dllinfos , phase2s = results |> Array.choose id |> List.ofArray |> List.unzip
22542256 fixupOrphanCcus ()
@@ -2282,7 +2284,7 @@ and [<Sealed>] TcImports
22822284 ReportWarnings warns
22832285
22842286 tcImports.RegisterAndImportReferencedAssemblies( ctok, res)
2285- |> NodeCode .RunImmediateWithoutCancellation
2287+ |> Async .RunImmediateWithoutCancellation
22862288 |> ignore
22872289
22882290 true
@@ -2383,7 +2385,7 @@ and [<Sealed>] TcImports
23832385 // we dispose TcImports is because we need to dispose type providers, and type providers are never included in the framework DLL set.
23842386 // If a framework set ever includes type providers, you will not have to worry about explicitly calling Dispose as the Finalizer will handle it.
23852387 static member BuildFrameworkTcImports ( tcConfigP : TcConfigProvider , frameworkDLLs , nonFrameworkDLLs ) =
2386- node {
2388+ async {
23872389 let ctok = CompilationThreadToken()
23882390 let tcConfig = tcConfigP.Get ctok
23892391
@@ -2460,7 +2462,7 @@ and [<Sealed>] TcImports
24602462 resolvedAssemblies |> List.choose tryFindEquivPrimaryAssembly
24612463
24622464 let! fslibCcu , fsharpCoreAssemblyScopeRef =
2463- node {
2465+ async {
24642466 if tcConfig.compilingFSharpCore then
24652467 // When compiling FSharp.Core.dll, the fslibCcu reference to FSharp.Core.dll is a delayed ccu thunk fixed up during type checking
24662468 return CcuThunk.CreateDelayed getFSharpCoreLibraryName, ILScopeRef.Local
@@ -2553,7 +2555,7 @@ and [<Sealed>] TcImports
25532555 dependencyProvider
25542556 ) =
25552557
2556- node {
2558+ async {
25572559 let ctok = CompilationThreadToken()
25582560 let tcConfig = tcConfigP.Get ctok
25592561
@@ -2571,7 +2573,7 @@ and [<Sealed>] TcImports
25712573 }
25722574
25732575 static member BuildTcImports ( tcConfigP : TcConfigProvider , dependencyProvider ) =
2574- node {
2576+ async {
25752577 let ctok = CompilationThreadToken()
25762578 let tcConfig = tcConfigP.Get ctok
25772579
@@ -2603,7 +2605,7 @@ let RequireReferences (ctok, tcImports: TcImports, tcEnv, thisAssemblyName, reso
26032605
26042606 let ccuinfos =
26052607 tcImports.RegisterAndImportReferencedAssemblies( ctok, resolutions)
2606- |> NodeCode .RunImmediateWithoutCancellation
2608+ |> Async .RunImmediateWithoutCancellation
26072609
26082610 let asms =
26092611 ccuinfos
0 commit comments