From 2f795a9a35e393c565bc451bd26d3dfd01604365 Mon Sep 17 00:00:00 2001 From: Kevin Ransom Date: Mon, 9 Sep 2024 18:35:08 -0700 Subject: [PATCH 1/5] Fix quickinfo text --- vsintegration/tests/FSharp.Editor.Tests/QuickInfoTests.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vsintegration/tests/FSharp.Editor.Tests/QuickInfoTests.fs b/vsintegration/tests/FSharp.Editor.Tests/QuickInfoTests.fs index 5f658cb515..7475f891a0 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/QuickInfoTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/QuickInfoTests.fs @@ -535,7 +535,7 @@ module Test = static let fu$$nc x = () """ - let expectedSignature = "val func: x: 'a -> unit" + let expectedSignature = "val private func: x: 'a -> unit" let tooltip = GetQuickInfoTextFromCode code From 8a06d1f5e33fc453d9c2d3719c86b4abb7c5109f Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Tue, 10 Sep 2024 20:23:30 -0700 Subject: [PATCH 2/5] realsig and globals --- eng/Build.ps1 | 14 +++++++-- src/Compiler/Service/IncrementalBuild.fs | 30 +++++++++++++++++++ src/Compiler/Service/TransparentCompiler.fs | 2 ++ src/Compiler/Service/service.fs | 2 ++ src/Compiler/TypedTree/TcGlobals.fs | 16 ++++++---- src/Compiler/TypedTree/TcGlobals.fsi | 8 +++++ .../FSharp.Editor.Tests.fsproj | 2 +- .../HelpContextServiceTests.fs | 6 ++-- .../FSharp.Editor.Tests/QuickInfoTests.fs | 6 ++-- 9 files changed, 71 insertions(+), 15 deletions(-) diff --git a/eng/Build.ps1 b/eng/Build.ps1 index 4d5cc47815..a6bda85ef6 100644 --- a/eng/Build.ps1 +++ b/eng/Build.ps1 @@ -64,6 +64,7 @@ param ( [switch]$testAllButIntegrationAndAot, [switch]$testpack, [switch]$testAOT, + [switch]$testEditor, [switch]$testBenchmarks, [string]$officialSkipTests = "false", [switch]$noVisualStudio, @@ -119,6 +120,7 @@ function Print-Usage() { Write-Host " -testVs Run F# editor unit tests" Write-Host " -testpack Verify built packages" Write-Host " -testAOT Run AOT/Trimming tests" + Write-Host " -testEditor Run VS Editor tests" Write-Host " -testBenchmarks Build and Run Benchmark suite" Write-Host " -officialSkipTests Set to 'true' to skip running tests" Write-Host "" @@ -178,7 +180,11 @@ function Process-Arguments() { $script:testFSharpQA = $True $script:testIntegration = $False $script:testVs = $True - $script:testAOT = $False + $script:testEditor = $True + } + + if($script:testVs) { + $script:testEditor = $True } if ([System.Boolean]::Parse($script:officialSkipTests)) { @@ -669,11 +675,15 @@ try { TestUsingMSBuild -testProject "$RepoRoot\tests\FSharp.Compiler.Private.Scripting.UnitTests\FSharp.Compiler.Private.Scripting.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Private.Scripting.UnitTests\" } - if ($testVs -and -not $noVisualStudio) { + if ($testEditor -and -not $noVisualStudio) { TestUsingMSBuild -testProject "$RepoRoot\vsintegration\tests\FSharp.Editor.Tests\FSharp.Editor.Tests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Editor.Tests\FSharp.Editor.Tests.fsproj" + } + + if ($testVs -and -not $noVisualStudio) { TestUsingMSBuild -testProject "$RepoRoot\vsintegration\tests\UnitTests\VisualFSharp.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\VisualFSharp.UnitTests\" } + if ($testIntegration) { TestUsingMSBuild -testProject "$RepoRoot\vsintegration\tests\FSharp.Editor.IntegrationTests\FSharp.Editor.IntegrationTests.csproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Editor.IntegrationTests\" } diff --git a/src/Compiler/Service/IncrementalBuild.fs b/src/Compiler/Service/IncrementalBuild.fs index 89f23605c7..01506dddf1 100644 --- a/src/Compiler/Service/IncrementalBuild.fs +++ b/src/Compiler/Service/IncrementalBuild.fs @@ -554,6 +554,34 @@ type FrameworkImportsCache(size) = let frameworkDLLs, nonFrameworkResolutions, unresolved = TcAssemblyResolutions.SplitNonFoundationalResolutions(tcConfig) let node = this.GetNode(tcConfig, frameworkDLLs, nonFrameworkResolutions) let! tcGlobals, frameworkTcImports = node.GetOrComputeValue() + + // If the tcGlobals was loaded from a different project, langVersion and realsig may be different + // for each cached project. So here we create a new tcGlobals, with the existing framework values + // and updated realsig and langversion + let tcGlobals = + if tcGlobals.langVersion.SpecifiedVersion <> tcConfig.langVersion.SpecifiedVersion + && tcGlobals.realsig <> tcConfig.realsig then + TcGlobals( + tcGlobals.compilingFSharpCore, + tcGlobals.ilg, + tcGlobals.fslibCcu, + tcGlobals.directoryToResolveRelativePaths, + tcGlobals.mlCompatibility, + tcGlobals.isInteractive, + tcGlobals.checkNullness, + tcGlobals.useReflectionFreeCodeGen, + // The helper to find system types amongst referenced DLLs + tcGlobals.tryFindSysTypeCcuHelper, + tcGlobals.emitDebugInfoInQuotations, + tcGlobals.noDebugAttributes, + tcGlobals.pathMap, + tcConfig.langVersion, + tcConfig.realsig + ) + + else + tcGlobals + return tcGlobals, frameworkTcImports, nonFrameworkResolutions, unresolved } @@ -1445,6 +1473,8 @@ type IncrementalBuilder(initialState: IncrementalBuilderInitialState, state: Inc tcConfigB.useSimpleResolution <- (getSwitchValue useSimpleResolutionSwitch) |> Option.isSome + tcConfigB.realsig <- List.contains "--realsig" commandLineArgs || List.contains "--realsig+" commandLineArgs + // Apply command-line arguments and collect more source files if they are in the arguments let sourceFilesNew = ApplyCommandLineArgs(tcConfigB, sourceFiles, commandLineArgs) diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index 908e289312..8dc090e27d 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -793,6 +793,8 @@ type internal TransparentCompiler define :: tcConfigB.conditionalDefines + tcConfigB.realsig <- List.contains "--realsig" commandLineArgs || List.contains "--realsig+" commandLineArgs + tcConfigB.projectReferences <- projectReferences tcConfigB.useSimpleResolution <- useSimpleResolution diff --git a/src/Compiler/Service/service.fs b/src/Compiler/Service/service.fs index f02495545a..2c915870f8 100644 --- a/src/Compiler/Service/service.fs +++ b/src/Compiler/Service/service.fs @@ -641,6 +641,8 @@ type FSharpChecker if isEditing then tcConfigB.conditionalDefines <- "EDITING" :: tcConfigB.conditionalDefines + tcConfigB.realsig <- List.contains "--realsig" argv || List.contains "--realsig+" argv + // Apply command-line arguments and collect more source files if they are in the arguments let sourceFilesNew = ApplyCommandLineArgs(tcConfigB, sourceFiles, argv) FSharpParsingOptions.FromTcConfigBuilder(tcConfigB, Array.ofList sourceFilesNew, isInteractive), errorScope.Diagnostics diff --git a/src/Compiler/TypedTree/TcGlobals.fs b/src/Compiler/TypedTree/TcGlobals.fs index 48d3df2c90..c78933864b 100644 --- a/src/Compiler/TypedTree/TcGlobals.fs +++ b/src/Compiler/TypedTree/TcGlobals.fs @@ -185,7 +185,7 @@ type TcGlobals( checkNullness: bool, useReflectionFreeCodeGen: bool, // The helper to find system types amongst referenced DLLs - tryFindSysTypeCcuHelper, + tryFindSysTypeCcuHelper: string list -> string -> bool -> FSharp.Compiler.TypedTree.CcuThunk option, emitDebugInfoInQuotations: bool, noDebugAttributes: bool, pathMap: PathMap, @@ -215,11 +215,9 @@ type TcGlobals( let mk_MFCompilerServices_tcref ccu n = mkNonLocalTyconRef2 ccu CompilerServicesPath n let mk_MFControl_tcref ccu n = mkNonLocalTyconRef2 ccu ControlPathArray n - let tryFindSysTypeCcu path nm = - tryFindSysTypeCcuHelper path nm false + let tryFindSysTypeCcu path nm = tryFindSysTypeCcuHelper path nm false - let tryFindPublicSysTypeCcu path nm = - tryFindSysTypeCcuHelper path nm true + let tryFindPublicSysTypeCcu path nm = tryFindSysTypeCcuHelper path nm true let vara = Construct.NewRigidTypar "a" envRange let varb = Construct.NewRigidTypar "b" envRange @@ -1089,11 +1087,17 @@ type TcGlobals( tryFindSysAttrib "System.Runtime.CompilerServices.RequiredMemberAttribute" ] |> List.choose (Option.map (fun x -> x.TyconRef)) + static member IsInEmbeddableKnownSet name = isInEmbeddableKnownSet name + override _.ToString() = "" + member _.directoryToResolveRelativePaths = directoryToResolveRelativePaths + member _.ilg = ilg - static member IsInEmbeddableKnownSet name = isInEmbeddableKnownSet name + member _.noDebugAttributes = noDebugAttributes + + member _.tryFindSysTypeCcuHelper: string list -> string -> bool -> FSharp.Compiler.TypedTree.CcuThunk option = tryFindSysTypeCcuHelper member _.tryRemoveEmbeddedILTypeDefs () = [ for key in embeddedILTypeDefs.Keys.OrderBy id do diff --git a/src/Compiler/TypedTree/TcGlobals.fsi b/src/Compiler/TypedTree/TcGlobals.fsi index 1af857aa53..1851bbeaf6 100644 --- a/src/Compiler/TypedTree/TcGlobals.fsi +++ b/src/Compiler/TypedTree/TcGlobals.fsi @@ -152,6 +152,12 @@ type internal TcGlobals = static member IsInEmbeddableKnownSet: name: string -> bool + member directoryToResolveRelativePaths: string + + member noDebugAttributes: bool + + member tryFindSysTypeCcuHelper: (string list -> string -> bool -> FSharp.Compiler.TypedTree.CcuThunk option) with get + member AddFieldGeneratedAttributes: mdef: FSharp.Compiler.AbstractIL.IL.ILFieldDef -> FSharp.Compiler.AbstractIL.IL.ILFieldDef @@ -1281,6 +1287,8 @@ type internal TcGlobals = member typeof_info: IntrinsicValRef + + member typeof_vref: FSharp.Compiler.TypedTree.ValRef member uint16_checked_info: IntrinsicValRef diff --git a/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj b/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj index a180accc43..f6574d0a4e 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj +++ b/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj @@ -31,8 +31,8 @@ - + diff --git a/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs index 0122d2f87f..e8a1588f13 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs @@ -98,7 +98,7 @@ type HelpContextServiceTests() = TestF1Keywords(keywords, file) [] - member _.``F1 help keyword Regression.DotNetMethod.854364``() = + member _.``F1 help keyword Regression.DotNetMethod-854364``() = let file = [ "let i : int = 42"; "i.ToStri$ng()"; "i.ToStri$ng(\"format\")" ] let keywords = [ Some "System.Int32.ToString"; Some "System.Int32.ToString" ] TestF1Keywords(keywords, file) @@ -335,13 +335,13 @@ type HelpContextServiceTests() = TestF1Keywords(keywords, file) [] - member _.``F1 help keyword Regression.NewInstance.854367``() = + member _.``F1 help keyword Regression.NewInstance-854367``() = let file = [ "let q : System.Runtime.Remoting.TypeE$ntry = null" ] let keywords = [ Some "System.Runtime.Remoting.TypeEntry" ] TestF1Keywords(keywords, file) [] - member _.``F1 help keyword Regression.NewInstance.854367.2``() = + member _.``F1 help keyword Regression.NewInstance-854367-2``() = let file = [ "let q1 = new System.Runtime.Remoting.Type$Entry()" // this constructor exists but is not accessible (it is protected), but the help entry still goes to the type diff --git a/vsintegration/tests/FSharp.Editor.Tests/QuickInfoTests.fs b/vsintegration/tests/FSharp.Editor.Tests/QuickInfoTests.fs index 7475f891a0..1bf2aba3af 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/QuickInfoTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/QuickInfoTests.fs @@ -508,7 +508,7 @@ module Test = () [] - let ``Automation.LetBindings.InsideType.Instance`` () = + let ``Automation.LetBindings.Instance`` () = let code = """ namespace FsTest @@ -525,7 +525,7 @@ module Test = Assert.StartsWith(expectedSignature, tooltip) [] - let ``Automation.LetBindings.InsideType.Static`` () = + let ``Automation.LetBindings.Static`` () = let code = """ namespace FsTest @@ -543,7 +543,7 @@ module Test = () [] - let ``Automation.LetBindings`` () = + let ``Automation.LetBindings.Do`` () = let code = """ namespace FsTest From faeb73060bc4a157be8cf5ff7664eae4af78d8b9 Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Tue, 10 Sep 2024 20:50:02 -0700 Subject: [PATCH 3/5] fantomas --- src/Compiler/Service/TransparentCompiler.fs | 4 +++- src/Compiler/TypedTree/TcGlobals.fsi | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index 8dc090e27d..735a6b241f 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -793,7 +793,9 @@ type internal TransparentCompiler define :: tcConfigB.conditionalDefines - tcConfigB.realsig <- List.contains "--realsig" commandLineArgs || List.contains "--realsig+" commandLineArgs + tcConfigB.realsig <- + List.contains "--realsig" commandLineArgs + || List.contains "--realsig+" commandLineArgs tcConfigB.projectReferences <- projectReferences diff --git a/src/Compiler/TypedTree/TcGlobals.fsi b/src/Compiler/TypedTree/TcGlobals.fsi index 1851bbeaf6..83b390e299 100644 --- a/src/Compiler/TypedTree/TcGlobals.fsi +++ b/src/Compiler/TypedTree/TcGlobals.fsi @@ -1287,8 +1287,6 @@ type internal TcGlobals = member typeof_info: IntrinsicValRef - - member typeof_vref: FSharp.Compiler.TypedTree.ValRef member uint16_checked_info: IntrinsicValRef From faf4fd138c4957e282d31f07ff67f2b6ad49871c Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Wed, 11 Sep 2024 00:04:58 -0700 Subject: [PATCH 4/5] oops --- src/Compiler/Service/IncrementalBuild.fs | 3 +-- .../tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj | 2 +- .../tests/FSharp.Editor.Tests/HelpContextServiceTests.fs | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Compiler/Service/IncrementalBuild.fs b/src/Compiler/Service/IncrementalBuild.fs index 01506dddf1..7951f3c932 100644 --- a/src/Compiler/Service/IncrementalBuild.fs +++ b/src/Compiler/Service/IncrementalBuild.fs @@ -560,7 +560,7 @@ type FrameworkImportsCache(size) = // and updated realsig and langversion let tcGlobals = if tcGlobals.langVersion.SpecifiedVersion <> tcConfig.langVersion.SpecifiedVersion - && tcGlobals.realsig <> tcConfig.realsig then + || tcGlobals.realsig <> tcConfig.realsig then TcGlobals( tcGlobals.compilingFSharpCore, tcGlobals.ilg, @@ -570,7 +570,6 @@ type FrameworkImportsCache(size) = tcGlobals.isInteractive, tcGlobals.checkNullness, tcGlobals.useReflectionFreeCodeGen, - // The helper to find system types amongst referenced DLLs tcGlobals.tryFindSysTypeCcuHelper, tcGlobals.emitDebugInfoInQuotations, tcGlobals.noDebugAttributes, diff --git a/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj b/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj index f6574d0a4e..a180accc43 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj +++ b/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj @@ -31,8 +31,8 @@ - + diff --git a/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs index e8a1588f13..93b49bfa68 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs @@ -12,7 +12,7 @@ open FSharp.Editor.Tests.Helpers open Microsoft.CodeAnalysis.Text open Microsoft.VisualStudio.FSharp.Editor.CancellableTasks -type HelpContextServiceTests() = +type HelpContextServiceTests () = let getMarkers (source: string) = let mutable cnt = 0 From 19abb3dfb86bd3696935b4ae45353ca9f002fcb7 Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Wed, 11 Sep 2024 00:16:57 -0700 Subject: [PATCH 5/5] fantomas --- .../tests/FSharp.Editor.Tests/HelpContextServiceTests.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs index 93b49bfa68..e8a1588f13 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs @@ -12,7 +12,7 @@ open FSharp.Editor.Tests.Helpers open Microsoft.CodeAnalysis.Text open Microsoft.VisualStudio.FSharp.Editor.CancellableTasks -type HelpContextServiceTests () = +type HelpContextServiceTests() = let getMarkers (source: string) = let mutable cnt = 0