From c62e89c210df7027a1ab0aec51a160944988e6e7 Mon Sep 17 00:00:00 2001 From: janusz Date: Sun, 17 Jul 2022 20:54:26 +0100 Subject: [PATCH 01/11] Allow parallel project analysis with an environment variable --- src/Compiler/Driver/CompilerImports.fs | 9 ++++++++- src/Compiler/Facilities/BuildGraph.fs | 8 +++++++- src/Compiler/Facilities/BuildGraph.fsi | 2 ++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Compiler/Driver/CompilerImports.fs b/src/Compiler/Driver/CompilerImports.fs index 1e63aa45dd5..310d011d29b 100644 --- a/src/Compiler/Driver/CompilerImports.fs +++ b/src/Compiler/Driver/CompilerImports.fs @@ -2152,6 +2152,13 @@ and [] TcImports node { CheckDisposed() + // TODO inject top-down from FSharpChecker + let runInParallel = + Environment.GetEnvironmentVariable("FCS_PARALLEL_PROJECTS_ANALYSIS") + |> bool.TryParse + |> function | true, runInParallel -> runInParallel | false, _ -> false + let runMethod = if runInParallel then NodeCode.Parallel else NodeCode.Sequential + let! results = nms |> List.map (fun nm -> @@ -2162,7 +2169,7 @@ and [] TcImports errorR (Error(FSComp.SR.buildProblemReadingAssembly (nm.resolvedPath, e.Message), nm.originalReference.Range)) return None }) - |> NodeCode.Sequential + |> runMethod let dllinfos, phase2s = results |> Array.choose id |> List.ofArray |> List.unzip fixupOrphanCcus () diff --git a/src/Compiler/Facilities/BuildGraph.fs b/src/Compiler/Facilities/BuildGraph.fs index 8227b96043f..6170d726d75 100644 --- a/src/Compiler/Facilities/BuildGraph.fs +++ b/src/Compiler/Facilities/BuildGraph.fs @@ -182,6 +182,12 @@ type NodeCode private () = return results.ToArray() } + + static member Parallel (computations: NodeCode<'T> seq) = + computations + |> Seq.map (fun (Node x) -> x) + |> Async.Parallel + |> Node type private AgentMessage<'T> = GetValue of AsyncReplyChannel> * callerCancellationToken: CancellationToken @@ -331,7 +337,7 @@ type GraphNode<'T>(retryCompute: bool, computation: NodeCode<'T>) = // occur, making sure we are under the protection of the 'try'. // For example, NodeCode's 'try/finally' (TryFinally) uses async.TryFinally which does // implicit cancellation checks even before the try is entered, as do the - // de-sugaring of 'do!' and other CodeCode constructs. + // de-sugaring of 'do!' and other NodeCode constructs. let mutable taken = false try diff --git a/src/Compiler/Facilities/BuildGraph.fsi b/src/Compiler/Facilities/BuildGraph.fsi index 798653f5f4b..76001d940da 100644 --- a/src/Compiler/Facilities/BuildGraph.fsi +++ b/src/Compiler/Facilities/BuildGraph.fsi @@ -65,6 +65,8 @@ type NodeCode = static member Sequential: computations: NodeCode<'T> seq -> NodeCode<'T[]> + static member Parallel: computations: (NodeCode<'T> seq) -> NodeCode<'T[]> + /// Execute the cancellable computation synchronously using the ambient cancellation token of /// the NodeCode. static member FromCancellable: computation: Cancellable<'T> -> NodeCode<'T> From 4431af5960bcaece76660ec3995faaf7d8d178ac Mon Sep 17 00:00:00 2001 From: janusz Date: Sun, 17 Jul 2022 21:56:14 +0100 Subject: [PATCH 02/11] reformat CompilerImports.fs --- src/Compiler/Driver/CompilerImports.fs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Compiler/Driver/CompilerImports.fs b/src/Compiler/Driver/CompilerImports.fs index 310d011d29b..991a9e23f6b 100644 --- a/src/Compiler/Driver/CompilerImports.fs +++ b/src/Compiler/Driver/CompilerImports.fs @@ -2156,8 +2156,15 @@ and [] TcImports let runInParallel = Environment.GetEnvironmentVariable("FCS_PARALLEL_PROJECTS_ANALYSIS") |> bool.TryParse - |> function | true, runInParallel -> runInParallel | false, _ -> false - let runMethod = if runInParallel then NodeCode.Parallel else NodeCode.Sequential + |> function + | true, runInParallel -> runInParallel + | false, _ -> false + + let runMethod = + if runInParallel then + NodeCode.Parallel + else + NodeCode.Sequential let! results = nms From ad26490d368fd5ddcd00550e3bac66a4a929e080 Mon Sep 17 00:00:00 2001 From: janusz Date: Sat, 17 Sep 2022 13:33:48 +0100 Subject: [PATCH 03/11] Wire in the flag from top-level, add an internal option to the FSC, add a constructor arg to the FSharpChecker. --- src/Compiler/Driver/CompilerConfig.fs | 9 ++++++ src/Compiler/Driver/CompilerConfig.fsi | 9 ++++++ src/Compiler/Driver/CompilerImports.fs | 16 +++------- src/Compiler/Driver/CompilerOptions.fs | 8 +++++ src/Compiler/Driver/fsc.fs | 21 +++++++++++- src/Compiler/Driver/fsc.fsi | 3 ++ src/Compiler/Service/IncrementalBuild.fs | 5 ++- src/Compiler/Service/IncrementalBuild.fsi | 3 +- src/Compiler/Service/service.fs | 39 +++++++++++++++++++---- src/Compiler/Service/service.fsi | 5 ++- 10 files changed, 96 insertions(+), 22 deletions(-) diff --git a/src/Compiler/Driver/CompilerConfig.fs b/src/Compiler/Driver/CompilerConfig.fs index 55ac85b9a3a..887027be72f 100644 --- a/src/Compiler/Driver/CompilerConfig.fs +++ b/src/Compiler/Driver/CompilerConfig.fs @@ -388,6 +388,11 @@ type MetadataAssemblyGeneration = | ReferenceOut of outputPath: string | ReferenceOnly +[] +type ParallelReferenceResolution = + | On + | Off + [] type TcConfigBuilder = { @@ -579,6 +584,8 @@ type TcConfigBuilder = mutable xmlDocInfoLoader: IXmlDocumentationInfoLoader option mutable exiter: Exiter + + mutable parallelReferenceResolution : ParallelReferenceResolution } // Directories to start probing in @@ -765,6 +772,7 @@ type TcConfigBuilder = sdkDirOverride = sdkDirOverride xmlDocInfoLoader = None exiter = QuitProcessExiter + parallelReferenceResolution = ParallelReferenceResolution.Off } member tcConfigB.FxResolver = @@ -1307,6 +1315,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) = member _.applyLineDirectives = data.applyLineDirectives member _.xmlDocInfoLoader = data.xmlDocInfoLoader member _.exiter = data.exiter + member _.parallelReferenceResolution = data.parallelReferenceResolution static member Create(builder, validate) = use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter diff --git a/src/Compiler/Driver/CompilerConfig.fsi b/src/Compiler/Driver/CompilerConfig.fsi index e200fb03e02..ef0a890ceb6 100644 --- a/src/Compiler/Driver/CompilerConfig.fsi +++ b/src/Compiler/Driver/CompilerConfig.fsi @@ -198,6 +198,11 @@ type MetadataAssemblyGeneration = /// Only emits the assembly as a reference assembly. | ReferenceOnly +[] +type ParallelReferenceResolution = + | On + | Off + [] type TcConfigBuilder = { @@ -480,6 +485,8 @@ type TcConfigBuilder = mutable xmlDocInfoLoader: IXmlDocumentationInfoLoader option mutable exiter: Exiter + + mutable parallelReferenceResolution: ParallelReferenceResolution } static member CreateNew: @@ -840,6 +847,8 @@ type TcConfig = member assumeDotNetFramework: bool member exiter: Exiter + + member parallelReferenceResolution : ParallelReferenceResolution /// Represents a computation to return a TcConfig. Normally this is just a constant immutable TcConfig, /// but for F# Interactive it may be based on an underlying mutable TcConfigBuilder. diff --git a/src/Compiler/Driver/CompilerImports.fs b/src/Compiler/Driver/CompilerImports.fs index 5977ff61b88..82e5bef377b 100644 --- a/src/Compiler/Driver/CompilerImports.fs +++ b/src/Compiler/Driver/CompilerImports.fs @@ -2141,19 +2141,13 @@ and [] TcImports node { CheckDisposed() - // TODO inject top-down from FSharpChecker - let runInParallel = - Environment.GetEnvironmentVariable("FCS_PARALLEL_PROJECTS_ANALYSIS") - |> bool.TryParse - |> function - | true, runInParallel -> runInParallel - | false, _ -> false + let tcConfig = tcConfigP.Get ctok + let runInParallel = tcConfig.parallelReferenceResolution let runMethod = - if runInParallel then - NodeCode.Parallel - else - NodeCode.Sequential + match runInParallel with + | ParallelReferenceResolution.On -> NodeCode.Parallel + | ParallelReferenceResolution.Off -> NodeCode.Sequential let! results = nms diff --git a/src/Compiler/Driver/CompilerOptions.fs b/src/Compiler/Driver/CompilerOptions.fs index 2a950193cc1..461feda16f8 100644 --- a/src/Compiler/Driver/CompilerOptions.fs +++ b/src/Compiler/Driver/CompilerOptions.fs @@ -1678,6 +1678,14 @@ let internalFlags (tcConfigB: TcConfigBuilder) = Some(InternalCommandLineOption("nodebugdata", rangeCmdArgs)), None ) + + CompilerOption( + "parallelreferenceresolution", + tagNone, + OptionUnit(fun () -> tcConfigB.parallelReferenceResolution <- ParallelReferenceResolution.On), + Some(InternalCommandLineOption("--parallelreferenceresolution", rangeCmdArgs)), + None + ) testFlag tcConfigB ] diff --git a/src/Compiler/Driver/fsc.fs b/src/Compiler/Driver/fsc.fs index fcf8578d2a9..5c4f0361dea 100644 --- a/src/Compiler/Driver/fsc.fs +++ b/src/Compiler/Driver/fsc.fs @@ -455,6 +455,20 @@ let TryFindVersionAttribute g attrib attribName attribs deterministic = [] type Args<'T> = Args of 'T +let getParallelReferenceResolutionFromEnvironment () = + Environment.GetEnvironmentVariable("FCS_ParallelReferenceResolution") + |> Option.ofObj + |> Option.bind (fun flag -> + match bool.TryParse flag with + | true, runInParallel -> + if runInParallel then + Some ParallelReferenceResolution.On + else + Some ParallelReferenceResolution.Off + | false, _ -> + None + ) + /// First phase of compilation. /// - Set up console encoding and code page settings /// - Process command line, flags and collect filenames @@ -543,7 +557,12 @@ let main1 exiter.Exit 1 tcConfigB.conditionalDefines <- "COMPILED" :: tcConfigB.conditionalDefines - + + // Override ParallelReferenceResolution set on the CLI with an environment setting if present. + match getParallelReferenceResolutionFromEnvironment() with + | Some parallelReferenceResolution -> tcConfigB.parallelReferenceResolution <- parallelReferenceResolution + | None -> () + // Display the banner text, if necessary if not bannerAlreadyPrinted then Console.Write(GetBannerText tcConfigB) diff --git a/src/Compiler/Driver/fsc.fsi b/src/Compiler/Driver/fsc.fsi index 12ed13273da..d4abe33a5a7 100644 --- a/src/Compiler/Driver/fsc.fsi +++ b/src/Compiler/Driver/fsc.fsi @@ -74,3 +74,6 @@ val CompileFromSyntaxTrees: tcImportsCapture: (TcImports -> unit) option * dynamicAssemblyCreator: (TcConfig * TcGlobals * string * ILModuleDef -> unit) option -> unit + +/// Read the parallelReferenceResolution flag from environment variables +val internal getParallelReferenceResolutionFromEnvironment : unit -> ParallelReferenceResolution option \ No newline at end of file diff --git a/src/Compiler/Service/IncrementalBuild.fs b/src/Compiler/Service/IncrementalBuild.fs index 45e50d441bf..914aca0fb55 100644 --- a/src/Compiler/Service/IncrementalBuild.fs +++ b/src/Compiler/Service/IncrementalBuild.fs @@ -1432,7 +1432,8 @@ type IncrementalBuilder(initialState: IncrementalBuilderInitialState, state: Inc keepAllBackgroundSymbolUses, enableBackgroundItemKeyStoreAndSemanticClassification, enablePartialTypeChecking: bool, - dependencyProvider + dependencyProvider, + parallelReferenceResolution ) = let useSimpleResolutionSwitch = "--simpleresolution" @@ -1513,6 +1514,8 @@ type IncrementalBuilder(initialState: IncrementalBuilderInitialState, state: Inc } |> Some + tcConfigB.parallelReferenceResolution <- parallelReferenceResolution + tcConfigB, sourceFilesNew // If this is a builder for a script, re-apply the settings inferred from the diff --git a/src/Compiler/Service/IncrementalBuild.fsi b/src/Compiler/Service/IncrementalBuild.fsi index cca65bcace1..a0efdd48401 100755 --- a/src/Compiler/Service/IncrementalBuild.fsi +++ b/src/Compiler/Service/IncrementalBuild.fsi @@ -263,7 +263,8 @@ type internal IncrementalBuilder = keepAllBackgroundSymbolUses: bool * enableBackgroundItemKeyStoreAndSemanticClassification: bool * enablePartialTypeChecking: bool * - dependencyProvider: DependencyProvider option -> + dependencyProvider: DependencyProvider option * + parallelReferenceResolution: ParallelReferenceResolution -> NodeCode /// Generalized Incremental Builder. This is exposed only for unit testing purposes. diff --git a/src/Compiler/Service/service.fs b/src/Compiler/Service/service.fs index e58b5be8261..520700a1fb6 100644 --- a/src/Compiler/Service/service.fs +++ b/src/Compiler/Service/service.fs @@ -292,7 +292,8 @@ type BackgroundCompiler suggestNamesForErrors, keepAllBackgroundSymbolUses, enableBackgroundItemKeyStoreAndSemanticClassification, - enablePartialTypeChecking + enablePartialTypeChecking, + parallelReferenceResolution ) as self = let beforeFileChecked = Event() @@ -419,7 +420,8 @@ type BackgroundCompiler keepAllBackgroundSymbolUses, enableBackgroundItemKeyStoreAndSemanticClassification, enablePartialTypeChecking, - dependencyProvider + dependencyProvider, + parallelReferenceResolution ) match builderOpt with @@ -1211,7 +1213,8 @@ type FSharpChecker suggestNamesForErrors, keepAllBackgroundSymbolUses, enableBackgroundItemKeyStoreAndSemanticClassification, - enablePartialTypeChecking + enablePartialTypeChecking, + parallelReferenceResolution ) = let backgroundCompiler = @@ -1224,7 +1227,8 @@ type FSharpChecker suggestNamesForErrors, keepAllBackgroundSymbolUses, enableBackgroundItemKeyStoreAndSemanticClassification, - enablePartialTypeChecking + enablePartialTypeChecking, + parallelReferenceResolution ) static let globalInstance = lazy FSharpChecker.Create() @@ -1235,7 +1239,24 @@ type FSharpChecker // This cache is safe for concurrent access. let braceMatchCache = MruCache(braceMatchCacheSize, areSimilar = AreSimilarForParsing, areSame = AreSameForParsing) - + + static let inferParallelReferenceResolution (parallelReferenceResolution : bool option) = + let explicitValue = + parallelReferenceResolution + |> Option.defaultValue false + |> function + | true -> ParallelReferenceResolution.On + | false -> ParallelReferenceResolution.Off + + let withEnvOverride = + // Override ParallelReferenceResolution set on the constructor with an environment setting if present. + getParallelReferenceResolutionFromEnvironment() + |> Option.defaultValue explicitValue + + withEnvOverride + + static member getParallelReferenceResolutionFromEnvironment () = getParallelReferenceResolutionFromEnvironment () + /// Instantiate an interactive checker. static member Create ( @@ -1247,7 +1268,8 @@ type FSharpChecker ?suggestNamesForErrors, ?keepAllBackgroundSymbolUses, ?enableBackgroundItemKeyStoreAndSemanticClassification, - ?enablePartialTypeChecking + ?enablePartialTypeChecking, + ?parallelReferenceResolution ) = let legacyReferenceResolver = @@ -1269,6 +1291,8 @@ type FSharpChecker if keepAssemblyContents && enablePartialTypeChecking then invalidArg "enablePartialTypeChecking" "'keepAssemblyContents' and 'enablePartialTypeChecking' cannot be both enabled." + + let parallelReferenceResolution = inferParallelReferenceResolution parallelReferenceResolution FSharpChecker( legacyReferenceResolver, @@ -1279,7 +1303,8 @@ type FSharpChecker suggestNamesForErrors, keepAllBackgroundSymbolUses, enableBackgroundItemKeyStoreAndSemanticClassification, - enablePartialTypeChecking + enablePartialTypeChecking, + parallelReferenceResolution ) member _.ReferenceResolver = legacyReferenceResolver diff --git a/src/Compiler/Service/service.fsi b/src/Compiler/Service/service.fsi index 25a5a2b412e..5a2b12d525a 100644 --- a/src/Compiler/Service/service.fsi +++ b/src/Compiler/Service/service.fsi @@ -8,6 +8,7 @@ open System open System.IO open FSharp.Compiler.AbstractIL.ILBinaryReader open FSharp.Compiler.CodeAnalysis +open FSharp.Compiler.CompilerConfig open FSharp.Compiler.Diagnostics open FSharp.Compiler.EditorServices open FSharp.Compiler.Symbols @@ -31,6 +32,7 @@ type public FSharpChecker = /// Indicate whether all symbol uses should be kept in background checking /// Indicates whether a table of symbol keys should be kept for background compilation /// Indicates whether to perform partial type checking. Cannot be set to true if keepAssmeblyContents is true. If set to true, can cause duplicate type-checks when richer information on a file is needed, but can skip background type-checking entirely on implementation files with signature files. + /// Indicates whether to resolve references in parallel. static member Create: ?projectCacheSize: int * ?keepAssemblyContents: bool * @@ -40,7 +42,8 @@ type public FSharpChecker = ?suggestNamesForErrors: bool * ?keepAllBackgroundSymbolUses: bool * ?enableBackgroundItemKeyStoreAndSemanticClassification: bool * - ?enablePartialTypeChecking: bool -> + ?enablePartialTypeChecking: bool * + ?parallelReferenceResolution: bool -> FSharpChecker /// From 4f1ea49a0a32430a1dce123d5e169f1c8d575990 Mon Sep 17 00:00:00 2001 From: janusz Date: Sat, 17 Sep 2022 13:40:29 +0100 Subject: [PATCH 04/11] Fantomas formatting --- src/Compiler/Driver/CompilerConfig.fs | 6 +++--- src/Compiler/Driver/CompilerConfig.fsi | 6 +++--- src/Compiler/Driver/CompilerOptions.fs | 2 +- src/Compiler/Driver/fsc.fs | 12 +++++------- src/Compiler/Driver/fsc.fsi | 2 +- src/Compiler/Service/service.fs | 19 ++++++++++--------- 6 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/Compiler/Driver/CompilerConfig.fs b/src/Compiler/Driver/CompilerConfig.fs index 887027be72f..7a57c64c7c2 100644 --- a/src/Compiler/Driver/CompilerConfig.fs +++ b/src/Compiler/Driver/CompilerConfig.fs @@ -584,8 +584,8 @@ type TcConfigBuilder = mutable xmlDocInfoLoader: IXmlDocumentationInfoLoader option mutable exiter: Exiter - - mutable parallelReferenceResolution : ParallelReferenceResolution + + mutable parallelReferenceResolution: ParallelReferenceResolution } // Directories to start probing in @@ -1315,7 +1315,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) = member _.applyLineDirectives = data.applyLineDirectives member _.xmlDocInfoLoader = data.xmlDocInfoLoader member _.exiter = data.exiter - member _.parallelReferenceResolution = data.parallelReferenceResolution + member _.parallelReferenceResolution = data.parallelReferenceResolution static member Create(builder, validate) = use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter diff --git a/src/Compiler/Driver/CompilerConfig.fsi b/src/Compiler/Driver/CompilerConfig.fsi index ef0a890ceb6..9dcb988bd96 100644 --- a/src/Compiler/Driver/CompilerConfig.fsi +++ b/src/Compiler/Driver/CompilerConfig.fsi @@ -485,7 +485,7 @@ type TcConfigBuilder = mutable xmlDocInfoLoader: IXmlDocumentationInfoLoader option mutable exiter: Exiter - + mutable parallelReferenceResolution: ParallelReferenceResolution } @@ -847,8 +847,8 @@ type TcConfig = member assumeDotNetFramework: bool member exiter: Exiter - - member parallelReferenceResolution : ParallelReferenceResolution + + member parallelReferenceResolution: ParallelReferenceResolution /// Represents a computation to return a TcConfig. Normally this is just a constant immutable TcConfig, /// but for F# Interactive it may be based on an underlying mutable TcConfigBuilder. diff --git a/src/Compiler/Driver/CompilerOptions.fs b/src/Compiler/Driver/CompilerOptions.fs index 461feda16f8..0cda3c9b2e2 100644 --- a/src/Compiler/Driver/CompilerOptions.fs +++ b/src/Compiler/Driver/CompilerOptions.fs @@ -1678,7 +1678,7 @@ let internalFlags (tcConfigB: TcConfigBuilder) = Some(InternalCommandLineOption("nodebugdata", rangeCmdArgs)), None ) - + CompilerOption( "parallelreferenceresolution", tagNone, diff --git a/src/Compiler/Driver/fsc.fs b/src/Compiler/Driver/fsc.fs index 5c4f0361dea..aa86409c99d 100644 --- a/src/Compiler/Driver/fsc.fs +++ b/src/Compiler/Driver/fsc.fs @@ -459,15 +459,13 @@ let getParallelReferenceResolutionFromEnvironment () = Environment.GetEnvironmentVariable("FCS_ParallelReferenceResolution") |> Option.ofObj |> Option.bind (fun flag -> - match bool.TryParse flag with + match bool.TryParse flag with | true, runInParallel -> if runInParallel then Some ParallelReferenceResolution.On else Some ParallelReferenceResolution.Off - | false, _ -> - None - ) + | false, _ -> None) /// First phase of compilation. /// - Set up console encoding and code page settings @@ -557,12 +555,12 @@ let main1 exiter.Exit 1 tcConfigB.conditionalDefines <- "COMPILED" :: tcConfigB.conditionalDefines - + // Override ParallelReferenceResolution set on the CLI with an environment setting if present. - match getParallelReferenceResolutionFromEnvironment() with + match getParallelReferenceResolutionFromEnvironment () with | Some parallelReferenceResolution -> tcConfigB.parallelReferenceResolution <- parallelReferenceResolution | None -> () - + // Display the banner text, if necessary if not bannerAlreadyPrinted then Console.Write(GetBannerText tcConfigB) diff --git a/src/Compiler/Driver/fsc.fsi b/src/Compiler/Driver/fsc.fsi index d4abe33a5a7..9302bf52dc3 100644 --- a/src/Compiler/Driver/fsc.fsi +++ b/src/Compiler/Driver/fsc.fsi @@ -76,4 +76,4 @@ val CompileFromSyntaxTrees: unit /// Read the parallelReferenceResolution flag from environment variables -val internal getParallelReferenceResolutionFromEnvironment : unit -> ParallelReferenceResolution option \ No newline at end of file +val internal getParallelReferenceResolutionFromEnvironment: unit -> ParallelReferenceResolution option diff --git a/src/Compiler/Service/service.fs b/src/Compiler/Service/service.fs index 520700a1fb6..db7ca082822 100644 --- a/src/Compiler/Service/service.fs +++ b/src/Compiler/Service/service.fs @@ -1239,24 +1239,25 @@ type FSharpChecker // This cache is safe for concurrent access. let braceMatchCache = MruCache(braceMatchCacheSize, areSimilar = AreSimilarForParsing, areSame = AreSameForParsing) - - static let inferParallelReferenceResolution (parallelReferenceResolution : bool option) = + + static let inferParallelReferenceResolution (parallelReferenceResolution: bool option) = let explicitValue = parallelReferenceResolution |> Option.defaultValue false |> function | true -> ParallelReferenceResolution.On | false -> ParallelReferenceResolution.Off - + let withEnvOverride = // Override ParallelReferenceResolution set on the constructor with an environment setting if present. - getParallelReferenceResolutionFromEnvironment() + getParallelReferenceResolutionFromEnvironment () |> Option.defaultValue explicitValue - + withEnvOverride - - static member getParallelReferenceResolutionFromEnvironment () = getParallelReferenceResolutionFromEnvironment () - + + static member getParallelReferenceResolutionFromEnvironment() = + getParallelReferenceResolutionFromEnvironment () + /// Instantiate an interactive checker. static member Create ( @@ -1291,7 +1292,7 @@ type FSharpChecker if keepAssemblyContents && enablePartialTypeChecking then invalidArg "enablePartialTypeChecking" "'keepAssemblyContents' and 'enablePartialTypeChecking' cannot be both enabled." - + let parallelReferenceResolution = inferParallelReferenceResolution parallelReferenceResolution FSharpChecker( From d3996c06209e9ff72baf30d1c4d89fbe023872a8 Mon Sep 17 00:00:00 2001 From: janusz Date: Sat, 17 Sep 2022 14:54:08 +0100 Subject: [PATCH 05/11] Update surface baseline --- .../FSharp.CompilerService.SurfaceArea.netstandard.expected | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected b/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected index 083c2ea9310..e23cdd00eec 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected @@ -2008,7 +2008,7 @@ FSharp.Compiler.CodeAnalysis.FSharpCheckProjectResults: System.String ToString() FSharp.Compiler.CodeAnalysis.FSharpCheckProjectResults: System.String[] DependencyFiles FSharp.Compiler.CodeAnalysis.FSharpCheckProjectResults: System.String[] get_DependencyFiles() FSharp.Compiler.CodeAnalysis.FSharpChecker -FSharp.Compiler.CodeAnalysis.FSharpChecker: FSharp.Compiler.CodeAnalysis.FSharpChecker Create(Microsoft.FSharp.Core.FSharpOption`1[System.Int32], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.CodeAnalysis.LegacyReferenceResolver], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpFunc`2[System.Tuple`2[System.String,System.DateTime],Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`3[System.Object,System.IntPtr,System.Int32]]]], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean]) +FSharp.Compiler.CodeAnalysis.FSharpChecker: FSharp.Compiler.CodeAnalysis.FSharpChecker Create(Microsoft.FSharp.Core.FSharpOption`1[System.Int32], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.CodeAnalysis.LegacyReferenceResolver], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpFunc`2[System.Tuple`2[System.String,System.DateTime],Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`3[System.Object,System.IntPtr,System.Int32]]]], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean]) FSharp.Compiler.CodeAnalysis.FSharpChecker: FSharp.Compiler.CodeAnalysis.FSharpChecker Instance FSharp.Compiler.CodeAnalysis.FSharpChecker: FSharp.Compiler.CodeAnalysis.FSharpChecker get_Instance() FSharp.Compiler.CodeAnalysis.FSharpChecker: FSharp.Compiler.CodeAnalysis.FSharpProjectOptions GetProjectOptionsFromCommandLineArgs(System.String, System.String[], Microsoft.FSharp.Core.FSharpOption`1[System.DateTime], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean]) From bac0f3ebb874921065608ddfb68daa31f3da7fc1 Mon Sep 17 00:00:00 2001 From: janusz Date: Sat, 17 Sep 2022 17:09:49 +0100 Subject: [PATCH 06/11] Cleanup --- src/Compiler/Driver/CompilerImports.fs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Compiler/Driver/CompilerImports.fs b/src/Compiler/Driver/CompilerImports.fs index 82e5bef377b..02fb42ce15e 100644 --- a/src/Compiler/Driver/CompilerImports.fs +++ b/src/Compiler/Driver/CompilerImports.fs @@ -2142,10 +2142,8 @@ and [] TcImports CheckDisposed() let tcConfig = tcConfigP.Get ctok - let runInParallel = tcConfig.parallelReferenceResolution - let runMethod = - match runInParallel with + match tcConfig.parallelReferenceResolution with | ParallelReferenceResolution.On -> NodeCode.Parallel | ParallelReferenceResolution.Off -> NodeCode.Sequential From 13c9044e97c0edaac3c540d1826e65f8cda4545d Mon Sep 17 00:00:00 2001 From: janusz Date: Sat, 17 Sep 2022 19:04:33 +0100 Subject: [PATCH 07/11] Dummy commit to trigger PR checks From b227343f5a5629bdafacc26c833ccf0d4004b06d Mon Sep 17 00:00:00 2001 From: janusz Date: Wed, 21 Sep 2022 20:43:35 +0100 Subject: [PATCH 08/11] Update surface baseline after merge --- .../FSharp.CompilerService.SurfaceArea.netstandard.expected | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected b/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected index 6f38d493913..3f138ee9dda 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected @@ -2008,7 +2008,7 @@ FSharp.Compiler.CodeAnalysis.FSharpCheckProjectResults: System.String ToString() FSharp.Compiler.CodeAnalysis.FSharpCheckProjectResults: System.String[] DependencyFiles FSharp.Compiler.CodeAnalysis.FSharpCheckProjectResults: System.String[] get_DependencyFiles() FSharp.Compiler.CodeAnalysis.FSharpChecker -FSharp.Compiler.CodeAnalysis.FSharpChecker: FSharp.Compiler.CodeAnalysis.FSharpChecker Create(Microsoft.FSharp.Core.FSharpOption`1[System.Int32], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.CodeAnalysis.LegacyReferenceResolver], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpFunc`2[System.Tuple`2[System.String,System.DateTime],Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`3[System.Object,System.IntPtr,System.Int32]]]], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean]) +FSharp.Compiler.CodeAnalysis.FSharpChecker: FSharp.Compiler.CodeAnalysis.FSharpChecker Create(Microsoft.FSharp.Core.FSharpOption`1[System.Int32], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.CodeAnalysis.LegacyReferenceResolver], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpFunc`2[System.Tuple`2[System.String,System.DateTime],Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`3[System.Object,System.IntPtr,System.Int32]]]], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean]) FSharp.Compiler.CodeAnalysis.FSharpChecker: FSharp.Compiler.CodeAnalysis.FSharpChecker Instance FSharp.Compiler.CodeAnalysis.FSharpChecker: FSharp.Compiler.CodeAnalysis.FSharpChecker get_Instance() FSharp.Compiler.CodeAnalysis.FSharpChecker: FSharp.Compiler.CodeAnalysis.FSharpProjectOptions GetProjectOptionsFromCommandLineArgs(System.String, System.String[], Microsoft.FSharp.Core.FSharpOption`1[System.DateTime], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean]) From 7521f35eda06107e837eaf5ab7f28b16ad31a3de Mon Sep 17 00:00:00 2001 From: janusz Date: Fri, 23 Sep 2022 22:57:25 +0100 Subject: [PATCH 09/11] Empty commit to trigger PR check rerun From 5bb7c1491a1d160e1dd94ccafa783f338acad4f7 Mon Sep 17 00:00:00 2001 From: janusz Date: Fri, 23 Sep 2022 22:57:37 +0100 Subject: [PATCH 10/11] Empty commit to trigger PR check rerun From bf9548ace9cd047a34ba93adba010692fca0a6fd Mon Sep 17 00:00:00 2001 From: Janusz Wrobel Date: Sat, 24 Sep 2022 01:08:42 +0100 Subject: [PATCH 11/11] Restore tests/fsharp/regression/13219/test.fsx --- tests/fsharp/regression/13219/test.fsx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/fsharp/regression/13219/test.fsx diff --git a/tests/fsharp/regression/13219/test.fsx b/tests/fsharp/regression/13219/test.fsx new file mode 100644 index 00000000000..c6ff7817805 --- /dev/null +++ b/tests/fsharp/regression/13219/test.fsx @@ -0,0 +1,22 @@ +#r "nuget: FSharp.Data, 4.2.10" + +open FSharp.Data + +[] +let url = "https://en.wikipedia.org/wiki/F_Sharp_(programming_language)" + +// Works +let html = new HtmlProvider() + +type System.Object with + + // Works + member x.Html1 = new HtmlProvider<"https://en.wikipedia.org/wiki/F_Sharp_(programming_language)">() + + // Error: FS0267 This is not a valid constant expression or custom attribute value + member x.Html2 = new HtmlProvider() + +// This is a compilation test, not a lot actually happens in the test +do (System.Console.Out.WriteLine "Test Passed"; + System.IO.File.WriteAllText("test.ok", "ok"); + exit 0)