From e5b3131f3a302abd0325c5d01fe0dfda87e3c97d Mon Sep 17 00:00:00 2001 From: Petr Pokorny Date: Thu, 25 Jan 2024 16:04:06 +0100 Subject: [PATCH 01/17] Transparent Compiler Tests --- tests/FSharp.Test.Utilities/CompilerAssert.fs | 2 +- tests/FSharp.Test.Utilities/ProjectGeneration.fs | 2 +- tests/service/Common.fs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/FSharp.Test.Utilities/CompilerAssert.fs b/tests/FSharp.Test.Utilities/CompilerAssert.fs index 7951ba31d5d..8117e5390ce 100644 --- a/tests/FSharp.Test.Utilities/CompilerAssert.fs +++ b/tests/FSharp.Test.Utilities/CompilerAssert.fs @@ -259,7 +259,7 @@ and Compilation = module rec CompilerAssertHelpers = - let useTransparentCompiler = FSharp.Compiler.CompilerConfig.FSharpExperimentalFeaturesEnabledAutomatically + let useTransparentCompiler = true let checker = FSharpChecker.Create(suggestNamesForErrors=true, useTransparentCompiler=useTransparentCompiler) // Unlike C# whose entrypoint is always string[] F# can make an entrypoint with 0 args, or with an array of string[] diff --git a/tests/FSharp.Test.Utilities/ProjectGeneration.fs b/tests/FSharp.Test.Utilities/ProjectGeneration.fs index 54c00ebe544..37eb2b54a63 100644 --- a/tests/FSharp.Test.Utilities/ProjectGeneration.fs +++ b/tests/FSharp.Test.Utilities/ProjectGeneration.fs @@ -837,7 +837,7 @@ type ProjectWorkflowBuilder ?autoStart ) = - let useTransparentCompiler = defaultArg useTransparentCompiler FSharp.Compiler.CompilerConfig.FSharpExperimentalFeaturesEnabledAutomatically + let useTransparentCompiler = defaultArg useTransparentCompiler true let useGetSource = not useTransparentCompiler && defaultArg useGetSource false let useChangeNotifications = not useTransparentCompiler && defaultArg useChangeNotifications false let autoStart = defaultArg autoStart true diff --git a/tests/service/Common.fs b/tests/service/Common.fs index 8516948626a..11723a53a8a 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -31,7 +31,7 @@ type Async with task.Result // Create one global interactive checker instance -let checker = FSharpChecker.Create(useTransparentCompiler=FSharp.Compiler.CompilerConfig.FSharpExperimentalFeaturesEnabledAutomatically) +let checker = FSharpChecker.Create(useTransparentCompiler=true) type TempFile(ext, contents: string) = let tmpFile = Path.ChangeExtension(tryCreateTemporaryFileName (), ext) From 44a2f6627d69a6cfc58ed707275ba95776234456 Mon Sep 17 00:00:00 2001 From: Petr Pokorny Date: Thu, 25 Jan 2024 18:21:23 +0100 Subject: [PATCH 02/17] Fail early with proper error message when no input files are specified --- src/Compiler/Service/TransparentCompiler.fs | 31 +++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index 298c0e6b627..099e49db71e 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -762,20 +762,23 @@ type internal TransparentCompiler |> List.map (fun (m, fileName) -> m, FSharpFileSnapshot.CreateFromFileSystem(fileName)) return - Some - { - Id = bootstrapId - AssemblyName = assemblyName - OutFile = outFile - TcConfig = tcConfig - TcImports = tcImports - TcGlobals = tcGlobals - InitialTcInfo = initialTcInfo - LoadedSources = loadedSources - LoadClosure = loadClosureOpt - LastFileName = sourceFiles |> List.last - //ImportsInvalidatedByTypeProvider = importsInvalidatedByTypeProvider - } + match sourceFiles with + | [] -> None + | _ -> + Some + { + Id = bootstrapId + AssemblyName = assemblyName + OutFile = outFile + TcConfig = tcConfig + TcImports = tcImports + TcGlobals = tcGlobals + InitialTcInfo = initialTcInfo + LoadedSources = loadedSources + LoadClosure = loadClosureOpt + LastFileName = sourceFiles |> List.tryLast |> Option.defaultValue "" + //ImportsInvalidatedByTypeProvider = importsInvalidatedByTypeProvider + } } let ComputeBootstrapInfo (projectSnapshot: ProjectSnapshot) = From e522b129122aebc8aafeefd8ef2f8f93345c35e7 Mon Sep 17 00:00:00 2001 From: Petr Pokorny Date: Thu, 25 Jan 2024 18:44:12 +0100 Subject: [PATCH 03/17] We don't guarantee the ordering of symbols --- tests/service/ProjectAnalysisTests.fs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index a1a58a709b2..134cbfe6098 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -2510,9 +2510,10 @@ let ``Test Project16 all symbols`` () = wholeProjectResults.GetAllUsesOfAllSymbols() |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project16.cleanFileName su.FileName, tups su.Range, attribsOfSymbolUse su, attribsOfSymbol su.Symbol) + |> Array.sort allUsesOfAllSymbols |> shouldEqual - [|("ClassAttribute", "ClassAttribute", "sig1", ((8, 6), (8, 11)), + ([|("ClassAttribute", "ClassAttribute", "sig1", ((8, 6), (8, 11)), ["attribute"], ["class"]); ("member .ctor", "ClassAttribute", "sig1", ((8, 6), (8, 11)), [], ["member"]); @@ -2591,7 +2592,7 @@ let ``Test Project16 all symbols`` () = ("val x", "x", "file1", ((5, 11), (5, 12)), ["defn"], []); ("val x", "x", "file1", ((8, 11), (8, 12)), ["defn"], []); ("val x", "x", "file1", ((11, 11), (11, 12)), ["defn"], []); - ("Impl", "Impl", "file1", ((2, 7), (2, 11)), ["defn"], ["module"])|] + ("Impl", "Impl", "file1", ((2, 7), (2, 11)), ["defn"], ["module"])|] |> Array.sort) [] let ``Test Project16 sig symbols are equal to impl symbols`` () = From f97683f2ff199912e50f5836410d40d0dbb21ad3 Mon Sep 17 00:00:00 2001 From: Petr Pokorny Date: Mon, 29 Jan 2024 18:29:42 +0100 Subject: [PATCH 04/17] update --- src/Compiler/Service/TransparentCompiler.fs | 2 +- tests/service/MultiProjectAnalysisTests.fs | 20 ++++++++++++++++---- tests/service/ProjectAnalysisTests.fs | 5 ++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index 099e49db71e..b1d506be62b 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -1652,7 +1652,7 @@ type internal TransparentCompiler | ProjectAssemblyDataResult.Available data -> Some data | _ -> None - let symbolUses = tcInfo.sink |> Seq.map (fun sink -> sink.GetSymbolUses()) + let symbolUses = tcInfo.sink |> Seq.rev |> Seq.map (fun sink -> sink.GetSymbolUses()) let details = (bootstrapInfo.TcGlobals, diff --git a/tests/service/MultiProjectAnalysisTests.fs b/tests/service/MultiProjectAnalysisTests.fs index a306107eb36..350cf73095e 100644 --- a/tests/service/MultiProjectAnalysisTests.fs +++ b/tests/service/MultiProjectAnalysisTests.fs @@ -133,8 +133,12 @@ let u = Case1 3 let cleanFileName a = if a = fileName1 then "file1" else "??" [] -let ``Test multi project 1 basic`` () = +[] +[] +let ``Test multi project 1 basic`` useTransparentCompiler = + let checker = if useTransparentCompiler then transparentCompilerChecker else checker + let wholeProjectResults = checker.ParseAndCheckProject(MultiProject1.options) |> Async.RunImmediate [ for x in wholeProjectResults.AssemblySignature.Entities -> x.DisplayName ] |> shouldEqual ["MultiProject1"] @@ -704,9 +708,12 @@ let ``Test multi project2 errors`` useTransparentCompiler = wholeProjectResultsC.Diagnostics.Length |> shouldEqual 1 - [] -let ``Test multi project 2 all symbols`` () = +[] +[] +let ``Test multi project 2 all symbols`` useTransparentCompiler = + + let checker = if useTransparentCompiler then transparentCompilerChecker else checker let mpA = checker.ParseAndCheckProject(Project2A.options) |> Async.RunImmediate let mpB = checker.ParseAndCheckProject(Project2B.options) |> Async.RunImmediate @@ -832,7 +839,12 @@ let ``Test active patterns' XmlDocSig declared in referenced projects`` useTrans [] -let ``In-memory cross-project references to projects using generative type provides should fallback to on-disk references`` () = +[] +[] +let ``In-memory cross-project references to projects using generative type provides should fallback to on-disk references`` useTransparentCompiler = + + let checker = if useTransparentCompiler then transparentCompilerChecker else checker + // The type provider and its dependency are compiled as part of the solution build #if DEBUG let csDLL = __SOURCE_DIRECTORY__ + @"/../../artifacts/bin/TestTP/Debug/netstandard2.0/CSharp_Analysis.dll" diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index 134cbfe6098..a1a58a709b2 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -2510,10 +2510,9 @@ let ``Test Project16 all symbols`` () = wholeProjectResults.GetAllUsesOfAllSymbols() |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project16.cleanFileName su.FileName, tups su.Range, attribsOfSymbolUse su, attribsOfSymbol su.Symbol) - |> Array.sort allUsesOfAllSymbols |> shouldEqual - ([|("ClassAttribute", "ClassAttribute", "sig1", ((8, 6), (8, 11)), + [|("ClassAttribute", "ClassAttribute", "sig1", ((8, 6), (8, 11)), ["attribute"], ["class"]); ("member .ctor", "ClassAttribute", "sig1", ((8, 6), (8, 11)), [], ["member"]); @@ -2592,7 +2591,7 @@ let ``Test Project16 all symbols`` () = ("val x", "x", "file1", ((5, 11), (5, 12)), ["defn"], []); ("val x", "x", "file1", ((8, 11), (8, 12)), ["defn"], []); ("val x", "x", "file1", ((11, 11), (11, 12)), ["defn"], []); - ("Impl", "Impl", "file1", ((2, 7), (2, 11)), ["defn"], ["module"])|] |> Array.sort) + ("Impl", "Impl", "file1", ((2, 7), (2, 11)), ["defn"], ["module"])|] [] let ``Test Project16 sig symbols are equal to impl symbols`` () = From 96f5b512ebf616079294b46a67396057776d1720 Mon Sep 17 00:00:00 2001 From: 0101 <0101@innit.cz> Date: Wed, 31 Jan 2024 15:26:46 +0100 Subject: [PATCH 05/17] Fix format specifiers in results --- src/Compiler/Service/TransparentCompiler.fs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index b1d506be62b..9a374f63aba 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -1115,7 +1115,7 @@ type internal TransparentCompiler ApplyMetaCommandsFromInputToTcConfig(tcConfig, input, Path.GetDirectoryName fileName, tcImports.DependencyProvider) |> ignore - let sink = TcResultsSinkImpl(tcGlobals) + let sink = TcResultsSinkImpl(tcGlobals, file.SourceText) let hadParseErrors = not (Array.isEmpty file.ParseErrors) @@ -1652,7 +1652,8 @@ type internal TransparentCompiler | ProjectAssemblyDataResult.Available data -> Some data | _ -> None - let symbolUses = tcInfo.sink |> Seq.rev |> Seq.map (fun sink -> sink.GetSymbolUses()) + let symbolUses = + tcInfo.sink |> Seq.rev |> Seq.map (fun sink -> sink.GetSymbolUses()) let details = (bootstrapInfo.TcGlobals, From fb99f362847e96ea5406c777fc607447a688116d Mon Sep 17 00:00:00 2001 From: 0101 <0101@innit.cz> Date: Wed, 31 Jan 2024 17:04:21 +0100 Subject: [PATCH 06/17] more fixes --- .../.FSharp.Compiler.Service/8.0.300.md | 2 +- .../Driver/GraphChecking/TrieMapping.fs | 2 +- .../TypeChecks/Graph/TrieMappingTests.fs | 23 ++++++++++++++++++- tests/service/CSharpProjectAnalysis.fs | 5 ++-- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md index 85735d5b430..3678f6a0f3f 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md @@ -2,7 +2,7 @@ * Code generated files with > 64K methods and generated symbols crash when loaded. Use infered sequence points for debugging. ([Issue #16399](https://github.com/dotnet/fsharp/issues/16399), [#PR 16514](https://github.com/dotnet/fsharp/pull/16514)) * `nameof Module` expressions and patterns are processed to link files in `--test:GraphBasedChecking`. ([PR #16550](https://github.com/dotnet/fsharp/pull/16550)) -* Graph Based Checking doesn't throw on invalid parsed input so it can be used for IDE scenarios ([PR #16575](https://github.com/dotnet/fsharp/pull/16575), [PR #16588](https://github.com/dotnet/fsharp/pull/16588)) +* Graph Based Checking doesn't throw on invalid parsed input so it can be used for IDE scenarios ([PR #16575](https://github.com/dotnet/fsharp/pull/16575), [PR #16588](https://github.com/dotnet/fsharp/pull/16588), [PR #16591](https://github.com/dotnet/fsharp/pull/16591)) * Keep parens for problematic exprs (`if`, `match`, etc.) in `$"{(…):N0}"`, `$"{(…),-3}"`, etc. ([PR #16578](https://github.com/dotnet/fsharp/pull/16578)) * Fix crash in DOTNET_SYSTEM_GLOBALIZATION_INVARIANT mode [#PR 16471](https://github.com/dotnet/fsharp/pull/16471)) diff --git a/src/Compiler/Driver/GraphChecking/TrieMapping.fs b/src/Compiler/Driver/GraphChecking/TrieMapping.fs index ff7b32e5640..add261d570c 100644 --- a/src/Compiler/Driver/GraphChecking/TrieMapping.fs +++ b/src/Compiler/Driver/GraphChecking/TrieMapping.fs @@ -123,7 +123,7 @@ let processSynModuleOrNamespace<'Decl> // Only the last node can be a module, depending on the SynModuleOrNamespaceKind. let rec visit continuation (xs: LongIdent) = match xs with - | [] -> failwith "should not be empty" + | [] -> ImmutableDictionary.Empty |> continuation | [ finalPart ] -> let name = finalPart.idText diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/TrieMappingTests.fs b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/TrieMappingTests.fs index e5bc3ef0299..6ad29818a2a 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/TrieMappingTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/TrieMappingTests.fs @@ -540,6 +540,27 @@ let ``Tries are built up incrementally`` () = ParsedInput = parseSourceCode ("D.fs", "module D") } |] - + for idx, t in trie do Assert.AreEqual(idx + 1, t.Children.Count) + + +module InvalidSyntax = + + [] + let ``Unnamed module`` () = + let trie = + getLastTrie + [| { Idx = 0 + FileName = "A.fs" + ParsedInput = + parseSourceCode ( + "A.fs", + """ + module + + () + """ + ) } |] + + Assert.True trie.Children.IsEmpty diff --git a/tests/service/CSharpProjectAnalysis.fs b/tests/service/CSharpProjectAnalysis.fs index f23f3038e42..69a13799d7f 100644 --- a/tests/service/CSharpProjectAnalysis.fs +++ b/tests/service/CSharpProjectAnalysis.fs @@ -27,7 +27,7 @@ let internal getProjectReferences (content: string, dllFiles, libDirs, otherFlag let projFileName = Path.ChangeExtension(base1, ".fsproj") FileSystem.OpenFileForWriteShim(fileName1).Write(content) let options = - checker.GetProjectOptionsFromCommandLineArgs(projFileName, + { checker.GetProjectOptionsFromCommandLineArgs(projFileName, [| yield "--debug:full" yield "--define:DEBUG" yield "--optimize-" @@ -41,8 +41,7 @@ let internal getProjectReferences (content: string, dllFiles, libDirs, otherFlag yield "-r:"+dllFile for libDir in libDirs do yield "-I:"+libDir - yield! otherFlags - yield fileName1 |]) + yield! otherFlags |]) with SourceFiles = [| fileName1 |] } let results = checker.ParseAndCheckProject(options) |> Async.RunImmediate if results.HasCriticalErrors then let builder = System.Text.StringBuilder() From 6d7a4f549e2a3b9c1f608f75fd67fb10dc0de483 Mon Sep 17 00:00:00 2001 From: 0101 <0101@innit.cz> Date: Wed, 31 Jan 2024 19:00:32 +0100 Subject: [PATCH 07/17] Remove redundant parsing errors --- src/Compiler/Service/TransparentCompiler.fs | 5 +---- .../FSharpChecker/TransparentCompiler.fs | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index 9a374f63aba..d0a95e57846 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -1144,16 +1144,13 @@ type internal TransparentCompiler //fileChecked.Trigger fileName - let newErrors = - Array.append file.ParseErrors (errHandler.CollectedPhasedDiagnostics) - fileChecked.Trigger(fileName, Unchecked.defaultof<_>) return { finisher = finisher moduleNamesDict = moduleNamesDict - tcDiagnosticsRev = [ newErrors ] + tcDiagnosticsRev = [ errHandler.CollectedPhasedDiagnostics ] tcDependencyFiles = [ fileName ] sink = sink } diff --git a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs index 90dc85c4a33..f1b2461476b 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs +++ b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs @@ -626,7 +626,7 @@ let fuzzingTest seed (project: SyntheticProject) = task { () with | e -> - let _log = log.Values |> Seq.collect id |> Seq.sortBy p13 |> Seq.toArray + // let _log = log.Values |> Seq.collect id |> Seq.sortBy p13 |> Seq.toArray failwith $"Seed: {seed}\nException: %A{e}" } let log = log.Values |> Seq.collect id |> Seq.sortBy p13 |> Seq.toArray From e0bedf117ec265b8761fe63a683d4107683200e9 Mon Sep 17 00:00:00 2001 From: 0101 <0101@innit.cz> Date: Wed, 31 Jan 2024 19:36:35 +0100 Subject: [PATCH 08/17] fix fuzzing tests --- .../FSharpChecker/TransparentCompiler.fs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs index f1b2461476b..859c629d742 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs +++ b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs @@ -479,12 +479,12 @@ type SignatureFiles = Yes = 1 | No = 2 | Some = 3 let fuzzingTest seed (project: SyntheticProject) = task { let rng = System.Random seed - let checkingThreads = 3 - let maxModificationDelayMs = 10 + let checkingThreads = 10 + let maxModificationDelayMs = 50 let maxCheckingDelayMs = 20 //let runTimeMs = 30000 let signatureFileModificationProbability = 0.25 - let modificationLoopIterations = 10 + let modificationLoopIterations = 50 let checkingLoopIterations = 5 let minCheckingTimeoutMs = 0 @@ -622,7 +622,7 @@ let fuzzingTest seed (project: SyntheticProject) = task { } try - let! _x = threads |> Seq.skip 1 |> Task.WhenAll + let! _x = threads |> Task.WhenAll () with | e -> From d7514a0aa426cf551c723604989ad5ceb348af90 Mon Sep 17 00:00:00 2001 From: 0101 <0101@innit.cz> Date: Thu, 1 Feb 2024 12:24:51 +0100 Subject: [PATCH 09/17] Added support for other refernce types --- src/Compiler/Service/FSharpProjectSnapshot.fs | 50 ++++++++++++------- src/Compiler/Service/TransparentCompiler.fs | 35 +++++++++++++ .../LanguageService/WorkspaceExtensions.fs | 1 + 3 files changed, 68 insertions(+), 18 deletions(-) diff --git a/src/Compiler/Service/FSharpProjectSnapshot.fs b/src/Compiler/Service/FSharpProjectSnapshot.fs index 259948dc706..b9c3e4bb489 100644 --- a/src/Compiler/Service/FSharpProjectSnapshot.fs +++ b/src/Compiler/Service/FSharpProjectSnapshot.fs @@ -364,7 +364,10 @@ and internal ProjectCore |> Md5Hasher.addDateTimes (ReferencesOnDisk |> Seq.map (fun r -> r.LastModified)) |> Md5Hasher.addBytes' ( ReferencedProjects - |> Seq.map (fun (FSharpReference(_name, p)) -> p.ProjectSnapshot.SignatureVersion) + |> Seq.map (function + | FSharpReference(_name, p) -> p.ProjectSnapshot.SignatureVersion + | PEReference(getStamp, _) -> Md5Hasher.empty |> Md5Hasher.addDateTime (getStamp ()) + | ILModuleReference(_name, getStamp, _) -> Md5Hasher.empty |> Md5Hasher.addDateTime (getStamp ())) )) let fullHashString = lazy (fullHash.Value |> Md5Hasher.toString) @@ -430,11 +433,11 @@ and internal ProjectCore and [] FSharpReferencedProjectSnapshot = | FSharpReference of projectOutputFile: string * options: FSharpProjectSnapshot - //| PEReference of projectOutputFile: string * getStamp: (unit -> DateTime) * delayedReader: DelayedILModuleReader - //| ILModuleReference of - // projectOutputFile: string * - // getStamp: (unit -> DateTime) * - // getReader: (unit -> ILModuleReader) + | PEReference of getStamp: (unit -> DateTime) * delayedReader: DelayedILModuleReader + | ILModuleReference of + projectOutputFile: string * + getStamp: (unit -> DateTime) * + getReader: (unit -> FSharp.Compiler.AbstractIL.ILBinaryReader.ILModuleReader) /// /// The fully qualified path to the output of the referenced project. This should be the same value as the -r @@ -442,7 +445,9 @@ and [ member this.OutputFile = match this with - | FSharpReference(projectOutputFile, _) -> projectOutputFile + | FSharpReference(projectOutputFile = projectOutputFile) + | ILModuleReference(projectOutputFile = projectOutputFile) -> projectOutputFile + | PEReference(delayedReader = reader) -> reader.OutputFile /// /// Creates a reference for an F# project. The physical data for it is stored/cached inside of the compiler service. @@ -458,6 +463,11 @@ and [ projectOutputFile1 = projectOutputFile2 && options1 = options2 + | PEReference(getStamp1, reader1), PEReference(getStamp2, reader2) -> + reader1.OutputFile = reader2.OutputFile && (getStamp1 ()) = (getStamp2 ()) + | ILModuleReference(projectOutputFile1, getStamp1, _), ILModuleReference(projectOutputFile2, getStamp2, _) -> + projectOutputFile1 = projectOutputFile2 && (getStamp1 ()) = (getStamp2 ()) + | _ -> false | _ -> false @@ -524,17 +534,19 @@ and [] FSha let! referencedProjects = options.ReferencedProjects - |> Seq.choose (function + |> Seq.map (function | FSharpReferencedProject.FSharpReference(outputName, options) -> - Some( - async { - let! snapshot = FSharpProjectSnapshot.FromOptions(options, getFileSnapshot, snapshotAccumulator) - - return FSharpReferencedProjectSnapshot.FSharpReference(outputName, snapshot) - } - ) - // TODO: other types - | _ -> None) + async { + let! snapshot = FSharpProjectSnapshot.FromOptions(options, getFileSnapshot, snapshotAccumulator) + + return FSharpReferencedProjectSnapshot.FSharpReference(outputName, snapshot) + } + | FSharpReferencedProject.PEReference(getStamp, reader) -> + async.Return <| FSharpReferencedProjectSnapshot.PEReference(getStamp, reader) + | FSharpReferencedProject.ILModuleReference(outputName, getStamp, getReader) -> + async.Return + <| FSharpReferencedProjectSnapshot.ILModuleReference(outputName, getStamp, getReader)) + |> Async.Sequential let referencesOnDisk, otherOptions = @@ -601,7 +613,9 @@ let rec internal snapshotToOptions (projectSnapshot: ProjectSnapshotBase<_>) = ReferencedProjects = projectSnapshot.ReferencedProjects |> Seq.map (function - | FSharpReference(name, opts) -> FSharpReferencedProject.FSharpReference(name, opts.ProjectSnapshot |> snapshotToOptions)) + | FSharpReference(name, opts) -> FSharpReferencedProject.FSharpReference(name, opts.ProjectSnapshot |> snapshotToOptions) + | PEReference(getStamp, reader) -> FSharpReferencedProject.PEReference(getStamp, reader) + | ILModuleReference(name, getStamp, getReader) -> FSharpReferencedProject.ILModuleReference(name, getStamp, getReader)) |> Seq.toArray IsIncompleteTypeCheckEnvironment = projectSnapshot.IsIncompleteTypeCheckEnvironment UseScriptResolutionRules = projectSnapshot.UseScriptResolutionRules diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index d0a95e57846..8e5f984d027 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -539,6 +539,41 @@ type internal TransparentCompiler member x.FileName = nm } + | FSharpReferencedProjectSnapshot.PEReference(getStamp, delayedReader) -> + { new IProjectReference with + member x.EvaluateRawContents() = + node { + let! ilReaderOpt = delayedReader.TryGetILModuleReader() |> NodeCode.FromCancellable + + match ilReaderOpt with + | Some ilReader -> + let ilModuleDef, ilAsmRefs = ilReader.ILModuleDef, ilReader.ILAssemblyRefs + let data = RawFSharpAssemblyData(ilModuleDef, ilAsmRefs) :> IRawFSharpAssemblyData + return ProjectAssemblyDataResult.Available data + | _ -> + // Note 'false' - if a PEReference doesn't find an ILModuleReader then we don't + // continue to try to use an on-disk DLL + return ProjectAssemblyDataResult.Unavailable false + } + + member x.TryGetLogicalTimeStamp _ = getStamp () |> Some + member x.FileName = delayedReader.OutputFile + } + + | FSharpReferencedProjectSnapshot.ILModuleReference(nm, getStamp, getReader) -> + { new IProjectReference with + member x.EvaluateRawContents() = + cancellable { + let ilReader = getReader () + let ilModuleDef, ilAsmRefs = ilReader.ILModuleDef, ilReader.ILAssemblyRefs + let data = RawFSharpAssemblyData(ilModuleDef, ilAsmRefs) :> IRawFSharpAssemblyData + return ProjectAssemblyDataResult.Available data + } + |> NodeCode.FromCancellable + + member x.TryGetLogicalTimeStamp _ = getStamp () |> Some + member x.FileName = nm + } ] let ComputeTcConfigBuilder (projectSnapshot: ProjectSnapshotBase<_>) = diff --git a/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs b/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs index 6e3de8133f1..154517ed6a1 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs @@ -58,6 +58,7 @@ module internal FSharpProjectSnapshotSerialization = | FSharpReference(projectOutputFile, snapshot) -> output.Add("projectOutputFile", projectOutputFile) output.Add("snapshot", serializeSnapshot snapshot) + | _ -> () output From af949ed1d0630a71c332f7917ac413b5c230a84d Mon Sep 17 00:00:00 2001 From: 0101 <0101@innit.cz> Date: Thu, 1 Feb 2024 13:25:49 +0100 Subject: [PATCH 10/17] surfacearea --- ...ervice.SurfaceArea.netstandard20.debug.bsl | 33 ++++++++++++++++--- ...vice.SurfaceArea.netstandard20.release.bsl | 33 ++++++++++++++++--- 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl index b7484492a42..361ff32f3cc 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl @@ -2338,19 +2338,44 @@ FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FS FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot] FromOptions(FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, System.String, Int32, FSharp.Compiler.Text.ISourceText) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.String Label FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.String get_Label() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: FSharpProjectSnapshot get_options() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: FSharpProjectSnapshot options +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: System.String get_projectOutputFile() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: System.String projectOutputFile +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+ILModuleReference: Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,FSharp.Compiler.AbstractIL.ILBinaryReader+ILModuleReader] getReader +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+ILModuleReference: Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,FSharp.Compiler.AbstractIL.ILBinaryReader+ILModuleReader] get_getReader() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+ILModuleReference: Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,System.DateTime] getStamp +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+ILModuleReference: Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,System.DateTime] get_getStamp() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+ILModuleReference: System.String get_projectOutputFile() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+ILModuleReference: System.String projectOutputFile +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+PEReference: FSharp.Compiler.CodeAnalysis.DelayedILModuleReader delayedReader +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+PEReference: FSharp.Compiler.CodeAnalysis.DelayedILModuleReader get_delayedReader() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+PEReference: Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,System.DateTime] getStamp +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+PEReference: Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,System.DateTime] get_getStamp() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+Tags: Int32 FSharpReference +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+Tags: Int32 ILModuleReference +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+Tags: Int32 PEReference FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Boolean Equals(System.Object) -FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharpProjectSnapshot get_options() -FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharpProjectSnapshot options +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Boolean IsFSharpReference +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Boolean IsILModuleReference +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Boolean IsPEReference +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Boolean get_IsFSharpReference() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Boolean get_IsILModuleReference() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Boolean get_IsPEReference() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+ILModuleReference +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+PEReference +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+Tags FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharpReferencedProjectSnapshot CreateFSharp(System.String, FSharpProjectSnapshot) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharpReferencedProjectSnapshot NewFSharpReference(System.String, FSharpProjectSnapshot) +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharpReferencedProjectSnapshot NewILModuleReference(System.String, Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,System.DateTime], Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,FSharp.Compiler.AbstractIL.ILBinaryReader+ILModuleReader]) +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharpReferencedProjectSnapshot NewPEReference(Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,System.DateTime], FSharp.Compiler.CodeAnalysis.DelayedILModuleReader) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Int32 GetHashCode() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Int32 Tag FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Int32 get_Tag() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: System.String OutputFile FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: System.String ToString() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: System.String get_OutputFile() -FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: System.String get_projectOutputFile() -FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: System.String projectOutputFile FSharp.Compiler.CodeAnalysis.ProjectSnapshot+ReferenceOnDisk: Boolean Equals(ReferenceOnDisk) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+ReferenceOnDisk: Boolean Equals(System.Object) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+ReferenceOnDisk: Boolean Equals(System.Object, System.Collections.IEqualityComparer) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index b7484492a42..361ff32f3cc 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -2338,19 +2338,44 @@ FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FS FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot] FromOptions(FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, System.String, Int32, FSharp.Compiler.Text.ISourceText) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.String Label FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.String get_Label() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: FSharpProjectSnapshot get_options() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: FSharpProjectSnapshot options +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: System.String get_projectOutputFile() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: System.String projectOutputFile +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+ILModuleReference: Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,FSharp.Compiler.AbstractIL.ILBinaryReader+ILModuleReader] getReader +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+ILModuleReference: Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,FSharp.Compiler.AbstractIL.ILBinaryReader+ILModuleReader] get_getReader() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+ILModuleReference: Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,System.DateTime] getStamp +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+ILModuleReference: Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,System.DateTime] get_getStamp() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+ILModuleReference: System.String get_projectOutputFile() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+ILModuleReference: System.String projectOutputFile +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+PEReference: FSharp.Compiler.CodeAnalysis.DelayedILModuleReader delayedReader +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+PEReference: FSharp.Compiler.CodeAnalysis.DelayedILModuleReader get_delayedReader() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+PEReference: Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,System.DateTime] getStamp +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+PEReference: Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,System.DateTime] get_getStamp() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+Tags: Int32 FSharpReference +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+Tags: Int32 ILModuleReference +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+Tags: Int32 PEReference FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Boolean Equals(System.Object) -FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharpProjectSnapshot get_options() -FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharpProjectSnapshot options +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Boolean IsFSharpReference +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Boolean IsILModuleReference +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Boolean IsPEReference +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Boolean get_IsFSharpReference() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Boolean get_IsILModuleReference() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Boolean get_IsPEReference() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+ILModuleReference +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+PEReference +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+Tags FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharpReferencedProjectSnapshot CreateFSharp(System.String, FSharpProjectSnapshot) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharpReferencedProjectSnapshot NewFSharpReference(System.String, FSharpProjectSnapshot) +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharpReferencedProjectSnapshot NewILModuleReference(System.String, Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,System.DateTime], Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,FSharp.Compiler.AbstractIL.ILBinaryReader+ILModuleReader]) +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: FSharpReferencedProjectSnapshot NewPEReference(Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,System.DateTime], FSharp.Compiler.CodeAnalysis.DelayedILModuleReader) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Int32 GetHashCode() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Int32 Tag FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: Int32 get_Tag() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: System.String OutputFile FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: System.String ToString() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: System.String get_OutputFile() -FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: System.String get_projectOutputFile() -FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot: System.String projectOutputFile FSharp.Compiler.CodeAnalysis.ProjectSnapshot+ReferenceOnDisk: Boolean Equals(ReferenceOnDisk) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+ReferenceOnDisk: Boolean Equals(System.Object) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+ReferenceOnDisk: Boolean Equals(System.Object, System.Collections.IEqualityComparer) From 8dcf23c95687968ecf862eb0e5b629b4a422d39c Mon Sep 17 00:00:00 2001 From: 0101 <0101@innit.cz> Date: Thu, 1 Feb 2024 18:55:35 +0100 Subject: [PATCH 11/17] deduplicate diagnostics --- src/Compiler/Service/TransparentCompiler.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index 8e5f984d027..b69a10ea10c 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -1388,7 +1388,7 @@ type internal TransparentCompiler let! snapshotWithSources = LoadSources bootstrapInfo priorSnapshot let file = snapshotWithSources.SourceFiles |> List.last - let! parseResults = getParseResult projectSnapshot creationDiags file bootstrapInfo.TcConfig + let! parseResults = getParseResult projectSnapshot Seq.empty file bootstrapInfo.TcConfig let! result, tcInfo = ComputeTcLastFile bootstrapInfo snapshotWithSources @@ -1441,7 +1441,7 @@ type internal TransparentCompiler ) let tcDiagnostics = - [| yield! creationDiags; yield! extraDiagnostics; yield! tcDiagnostics |] + [| yield! extraDiagnostics; yield! tcDiagnostics |] let loadClosure = None // TODO: script support From 44320921410d77b7b812ff9909a29981c9f9a57e Mon Sep 17 00:00:00 2001 From: 0101 <0101@innit.cz> Date: Thu, 1 Feb 2024 18:56:29 +0100 Subject: [PATCH 12/17] f --- src/Compiler/Service/TransparentCompiler.fs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index b69a10ea10c..9f3881ecfd2 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -1440,8 +1440,7 @@ type internal TransparentCompiler Some symbolEnv ) - let tcDiagnostics = - [| yield! extraDiagnostics; yield! tcDiagnostics |] + let tcDiagnostics = [| yield! extraDiagnostics; yield! tcDiagnostics |] let loadClosure = None // TODO: script support From 9663c3bc234bc00ef12a3e443141fb874b1b9c74 Mon Sep 17 00:00:00 2001 From: 0101 <0101@innit.cz> Date: Thu, 1 Feb 2024 20:29:58 +0100 Subject: [PATCH 13/17] revert test config --- tests/FSharp.Test.Utilities/CompilerAssert.fs | 2 +- tests/FSharp.Test.Utilities/ProjectGeneration.fs | 2 +- tests/service/Common.fs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/FSharp.Test.Utilities/CompilerAssert.fs b/tests/FSharp.Test.Utilities/CompilerAssert.fs index 8117e5390ce..7951ba31d5d 100644 --- a/tests/FSharp.Test.Utilities/CompilerAssert.fs +++ b/tests/FSharp.Test.Utilities/CompilerAssert.fs @@ -259,7 +259,7 @@ and Compilation = module rec CompilerAssertHelpers = - let useTransparentCompiler = true + let useTransparentCompiler = FSharp.Compiler.CompilerConfig.FSharpExperimentalFeaturesEnabledAutomatically let checker = FSharpChecker.Create(suggestNamesForErrors=true, useTransparentCompiler=useTransparentCompiler) // Unlike C# whose entrypoint is always string[] F# can make an entrypoint with 0 args, or with an array of string[] diff --git a/tests/FSharp.Test.Utilities/ProjectGeneration.fs b/tests/FSharp.Test.Utilities/ProjectGeneration.fs index 2fdb9c4c49f..144e535bccb 100644 --- a/tests/FSharp.Test.Utilities/ProjectGeneration.fs +++ b/tests/FSharp.Test.Utilities/ProjectGeneration.fs @@ -926,7 +926,7 @@ type ProjectWorkflowBuilder ?isExistingProject ) = - let useTransparentCompiler = defaultArg useTransparentCompiler true + let useTransparentCompiler = defaultArg useTransparentCompiler FSharp.Compiler.CompilerConfig.FSharpExperimentalFeaturesEnabledAutomatically let useGetSource = not useTransparentCompiler && defaultArg useGetSource false let useChangeNotifications = not useTransparentCompiler && defaultArg useChangeNotifications false let autoStart = defaultArg autoStart true diff --git a/tests/service/Common.fs b/tests/service/Common.fs index 11723a53a8a..8516948626a 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -31,7 +31,7 @@ type Async with task.Result // Create one global interactive checker instance -let checker = FSharpChecker.Create(useTransparentCompiler=true) +let checker = FSharpChecker.Create(useTransparentCompiler=FSharp.Compiler.CompilerConfig.FSharpExperimentalFeaturesEnabledAutomatically) type TempFile(ext, contents: string) = let tmpFile = Path.ChangeExtension(tryCreateTemporaryFileName (), ext) From f509f2d21da05410e4a615975030228533873f9e Mon Sep 17 00:00:00 2001 From: 0101 <0101@innit.cz> Date: Fri, 2 Feb 2024 11:19:55 +0100 Subject: [PATCH 14/17] docs --- src/Compiler/Service/FSharpProjectSnapshot.fs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Compiler/Service/FSharpProjectSnapshot.fs b/src/Compiler/Service/FSharpProjectSnapshot.fs index b9c3e4bb489..148d39da787 100644 --- a/src/Compiler/Service/FSharpProjectSnapshot.fs +++ b/src/Compiler/Service/FSharpProjectSnapshot.fs @@ -432,8 +432,28 @@ and internal ProjectCore member _.CacheKey = cacheKey.Value and [] FSharpReferencedProjectSnapshot = - | FSharpReference of projectOutputFile: string * options: FSharpProjectSnapshot + /// + /// A reference to an F# project. The physical data for it is stored/cached inside of the compiler service. + /// + /// The fully qualified path to the output of the referenced project. This should be the same value as the -r reference in the project options for this referenced project. + /// Snapshot of the referenced F# project + | FSharpReference of projectOutputFile: string * snapshot: FSharpProjectSnapshot + /// + /// A reference to any portable executable, including F#. The stream is owned by this reference. + /// The stream will be automatically disposed when there are no references to FSharpReferencedProject and is GC collected. + /// Once the stream is evaluated, the function that constructs the stream will no longer be referenced by anything. + /// If the stream evaluation throws an exception, it will be automatically handled. + /// + /// A function that calculates a last-modified timestamp for this reference. This will be used to determine if the reference is up-to-date. + /// A function that opens a Portable Executable data stream for reading. | PEReference of getStamp: (unit -> DateTime) * delayedReader: DelayedILModuleReader + + /// + /// A reference to an ILModuleReader. + /// + /// The fully qualified path to the output of the referenced project. This should be the same value as the -r reference in the project options for this referenced project. + /// A function that calculates a last-modified timestamp for this reference. This will be used to determine if the reference is up-to-date. + /// A function that creates an ILModuleReader for reading module data. | ILModuleReference of projectOutputFile: string * getStamp: (unit -> DateTime) * From 1fe0323a6c718bba8846e54d3dac3f98ec60afb9 Mon Sep 17 00:00:00 2001 From: 0101 <0101@innit.cz> Date: Fri, 2 Feb 2024 13:34:26 +0100 Subject: [PATCH 15/17] surfacearea --- ...Sharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl | 4 ++-- ...arp.Compiler.Service.SurfaceArea.netstandard20.release.bsl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl index 361ff32f3cc..b6eeea8f992 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl @@ -2338,8 +2338,8 @@ FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FS FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot] FromOptions(FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, System.String, Int32, FSharp.Compiler.Text.ISourceText) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.String Label FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.String get_Label() -FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: FSharpProjectSnapshot get_options() -FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: FSharpProjectSnapshot options +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: FSharpProjectSnapshot get_snapshot() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: FSharpProjectSnapshot snapshot FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: System.String get_projectOutputFile() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: System.String projectOutputFile FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+ILModuleReference: Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,FSharp.Compiler.AbstractIL.ILBinaryReader+ILModuleReader] getReader diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index 361ff32f3cc..b6eeea8f992 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -2338,8 +2338,8 @@ FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FS FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot] FromOptions(FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, System.String, Int32, FSharp.Compiler.Text.ISourceText) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.String Label FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.String get_Label() -FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: FSharpProjectSnapshot get_options() -FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: FSharpProjectSnapshot options +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: FSharpProjectSnapshot get_snapshot() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: FSharpProjectSnapshot snapshot FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: System.String get_projectOutputFile() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+FSharpReference: System.String projectOutputFile FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot+ILModuleReference: Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,FSharp.Compiler.AbstractIL.ILBinaryReader+ILModuleReader] getReader From d69f9711df733ed04e02fd3eefb6c1144622215f Mon Sep 17 00:00:00 2001 From: 0101 <0101@innit.cz> Date: Fri, 2 Feb 2024 13:44:02 +0100 Subject: [PATCH 16/17] fix release notes --- docs/release-notes/.FSharp.Compiler.Service/8.0.300.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md index 3678f6a0f3f..a090daf5cf3 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md @@ -2,7 +2,7 @@ * Code generated files with > 64K methods and generated symbols crash when loaded. Use infered sequence points for debugging. ([Issue #16399](https://github.com/dotnet/fsharp/issues/16399), [#PR 16514](https://github.com/dotnet/fsharp/pull/16514)) * `nameof Module` expressions and patterns are processed to link files in `--test:GraphBasedChecking`. ([PR #16550](https://github.com/dotnet/fsharp/pull/16550)) -* Graph Based Checking doesn't throw on invalid parsed input so it can be used for IDE scenarios ([PR #16575](https://github.com/dotnet/fsharp/pull/16575), [PR #16588](https://github.com/dotnet/fsharp/pull/16588), [PR #16591](https://github.com/dotnet/fsharp/pull/16591)) +* Graph Based Checking doesn't throw on invalid parsed input so it can be used for IDE scenarios ([PR #16575](https://github.com/dotnet/fsharp/pull/16575), [PR #16588](https://github.com/dotnet/fsharp/pull/16588), [PR #16643](https://github.com/dotnet/fsharp/pull/16643)) * Keep parens for problematic exprs (`if`, `match`, etc.) in `$"{(…):N0}"`, `$"{(…),-3}"`, etc. ([PR #16578](https://github.com/dotnet/fsharp/pull/16578)) * Fix crash in DOTNET_SYSTEM_GLOBALIZATION_INVARIANT mode [#PR 16471](https://github.com/dotnet/fsharp/pull/16471)) From d987d231059524d42b4ba1d4217ceb5eb8026b44 Mon Sep 17 00:00:00 2001 From: Petr Pokorny Date: Fri, 2 Feb 2024 18:07:41 +0100 Subject: [PATCH 17/17] uncomment --- .../FSharpChecker/TransparentCompiler.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs index 859c629d742..5ff288185c4 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs +++ b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs @@ -626,7 +626,7 @@ let fuzzingTest seed (project: SyntheticProject) = task { () with | e -> - // let _log = log.Values |> Seq.collect id |> Seq.sortBy p13 |> Seq.toArray + let _log = log.Values |> Seq.collect id |> Seq.sortBy p13 |> Seq.toArray failwith $"Seed: {seed}\nException: %A{e}" } let log = log.Values |> Seq.collect id |> Seq.sortBy p13 |> Seq.toArray