From 702b8e77f5fbfe21e6743324c1750503e02f182d Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Wed, 29 Jun 2022 11:01:17 +0200 Subject: [PATCH] Cherry-pick #13313 to 17.2 (#13399) Co-authored-by: Petr Semkin --- azure-pipelines.yml | 23 ------------------- .../LanguageService/LanguageService.fs | 12 +++++++--- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0efb6990d57..c5bd115e2bb 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -356,29 +356,6 @@ stages: - script: .\tests\EndToEndBuildTests\EndToEndBuildTests.cmd -c Release displayName: End to end build tests - # Determinism, we want to run it only in PR builds - - job: Determinism_Debug - condition: eq(variables['Build.Reason'], 'PullRequest') - variables: - - name: _SignType - value: Test - pool: - name: NetCore1ESPool-Public - demands: ImageOverride -equals $(WindowsMachineQueueName) - timeoutInMinutes: 90 - steps: - - checkout: self - clean: true - - script: .\eng\test-determinism.cmd -configuration Debug - displayName: Determinism tests with Debug configuration - - task: PublishPipelineArtifact@1 - displayName: Publish Determinism Logs - inputs: - targetPath: '$(Build.SourcesDirectory)/artifacts/log/Debug' - artifactName: 'Determinism_Debug Attempt $(System.JobAttempt) Logs' - continueOnError: true - condition: not(succeeded()) - # Up-to-date - disabled due to it being flaky #- job: UpToDate_Windows # pool: diff --git a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs index 777215a3e83..b50277c019b 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs @@ -346,7 +346,7 @@ type internal HackCpsCommandLineChanges /// This handles commandline change notifications from the Dotnet Project-system /// Prior to VS 15.7 path contained path to project file, post 15.7 contains target binpath /// binpath is more accurate because a project file can have multiple in memory projects based on configuration - member _.HandleCommandLineChanges(path:string, sources:ImmutableArray, _references:ImmutableArray, options:ImmutableArray) = + member _.HandleCommandLineChanges(path:string, sources:ImmutableArray, references:ImmutableArray, options:ImmutableArray) = use _logBlock = Logger.LogBlock(LogEditorFunctionId.LanguageService_HandleCommandLineArgs) let projectId = @@ -363,5 +363,11 @@ type internal HackCpsCommandLineChanges let sourcePaths = sources |> Seq.map(fun s -> getFullPath s.Path) |> Seq.toArray - let workspaceService = workspace.Services.GetRequiredService() - workspaceService.FSharpProjectOptionsManager.SetCommandLineOptions(projectId, sourcePaths, options) + /// Due to an issue in project system, when we close and reopen solution, it sends the CommandLineChanges twice for every project. + /// First time it sends a correct path, sources, references and options. + /// Second time it sends a correct path, empty sources, empty references and empty options, and we rewrite our cache, and fail to colourize the document later. + /// As a workaround, until we have a fix from PS or will move to Roslyn as a source of truth, we will not overwrite the cache in case of empty lists. + + if not (sources.IsEmpty && references.IsEmpty && options.IsEmpty) then + let workspaceService = workspace.Services.GetRequiredService() + workspaceService.FSharpProjectOptionsManager.SetCommandLineOptions(projectId, sourcePaths, options)