diff --git a/azure-pipelines.yml b/azure-pipelines.yml index df00f0bc2c2..d3ccdd3792f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,4 +1,4 @@ -# CI and PR triggers +# CI and PR triggers trigger: branches: include: @@ -433,6 +433,10 @@ stages: vs_release: _configuration: Release _testKind: testVs + transparent_compiler_release: + _configuration: Release + _testKind: testCoreclr + ${{ if eq(variables['Build.Reason'], 'Flaky, disabled, was PullRequest') }}: inttests_release: _configuration: Release @@ -450,7 +454,15 @@ stages: env: NativeToolsOnMachine: true displayName: Build / Test - condition: ne(variables['_testKind'], 'testIntegration') + condition: and( ne(variables['_testKind'], 'testIntegration'), ne(variables['System.JobName'], 'transparent_compiler_release') ) + + - script: eng\CIBuild.cmd -compressallmetadata -configuration $(_configuration) -$(_testKind) + env: + TEST_TRANSPARENT_COMPILER: 1 + NativeToolsOnMachine: true + displayName: Build / Test Transparent Compiler + condition: and( eq(variables['System.JobName'], 'transparent_compiler_release'), ne(variables['_testKind'], 'testIntegration') ) + - script: eng\CIBuild.cmd -compressallmetadata -configuration $(_configuration) -$(_testKind) env: NativeToolsOnMachine: true diff --git a/src/Compiler/Service/FSharpCheckerResults.fs b/src/Compiler/Service/FSharpCheckerResults.fs index f55010a9025..045e0aae7a0 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fs +++ b/src/Compiler/Service/FSharpCheckerResults.fs @@ -60,6 +60,11 @@ open Internal.Utilities.Hashing type FSharpUnresolvedReferencesSet = FSharpUnresolvedReferencesSet of UnresolvedAssemblyReference list +[] +type DocumentSource = + | FileSystem + | Custom of (string -> Async) + [] type DelayedILModuleReader = val private name: string diff --git a/src/Compiler/Service/FSharpCheckerResults.fsi b/src/Compiler/Service/FSharpCheckerResults.fsi index 26781c4356e..0ae8b3039d9 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fsi +++ b/src/Compiler/Service/FSharpCheckerResults.fsi @@ -30,6 +30,12 @@ open FSharp.Compiler.Text open Internal.Utilities.Collections +[] +[] +type DocumentSource = + | FileSystem + | Custom of (string -> Async) + /// Delays the creation of an ILModuleReader [] type DelayedILModuleReader = diff --git a/src/Compiler/Service/FSharpProjectSnapshot.fs b/src/Compiler/Service/FSharpProjectSnapshot.fs index 148d39da787..cdc7ffe9252 100644 --- a/src/Compiler/Service/FSharpProjectSnapshot.fs +++ b/src/Compiler/Service/FSharpProjectSnapshot.fs @@ -81,6 +81,25 @@ type FSharpFileSnapshot(FileName: string, Version: string, GetSource: unit -> Ta |> Task.FromResult ) + static member CreateFromDocumentSource(fileName: string, documentSource: DocumentSource) = + + match documentSource with + | DocumentSource.Custom f -> + let version = DateTime.Now.Ticks.ToString() + + FSharpFileSnapshot( + fileName, + version, + fun () -> + task { + match! f fileName |> Async.StartAsTask with + | Some source -> return SourceTextNew.ofISourceText source + | None -> return failwith $"Couldn't get source for file {f}" + } + ) + + | DocumentSource.FileSystem -> FSharpFileSnapshot.CreateFromFileSystem fileName + member public _.FileName = FileName member _.Version = Version member _.GetSource() = GetSource() @@ -603,13 +622,22 @@ and [] FSha return snapshotAccumulator[options] } - static member internal GetFileSnapshotFromDisk _ fileName = - FSharpFileSnapshot.CreateFromFileSystem fileName |> async.Return - - static member FromOptions(options: FSharpProjectOptions) = - FSharpProjectSnapshot.FromOptions(options, FSharpProjectSnapshot.GetFileSnapshotFromDisk) + static member FromOptions(options: FSharpProjectOptions, documentSource: DocumentSource) = + FSharpProjectSnapshot.FromOptions( + options, + fun _ fileName -> + FSharpFileSnapshot.CreateFromDocumentSource(fileName, documentSource) + |> async.Return + ) - static member FromOptions(options: FSharpProjectOptions, fileName: string, fileVersion: int, sourceText: ISourceText) = + static member FromOptions + ( + options: FSharpProjectOptions, + fileName: string, + fileVersion: int, + sourceText: ISourceText, + documentSource: DocumentSource + ) = let getFileSnapshot _ fName = if fName = fileName then @@ -619,7 +647,7 @@ and [] FSha fun () -> Task.FromResult(SourceTextNew.ofISourceText sourceText) ) else - FSharpFileSnapshot.CreateFromFileSystem fName + FSharpFileSnapshot.CreateFromDocumentSource(fName, documentSource) |> async.Return FSharpProjectSnapshot.FromOptions(options, getFileSnapshot) diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index 0795cb6c17a..124be183fd9 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -325,6 +325,11 @@ type internal TransparentCompiler useSyntaxTreeCache ) as self = + let documentSource = + match getSource with + | Some getSource -> DocumentSource.Custom getSource + | None -> DocumentSource.FileSystem + // Is having just one of these ok? let lexResourceManager = Lexhelp.LexResourceManager() @@ -1474,8 +1479,6 @@ type internal TransparentCompiler let tcSymbolUses = sink.GetSymbolUses() let tcOpenDeclarations = sink.GetOpenDeclarations() - let tcDependencyFiles = [] // TODO add as a set to TcIntermediate - // TODO: Apparently creating diagnostics can produce further diagnostics. So let's capture those too. Hopefully there is a more elegant solution... // Probably diagnostics need to be evaluated during typecheck anyway for proper formatting, which might take care of this too. let extraLogger = CapturingDiagnosticsLogger("DiagnosticsWhileCreatingDiagnostics") @@ -1535,7 +1538,7 @@ type internal TransparentCompiler projectSnapshot.IsIncompleteTypeCheckEnvironment, None, projectSnapshot.ToOptions(), - Array.ofList tcDependencyFiles, + Array.ofList tcInfo.tcDependencyFiles, creationDiags, parseResults.Diagnostics, tcDiagnostics, @@ -1934,7 +1937,7 @@ type internal TransparentCompiler ) : NodeCode = node { let! snapshot = - FSharpProjectSnapshot.FromOptions(options, fileName, fileVersion, sourceText) + FSharpProjectSnapshot.FromOptions(options, fileName, fileVersion, sourceText, documentSource) |> NodeCode.AwaitAsync ignore parseResults @@ -1955,7 +1958,7 @@ type internal TransparentCompiler ) : NodeCode = node { let! snapshot = - FSharpProjectSnapshot.FromOptions(options, fileName, fileVersion, sourceText) + FSharpProjectSnapshot.FromOptions(options, fileName, fileVersion, sourceText, documentSource) |> NodeCode.AwaitAsync ignore parseResults @@ -2007,7 +2010,10 @@ type internal TransparentCompiler ) : NodeCode> = node { ignore canInvalidateProject - let! snapshot = FSharpProjectSnapshot.FromOptions options |> NodeCode.AwaitAsync + + let! snapshot = + FSharpProjectSnapshot.FromOptions(options, documentSource) + |> NodeCode.AwaitAsync return! this.FindReferencesInFile(fileName, snapshot.ProjectSnapshot, symbol, userOpName) } @@ -2020,7 +2026,10 @@ type internal TransparentCompiler member this.GetAssemblyData(options: FSharpProjectOptions, fileName, userOpName: string) : NodeCode = node { - let! snapshot = FSharpProjectSnapshot.FromOptions options |> NodeCode.AwaitAsync + let! snapshot = + FSharpProjectSnapshot.FromOptions(options, documentSource) + |> NodeCode.AwaitAsync + return! this.GetAssemblyData(snapshot.ProjectSnapshot, fileName, userOpName) } @@ -2039,7 +2048,9 @@ type internal TransparentCompiler userOpName: string ) : NodeCode = node { - let! snapshot = FSharpProjectSnapshot.FromOptions options |> NodeCode.AwaitAsync + let! snapshot = + FSharpProjectSnapshot.FromOptions(options, documentSource) + |> NodeCode.AwaitAsync match! this.ParseAndCheckFileInProject(fileName, snapshot.ProjectSnapshot, userOpName) with | parseResult, FSharpCheckFileAnswer.Succeeded checkResult -> return parseResult, checkResult @@ -2053,7 +2064,10 @@ type internal TransparentCompiler userOpName: string ) : NodeCode = node { - let! snapshot = FSharpProjectSnapshot.FromOptions options |> NodeCode.AwaitAsync + let! snapshot = + FSharpProjectSnapshot.FromOptions(options, documentSource) + |> NodeCode.AwaitAsync + return! this.ParseFile(fileName, snapshot.ProjectSnapshot, userOpName) } @@ -2068,7 +2082,7 @@ type internal TransparentCompiler ignore builder let! snapshot = - FSharpProjectSnapshot.FromOptions(options, fileName, 1, sourceText) + FSharpProjectSnapshot.FromOptions(options, fileName, 1, sourceText, documentSource) |> NodeCode.AwaitAsync match! this.ParseAndCheckFileInProject(fileName, snapshot.ProjectSnapshot, "GetCachedCheckFileResult") with @@ -2118,7 +2132,11 @@ type internal TransparentCompiler ) : NodeCode = node { ignore userOpName - let! snapshot = FSharpProjectSnapshot.FromOptions options |> NodeCode.AwaitAsync + + let! snapshot = + FSharpProjectSnapshot.FromOptions(options, documentSource) + |> NodeCode.AwaitAsync + return! ComputeSemanticClassification(fileName, snapshot.ProjectSnapshot) } @@ -2141,7 +2159,7 @@ type internal TransparentCompiler ) : NodeCode = node { let! snapshot = - FSharpProjectSnapshot.FromOptions(options, fileName, fileVersion, sourceText) + FSharpProjectSnapshot.FromOptions(options, fileName, fileVersion, sourceText, documentSource) |> NodeCode.AwaitAsync return! this.ParseAndCheckFileInProject(fileName, snapshot.ProjectSnapshot, userOpName) @@ -2153,7 +2171,11 @@ type internal TransparentCompiler member this.ParseAndCheckProject(options: FSharpProjectOptions, userOpName: string) : NodeCode = node { ignore userOpName - let! snapshot = FSharpProjectSnapshot.FromOptions options |> NodeCode.AwaitAsync + + let! snapshot = + FSharpProjectSnapshot.FromOptions(options, documentSource) + |> NodeCode.AwaitAsync + return! ComputeParseAndCheckProject snapshot.ProjectSnapshot } diff --git a/src/Compiler/Service/service.fs b/src/Compiler/Service/service.fs index 492ff2da497..803755ab13f 100644 --- a/src/Compiler/Service/service.fs +++ b/src/Compiler/Service/service.fs @@ -37,11 +37,6 @@ open FSharp.Compiler.Text.Range open FSharp.Compiler.TcGlobals open FSharp.Compiler.BuildGraph -[] -type DocumentSource = - | FileSystem - | Custom of (string -> Async) - /// Callback that indicates whether a requested result has become obsolete. [] type IsResultObsolete = IsResultObsolete of (unit -> bool) diff --git a/src/Compiler/Service/service.fsi b/src/Compiler/Service/service.fsi index 14124fbda6b..e74249cd604 100644 --- a/src/Compiler/Service/service.fsi +++ b/src/Compiler/Service/service.fsi @@ -19,12 +19,6 @@ open FSharp.Compiler.Syntax open FSharp.Compiler.Text open FSharp.Compiler.Tokenization -[] -[] -type DocumentSource = - | FileSystem - | Custom of (string -> Async) - /// Used to parse and check F# source code. [] type public FSharpChecker = diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerService/AsyncMemoize.fs b/tests/FSharp.Compiler.ComponentTests/CompilerService/AsyncMemoize.fs index e442335f940..7c252019e2d 100644 --- a/tests/FSharp.Compiler.ComponentTests/CompilerService/AsyncMemoize.fs +++ b/tests/FSharp.Compiler.ComponentTests/CompilerService/AsyncMemoize.fs @@ -54,6 +54,8 @@ type internal EventRecorder<'a, 'b, 'c when 'a : equality and 'b : equality>(mem let actual = events |> Seq.toArray Assert.Equal<_ array>(expected, actual) + member _.Sequence = events |> Seq.map id + [] let ``Basics``() = @@ -63,10 +65,8 @@ let ``Basics``() = return key * 2 } - let eventLog = ConcurrentBag() - let memoize = AsyncMemoize() - memoize.OnEvent(fun (e, (_label, k, _version)) -> eventLog.Add (e, k)) + let events = EventRecorder(memoize) let result = seq { @@ -84,7 +84,9 @@ let ``Basics``() = Assert.Equal(expected, result) - let groups = eventLog |> Seq.groupBy snd |> Seq.toList + (waitUntil (events.CountOf Finished) 3).Wait() + + let groups = events.Sequence |> Seq.groupBy snd |> Seq.toList Assert.Equal(3, groups.Length) for key, events in groups do Assert.Equal>(Set [ Requested, key; Started, key; Finished, key ], Set events) diff --git a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs index 664b79d4e0e..cbc8e7690fe 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs +++ b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs @@ -651,7 +651,7 @@ let fuzzingTest seed (project: SyntheticProject) = task { [] let Fuzzing signatureFiles = - let seed = 1106087513 + let seed = System.Random().Next() let rng = System.Random(int seed) let fileCount = 30 @@ -711,7 +711,6 @@ type GiraffeTheoryAttribute() = [] let GiraffeFuzzing signatureFiles = let seed = System.Random().Next() - //let seed = 1044159179 let giraffeDir = if signatureFiles then giraffeSignaturesDir else giraffeDir let giraffeTestsDir = if signatureFiles then giraffeSignaturesTestsDir else giraffeTestsDir diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/TyparNameTests.fs b/tests/FSharp.Compiler.ComponentTests/TypeChecks/TyparNameTests.fs index 339fa1e2629..d8316d365e7 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/TyparNameTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/TyparNameTests.fs @@ -14,7 +14,7 @@ module TyparNameTests = (additionalFile: SourceCodeFileKind) : string array = let typeCheckResult = - cUnit |> withAdditionalSourceFile additionalFile |> typecheckProject false false + cUnit |> withAdditionalSourceFile additionalFile |> typecheckProject false CompilerAssertHelpers.UseTransparentCompiler assert (Array.isEmpty typeCheckResult.Diagnostics) 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 e53606d2de3..da61adbe19b 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 @@ -2304,6 +2304,7 @@ FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot: Boolean Equals( FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot: Boolean IsSignatureFile FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot: Boolean get_IsSignatureFile() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot: FSharpFileSnapshot Create(System.String, System.String, Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,System.Threading.Tasks.Task`1[FSharp.Compiler.Text.ISourceTextNew]]) +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot: FSharpFileSnapshot CreateFromDocumentSource(System.String, FSharp.Compiler.CodeAnalysis.DocumentSource) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot: FSharpFileSnapshot CreateFromFileSystem(System.String) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot: Int32 GetHashCode() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot: System.String FileName @@ -2333,9 +2334,9 @@ FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: FSharpProjec FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: FSharpProjectIdentifier get_Identifier() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: FSharpProjectSnapshot Create(System.String, Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+ReferenceOnDisk], Microsoft.FSharp.Collections.FSharpList`1[System.String], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot], Boolean, Boolean, System.DateTime, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet], Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[FSharp.Compiler.Text.Range,System.String,System.String]], Microsoft.FSharp.Core.FSharpOption`1[System.Int64]) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: FSharpProjectSnapshot Replace(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot]) -FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot] FromOptions(FSharp.Compiler.CodeAnalysis.FSharpProjectOptions) +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot] FromOptions(FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, FSharp.Compiler.CodeAnalysis.DocumentSource) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot] FromOptions(FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpFunc`2[FSharp.Compiler.CodeAnalysis.FSharpProjectOptions,Microsoft.FSharp.Core.FSharpFunc`2[System.String,Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot]]], Microsoft.FSharp.Core.FSharpOption`1[System.Collections.Generic.Dictionary`2[FSharp.Compiler.CodeAnalysis.FSharpProjectOptions,FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot]]) -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: 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.DocumentSource) 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_snapshot() 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 e53606d2de3..da61adbe19b 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 @@ -2304,6 +2304,7 @@ FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot: Boolean Equals( FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot: Boolean IsSignatureFile FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot: Boolean get_IsSignatureFile() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot: FSharpFileSnapshot Create(System.String, System.String, Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,System.Threading.Tasks.Task`1[FSharp.Compiler.Text.ISourceTextNew]]) +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot: FSharpFileSnapshot CreateFromDocumentSource(System.String, FSharp.Compiler.CodeAnalysis.DocumentSource) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot: FSharpFileSnapshot CreateFromFileSystem(System.String) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot: Int32 GetHashCode() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot: System.String FileName @@ -2333,9 +2334,9 @@ FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: FSharpProjec FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: FSharpProjectIdentifier get_Identifier() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: FSharpProjectSnapshot Create(System.String, Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+ReferenceOnDisk], Microsoft.FSharp.Collections.FSharpList`1[System.String], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot], Boolean, Boolean, System.DateTime, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet], Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[FSharp.Compiler.Text.Range,System.String,System.String]], Microsoft.FSharp.Core.FSharpOption`1[System.Int64]) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: FSharpProjectSnapshot Replace(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot]) -FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot] FromOptions(FSharp.Compiler.CodeAnalysis.FSharpProjectOptions) +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot] FromOptions(FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, FSharp.Compiler.CodeAnalysis.DocumentSource) FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot] FromOptions(FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpFunc`2[FSharp.Compiler.CodeAnalysis.FSharpProjectOptions,Microsoft.FSharp.Core.FSharpFunc`2[System.String,Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot]]], Microsoft.FSharp.Core.FSharpOption`1[System.Collections.Generic.Dictionary`2[FSharp.Compiler.CodeAnalysis.FSharpProjectOptions,FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot]]) -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: 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.DocumentSource) 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_snapshot() diff --git a/tests/FSharp.Compiler.Service.Tests/FSharpExprPatternsTests.fs b/tests/FSharp.Compiler.Service.Tests/FSharpExprPatternsTests.fs index 5d31b6f74fc..a50010f6f86 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharpExprPatternsTests.fs +++ b/tests/FSharp.Compiler.Service.Tests/FSharpExprPatternsTests.fs @@ -1,5 +1,7 @@ module FSharp.Compiler.Service.Tests.FSharpExprPatternsTests +open FSharp.Test + #nowarn "57" open FSharp.Compiler.CodeAnalysis @@ -137,7 +139,7 @@ let testPatterns handler source = } let checker = - FSharpChecker.Create(documentSource = DocumentSource.Custom documentSource, keepAssemblyContents = true) + FSharpChecker.Create(documentSource = DocumentSource.Custom documentSource, keepAssemblyContents = true, useTransparentCompiler = CompilerAssertHelpers.UseTransparentCompiler) let checkResult = checker.ParseAndCheckFileInProject("A.fs", 0, Map.find "A.fs" files, projectOptions) diff --git a/tests/FSharp.Compiler.Service.Tests/TooltipTests.fs b/tests/FSharp.Compiler.Service.Tests/TooltipTests.fs index 92993a62a61..d3e08461809 100644 --- a/tests/FSharp.Compiler.Service.Tests/TooltipTests.fs +++ b/tests/FSharp.Compiler.Service.Tests/TooltipTests.fs @@ -1,5 +1,6 @@ module FSharp.Compiler.Service.Tests.TooltipTests + #nowarn "57" open FSharp.Compiler.CodeAnalysis @@ -8,6 +9,7 @@ open FSharp.Compiler.Text open FSharp.Compiler.Tokenization open FSharp.Compiler.EditorServices open FSharp.Compiler.Symbols +open FSharp.Test open NUnit.Framework let testXmlDocFallbackToSigFileWhileInImplFile sigSource implSource line colAtEndOfNames lineText names (expectedContent: string) = @@ -29,7 +31,8 @@ let testXmlDocFallbackToSigFileWhileInImplFile sigSource implSource line colAtEn SourceFiles = [| "A.fsi"; "A.fs" |] } let checker = - FSharpChecker.Create(documentSource = DocumentSource.Custom documentSource) + FSharpChecker.Create(documentSource = DocumentSource.Custom documentSource, + useTransparentCompiler = CompilerAssertHelpers.UseTransparentCompiler) let checkResult = checker.ParseAndCheckFileInProject("A.fs", 0, Map.find "A.fs" files, projectOptions) @@ -276,7 +279,8 @@ let testToolTipSquashing source line colAtEndOfNames lineText names tokenTag = SourceFiles = [| "A.fs" |] } let checker = - FSharpChecker.Create(documentSource = DocumentSource.Custom documentSource) + FSharpChecker.Create(documentSource = DocumentSource.Custom documentSource, + useTransparentCompiler = CompilerAssertHelpers.UseTransparentCompiler) let checkResult = checker.ParseAndCheckFileInProject("A.fs", 0, Map.find "A.fs" files, projectOptions) diff --git a/tests/FSharp.Test.Utilities/CompilerAssert.fs b/tests/FSharp.Test.Utilities/CompilerAssert.fs index 7951ba31d5d..b22e0b2d020 100644 --- a/tests/FSharp.Test.Utilities/CompilerAssert.fs +++ b/tests/FSharp.Test.Utilities/CompilerAssert.fs @@ -259,8 +259,11 @@ and Compilation = module rec CompilerAssertHelpers = - let useTransparentCompiler = FSharp.Compiler.CompilerConfig.FSharpExperimentalFeaturesEnabledAutomatically - let checker = FSharpChecker.Create(suggestNamesForErrors=true, useTransparentCompiler=useTransparentCompiler) + let UseTransparentCompiler = + FSharp.Compiler.CompilerConfig.FSharpExperimentalFeaturesEnabledAutomatically || + not (String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("TEST_TRANSPARENT_COMPILER"))) + + 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[] let mkDefaultArgs (entryPoint:MethodBase) : obj[] = [| diff --git a/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj b/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj index 5cfcba98ca7..d3307295480 100644 --- a/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj +++ b/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj @@ -28,11 +28,11 @@ scriptlib.fsx - + diff --git a/tests/FSharp.Test.Utilities/ProjectGeneration.fs b/tests/FSharp.Test.Utilities/ProjectGeneration.fs index 2236eee988d..2157d8fb7fe 100644 --- a/tests/FSharp.Test.Utilities/ProjectGeneration.fs +++ b/tests/FSharp.Test.Utilities/ProjectGeneration.fs @@ -931,7 +931,7 @@ type ProjectWorkflowBuilder ?isExistingProject ) = - let useTransparentCompiler = defaultArg useTransparentCompiler FSharp.Compiler.CompilerConfig.FSharpExperimentalFeaturesEnabledAutomatically + let useTransparentCompiler = defaultArg useTransparentCompiler CompilerAssertHelpers.UseTransparentCompiler let useGetSource = not useTransparentCompiler && defaultArg useGetSource false let useChangeNotifications = not useTransparentCompiler && defaultArg useChangeNotifications false let autoStart = defaultArg autoStart true diff --git a/tests/service/AssemblyContentProviderTests.fs b/tests/service/AssemblyContentProviderTests.fs index 41d6a8c660f..03deb321c24 100644 --- a/tests/service/AssemblyContentProviderTests.fs +++ b/tests/service/AssemblyContentProviderTests.fs @@ -12,6 +12,7 @@ open NUnit.Framework open FSharp.Compiler.CodeAnalysis open FSharp.Compiler.EditorServices open FSharp.Compiler.Service.Tests.Common +open FSharp.Test let private filePath = "C:\\test.fs" @@ -28,7 +29,7 @@ let private projectOptions : FSharpProjectOptions = UnresolvedReferences = None Stamp = None } -let private checker = FSharpChecker.Create() +let private checker = FSharpChecker.Create(useTransparentCompiler=CompilerAssertHelpers.UseTransparentCompiler) let private assertAreEqual (expected, actual) = if actual <> expected then diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index a1a58a709b2..8a643c9a7bc 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -4593,8 +4593,13 @@ let ``Test project35b Dependency files for ParseAndCheckFileInProject`` () = for d in checkFileResults.DependencyFiles do printfn "ParseAndCheckFileInProject dependency: %s" d checkFileResults.DependencyFiles |> Array.exists (fun s -> s.Contains "notexist.dll") |> shouldEqual true - // The file itself is not a dependency since it is never read from the file system when using ParseAndCheckFileInProject - checkFileResults.DependencyFiles |> Array.exists (fun s -> s.Contains Project35b.fileName1) |> shouldEqual false + + if not checker.UsesTransparentCompiler then + // The file itself is not a dependency since it is never read from the file system when using ParseAndCheckFileInProject + checkFileResults.DependencyFiles |> Array.exists (fun s -> s.Contains Project35b.fileName1) |> shouldEqual false + else + // Transparent compiler doesn't differentiate between foreground and background requests. All files have to be present in the input snapshot so the filesystem doesn't have to be watched for those. Maybe source files shouldn't be included in the dependency list at all. But they show the dependencies gathered from graph-based checking which could be useful? + () [] let ``Test project35b Dependency files for GetBackgroundCheckResultsForFileInProject`` () = @@ -4602,8 +4607,13 @@ let ``Test project35b Dependency files for GetBackgroundCheckResultsForFileInPro for d in checkFileResults.DependencyFiles do printfn "GetBackgroundCheckResultsForFileInProject dependency: %s" d checkFileResults.DependencyFiles |> Array.exists (fun s -> s.Contains "notexist.dll") |> shouldEqual true - // The file is a dependency since it is read from the file system when using GetBackgroundCheckResultsForFileInProject - checkFileResults.DependencyFiles |> Array.exists (fun s -> s.Contains Project35b.fileName1) |> shouldEqual true + + if not checker.UsesTransparentCompiler then + // The file is a dependency since it is read from the file system when using GetBackgroundCheckResultsForFileInProject + checkFileResults.DependencyFiles |> Array.exists (fun s -> s.Contains Project35b.fileName1) |> shouldEqual true + else + // Transparent compiler doesn't differentiate between foreground and background requests. All files have to be present in the input snapshot so the filesystem doesn't have to be watched for those. Maybe source files shouldn't be included in the dependency list at all. But they show the dependencies gathered from graph-based checking which could be useful? + () [] let ``Test project35b Dependency files for check of project`` () = diff --git a/vsintegration/tests/FSharp.Editor.Tests/BraceMatchingServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/BraceMatchingServiceTests.fs index 135d5d31f2f..8027a06e85f 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/BraceMatchingServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/BraceMatchingServiceTests.fs @@ -8,9 +8,11 @@ open Microsoft.CodeAnalysis.Text open FSharp.Compiler.CodeAnalysis open Microsoft.VisualStudio.FSharp.Editor open FSharp.Editor.Tests.Helpers +open FSharp.Test type BraceMatchingServiceTests() = - let checker = FSharpChecker.Create() + let checker = + FSharpChecker.Create(useTransparentCompiler = CompilerAssertHelpers.UseTransparentCompiler) let fileName = "C:\\test.fs" diff --git a/vsintegration/tests/FSharp.Editor.Tests/EditorFormattingServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/EditorFormattingServiceTests.fs index 9442957325f..985abc67e31 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/EditorFormattingServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/EditorFormattingServiceTests.fs @@ -57,7 +57,9 @@ marker4""" [] [] member this.TestIndentation(marker: string, expectedLine: string) = - let checker = FSharpChecker.Create() + let checker = + FSharpChecker.Create(useTransparentCompiler = CompilerAssertHelpers.UseTransparentCompiler) + let position = indentTemplate.IndexOf(marker) Assert.True(position >= 0, "Precondition failed: unable to find marker in template") @@ -94,7 +96,8 @@ marker4""" [] [] member this.TestPasteChanges_PastingOntoIndentedLine(enabled: bool, prefix: string) = - let checker = FSharpChecker.Create() + let checker = + FSharpChecker.Create(useTransparentCompiler = CompilerAssertHelpers.UseTransparentCompiler) let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions @@ -160,7 +163,8 @@ somethingElseHere [] [] member this.TestPasteChanges_PastingOntoEmptyLine(prefix: string) = - let checker = FSharpChecker.Create() + let checker = + FSharpChecker.Create(useTransparentCompiler = CompilerAssertHelpers.UseTransparentCompiler) let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions @@ -220,7 +224,8 @@ somethingElseHere [] member this.TestPasteChanges_PastingWithAutoIndentationInPasteSpan() = - let checker = FSharpChecker.Create() + let checker = + FSharpChecker.Create(useTransparentCompiler = CompilerAssertHelpers.UseTransparentCompiler) let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions diff --git a/vsintegration/tests/FSharp.Editor.Tests/IndentationServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/IndentationServiceTests.fs index 81f2bfc7f09..6b70bb07c8c 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/IndentationServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/IndentationServiceTests.fs @@ -12,7 +12,8 @@ open FSharp.Editor.Tests.Helpers open FSharp.Test type IndentationServiceTests() = - let checker = FSharpChecker.Create() + let checker = + FSharpChecker.Create(useTransparentCompiler = CompilerAssertHelpers.UseTransparentCompiler) let filePath = "C:\\test.fs" diff --git a/vsintegration/tests/FSharp.Editor.Tests/SignatureHelpProviderTests.fs b/vsintegration/tests/FSharp.Editor.Tests/SignatureHelpProviderTests.fs index af66c01ed69..f85ee51a6c8 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/SignatureHelpProviderTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/SignatureHelpProviderTests.fs @@ -12,6 +12,7 @@ open FSharp.Editor.Tests.Helpers open Microsoft.CodeAnalysis open Microsoft.IO open Microsoft.VisualStudio.FSharp.Editor.CancellableTasks +open FSharp.Test module SignatureHelpProvider = let private DefaultDocumentationProvider = @@ -20,7 +21,8 @@ module SignatureHelpProvider = override doc.AppendDocumentation(_, _, _, _, _, _, _, _) = () } - let checker = FSharpChecker.Create() + let checker = + FSharpChecker.Create(useTransparentCompiler = CompilerAssertHelpers.UseTransparentCompiler) let filePath = "C:\\test.fs"